Basics of Prompting Coding AI
AI coding tools' output quality changes greatly with how you ask. Here are coding-specific tips distinct from general prompts.
5 Golden Rules
1. Give Enough Context
Over "fix this code," say "this project uses Next.js 16, TypeScript strict, Vitest. Fix module X like Y."
2. State the Completion Condition
Over "make it nice," say "all tests pass, no lint errors, existing API compatible."
3. Convey Constraints
- "Libraries you may use: existing dependencies only"
- "Don't call external APIs"
- "O(N) or less"
- "Within 100 lines"
4. Use File References
- Cursor: reference with @filename
- Claude Code: "refer to @auth.ts"
- Copilot Chat: auto-references the file open in the editor
5. Ask for a Plan First
"First a 5-step implementation plan. Start implementing after I OK it. Ask if questions arise midway"