Why This Matters
If you're new to coding, you've probably heard about AI tools like ChatGPT, GitHub Copilot, or Cursor that can help write code. Maybe you've tried them and got frustrated when they gave you confusing or broken code.
Here's the thing: AI is incredibly powerful, but it's not a mind reader. The secret isn't just asking AI to write code—it's learning how to ask the right way.
Think of it like this: If you walked up to a expert programmer and said "make me a website," they'd probably ask you dozens of questions before writing a single line of code. AI needs the same clarity.
The Golden Rule: Be Specific
The biggest mistake beginners make is being too vague. Let's see the difference:
❌ Vague Prompt (Bad)
"Create a button"
✅ Specific Prompt (Good)
"Create a blue button with white text that says 'Submit' and changes
to a darker blue when you hover over it. Use HTML and CSS."
Why the second one works better:
- Specifies the color (blue)
- Tells what text to show ('Submit')
- Explains the behavior (hover effect)
- Mentions the languages to use (HTML and CSS)
The 5 Simple Rules for Better AI Prompts
Rule 1: Tell AI What You're Building
Instead of just asking for code, explain the bigger picture.
Example:
"I'm building a simple to-do list app for beginners. I need a function
that adds a new task to an array and displays it on the webpage.
Use JavaScript and make it easy to understand."
Rule 2: Mention Your Skill Level
Don't be shy about being a beginner! AI can adjust its explanations.
Example:
"I'm new to JavaScript. Can you create a simple calculator that adds
two numbers? Please explain each line of code so I can learn."
Rule 3: Specify the Languages/Tools
AI knows hundreds of programming languages. Tell it which ones you want.
Example:
"Create a contact form using HTML for structure, CSS for styling,
and JavaScript for validation. I'm learning web development basics."
Rule 4: Ask for Explanations
Code without understanding is just copy-pasting. Ask AI to teach you.
Example:
"Create a simple function that checks if a password is strong enough.
Use Python and explain what each part does so I can understand the logic."
Rule 5: Be Clear About the Output
Tell AI exactly how you want the response formatted.
Example:
"Give me the HTML and CSS code separately, add comments to explain
each section, and include instructions on how to test it in a browser."
Real Examples: Before and After
Example 1: Creating a Simple Webpage
❌ Bad Prompt:
"Make a webpage"
✅ Good Prompt:
"Create a simple personal webpage for a beginner. Include:
- A header with my name 'John Doe'
- A paragraph about me
- A list of my hobbies
- Basic CSS to make it look nice
- Comments explaining each HTML tag
Use beginner-friendly HTML and CSS only."
Example 2: JavaScript Function
❌ Bad Prompt:
"Write a function"
✅ Good Prompt:
"I'm learning JavaScript functions. Create a simple function that:
- Takes a person's age as input
- Returns whether they can vote (18 or older)
- Include comments explaining how if/else statements work
- Show me how to test the function with different ages"
Example 3: Fixing Broken Code
❌ Bad Prompt:
"This doesn't work, fix it"
✅ Good Prompt:
"I'm a beginner and this JavaScript code isn't working. Here's my code:
[paste your code]
The error message says: [paste error message]
Can you explain what's wrong and show me the fixed version?
Please explain why the error happened so I can avoid it next time."
Prompt Templates You Can Use Right Now
Copy these templates and fill in your specific needs:
For Learning New Concepts
"I'm learning [topic/language]. Can you create a simple example of
[specific thing] with comments explaining each part? Make it beginner-friendly."
For Building Projects
"I'm building a [type of project] as a beginner project. I need
[specific feature] that does [specific action]. Use [languages]
and include comments explaining the code."
For Debugging Help
"I'm new to programming and have an error. Here's my code: [code]
The error is: [error message]
Can you explain what's wrong and show me how to fix it?"
For Code Review
"I wrote this [language] code as a beginner. Can you review it and
suggest improvements? Please explain why each suggestion would make
the code better: [your code]"
Common Beginner Mistakes to Avoid
Mistake 1: Assuming AI Knows Your Setup
Don't say: "The code doesn't work"
Instead say: "I'm using Chrome browser on Windows, and when I open my HTML file, the button doesn't change color when I hover over it"
Mistake 2: Asking for Everything at Once
Don't say: "Build me a complete social media app"
Instead say: "Help me create a simple user registration form first, then we can add more features later"
Mistake 3: Not Asking Follow-up Questions
If you don't understand something, ask! AI is patient and won't judge you.
Good follow-ups:
- "Can you explain what this line does?"
- "What does this error mean?"
- "Is there a simpler way to do this?"
Level Up Your AI Conversations
As you get more comfortable, you can start having actual conversations with AI:
You: "Create a simple JavaScript function that calculates the area of a rectangle"
AI: [Provides code]
You: "Can you modify it to also calculate the perimeter? And explain the math behind both calculations?"
AI: [Provides updated code with explanations]
You: "What if I wanted to make this work for any shape, not just rectangles?"
This back-and-forth approach helps you learn while building exactly what you need.
Remember: Every expert was once a beginner. The difference is they learned how to ask better questions. With these prompting techniques, you're not just getting code—you're accelerating your learning journey.
Happy coding!
Great article - and I'm pretty sure it wasn't written by AI ! (interesting - can AI already think or reason about ... AI ?)