implement
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplement
功能实现流水线
End-to-end feature implementation pipeline. Runs pre-flight validation, TDD cycle, scope enforcement, and quality commit as a single orchestrated flow.
端到端功能实现流水线,将预检验证、TDD循环、范围管控和高质量提交整合为一个协调的工作流。
Pipeline Phases
流水线阶段
Phase 0: Pre-flight (< 30 seconds)
阶段0:预检(< 30秒)
Before writing any code, validate the workspace is ready:
- Git status — check for uncommitted changes that might conflict
- Monorepo freshness — if shared/library packages exist, check if source is newer than compiled output. If yes, rebuild first.
- Workspace typecheck — run (or equivalent) on the target workspace
tsc --noEmit - Existing test check — if a test file exists for the target module, run it to confirm green baseline
If any check fails, report and ask the user how to proceed before writing code.
在编写任何代码之前,验证工作区是否就绪:
- Git状态 — 检查是否存在可能导致冲突的未提交变更
- 单体仓库新鲜度 — 若存在共享/库包,检查源代码是否比编译输出更新。若是,先重新构建
- 工作区类型检查 — 在目标工作区运行(或等效命令)
tsc --noEmit - 现有测试检查 — 若目标模块存在测试文件,运行该文件确认基线状态正常
如果任何检查失败,在编写代码前向用户报告并询问后续处理方式。
Phase 1: Understand & Plan (no code yet)
阶段1:需求理解与规划(暂不编写代码)
- Read the target file(s) mentioned in
$ARGUMENTS - Identify the module type (route handler, repository, plugin, utility, service, component)
- Determine the mock strategy — check nearest test files for established patterns
- Plan what tests to write and what implementation to add
Present a brief summary: "I'll add X tests covering Y, then implement Z." Wait for user confirmation if the scope seems large (> 3 files).
- 读取中指定的目标文件
$ARGUMENTS - 识别模块类型(路由处理器、仓库、插件、工具类、服务、组件)
- 确定Mock策略 — 查看最近的测试文件,参考已有的模式
- 规划要编写的测试内容和要实现的功能
呈现简要总结:"我将添加X个测试覆盖Y场景,然后实现Z功能。"若范围较大(> 3个文件),等待用户确认后再继续。
Phase 2: Bootstrap Mock (1 test)
阶段2:初始化Mock(1个测试用例)
Follow Step 3 exactly:
/tdd- Check test runner config for mock reset/restore settings
- Write ONE minimal test that imports the module and verifies mocks resolve
- Run it, confirm it passes
- If it fails, diagnose mock wiring before proceeding
严格遵循步骤3:
/tdd- 检查测试运行器配置中的Mock重置/恢复设置
- 编写一个最小化测试用例,导入模块并验证Mock解析正常
- 运行测试,确认通过
- 若失败,先排查Mock配置问题再继续
Phase 3: Red — Write Failing Tests
阶段3:红阶段 — 编写失败的测试用例
Write test cases for:
- Happy path
- Edge cases
- Error cases
Run the test file — all new tests MUST fail. If any pass unexpectedly, the tests aren't testing new behavior.
编写以下场景的测试用例:
- 正常路径
- 边缘场景
- 错误场景
运行测试文件 — 所有新增测试必须失败。若有测试意外通过,说明该测试未覆盖新的行为。
Phase 4: Green — Minimum Implementation
阶段4:绿阶段 — 最小化实现
Write the minimum code to make all tests pass. Do NOT:
- Add features not covered by tests
- Optimize prematurely
- Refactor existing code
Run the test file — all tests MUST pass.
编写最少代码使所有测试通过。禁止:
- 添加测试未覆盖的功能
- 过早优化
- 重构现有代码
运行测试文件 — 所有测试必须通过。
Phase 5: Scope Guard
阶段5:范围管控
Before committing, self-audit the changes:
- Run to see all modified files
git diff --name-only - Compare against the original task from
$ARGUMENTS - Flag any files that don't relate to the task:
- Formatting-only changes → revert with
git checkout -- <file> - Unrelated refactors → revert or split into separate commit
- Docstring additions to untouched code → revert
- Formatting-only changes → revert with
If scope creep is detected, report it and ask the user whether to keep or revert the extra changes.
提交前,自动审计变更:
- 运行查看所有修改的文件
git diff --name-only - 与中的原始任务对比
$ARGUMENTS - 标记任何与任务无关的文件:
- 仅格式变更 → 使用撤销
git checkout -- <file> - 无关重构 → 撤销或拆分为单独提交
- 对未修改代码添加文档注释 → 撤销
- 仅格式变更 → 使用
若检测到范围蔓延,向用户报告并询问是否保留或撤销额外变更。
Phase 6: Full Suite + Quality Gates
阶段6:全量测试套件 + 质量门禁
- Run the full test suite (e.g., )
npx vitest run --reporter=dot - Run workspace typecheck (or equivalent)
tsc --noEmit - Run linter on changed files only
If any gate fails:
- Test failure: determine if your change caused it (regression) or pre-existing
- Type error: fix it
- Lint error in your files: fix it
- Lint error in files you didn't touch: ignore, note in commit message
- 运行完整测试套件(例如)
npx vitest run --reporter=dot - 运行工作区类型检查(或等效命令)
tsc --noEmit - 仅对变更文件运行代码检查工具
若任何门禁检查失败:
- 测试失败:判断是你的变更导致的回归还是原有问题
- 类型错误:修复该错误
- 你的文件存在代码检查错误:修复该错误
- 未修改文件存在代码检查错误:忽略,并在提交信息中注明
Phase 7: Commit
阶段7:提交代码
Stage only the files you changed (NEVER ). Commit with conventional format:
git add -Atype(scope): description
Co-Authored-By: Claude <noreply@anthropic.com>仅暂存你修改的文件(绝对不要使用)。使用约定式提交格式:
git add -Atype(scope): description
Co-Authored-By: Claude <noreply@anthropic.com>Abort Conditions
终止条件
STOP the pipeline and ask the user if:
- Pre-flight finds the workspace in a broken state
- More than 5 files need modification (scope may be too large)
- Bootstrap mock test fails after 2 attempts
- Full suite regression is caused by your changes
在以下情况时,停止流水线并询问用户:
- 预检发现工作区处于损坏状态
- 需要修改超过5个文件(范围可能过大)
- 初始化Mock测试尝试2次后仍失败
- 你的变更导致全量测试套件出现回归
Arguments
参数
- : What to implement
$ARGUMENTS- Example:
/implement add rate limiting to POST /api/search - Example:
/implement src/routes/admin/settings.ts — add PATCH endpoint for theme - If empty, ask the user what to implement
- Example:
- : 要实现的内容
$ARGUMENTS- 示例:
/implement add rate limiting to POST /api/search - 示例:
/implement src/routes/admin/settings.ts — add PATCH endpoint for theme - 若为空,询问用户要实现的内容
- 示例:
Integration
集成说明
This skill orchestrates:
- — Phase 2-4 (mock bootstrap, red, green)
/tdd - — Phase 7 (stage + commit with gates)
/quality-commit
Use instead of calling these individually for full pipeline coverage.
/implement该技能整合了:
- — 阶段2-4(Mock初始化、红阶段、绿阶段)
/tdd - — 阶段7(暂存+门禁提交)
/quality-commit
为了覆盖完整流水线,请使用而非单独调用上述技能。
/implement