Implementation Plan Best Practices
Proven best practices for creating implementation plans that prevent drift and maintain alignment with project standards.
Core Principle
Models optimize locally; enforce global constraints with layered verification (prompt → IDE → commit → CI → runtime).
1. Style Anchors
- Always include 2-3 exemplary files as templates in prompts
- Reference exact paths and line numbers (e.g.,
src/auth/login.ts:45-78)
- Prefer concrete repository examples with code + tests + README
- Example:
examples/style-anchor/pkg/greeter/greeter.go (code), greeter_test.go (tests), README.md (docs)
- Place anchors early in task instructions to prevent architectural drift
Template:
Style Anchors:
- src/auth/login.ts:45-78 (authentication pattern with proper error handling)
- src/auth/login.test.ts:12-34 (test structure for auth flows)
- src/middleware/validation.ts:15-30 (input validation pattern)
2. Task Sizing
- Target duration: 30-150 minutes (0.5-2.5 hours)
- File scope: 1-3 files per task (max 5 with justification)
- Splitting strategy: tests + scaffolding → minimal implementation → refactor & polish
- Commit after each small task; revert immediately on drift
- If task <30m, document rationale or split it
Examples:
- Small: Fix bug in
src/utils/parse.ts — 30-60 mins
- Medium: Add API endpoint
src/server/user.ts with tests — 90-150 mins
- Large: Migrate auth system — Split into design + 3-5 incremental tasks
3. Affirmative Instructions
- State permitted actions explicitly (e.g.,
ONLY use: cobra, go-playground/validator, sqlite)
- Avoid negative framing ("Don't use X" → "ONLY use: Y, Z")
- Specify exact file scopes:
Touch ONLY: src/api/handlers/user.ts, user.test.ts
4. Tiered Rules
- Global: User prefs (format, language, length)
- Project: Persistent rules in
CLAUDE.md or .cursor/rules/ (loaded every session)
- Context-aware: Auto-attached rules per directory or file pattern
5. TDD as Anchor
- Require TDD checklist: tests → minimal code → more tests → refactor
- When tests fail: "Revise implementation to pass this test while keeping all previously passing tests. Do not modify the test. Do not add dependencies."
- Include explicit validation commands:
npm test src/auth/login.test.ts
go test ./pkg/auth -v
pytest tests/test_auth.py -v
6. Prompt Positioning
- Put critical specs, style anchors, and hard rules at the beginning
- Reiterate them at the end of prompts
- Avoid burying requirements in the middle
7. Model Strategies
- Claude: Use for surgical, minimal-diff edits; request
research → plan → implement, minimal diff, no renames, explain each edit; use thinking triggers (think, think hard, ultrathink)
- GPT: Use for exploratory/greenfield work and code review; ask for tactical plans and side-effect checks
8. Self-Consistency & AI-on-AI Review
- Generate 3+ implementations (higher temperature), then ask model to pick most consistent
- Use multi-model review (e.g., Claude writes, GPT/Gemini reviews) to catch subtle issues
9. Drift Handling
Stop & revert immediately if:
- New dependencies introduced (not in allowed list)
- Files touched outside specified targets (>3 unexpected files)
- Linting/type errors cannot be resolved within task scope
- Tests fail and model proposes changing tests instead of implementation
Immediate actions:
- Stop the session
- Revert to pre-task state (only if changes produced by agent in this session)
- Create incident note in
docs/drift-incidents/ with:
- What happened
- Files changed unexpectedly
- New dependencies proposed
- Remediation steps
Allowed deviations:
- Minor formatting (editorconfig)
- Whitespace-only edits
- Single-line refactors within scope and type-checked
Recording learnings:
- Update
.cursor/rules/ or CLAUDE.md with new rules after each session
- Add to style anchors if new pattern discovered
10. Quality Gates
Pre-commit:
make lint with zero warnings
make test with all tests passing
make typecheck with zero errors
CI gates:
- Count violations (gofmt, lint, typecheck) and fail if threshold exceeded
- Run tests with race detection (e.g.,
go test -race)
Per-task validation:
validation:
commands:
- npm run lint
- npm test src/[module].test.ts
- npm run typecheck
expected_output: "All tests passing, 0 lint errors"
failure_handling: "STOP and report. Do not continue to next task."
11. Layered Verification
- Prompt level: Explicit constraints, style anchors, task sizing
- IDE level: Linting, type checking, auto-formatting
- Commit level: Pre-commit hooks, validation scripts
- CI level: Quality gates, test suites, coverage thresholds
- Runtime level: Input validation, proper error handling, monitoring
12. Key Learnings from Milestone 0
- Make templates explicit vs concrete: Include all schema-required top-level fields to avoid validation failures
- Enforce concrete style anchors early: Include 2-3 concrete anchors (code + tests + README) on every planning task
- Mark inferred edits: Use
assumption: true with rationale for any inferred additions
- Respect task-sizing constraints: Enforce 30-150m task estimates; split shorter tasks with rationale
- Keep validation inline: Add
validation summary with quality_score, issues, and approval
- Prefer concrete execution snippets: Add explicit validator commands in
instructions
- Scope implementation rules: Keep implementation-only pattern checks scoped with
when: implementation_phase
- Use repository examples as anchors: Small, well-scoped examples are high-leverage anchors
Task Template Example
task:
id: t-auth-001
name: "Add login endpoint with JWT validation"
estimate_minutes: 90
files:
touch_only: [src/api/handlers/auth.ts, src/api/handlers/auth.test.ts]
modify_only: [src/api/routes.ts]
style_anchors:
- {path: src/api/handlers/user.ts, lines: 45-78, pattern: "Handler with proper error handling"}
- {path: src/api/handlers/user.test.ts, lines: 12-45, pattern: "Test structure for API handlers"}
constraints:
dependencies:
only_use: [jsonwebtoken, express-validator]
file_scope:
max_files: 3
stop_if_exceeded: true
instructions: |
## CRITICAL CONSTRAINTS
- ONLY modify files listed above
- ONLY use dependencies: jsonwebtoken, express-validator
- MUST pass: npm test, npm run lint
## Style Anchors
See src/api/handlers/user.ts:45-78 for handler pattern
See src/api/handlers/user.test.ts:12-45 for test structure
## TDD Checklist
- [ ] Write failing test for POST /auth/login
- [ ] Implement minimal handler to pass
- [ ] Add tests for edge cases
- [ ] Refactor for clarity
## Drift Policy
STOP if: files touched >3, new dependencies, tests fail
## Validation
npm test src/api/handlers/auth.test.ts && npm run lint && npm run typecheck
validation:
commands: [npm test src/api/handlers/auth.test.ts, npm run lint, npm run typecheck]
expected_output: "All tests passing, 0 errors"
failure_handling: "STOP. Revise implementation to pass tests."
Quick Practical Checklist
When creating implementation plans:
- Create
CLAUDE.md or .cursor/rules/ with prompt-level rules
- Add 2-3 concrete style anchors to prompts (prefer repository examples)
- Rescope tasks to 30m-2.5h and commit per task
- Convert negative constraints to affirmative instructions
- Enforce linting zero-warnings, pre-commit hooks, and CI gates
- Require TDD plans and tests before making changes
- Use proper error handling for runtime validation
- Include all schema-required fields in generated YAML
- Mark inferred additions with
assumption: true and rationale
- Place critical constraints at beginning AND end of prompts
Common Anti-Patterns
| Anti-Pattern |
Problem |
Fix |
| No style anchors |
Model introduces inconsistent patterns |
Add 2-3 concrete examples with line numbers |
| Tasks >2.5 hours |
Difficult to review, easy to drift |
Split into tests + implementation + refactor |
| Negative framing |
"Don't use X" is harder to follow |
"ONLY use: Y, Z" |
| Buried rules |
Model misses important constraints |
Put at beginning AND end |
| No validation commands |
Unclear when task is complete |
Include explicit lint/test/typecheck commands |
| Allowing test modification |
Tests weakened to pass implementation |
"Revise implementation, not tests" |
| No drift policy |
Small drifts compound |
Explicit stop criteria and revert process |
| No commit checkpoints |
Large uncommitted changes hard to debug |
Commit after each task |
Integration with Other Skills
- implementation-planner: Apply these practices when generating plans
- implementation-plan-review: Validate plans against these practices
- business-requirements-interview: Ensure requirements align with these practices
- technical-requirements-interview: Technical specs should follow these practices
Examples
See examples/ directory for:
- Well-structured task with all best practices applied
- Before/after examples showing improvements
- Common mistakes and how to fix them
1---2name: implementation-plan-best-practices3description: Educational guide on best practices for creating implementation plans that prevent drift. Covers style anchors, task sizing, TDD requirements, affirmative instructions, drift handling, and quality gates. Use when creating or improving implementation plans to ensure they follow proven patterns.4---56# Implementation Plan Best Practices78Proven best practices for creating implementation plans that prevent drift and maintain alignment with project standards.910## Core Principle1112> Models optimize locally; enforce global constraints with layered verification (prompt → IDE → commit → CI → runtime).1314## 1. Style Anchors15- Always include 2-3 exemplary files as templates in prompts16- Reference exact paths and line numbers (e.g., `src/auth/login.ts:45-78`)17- Prefer concrete repository examples with code + tests + README18- Example: `examples/style-anchor/pkg/greeter/greeter.go` (code), `greeter_test.go` (tests), `README.md` (docs)19- Place anchors early in task instructions to prevent architectural drift2021**Template:**22```23Style Anchors:24- src/auth/login.ts:45-78 (authentication pattern with proper error handling)25- src/auth/login.test.ts:12-34 (test structure for auth flows)26- src/middleware/validation.ts:15-30 (input validation pattern)27```2829## 2. Task Sizing30- **Target duration:** 30-150 minutes (0.5-2.5 hours)31- **File scope:** 1-3 files per task (max 5 with justification)32- **Splitting strategy:** tests + scaffolding → minimal implementation → refactor & polish33- Commit after each small task; revert immediately on drift34- If task <30m, document rationale or split it3536**Examples:**37- Small: Fix bug in `src/utils/parse.ts` — 30-60 mins38- Medium: Add API endpoint `src/server/user.ts` with tests — 90-150 mins39- Large: Migrate auth system — Split into design + 3-5 incremental tasks4041## 3. Affirmative Instructions42- State permitted actions explicitly (e.g., `ONLY use: cobra, go-playground/validator, sqlite`)43- Avoid negative framing ("Don't use X" → "ONLY use: Y, Z")44- Specify exact file scopes: `Touch ONLY: src/api/handlers/user.ts, user.test.ts`4546## 4. Tiered Rules47- **Global:** User prefs (format, language, length)48- **Project:** Persistent rules in `CLAUDE.md` or `.cursor/rules/` (loaded every session)49- **Context-aware:** Auto-attached rules per directory or file pattern5051## 5. TDD as Anchor52- Require TDD checklist: tests → minimal code → more tests → refactor53- When tests fail: "Revise implementation to pass this test while keeping all previously passing tests. Do not modify the test. Do not add dependencies."54- Include explicit validation commands:55```bash56npm test src/auth/login.test.ts57go test ./pkg/auth -v58pytest tests/test_auth.py -v59```6061## 6. Prompt Positioning62- Put critical specs, style anchors, and hard rules at the **beginning**63- Reiterate them at the **end** of prompts64- Avoid burying requirements in the middle6566## 7. Model Strategies67- **Claude:** Use for surgical, minimal-diff edits; request `research → plan → implement`, `minimal diff, no renames, explain each edit`; use thinking triggers (`think`, `think hard`, `ultrathink`)68- **GPT:** Use for exploratory/greenfield work and code review; ask for tactical plans and side-effect checks6970## 8. Self-Consistency & AI-on-AI Review71- Generate 3+ implementations (higher temperature), then ask model to pick most consistent72- Use multi-model review (e.g., Claude writes, GPT/Gemini reviews) to catch subtle issues7374## 9. Drift Handling7576**Stop & revert immediately if:**77- New dependencies introduced (not in allowed list)78- Files touched outside specified targets (>3 unexpected files)79- Linting/type errors cannot be resolved within task scope80- Tests fail and model proposes changing tests instead of implementation8182**Immediate actions:**831. Stop the session842. Revert to pre-task state (only if changes produced by agent in this session)853. Create incident note in `docs/drift-incidents/` with:86 - What happened87 - Files changed unexpectedly88 - New dependencies proposed89 - Remediation steps9091**Allowed deviations:**92- Minor formatting (editorconfig)93- Whitespace-only edits94- Single-line refactors within scope and type-checked9596**Recording learnings:**97- Update `.cursor/rules/` or `CLAUDE.md` with new rules after each session98- Add to style anchors if new pattern discovered99100## 10. Quality Gates101102**Pre-commit:**103- `make lint` with zero warnings104- `make test` with all tests passing105- `make typecheck` with zero errors106107**CI gates:**108- Count violations (gofmt, lint, typecheck) and fail if threshold exceeded109- Run tests with race detection (e.g., `go test -race`)110111**Per-task validation:**112```yaml113validation:114 commands:115 - npm run lint116 - npm test src/[module].test.ts117 - npm run typecheck118 expected_output: "All tests passing, 0 lint errors"119 failure_handling: "STOP and report. Do not continue to next task."120```121122## 11. Layered Verification1231241. **Prompt level:** Explicit constraints, style anchors, task sizing1252. **IDE level:** Linting, type checking, auto-formatting1263. **Commit level:** Pre-commit hooks, validation scripts1274. **CI level:** Quality gates, test suites, coverage thresholds1285. **Runtime level:** Input validation, proper error handling, monitoring129130## 12. Key Learnings from Milestone 0131- **Make templates explicit vs concrete:** Include all schema-required top-level fields to avoid validation failures132- **Enforce concrete style anchors early:** Include 2-3 concrete anchors (code + tests + README) on every planning task133- **Mark inferred edits:** Use `assumption: true` with rationale for any inferred additions134- **Respect task-sizing constraints:** Enforce 30-150m task estimates; split shorter tasks with rationale135- **Keep validation inline:** Add `validation` summary with `quality_score`, `issues`, and `approval`136- **Prefer concrete execution snippets:** Add explicit validator commands in `instructions`137- **Scope implementation rules:** Keep implementation-only pattern checks scoped with `when: implementation_phase`138- **Use repository examples as anchors:** Small, well-scoped examples are high-leverage anchors139140## Task Template Example141142```yaml143task:144 id: t-auth-001145 name: "Add login endpoint with JWT validation"146 estimate_minutes: 90147148 files:149 touch_only: [src/api/handlers/auth.ts, src/api/handlers/auth.test.ts]150 modify_only: [src/api/routes.ts]151152 style_anchors:153 - {path: src/api/handlers/user.ts, lines: 45-78, pattern: "Handler with proper error handling"}154 - {path: src/api/handlers/user.test.ts, lines: 12-45, pattern: "Test structure for API handlers"}155156 constraints:157 dependencies:158 only_use: [jsonwebtoken, express-validator]159 file_scope:160 max_files: 3161 stop_if_exceeded: true162163 instructions: |164 ## CRITICAL CONSTRAINTS165 - ONLY modify files listed above166 - ONLY use dependencies: jsonwebtoken, express-validator167 - MUST pass: npm test, npm run lint168169 ## Style Anchors170 See src/api/handlers/user.ts:45-78 for handler pattern171 See src/api/handlers/user.test.ts:12-45 for test structure172173 ## TDD Checklist174 - [ ] Write failing test for POST /auth/login175 - [ ] Implement minimal handler to pass176 - [ ] Add tests for edge cases177 - [ ] Refactor for clarity178179 ## Drift Policy180 STOP if: files touched >3, new dependencies, tests fail181182 ## Validation183 npm test src/api/handlers/auth.test.ts && npm run lint && npm run typecheck184185 validation:186 commands: [npm test src/api/handlers/auth.test.ts, npm run lint, npm run typecheck]187 expected_output: "All tests passing, 0 errors"188 failure_handling: "STOP. Revise implementation to pass tests."189```190191## Quick Practical Checklist192193When creating implementation plans:1941951. Create `CLAUDE.md` or `.cursor/rules/` with prompt-level rules1962. Add 2-3 concrete style anchors to prompts (prefer repository examples)1973. Rescope tasks to 30m-2.5h and commit per task1984. Convert negative constraints to affirmative instructions1995. Enforce linting zero-warnings, pre-commit hooks, and CI gates2006. Require TDD plans and tests before making changes2017. Use proper error handling for runtime validation2028. Include all schema-required fields in generated YAML2039. Mark inferred additions with `assumption: true` and rationale20410. Place critical constraints at beginning AND end of prompts205206## Common Anti-Patterns207208| Anti-Pattern | Problem | Fix |209|--------------|---------|-----|210| No style anchors | Model introduces inconsistent patterns | Add 2-3 concrete examples with line numbers |211| Tasks >2.5 hours | Difficult to review, easy to drift | Split into tests + implementation + refactor |212| Negative framing | "Don't use X" is harder to follow | "ONLY use: Y, Z" |213| Buried rules | Model misses important constraints | Put at beginning AND end |214| No validation commands | Unclear when task is complete | Include explicit lint/test/typecheck commands |215| Allowing test modification | Tests weakened to pass implementation | "Revise implementation, not tests" |216| No drift policy | Small drifts compound | Explicit stop criteria and revert process |217| No commit checkpoints | Large uncommitted changes hard to debug | Commit after each task |218219## Integration with Other Skills220221- **implementation-planner:** Apply these practices when generating plans222- **implementation-plan-review:** Validate plans against these practices223- **business-requirements-interview:** Ensure requirements align with these practices224- **technical-requirements-interview:** Technical specs should follow these practices225226## Examples227228See `examples/` directory for:229- Well-structured task with all best practices applied230- Before/after examples showing improvements231- Common mistakes and how to fix them