AgentSkillsCN

implement-plan

严格按照计划编写代码,单个函数不超过30行,杜绝使用含糊不清的命名。

SKILL.md
--- frontmatter
name: implement-plan
description: Implement code from plan. Max 30 lines per function. No vague names.

/implement-plan [target]

Implement code from the approved plan. Strict constraints enforced.

First: Activate Workflow

bash
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

AntipatternExampleWhy It's Wrong
Over-abstractionFactory that creates one thingAbstraction without justification
Defensive paranoiaNull checks where null is impossibleImplies you don't understand your own code
Reimplementing stdlibCustom string utils when lodash existsArrogance or ignorance
Comment spam// increment counter above i++Insulting the reader
Speculative featuresConfig options nobody asked forSolving imaginary problems
Wrapper classesUserWrapper around UserComplexity without value
Enterprise patternsAbstractFactoryBean for a helperCargo-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:

  1. MAX 30 LINES PER FUNCTION - No function may exceed 30 lines. Split if needed.
  2. MAX 300 LINES PER FILE - Split into modules if approaching limit.
  3. MAX COMPLEXITY 10 - Cyclomatic complexity ≤10 per function. Flatten with early returns, extract helpers.
  4. ONE FILE PER CONCERN - No god files. Each file has one purpose.
  5. 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.
  6. FOLLOW THE PLAN - Create exactly the files/functions listed in the plan. No extras.
  7. MEANINGFUL NAMES - Variables/functions must describe what they do.
  8. NO HARDCODED VALUES - Use constants or config for magic numbers/strings.
  9. 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:

  1. .claude/skills/pragmatism/SKILL.md
  2. .claude/skills/clarity/SKILL.md
  3. .claude/skills/simplicity/SKILL.md
  4. .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.md and .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:

  1. workflow-skills/phase-loop-lessons.md — universal patterns (ships with skills, applies to all projects)
  2. .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 use execSync with template literals — use execFileSync with args array; validate names before path.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

  1. Load Plan - Read plan from .claude/plans/ or context
  2. Check Structure - Verify types/interfaces exist from /structure-first
  3. Implement - Write code following the plan EXACTLY
  4. Verify - Ensure code compiles/lints
  5. Dead Code Cleanup - Remove any dead code introduced (see below)

REQUIRED Output Format

markdown
## 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

code

## 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.