Security Expert
“You are an expert security engineer. Review this code for potential vulnerabilities like XSS, CSRF, and SQL injection. Provide a list of any issues you find and suggest fixes.”
Communicating effectively with an AI coding assistant is a skill. While you can get useful results with simple questions, mastering the art of prompting allows you to guide the AI’s reasoning process, leading to more accurate, well-architected, and reliable code.
This guide covers several powerful techniques that will transform your conversations with your AI partner.
The more information and constraints you provide, the better the AI can tailor its response to your exact needs. Don’t be vague.
pg
library. The connection string should be loaded from the DATABASE_URL
environment variable. Ensure the connection includes retry logic with exponential backoff.”By providing these details upfront, you guide the AI towards the correct implementation and prevent it from making incorrect assumptions.
For any task more complex than a one-line change, force the AI to think before it codes.
Ask for a Plan First. Start with a prompt that explicitly asks for a plan and forbids writing code.
I need to add a feature that allows users to upload a profile picture. First, create a detailed, step-by-step plan for how you will implement this. List the files you will need to create or modify. **Do not write any code yet.**
Review and Refine the Plan.
The AI will produce an outline (e.g., “1. Create a new API endpoint /api/upload-avatar
. 2. Add a file input to the ProfilePage
component…”). Review this plan. If it looks good, you can proceed. If not, you can provide corrections (“Actually, let’s use a separate AvatarUpload
component.”) before any code is written.
Execute the Plan. Once you’re happy with the plan, give the green light.
The plan looks good. Please proceed with the implementation.
This two-step process prevents the AI from rushing into a flawed implementation and ensures the solution is well-thought-out.
If you want the AI to follow a specific coding style, pattern, or structure, the best way to communicate that is by showing it an example.
PaymentService
class that follows the exact same pattern and structure as the @/services/AuthService.ts
file.”The AI is excellent at pattern recognition. By providing a concrete example, you give it a perfect template to follow.
You can prime the model to adopt a specific mindset or access a particular domain of knowledge by assigning it a role at the beginning of your prompt.
Security Expert
“You are an expert security engineer. Review this code for potential vulnerabilities like XSS, CSRF, and SQL injection. Provide a list of any issues you find and suggest fixes.”
Performance Guru
“You are a senior performance engineer. Analyze this function and identify any performance bottlenecks. Suggest optimizations to make it faster and more memory-efficient.”
Don’t treat the conversation as a single-shot question and answer. It’s a dialogue. If the AI’s first attempt isn’t perfect, guide it with follow-up instructions.
switch
statement instead of nested if
s?”By iterating and providing feedback, you can collaboratively shape the AI’s output until it meets your exact specifications.
Before blaming the model, check these common configuration issues:
Symptom | Root Cause | Fix |
---|---|---|
Model doesn’t understand your codebase structure | Missing or outdated context rules | Cursor: Run /Generate Cursor Rules commandClaude Code: Run /init command |
Model recreates existing functionality | Not referencing existing code | Use @-mentions: @auth.ts extend the login logic |
Consistently poor response quality | Wrong model or mode | Verify you’re using Sonnet 4/Opus 4.1/GPT-5 in MAX mode |
Model “forgets” important details | Insufficient reasoning allocation | Use ultrathink in Claude Code or MAX mode in Cursor |
Confusion about libraries/frameworks | Missing documentation context | Use Context7 MCP: “Use Context7 for docs” OR web search: “Search web for [library] docs” |
Unexpected implementation choices | Incomplete requirements | Always end with: “Ask for everything you need to prepare the best solution” |
Follow these steps for consistently excellent results:
Set Up Context
Use Maximum Capabilities
ultrathink
) for architecture decisionsBe Explicit
Request Clarification
Configure Documentation Access
With this approach, you’ll achieve the best possible results from these advanced models.