/implement-plan [target]
Implement code from the approved plan. Strict constraints enforced.
First: Activate Workflow
mkdir -p .claude && echo '{"skill":"implement","started":"'$(date -Iseconds)'"}' > .claude/active-workflow.json
Craft Standards (MANDATORY)
Write code a master craftsperson would be proud of.
Code must look like it was written by a skilled human engineer, not generated by AI.
AI Antipatterns to REJECT
| Antipattern | Example | Why It's Wrong |
|---|---|---|
| Over-abstraction | Factory that creates one thing | Abstraction without justification |
| Defensive paranoia | Null checks where null is impossible | Implies you don't understand your own code |
| Reimplementing stdlib | Custom string utils when lodash exists | Arrogance or ignorance |
| Comment spam | // increment counter above i++ | Insulting the reader |
| Speculative features | Config options nobody asked for | Solving imaginary problems |
| Wrapper classes | UserWrapper around User | Complexity without value |
| Enterprise patterns | AbstractFactoryBean for a helper | Cargo-culting |
Human Craft to ACHIEVE
- •Code that reads like well-written prose
- •Functions that do exactly one thing, perfectly
- •Names that reveal intent without comments
- •Structure that guides the reader naturally
- •Simplicity that clearly took effort to achieve
- •Every line earns its place
Test: Would a senior engineer mass-delete your code in review? If yes, don't write it.
⚠️ STRICT REQUIREMENTS - NO JUDGMENT CALLS
You MUST follow these constraints EXACTLY:
- •MAX 30 LINES PER FUNCTION - No function may exceed 30 lines. Split if needed.
- •MAX 300 LINES PER FILE - Split into modules if approaching limit.
- •MAX COMPLEXITY 10 - Cyclomatic complexity ≤10 per function. Flatten with early returns, extract helpers.
- •ONE FILE PER CONCERN - No god files. Each file has one purpose.
- •SEARCH BEFORE CREATE - Before writing a utility function, search for existing implementations:
- •Check
utils/,lib/,helpers/,common/directories - •
grep -r "function copyDir" --include="*.ts"(or similar) - •If similar exists, import it. Don't recreate.
- •Check
- •FOLLOW THE PLAN - Create exactly the files/functions listed in the plan. No extras.
- •MEANINGFUL NAMES - Variables/functions must describe what they do.
- •NO HARDCODED VALUES - Use constants or config for magic numbers/strings.
- •HANDLE ALL ERRORS - Every operation that can fail must have error handling.
FORBIDDEN (Phase will FAIL if detected):
- •Functions longer than 30 lines
- •Files longer than 300 lines
- •Cyclomatic complexity > 10 (too many branches/paths)
- •Vague names:
data,result,temp,item,stuff,info,obj - •Multiple concerns in one file
- •Recreating utilities that already exist in the codebase
- •Hardcoded configuration values
- •Ignored error cases
- •Features not in the plan
Process
Step 0: Load Expert Guidance
Before starting, read these canon skills and apply their principles throughout:
Always load:
- •
.claude/skills/pragmatism/SKILL.md - •
.claude/skills/clarity/SKILL.md - •
.claude/skills/simplicity/SKILL.md - •
.claude/skills/composition/SKILL.md
Load if applicable to target code:
- •TypeScript files (.ts) → also read
.claude/skills/typescript/SKILL.md - •Auth, tokens, passwords, encryption → also read
.claude/skills/security-mindset/SKILL.mdand.claude/skills/owasp/SKILL.md
If a skill file doesn't exist (not installed in this project), skip it and continue. Reference loaded experts in your APPLIED output.
Step 0b: Learn From Past Mistakes
Read both lessons files if they exist:
- •
workflow-skills/phase-loop-lessons.md— universal patterns (ships with skills, applies to all projects) - •
.claude/phase-loop-lessons.md— project-specific patterns (accumulated from this project's runs)
Apply these lessons as you write code:
- •LOGIC entries → avoid these exact bug patterns (e.g., never pair
existsSync+readFileSync— use try-catch; never useexecSyncwith template literals — useexecFileSyncwith args array; validate names beforepath.join; escape</in embedded JSON) - •CODE_QUALITY entries → avoid dead exports, unused imports, redundant verification reads
- •DESIGN entries → respect size limits, avoid unbounded lists from user-controlled input
- •AI_SMELL entries → do NOT generate these antipatterns: no single-use helpers, no JSDoc restating function names, no null checks on typed params, no speculative types/config, no empty catch blocks
This is the most impactful phase for preventing recurring issues. Check each LOGIC entry against your implementation.
If a file doesn't exist, skip it and continue.
Step 1: Load Plan
- •Load Plan - Read plan from
.claude/plans/or context - •Check Structure - Verify types/interfaces exist from
/structure-first - •Implement - Write code following the plan EXACTLY
- •Verify - Ensure code compiles/lints
- •Dead Code Cleanup - Remove any dead code introduced (see below)
REQUIRED Output Format
## Implementation: [feature] FILES_CREATED: - path/to/file.ts: [functions defined] LONGEST_FUNCTION: [name] at [N] lines (must be ≤30) ### Verification: ```bash $ npx tsc --noEmit (no errors)
Dead Code Cleanup:
TOOL_USED: [knip|qodana|vulture|deadcode|cargo-udeps] DEAD_CODE_FOUND: [N] items DEAD_CODE_REMOVED: [list or "none"]
APPLIED:
- •
IMPLEMENT_COMPLETE
## Dead Code Cleanup (MANDATORY) After implementation, detect language and remove dead code: | Language | Detection | Tool | Command | |----------|-----------|------|---------| | JS/TS | `package.json` | knip | `npx knip --reporter compact` | | Java | `pom.xml` or `build.gradle` | Qodana | Use `mcp__qodana__qodana_scan` | | Python | `pyproject.toml` or `*.py` | vulture | `uvx vulture . --min-confidence 80` | | Go | `go.mod` | deadcode | `go run golang.org/x/tools/cmd/deadcode@latest ./...` | | Rust | `Cargo.toml` | cargo-udeps | `cargo +nightly udeps` | | C# | `*.csproj` | Qodana | Use `mcp__qodana__qodana_scan` | **Process:** 1. Run the appropriate tool for the detected language 2. Parse output for unused exports, functions, imports, variables 3. Remove dead code directly (no confirmation needed for code YOU just wrote) 4. Re-run tool to verify cleanup <critical>Only remove dead code in files YOU modified during this implementation. Never touch unrelated files.</critical> Skip items marked with `@keep`, `// keep`, or `# keep`. ## Validation (Phase will FAIL if violated) - Any function > 30 lines - Any file > 300 lines - Any function with cyclomatic complexity > 10 - Vague variable names detected - Duplicated utility that exists elsewhere in codebase - Files not in plan created without justification - Dead code left behind in files you created/modified ## 🛑 MANDATORY STOP After implementation: - DO NOT proceed to next phase - DO NOT continue with "let me also..." **Your turn ends here.** Output IMPLEMENT_COMPLETE and STOP.