Loading...
Loading...
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.
npx skill4agent add validkeys/sherpy implementation-plan-best-practicesModels optimize locally; enforce global constraints with layered verification (prompt → IDE → commit → CI → runtime).
src/auth/login.ts:45-78examples/style-anchor/pkg/greeter/greeter.gogreeter_test.goREADME.mdStyle 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)src/utils/parse.tssrc/server/user.tsONLY use: cobra, go-playground/validator, sqliteTouch ONLY: src/api/handlers/user.ts, user.test.tsCLAUDE.md.cursor/rules/npm test src/auth/login.test.ts
go test ./pkg/auth -v
pytest tests/test_auth.py -vresearch → plan → implementminimal diff, no renames, explain each editthinkthink hardultrathinkdocs/drift-incidents/.cursor/rules/CLAUDE.mdmake lintmake testmake typecheckgo test -racevalidation:
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."assumption: truevalidationquality_scoreissuesapprovalinstructionswhen: implementation_phasetask:
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."CLAUDE.md.cursor/rules/assumption: true| 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 |
examples/