task

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Task — Systematic Implementation Workflow

任务 — 系统化实现工作流

Standard 5-phase workflow for all implementation tasks with built-in quality gates.
<essential_principles>
内置质量门的所有实现任务标准5阶段工作流。
<essential_principles>

Serena Think Checkpoints (Mandatory)

Serena思考检查点(强制要求)

These three tools MUST be called at the specified points. Never skip them.
CheckpointToolWhenPurpose
Information Gate
mcp__serena__think_about_collected_information
After Phase 1 (Investigate) and Phase 2 (Plan)Verify sufficient information before proceeding
Adherence Gate
mcp__serena__think_about_task_adherence
Before each code edit in Phase 3Confirm still aligned with original task
Completion Gate
mcp__serena__think_about_whether_you_are_done
Before exiting Phase 4 (Verify)Confirm all work is truly complete
必须在指定节点调用这三个工具,绝不能跳过。
检查点工具时机目的
信息门
mcp__serena__think_about_collected_information
阶段1(调查)和阶段2(计划)之后继续前验证信息是否充分
合规门
mcp__serena__think_about_task_adherence
阶段3中每次代码编辑前确认仍与原始任务对齐
完成门
mcp__serena__think_about_whether_you_are_done
退出阶段4(验证)前确认所有工作已真正完成

Introspection Markers (Always Active)

自省标记(始终启用)

Use these markers throughout all phases to make reasoning visible:
  • 🤔 Reasoning — "🤔 The error suggests a missing dependency"
  • 🎯 Decision — "🎯 Choosing approach A over B because..."
  • ⚡ Performance — "⚡ This query may cause N+1"
  • 📊 Quality — "📊 Checking consistency with existing patterns"
  • 💡 Insight — "💡 This pattern can be reused for..."
在所有阶段中使用这些标记,使推理过程可见:
  • 🤔 推理 — "🤔 该错误表明缺少依赖项"
  • 🎯 决策 — "🎯 选择方案A而非B,原因是..."
  • ⚡ 性能 — "⚡ 该查询可能导致N+1问题"
  • 📊 质量 — "📊 检查与现有模式的一致性"
  • 💡 洞察 — "💡 该模式可复用至..."

Safety Rules

安全规则

  • Before destructive operations (delete, overwrite, reset): Always confirm with user
  • Before code edits: Call
    think_about_task_adherence
  • Never auto-commit: Phase 5 waits for user instruction to commit/push
  • Quality gate required: Phase 4 must pass before Phase 5
</essential_principles>
  • 执行破坏性操作前(删除、覆盖、重置):务必与用户确认
  • 代码编辑前:调用
    think_about_task_adherence
  • 禁止自动提交:阶段5需等待用户指令再执行提交/推送
  • 必须通过质量门:阶段4通过后才能进入阶段5
</essential_principles>

Phase 1: Investigate

阶段1:调查

Understand the task and gather context.
  1. Parse task requirements from user input
  2. Read relevant code files (Grep, Read, Serena symbolic tools)
  3. Check external libraries with Context7 if needed
  4. Identify existing patterns and conventions
  5. 🔶
    think_about_collected_information
    — Is the information sufficient?
Tools: Grep, Read, Glob,
mcp__serena__find_symbol
,
mcp__serena__get_symbols_overview
,
mcp__context7__query-docs
理解任务并收集上下文信息。
  1. 从用户输入中解析任务需求
  2. 阅读相关代码文件(Grep、Read、Serena符号工具)
  3. 必要时使用Context7检查外部库
  4. 识别现有模式与规范
  5. 🔶
    think_about_collected_information
    — 信息是否充分?
工具:Grep、Read、Glob、
mcp__serena__find_symbol
mcp__serena__get_symbols_overview
mcp__context7__query-docs

Phase 2: Plan

阶段2:计划

Break down the task and design the approach.
  1. Create task breakdown with
    TodoWrite
  2. Identify parallelizable steps:
    Plan: 1) Parallel [Read A, B] → 2) Edit → 3) Parallel [Test, Lint]
  3. Save plan to Serena Memory:
    mcp__serena__write_memory("plan_<topic>", content)
  4. 🔶
    think_about_collected_information
    — Any gaps in the plan?
Output: TodoWrite entries with clear acceptance criteria per step.
拆分任务并设计实现方案。
  1. 使用
    TodoWrite
    创建任务拆分清单
  2. 识别可并行的步骤:
    计划:1) 并行 [读取A、B] → 2) 编辑 → 3) 并行 [测试、代码检查]
  3. 将计划保存至Serena内存:
    mcp__serena__write_memory("plan_<topic>", content)
  4. 🔶
    think_about_collected_information
    — 计划中是否存在遗漏?
输出:带有清晰分步验收标准的TodoWrite条目。

Phase 3: Implement

阶段3:实现

Execute the plan with continuous adherence checks.
For each implementation step:
  1. Mark TodoWrite item as in-progress
  2. 🔶
    think_about_task_adherence
    — Still on track?
  3. Edit code (Edit, Write)
  4. Use introspection markers (🤔🎯⚡📊💡) to explain reasoning
  5. Mark TodoWrite item as complete
