AgentSkillsCN

implementation

适用于从 feature-list.json 实施功能时。在 IMPLEMENT 状态下加载,完成端到端功能开发:代码、测试、验证、提交。BLOCKING:如果 .claude/scripts/ 中存在 TEMPLATE-*.sh 文件,需先自定义并重命名。功能完成后,进行会话反思以更新脚本并预防未来问题。涵盖编码模式、测试编写、上下文图查询、健康检查及持续改进。

SKILL.md
--- frontmatter
name: implementation
description: "Use when implementing features from feature-list.json. Load in IMPLEMENT state for end-to-end feature development: code, tests, verification, commits. BLOCKING: If TEMPLATE-*.sh files exist in .claude/scripts/, customize and rename them first. After feature completion, performs session introspection to update scripts and prevent future issues. Covers coding patterns, test writing, context graph queries, health checks, and continuous improvement."
context: fork
agent: general-purpose

Implementation

Feature development for IMPLEMENT state.

When to Load

  • State: IMPLEMENT
  • Condition: Pending feature exists in feature-list.json

Core Workflow

StepActionCommand/Tool
1Get feature.claude/scripts/get-current-feature.sh
2BLOCKING: Check for templatesls .claude/scripts/TEMPLATE-*.sh 2>/dev/null
3Analyze codebasemcp__token-efficient__execute_code
4Query past decisionscontext_query_traces(query=feature_description)
5Implement featureSee Step 5 detailed workflow below
6Commit (ONLY after tests pass).claude/scripts/feature-commit.sh feat-ID "desc"
7Mark complete.claude/scripts/mark-feature-complete.sh feat-ID implemented
8Session introspectionDetect issues → Update scripts → Commit separately

Step 2: TEMPLATE- Gate (Critical)

If TEMPLATE-*.sh files exist → STOP

ActionCommand
Read script purposescat .claude/scripts/README.md
Customize scriptEdit for your project (ports, paths, commands)
Rename to activatemv TEMPLATE-script.sh script.sh
Test scriptRun and verify output
Commitgit add .claude/scripts/ && git commit

Only proceed when: ls .claude/scripts/TEMPLATE-*.sh returns nothing

See references/template-scripts.md for detailed customization guide.

Step 5: Feature Implementation Sub-Workflow (CRITICAL)

NEVER commit until ALL verification steps pass.

Sub-stepActionDetails
5aWrite codeFollow project patterns, add types/error handling
5bWrite testsUnit tests (happy paths, error cases, edge cases)
5cVerify ALL passRun verification commands in order
5dManual testingTest functionality if automated tests unclear

5c: Verification Commands (Run in Order)

Stop at first failure. Fix issue, then restart from top.

CommandPurposeMust Pass
Type checkVerify types (TS/typed languages)✅ Exit code 0
Run testsAll unit/integration tests✅ Exit code 0
BuildProject builds successfully✅ Exit code 0
Health checkServers/services healthy✅ Exit code 0

Common commands by project type:

Project TypeType CheckRun TestsBuild
TypeScript/Nodepnpm typecheckpnpm testpnpm build
Pythonmypy .pytestpython -m build
Gogo vet ./...go test ./...go build
Rustcargo checkcargo testcargo build

Golden Rule: git commit ONLY when all commands exit with code 0.

5d: Manual Testing (When Needed)

ScenarioAction
API endpointsTest with curl/Postman
Web UITest in browser
CLI toolRun with sample inputs
Automated tests timeout/failVerify functionality works manually

Purpose: Confirm implementation works before committing.

Token-Efficient Analysis (Step 3)

TaskToolSavings
Code executionmcp__token-efficient__execute_code98%
Log parsingmcp__token-efficient__process_logs95%
Large datasetsmcp__token-efficient__process_csv99%

Rule: Never load raw logs/code into context.

Exit Criteria (All Must Pass)

  • No TEMPLATE-*.sh files remain
  • Code written with proper types/error handling
  • Tests written (unit tests for happy paths, errors, edge cases)
  • ALL verification commands pass (exit code 0)
    • Type check passes
    • All tests pass
    • Build succeeds
    • Health check passes (if applicable)
  • Manual testing confirms functionality (if needed)
  • Committed with feature ID in message
  • feature-list.json status updated
  • Session introspection complete (Step 8)
    • Issues identified and documented
    • Scripts updated (if issues found)
    • Script updates committed separately (chore:)

