$ARGUMENTS
Core protocol
- Language protocol: for interacting with tools, useEnglish; for interacting with the user, useChinese
- Implementation ownership: all product code modifications are performed directly by the Claude main thread
- Use subagents as needed: only when the context retrieval scope is large, the implementation involves multiple modules, or an additional read-only self-review is needed before delivery, use the
Agenttool to launch subagents for assistance - Read-only assistance: subagents are only responsible for retrieval, analysis, and self-review; they do not directly edit code, do not write plan files, and do not replace main thread delivery
- Minimal changes: only modify the necessary code within the planned scope
- Prerequisites: preferentially execute based on the plan that was generated by
/ac-planand has been approved; if the plan is missing or the plan information is incomplete, first confirm with the user
Execution constraints
Working directory:
{{WORKDIR}}: use the absolute path of the current working directory as the root directory for context retrieval and code modification- If the user has added multiple workspaces via
/add-dir, first use Glob/Grep to determine the workspace relevant to the task - If it cannot be determined, use
AskUserQuestionto ask the user to select the target workspace
Conditions for using subagents:
- Applicable: the critical path is unclear, multiple modules need to be investigated in parallel, or an additional read-only review is needed after the changes are complete
- Prefer:
Explorefor context retrieval; additional review before delivery should also preferentially use a read-only subagent - Not applicable: small single-file changes, clear paths, or simple tasks that the main thread can complete in one reading
Important:
- It is not allowed to use Bash to call external models, generate prototypes, or perform additional orchestration
- It is not allowed to save, reference, or hand off any external session identifier
- Subagents must not directly implement code modifications, and multiple agents are prohibited from writing to the same task in parallel
- For retrieval or review content that has been delegated to subagents, the main thread should not repeat the work
- Only for local verification, run lint / typecheck / tests on the minimal relevant scope as needed
- If information is insufficient, you must ask questions first before continuing execution
Execution workflow
Execute the task:$ARGUMENTS
📖 Phase 0: Read the plan
[模式:准备]
- Identify the input type:
- Plan file path (e.g.,
.claude/plan/xxx.md) - Direct task description
- Plan file path (e.g.,
- Read the plan content:
- If a plan file path is provided, read and parse it
- Extract: task type, implementation steps, key files, risks, and verification requirements
- Pre-execution confirmation:
- If the input is a direct task description: first confirm whether an approved plan already exists
- If the plan is missing key files, acceptance criteria, or scope boundaries: first ask the user for additional confirmation
- If it cannot be confirmed whether the user has agreed to execute: you must ask first before proceeding to the next phase
🔎 Phase 1: Context retrieval
[模式:检索]
- Preferentially read the key files listed in the plan
- If the plan does not provide complete paths or the implementation involves multiple modules:
- Used by the main thread as needed
AgentLaunch subagents in parallel with tools - Tasks can be split by file group, module, or concern
- Used by the main thread as needed
- Supplement by reading the entry files, dependency modules, and related type definitions required for implementation
- If a clear inconsistency between the plan and the current code is found, pause and confirm with the user
After retrieval is complete:
- Organize the key context
- Confirm that the information required for implementation is available
- Proceed to Phase 2
⚡ Phase 2: Main thread implementation
[模式:实施]
- Based on the plan and contextImplement directly
- First read the target file to understand the existing implementation approach
- The main thread uses the Edit / Write tools to perform the actual modifications
- Follow the project's existing code style and structure
- Modify only the necessary code; avoid incidental refactoring and out-of-scope changes
- If the implementation reveals that the plan needs to change, pause first and confirm with the user
✅ Phase 3: Verification
[模式:验证]
- Prefer running the smallest relevant scope of lint / typecheck / tests
- If verification fails: fix the regression issues first, then continue delivery
- If the project lacks automated checks: provide minimal manual verification steps
- Do not proceed to final delivery until verification passes
🧪 Phase 4: Main thread self-review and delivery
[模式:审查]
4.1 Self-review
- Check logical correctness
- Check boundary conditions and side effects
- Check security and input boundaries
- Check whether there are any out-of-scope modifications
- Check whether it is consistent with the plan goals
4.2 Additional subagent review (enabled as needed for complex scenarios)
When changes span multiple modules, verification cost is high, or integration risk exists:
- Use read-only subagents to review different concerns in parallel
- Typical split approaches:
- Correctness and regression risk
- Maintainability and integration consistency
- The main thread consolidates the review results and decides whether additional fixes are needed
4.3 Consolidate fixes
- Perform necessary fixes based on the review results from the main thread and subagents
- Repeat the minimal verification after fixes
- Deliver only after the risk is acceptable
4.4 Delivery confirmation
Report to the user:
## ✅ 执行完成
### 变更摘要
| 文件 | 操作 | 说明 |
|------|------|------|
| path/to/file.ts | 修改 | 描述 |
### 验证结果
- 已执行:<lint / typecheck / tests / 手动验证>
- 结果:<通过 / 失败后已修复 / 无自动化检查>
### 后续建议
1. [ ] <建议的测试步骤>
2. [ ] <建议的验证步骤>
Key rules
- Main thread implementation – Product code is modified only by the main thread of the current session
- subagents only assist with retrieval/review – Use as needed, not enabled by default, and do not modify code directly
- Minimal changes – Modify only the necessary code and do not introduce extra side effects
- Verify before delivery – If checks can be run, run them first
- Confirm first when information is incomplete – When the plan, key files, or acceptance criteria are missing, you must ask the user first