The Art of Prompting
Good prompts are the difference between getting useful code and getting frustrated. These strategies work across all AI coding tools.
Strategy 1: Be Specific About Context
Don't assume the AI knows your setup. State your tech stack, constraints, and goals explicitly.
❌ Bad: "Create a login form"
✅ Good: "Create a login form using React and Tailwind CSS.
Requirements:
- Email and password fields
- Client-side validation
- Show loading state during submit
- Handle errors with toast notifications
- Use our existing Button component from @/components/ui"Strategy 2: The Q&A Strategy
Get the AI to ask clarifying questions before providing solutions. This helps the model understand your requirements better.
I need to implement Stripe payments. Before providing a solution, please ask me relevant questions about my specific requirements and constraints so you can give me the most appropriate implementation advice.Best for:
- API integrations
- Authentication systems
- Database design
- Complex app features (notifications, etc.)
Strategy 3: Pros and Cons Analysis
Prevent one-sided recommendations by asking for balanced analysis.
I need to implement transactional email into my app. Analyze the pros and cons of Resend, Loops, and Mailersend. Consider factors like scalability, UX, ease of development, and maintenance requirements.Strategy 4: Role-Based Prompting
Get advice that reflects a specific role's priorities and expertise.
You're a security expert and ethical hacker. Review my app to identify any security vulnerabilities, potential edge cases, or implementation flaws. Be particularly attentive to common OWASP security risks.Strategy 5: Provide Examples
Show the AI what you want by providing examples of similar code in your codebase.
Create a ProductCard component following the same pattern as this existing UserCard:
[paste UserCard code]
The ProductCard should display: image, title, price, and an 'Add to Cart' button.Strategy 6: Iterative Refinement
Don't try to get everything perfect in one prompt. Build incrementally.
The iteration loop:
- 1. Start with core functionality
- 2. Review and test what you got
- 3. Ask for specific modifications
- 4. Add edge cases and polish
- 5. Refactor if needed
Strategy 7: Constrain the Output
Tell the AI what NOT to do. This prevents over-engineering.
Create a simple counter component.
Constraints:
- No external state management (no Redux/Zustand)
- No TypeScript generics
- Keep it under 30 lines
- Don't add features I didn't ask forThe best prompt is one you can reuse. Save your effective prompts as templates.