NEVER skip verification. Commit only after ALL checks pass.

Post-Implementation: Store Learnings

After successful feature completion, store key decisions in context-graph:

CategoryWhat to Store
architectureDesign patterns, component reuse, state management
apiEndpoint patterns, error handling, response formats
testingTest strategies, mock patterns, edge cases discovered
deploymentBuild steps, server restart requirements, configuration

Example:

code
context_store_trace(
  decision="Used StateStore for session management with 30min TTL",
  category="architecture",
  outcome="success",
  feature_id="FEATURE-001"
)

Purpose: Future features can query past decisions for consistency.

Step 8: Session Introspection & Script Updates

Purpose: Create continuous improvement feedback loop. Detect friction points and update scripts to prevent future issues.

When to Run

  • After feature marked complete
  • After learnings stored in context-graph
  • Before session ends

Detection Patterns

Issue PatternRoot CauseScript Update
Manual rebuildsnode dist/index.js vs tsx watchrestart-servers.sh: Use tsx watch
Tests not foundVitest pattern missing nested packagesvitest.config.ts: Add packages/*/*/src/**/*.test.ts
Route collisionsDynamic routes before static routesAdd comments to templates
Missing API testsNew endpoints not in run-tests.shrun-tests.sh: Add endpoint checks
Repeated type errorsMissing type definitionsUpdate template imports
Libsodium/ESM issuesDirect imports failingDocument workaround in templates

Detection Methods

MethodWhat to CheckTool
Command historyRepeated commands`history | grep -E "(build
Manual editsFiles changed outside featuregit diff --stat
Error patternsSystemic issuesSession error logs
Frequency analysisCommands run 3+ timesCount occurrences

Output Format

When issues detected:

code
🔧 Session Issues Detected:
- [Issue 1]: [Impact]
- [Issue 2]: [Impact]

📝 Recommended Script Updates:
- [script-name]: [Update description] (BEFORE → AFTER)

Apply updates? (y/n)

Implementation Guidelines

RuleWhy
NON-BLOCKINGUser can skip if unsure
Explain WHYContext for the update
Show BEFORE/AFTERClear comparison
Commit separatelychore: prefix, not feat:
Store in context-graphFuture sessions can learn

Commit Format

bash
git add .claude/scripts/
git commit -m "chore: Update scripts based on [FEATURE-ID] learnings

- [script-1]: [update description]
- [script-2]: [update description]

Prevents: [issue description]"

Example from SDK-BUYER-CART-003

Issues Detected:

  • Rebuilt api-server 5+ times manually
  • Tests in nested packages not discovered
  • New endpoints (cart, checkout) untested

Updates Applied:

  1. restart-servers.sh: Use tsx watch for hot-reload
  2. vitest.config.ts: Added packages/*/*/src/**/*.test.ts
  3. run-tests.sh: Added POST /api/cart, PUT /api/cart/buyer, POST /api/checkout

Result: Future sessions have hot-reload, all tests discovered, endpoints validated

Success Criteria

MetricTarget
Manual work reduced<10% of session time
Repeated issues0 in next 3 sessions
Script coverageAll common patterns automated
Learnings codifiedEvery feature updates at least 1 script

Scripts Reference

ScriptPurpose
get-current-feature.shExtract next pending feature
health-check.shVerify implementation health
feature-commit.shCommit with feature ID
mark-feature-complete.shUpdate feature status
run-tests.shRun project tests

If Scripts Don't Exist

When project scripts are missing → Create minimal versions:

ScriptMinimal Template
get-current-feature.sh`jq '.features[]
feature-commit.shgit commit -m "feat: $1 $2"
mark-feature-complete.sh`jq --arg id "$1" '.features[]
run-tests.shProject test command (see verification table)

References

FileLoad When
references/template-scripts.mdCustomizing TEMPLATE- scripts
references/token-efficient-mcp-patterns.mdLarge dataset analysis
references/coding-patterns.mdProject-specific patterns