AI Prompting for Code
Last reviewed: June 2026
Pair with the full guide: Prompting for Code · Project Rules
Prompt Template
## Goal
[One sentence — what should exist when done]
## Stack
[Framework versions, language, key libraries]
## Requirements
- [ ] Requirement 1
- [ ] Requirement 2
## Constraints
- Only modify: [files]
- Do not: [add deps, refactor X]
## Verify
[Commands: npm test, npm run lint]
Context Checklist
Before sending a coding prompt, attach or mention:
| Item | Include? |
|---|---|
| Target file(s) | Yes — @Files or path |
| Pattern to match | Yes — "like LoginForm.jsx" |
| Stack versions | Yes — in rules or prompt |
| Entire repo | No |
| Error output (full) | Yes — when debugging |
Secrets / .env | Never |
Mode Quick Reference
| Mode | Prompt starter |
|---|---|
| Ask | "Explain how X works in @Files" |
| Plan | "Propose a plan. Do not implement." |
| Agent | "Implement step N of the plan above." |
| Debug | "Root cause of this error: [paste stack]" |
Review Checklist (Before Merge)
- [ ]
git diff— only expected files - [ ] Lint + typecheck pass
- [ ] Tests pass; new tests assert behavior
- [ ] No new env vars without docs
- [ ] No hardcoded secrets
- [ ] Imports resolve (
npm run build)
Bad Prompt → Better Prompt
| Bad | Better |
|---|---|
| Fix the bug | In Footer.jsx, fix broken link on line 42; match other footer links |
| Make it faster | Profile fetchData; cache GET /api/users for 60s; no new deps |
| Add tests | Add tests for validateEmail edge cases: empty, invalid, valid |