Stop Writing Terrible Prompts: A Developer's Guide to Getting AI to Actually Help
Your prompts are probably trash. Here's how I learned to write AI prompts that actually work instead of generating generic nonsense.

I used to suck at prompting AI models. Like, really suck.
I'd throw vague requests at ChatGPT like "help me with my React component" and wonder why I got back boilerplate code that looked like it came from a 2019 tutorial. Sound familiar?
After spending way too much time wrestling with Claude and ChatGPT on client projects, I've figured out what actually works. The difference between a mediocre prompt and a great one isn't just better results – it's the difference between AI being a glorified search engine and becoming your most productive pair programming partner.

Context Is Everything (And You're Probably Skipping It)
Here's what I learned the hard way: AI models are context-hungry beasts. They need to understand not just what you want, but why you want it, what constraints you're working with, and what your end goal looks like.
Bad prompt:
Write a function to handle user authenticationGood prompt:
I'm building a Next.js 13 app with TypeScript and Supabase auth. I need a custom hook that handles login/logout state, automatically redirects unauthenticated users to /login, and shows loading states during auth operations. The app uses shadcn/ui components. Here's my current auth context: [paste relevant code]See the difference? The second prompt gives the AI everything it needs to write code that actually fits your project. I've found that spending an extra 30 seconds adding context saves me 10 minutes of back-and-forth.
The Power of Constraints
This might sound counterintuitive, but the more constraints you give an AI model, the better its output becomes. It's like giving a designer a brief versus saying "make it look good."
I always include:
- Tech stack specifics: "Using React 18 with TypeScript and Tailwind CSS"
- Performance requirements: "This needs to work on mobile with slow connections"
- Code style preferences: "Use functional components with custom hooks, no classes"
- Business constraints: "This feature needs to work for both free and premium users"
Here's a real example from a recent project:
I need a TypeScript utility function for my e-commerce app that calculates shipping costs. Requirements:
- Must handle Nigerian postal codes (6 digits)
- Different rates for Lagos (₦1500), other states (₦2500), rural areas (₦3500)
- Add 50% surcharge for items over 10kg
- Return type should include cost breakdown for UI display
- Handle edge cases gracefully with clear error messagesThe AI gave me exactly what I needed, including proper TypeScript types and error handling I hadn't even thought of.

Examples Are Your Secret Weapon
I used to think giving examples was hand-holding the AI too much. Wrong. Examples are like showing instead of telling – they're incredibly powerful for getting the exact output format and style you want.
For code generation, I'll often include:
- A similar function that works well in my codebase
- The exact API response format I'm working with
- Error handling patterns I prefer
- Testing patterns I want to follow
For content or copy, I'll paste examples of my writing style or brand voice. The AI picks up on nuances that are hard to describe in words.
Iterative Prompting (The Conversation Approach)
Here's something that changed my whole approach: don't try to get everything perfect in one shot. Treat it like a conversation with a really smart colleague who needs guidance.
My typical flow:
- 1Initial prompt: Get the basic structure or approach
- 2Refinement: "This is close, but can you modify X to handle Y case?"
- 3Polish: "Add error handling and make the TypeScript types more specific"
- 4Integration: "How would this integrate with my existing auth system?"
This works way better than trying to cram everything into one massive prompt. Plus, you can course-correct if the AI goes down the wrong path.
Role-Based Prompting Actually Works
I was skeptical of the "act as a senior developer" approach, but it genuinely improves output quality. The key is being specific about the role and expertise level.
Instead of:
Act as a senior developerTry:
You're a senior full-stack developer with 8+ years of experience in React and Node.js. You prioritize clean, maintainable code and have strong opinions about TypeScript best practices. You're helping a mid-level developer on your team.This primes the AI to give more opinionated, experienced-level advice instead of generic "best practices" fluff.
Domain-Specific Language Matters
When working on AI integration projects, I've noticed that using the right technical vocabulary makes a huge difference. Instead of "make the API call faster," I'll say "optimize this for lower latency" or "implement request batching." The AI responds with more sophisticated solutions.
Same goes for business domain language. When working on fintech projects, using terms like "settlement," "reconciliation," and "compliance requirements" gets me more accurate, industry-appropriate solutions.

Common Pitfalls I've Learned to Avoid
The "just make it work" trap: Vague prompts get vague results. Always be specific about what "working" means in your context.
Assuming the AI knows your codebase: It doesn't. Paste relevant code snippets, explain your architecture, mention your conventions.
Not specifying error handling: AI-generated code often has happy-path bias. Explicitly ask for error handling, edge cases, and validation.
Forgetting about maintainability: Ask for code that your team can understand and modify, not just code that works.
Advanced Techniques for Complex Problems
For really complex problems, I use what I call "decomposition prompting":
- 1Ask the AI to break down the problem into smaller pieces
- 2Work through each piece individually
- 3Ask for integration guidance
- 4Request testing strategies
This works especially well for system design questions or complex business logic.
Practical Takeaways
- Always include your tech stack, constraints, and context in prompts
- Use examples to show the AI exactly what you want
- Treat prompting as a conversation, not a one-shot request
- Be specific about roles and expertise levels
- Use domain-appropriate technical language
- Explicitly request error handling and edge case coverage
- Break complex problems into smaller, manageable pieces
- Save your best prompts as templates for similar future tasks
The biggest mindset shift for me was realizing that prompting is a skill worth developing, not just a necessary evil. Good prompts are like good documentation – they take a bit more effort upfront but save tons of time later.
What's your biggest prompt engineering frustration? I'm always curious to hear how other developers are tackling this stuff.

Ibrahim Lawal
Full-Stack Developer & AI Integration Specialist. Building AI-powered products that solve real problems.
View Portfolio