Rules:
  • No
    // TODO: implement later
    — write working code
  • No mock objects outside tests
  • Follow existing code patterns and conventions
  • Confirm with user before destructive operations
执行计划并持续检查合规性。
对于每个实现步骤:
  1. 将TodoWrite项标记为进行中
  2. 🔶
    think_about_task_adherence
    — 是否仍在正轨?
  3. 编辑代码(Edit、Write)
  4. 使用自省标记(🤔🎯⚡📊💡)解释推理过程
  5. 将TodoWrite项标记为已完成
规则
  • 禁止使用
    // TODO: implement later
    — 编写可运行的代码
  • 测试外禁止使用模拟对象
  • 遵循现有代码模式与规范
  • 执行破坏性操作前需与用户确认

Phase 4: Verify

阶段4:验证

Run quality checks and validate correctness.
运行质量检查并验证正确性。

Standard Verification (always)

标准验证(始终执行)

Run in parallel where possible:
bash
undefined
尽可能并行运行:
bash
undefined

Parallel execution

并行执行

pnpm lint & pnpm typecheck & pnpm test & pnpm build & wait

If any check fails → investigate root cause → fix in Phase 3 → re-verify.
pnpm lint & pnpm typecheck & pnpm test & pnpm build & wait

若任何检查失败 → 调查根本原因 → 返回阶段3修复 → 重新验证。

--frontend-verify
(when flag is provided)

--frontend-verify
(提供该标志时执行)

Visual verification across platforms. Auto-detect platform from
package.json
:
DependencyPlatformPreflightVerification Tool
(default)Web
kill-port <port> && pnpm dev
Claude Chrome MCP (
tabs_context_mcp
,
read_page
,
take_screenshot
)
electron
Electron
pnpm electron:dev
Electron MCP (
mcp__electron__take_screenshot
)
expo
/
react-native
Mobile
mcp__ios-simulator__open_simulator
iOS Simulator MCP (
screenshot
,
ui_tap
,
ui_swipe
)
commander
/
inquirer
/
oclif
CLIshell sessionShellwright MCP (TUI/CLI operation and output verification)
Frontend Verify Workflow:
  1. Preflight: Start dev server / app, confirm MCP connection
  2. Scenario creation: Design test scenarios based on changes, save to Serena Memory
  3. Execute: Run each scenario, take screenshot after each step
  4. Judge: All pass → continue. Any fail → return to Phase 3
跨平台视觉验证。从
package.json
自动检测平台:
依赖项平台预检查验证工具
(默认)Web
kill-port <port> && pnpm dev
Claude Chrome MCP (
tabs_context_mcp
,
read_page
,
take_screenshot
)
electron
Electron
pnpm electron:dev
Electron MCP (
mcp__electron__take_screenshot
)
expo
/
react-native
移动端
mcp__ios-simulator__open_simulator
iOS模拟器MCP (
screenshot
,
ui_tap
,
ui_swipe
)
commander
/
inquirer
/
oclif
CLIShell会话Shellwright MCP(TUI/CLI操作与输出验证)
前端验证工作流:
  1. 预检查:启动开发服务器/应用,确认MCP连接正常
  2. 场景创建:基于变更设计测试场景,保存至Serena内存
  3. 执行:运行每个场景,每步后截取屏幕截图
  4. 判定:全部通过 → 继续。任何失败 → 返回阶段3

Completion Gate

完成门

🔶
think_about_whether_you_are_done
— Is everything truly complete?
🔶
think_about_whether_you_are_done
— 所有工作是否真的完成?

Phase 5: Complete

阶段5:收尾

Report results and wait for user instruction.
  1. Present verification summary to user:
    • What was changed (files, functions)
    • Test results
    • Screenshots (if --frontend-verify)
  2. Update TodoWrite — mark all items complete
  3. ⏸️ Wait for user instruction to commit/push
  4. On user confirmation:
    git commit && git push
汇报结果并等待用户指令。
  1. 向用户展示验证总结:
    • 变更内容(文件、函数)
    • 测试结果
    • 屏幕截图(若使用--frontend-verify)
  2. 更新TodoWrite — 将所有项标记为已完成
  3. ⏸️ 等待用户指令再执行提交/推送
  4. 收到用户确认后:
    git commit && git push

Quick Reference

快速参考

/task fix the login button styling
/task add dark mode support --frontend-verify
/task refactor the API error handling
/task fix the login button styling
/task add dark mode support --frontend-verify
/task refactor the API error handling

Phase Flow Diagram

阶段流程图

[Investigate] → 🔶 info gate
  [Plan] → 🔶 info gate
[Implement] → 🔶 adherence gate (per edit)
 [Verify] → 🔶 completion gate
[Complete] → ⏸️ wait for user → commit/push
[调查] → 🔶 信息门
  [计划] → 🔶 信息门
[实现] → 🔶 合规门(每次编辑前)
 [验证] → 🔶 完成门
[收尾] → ⏸️ 等待用户 → 提交/推送