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!
Top comments (34)
Great article - and I'm pretty sure it wasn't written by AI ! (interesting - can AI already think or reason about ... AI ?)
*Great comment here. Thought so myself *
Sorry but saying truth.... this article was formatted in english by AI. I used my own dev.to mcp server to write about the article in plain english(you can find this in my github).
Atfirst i think about good quality topic and write an outline. I feed that outline in a LLM. Then the prompt generated by AI, I feed that in my mcp server and it creates a post for dev.to. Finally I tweak some changes, add some gifs and then publish my articles live.
So, yes AI is creating content for another AI
No need to apologize genAI isn’t magic...
Thanks for the article btw.
This while AI thing... It's just a force multiplier of what you already understand, and not a substitute for intuition, knowledge, or structure...
On it's own models only output meaningful content if the question/prompt you provide hits the training data.
Exactly, this is how it works and provides us with meaningful outputs.
That's clever! You still "authored" it, but used "AI" as your 'editor-in-chief' (or should I say "ghost writer") :)
Yes, AI is now my junior support and it helps me achieving my goals faster than ever.
AI tools like ChatGPT, GitHub Copilot, and Cursor are amazing but only if you know how to talk to them. I love how this guide breaks down the art of prompting with clear examples and real-world tips.
The “be specific” rule is gold. I’ve seen huge improvements just by adding context like skill level, language, and desired output.
This isn’t just about getting code it’s about learning smarter and faster. Bookmarking this for every new coder I meet!
I agree. People who feeds bad prompt and expects AI to do everything speaks bad about ai. They are just missing good prompt and that all they need to boost their productivity.
Great stuff! I've been coding for few years now (not a pro, but I get by 😉), and I'm always arguing with Claud (windsurf) about how the code/app should work. It definitely takes some trial & error to get the prompts just right!
I too sometimes gets struck in the merry-go-round. Then I try to switch to some other models or rephrase what I said. Even if it does not work, then I do that work myself :)
I have learned writing bots in Node.js and Python with various LLMs is that once your code becomes a larger project and especially if you make it modular you need to make sure you are specific on exact changes and it does not hurt to say "Please do not change anything else".
I have had AI make changes assuming I wanted something. They do eventually get and actually state "I am leaving everything else as is".
Articles like this are so much needed. AI needs enough context to create good answers (just as humans).
One interesting thing I noted after using AI for quite some time is how much models have improved in context awareness when you use an AI that has access to your whole project. For example, when some time ago the AI would generate working but quite verbose code, I now get answers like "here, need to be done and I noticed you already have a Utility class X with method y that does exactly that, so I used it" and provide very concise and readable code.
Agreed, AI is all about context, dataset, training and accuracy. It is definitely improving day by day!
These are great!
I’ve been using ChatGOT for coding and find that running the same prompt on DeepSeek and GPT-4o gives me two solid options to start with.
It’s like getting a second opinion from another senior dev.
Great post btw. I would like to suggest create AI context engineering post like this man...
Thanks, what kind of posts you would like to see? I post stuffs from various fields. Let me know. Also you can follow to get more such contents.
Sure, I already following you 🙌, I want context engineering post Aaditya
Okay, I'll be posting more about prompting in the upcoming posts
Ok, let's be specific, but who prompts "write a function" anyway?
Lol. "I know a guy who knows a guy" writes like this
that guy would be me😂
This was a solid read. I've observed that when I simply ask for code, the output tends to be very generic. However, when I provide context, such as what I’m building, my skill level, or the programming language I want to use, the responses become much more useful. Requesting explanations alongside the code also aids my learning, as it prevents me from just copy-pasting without understanding.
Being a good prompt engineer requires you to be a good engineer first. Your algorithm and problem solving skills decides how you gonna direct the AI to do things. That's how it always should be.
Very good article! I been the bad and I'm getting better at prompting. The key takeaway for me is about 'specificity' - the more specific the better the results. I can't tell you how many times my coding agent and I went round and round to resolve a problem not because it was incapable, but because I was incapable of specifying what I needed. Burned through a lot of tokens on that lesson. But, here I am, 4 full-stacked apps later, fully AI generated, [I couldn't code a single line of anything!] and still can't get enough about learning how to prompt with AI.
Im glad that you liked this article. I'm also learning on how we can use AI to leverage our productivity. Right now I'm also experimenting with prompts and its output. I'll keep writing more n more as I keep learning. I'm really happy that you liked my article!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.