apex
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<objective>
Execute systematic implementation workflows using the APEX methodology. This skill uses progressive step loading to minimize context usage and supports saving outputs for review and resumption.
</objective>
</flags>
<examples>
```bash
<quick_start>
Basic usage:
bash
/apex add authentication middlewareRecommended workflow (autonomous with save):
bash
/apex -a -s implement user registrationWith adversarial review:
bash
/apex -a -x -s fix login bugFlags:
- (auto): Skip confirmations
-a - (save): Save outputs to
-s.claude/output/apex/ - (examine): Include adversarial code review
-x - (test): Create and run tests
-t - (pull-request): Create PR at end
-pr
See for complete flag list.
</quick_start>
<parameters>
<flags>
**Enable flags (turn ON):**
| Short | Long | Description |
|-------|------|-------------|
| `-a` | `--auto` | Autonomous mode: skip confirmations, auto-approve plans |
| `-x` | `--examine` | Auto-examine mode: proceed to adversarial review |
| `-s` | `--save` | Save mode: output each step to `.claude/output/apex/` |
| `-t` | `--test` | Test mode: include test creation and runner steps |
| `-e` | `--economy` | Economy mode: no subagents, save tokens (for limited plans) |
| `-r` | `--resume` | Resume mode: continue from a previous task |
| `-b` | `--branch` | Branch mode: verify not on main, create branch if needed |
| `-pr` | `--pull-request` | PR mode: create pull request at end (enables -b) |
| `-i` | `--interactive` | Interactive mode: configure flags via AskUserQuestion |
<parameters>Disable flags (turn OFF):
| Short | Long | Description |
|---|---|---|
| | Disable auto mode |
| | Disable examine mode |
| | Disable save mode |
| | Disable test mode |
| | Disable economy mode |
| | Disable branch mode |
| | Disable PR mode |
<objective>
采用APEX方法论执行系统化的实现工作流。该技能采用渐进式步骤加载以最小化上下文占用,并支持保存输出结果以便审查和恢复。
</objective>
</flags>
<examples>
```bash
<quick_start>
快速开始
bash
/apex add authentication middleware推荐工作流(自主模式+保存):
bash
/apex -a -s implement user registration包含对抗性审查:
bash
/apex -a -x -s fix login bug参数说明:
- (auto):跳过确认步骤
-a - (save):将输出保存至
-s.claude/output/apex/ - (examine):包含对抗性代码审查
-x - (test):创建并运行测试
-t - (pull-request):在流程末尾创建PR
-pr
完整参数列表请查看部分。
</quick_start>
<parameters>
<flags>
**启用参数(开启功能):**
| 短参数 | 长参数 | 说明 |
|-------|------|-------------|
| `-a` | `--auto` | 自主模式:跳过确认步骤,自动批准计划 |
| `-x` | `--examine` | 自动审查模式:自动进入对抗性审查环节 |
| `-s` | `--save` | 保存模式:将每个步骤的输出保存至`.claude/output/apex/` |
| `-t` | `--test` | 测试模式:包含测试创建和运行步骤 |
| `-e` | `--economy` | 经济型模式:不使用子Agent,节省Token(适用于受限方案) |
| `-r` | `--resume` | 恢复模式:从之前的任务继续执行 |
| `-b` | `--branch` | 分支模式:验证当前不在主分支,必要时创建新分支 |
| `-pr` | `--pull-request` | PR模式:在流程末尾创建Pull Request(自动启用-b参数) |
| `-i` | `--interactive` | 交互模式:通过AskUserQuestion交互式配置参数 |
<parameters>禁用参数(关闭功能):
| 短参数 | 长参数 | 说明 |
|---|---|---|
| | 禁用自主模式 |
| | 禁用审查模式 |
| | 禁用保存模式 |
| | 禁用测试模式 |
| | 禁用经济型模式 |
| | 禁用分支模式 |
| | 禁用PR模式 |
Basic
基础用法
/apex add auth middleware
/apex add auth middleware
Autonomous (skip confirmations)
自主模式(跳过确认)
/apex -a add auth middleware
/apex -a add auth middleware
Save outputs + examine
保存输出+对抗性审查
/apex -a -x -s add auth middleware
/apex -a -x -s add auth middleware
Full workflow with tests
完整工作流(含测试)
/apex -a -x -s -t add auth middleware
/apex -a -x -s -t add auth middleware
With PR creation
包含PR创建
/apex -a -pr add auth middleware
/apex -a -pr add auth middleware
Resume previous task
恢复之前的任务
/apex -r 01-auth-middleware
/apex -r 01 # Partial match
/apex -r 01-auth-middleware
/apex -r 01 # 部分匹配
Economy mode (save tokens)
经济型模式(节省Token)
/apex -e add auth middleware
/apex -e add auth middleware
Interactive flag config
交互式参数配置
/apex -i add auth middleware
/apex -i add auth middleware
Disable flags (uppercase)
禁用参数(大写)
/apex -A add auth middleware # Disable auto
</examples>
<parsing_rules>
**Flag parsing:**
1. Defaults loaded from `steps/step-00-init.md` `<defaults>` section
2. Command-line flags override defaults (enable with lowercase `-x`, disable with uppercase `-X`)
3. Flags removed from input, remainder becomes `{task_description}`
4. Task ID generated as `NN-kebab-case-description`
For detailed parsing algorithm, see `steps/step-00-init.md`.
</parsing_rules>
</parameters>
<output_structure>
**When `{save_mode}` = true:**
All outputs saved to PROJECT directory (where Claude Code is running):.claude/output/apex/{task-id}/
├── 00-context.md # Params, user request, timestamp
├── 01-analyze.md # Analysis findings
├── 02-plan.md # Implementation plan
├── 03-execute.md # Execution log
├── 04-validate.md # Validation results
├── 05-examine.md # Review findings (if -x)
├── 06-resolve.md # Resolution log (if -x)
├── 07-tests.md # Test analysis and creation (if --test)
├── 08-run-tests.md # Test runner log (if --test)
└── 09-finish.md # Workflow finish and PR creation (if --pull-request)
**00-context.md structure:**
```markdown/apex -A add auth middleware # 禁用自主模式
</examples>
<parsing_rules>
**参数解析规则:**
1. 从`steps/step-00-init.md`的`<defaults>`部分加载默认配置
2. 命令行参数覆盖默认配置(小写`-x`启用,大写`-X`禁用)
3. 参数将从输入中移除,剩余部分作为`{task_description}`
4. 任务ID格式为`NN-kebab-case-description`
详细解析算法请查看`steps/step-00-init.md`。
</parsing_rules>
</parameters>
<output_structure>
**当`{save_mode}` = true时:**
所有输出将保存至Claude Code运行的项目目录:.claude/output/apex/{task-id}/
├── 00-context.md # 参数、用户请求、时间戳
├── 01-analyze.md # 分析结果
├── 02-plan.md # 实现计划
├── 03-execute.md # 执行日志
├── 04-validate.md # 验证结果
├── 05-examine.md # 审查结果(如果启用-x)
├── 06-resolve.md # 问题修复日志(如果启用-x)
├── 07-tests.md # 测试分析与创建(如果启用--test)
├── 08-run-tests.md # 测试运行日志(如果启用--test)
└── 09-finish.md # 工作流完成与PR创建(如果启用--pull-request)
**00-context.md结构:**
```markdownAPEX Task: {task_id}
APEX任务: {task_id}
Created: {timestamp}
Task: {task_description}
创建时间: {timestamp}
任务描述: {task_description}
Flags
参数配置
- Auto mode: {auto_mode}
- Examine mode: {examine_mode}
- Save mode: {save_mode}
- Test mode: {test_mode}
- 自主模式: {auto_mode}
- 审查模式: {examine_mode}
- 保存模式: {save_mode}
- 测试模式: {test_mode}
User Request
用户请求
{original user input}
{original user input}
Acceptance Criteria
验收标准
- AC1: {inferred criterion}
- AC2: {inferred criterion}
</output_structure>
<resume_workflow>
**Resume mode (`-r {task-id}`):**
When provided, step-00 will:
1. Locate the task folder in `.claude/output/apex/`
2. Restore state from `00-context.md`
3. Find the last completed step
4. Continue from the next step
Supports partial matching (e.g., `-r 01` finds `01-add-auth-middleware`).
For implementation details, see `steps/step-00-init.md`.
</resume_workflow>
<workflow>
**Standard flow:**
1. Parse flags and task description
2. If `-r`: Execute resume workflow
3. If `-s`: Create output folder and 00-context.md
4. Load step-01-analyze.md → gather context
5. Load step-02-plan.md → create strategy
6. Load step-03-execute.md → implement
7. Load step-04-validate.md → verify
8. If `--test`: Load step-07-tests.md → analyze and create tests
9. If `--test`: Load step-08-run-tests.md → run until green
10. If `-x` or user requests: Load step-05-examine.md → adversarial review
11. If findings: Load step-06-resolve.md → fix findings
12. If `-pr`: Load step-09-finish.md → create pull request
</workflow>
<state_variables>
**Persist throughout all steps:**
| Variable | Type | Description |
| ----------------------- | ------- | ------------------------------------------------------ |
| `{task_description}` | string | What to implement (flags removed) |
| `{feature_name}` | string | Kebab-case name without number (e.g., `add-auth-middleware`) |
| `{task_id}` | string | Full identifier with number (e.g., `01-add-auth-middleware`) |
| `{acceptance_criteria}` | list | Success criteria (inferred or explicit) |
| `{auto_mode}` | boolean | Skip confirmations, use recommended options |
| `{examine_mode}` | boolean | Auto-proceed to adversarial review |
| `{save_mode}` | boolean | Save outputs to .claude/output/apex/ |
| `{test_mode}` | boolean | Include test steps (07-08) |
| `{economy_mode}` | boolean | No subagents, direct tool usage only |
| `{branch_mode}` | boolean | Verify not on main, create branch if needed |
| `{pr_mode}` | boolean | Create pull request at end |
| `{interactive_mode}` | boolean | Configure flags interactively |
| `{resume_task}` | string | Task ID to resume (if -r provided) |
| `{output_dir}` | string | Full path to output directory |
| `{branch_name}` | string | Created branch name (if branch_mode) |
</state_variables>
<entry_point>
**FIRST ACTION:** Load `steps/step-00-init.md`
Step 00 handles:
- Flag parsing (-a, -x, -s, -r, --test)
- Resume mode detection and task lookup
- Output folder creation (if save_mode)
- 00-context.md creation (if save_mode)
- State variable initialization
After initialization, step-00 loads step-01-analyze.md.
</entry_point>
<step_files>
**Progressive loading - only load current step:**
| Step | File | Purpose |
| ---- | ---------------------------- | ---------------------------------------------------- |
| 00 | `steps/step-00-init.md` | Parse flags, create output folder, initialize state |
| 01 | `steps/step-01-analyze.md` | Smart context gathering with 1-10 parallel agents based on complexity |
| 02 | `steps/step-02-plan.md` | File-by-file implementation strategy |
| 03 | `steps/step-03-execute.md` | Todo-driven implementation |
| 04 | `steps/step-04-validate.md` | Self-check and validation |
| 05 | `steps/step-05-examine.md` | Adversarial code review (optional) |
| 06 | `steps/step-06-resolve.md` | Finding resolution (optional) |
| 07 | `steps/step-07-tests.md` | Test analysis and creation (if --test) |
| 08 | `steps/step-08-run-tests.md` | Test runner loop until green (if --test) |
| 09 | `steps/step-09-finish.md` | Create pull request (if --pull-request) |
</step_files>
<execution_rules>
- **Load one step at a time** - Only load the current step file
- **ULTRA THINK** before major decisions
- **Persist state variables** across all steps
- **Follow next_step directive** at end of each step
- **Save outputs** if `{save_mode}` = true (append to step file)
- **Use parallel agents** for independent exploration tasks- AC1: {inferred criterion}
- AC2: {inferred criterion}
</output_structure>
<resume_workflow>
**恢复模式(`-r {task-id}`):**
当使用该参数时,step-00将执行以下操作:
1. 在`.claude/output/apex/`中定位任务文件夹
2. 从`00-context.md`恢复状态
3. 找到最后完成的步骤
4. 从下一个步骤继续执行
支持部分匹配(例如:`-r 01`将匹配`01-add-auth-middleware`)。
实现细节请查看`steps/step-00-init.md`。
</resume_workflow>
<workflow>
**标准工作流:**
1. 解析参数和任务描述
2. 如果启用`-r`: 执行恢复工作流
3. 如果启用`-s`: 创建输出文件夹和00-context.md
4. 加载step-01-analyze.md → 收集上下文信息
5. 加载step-02-plan.md → 制定实现策略
6. 加载step-03-execute.md → 执行实现
7. 加载step-04-validate.md → 验证结果
8. 如果启用`--test`: 加载step-07-tests.md → 分析并创建测试
9. 如果启用`--test`: 加载step-08-run-tests.md → 运行测试直至通过
10. 如果启用`-x`或用户请求: 加载step-05-examine.md → 对抗性审查
11. 如果发现问题: 加载step-06-resolve.md → 修复问题
12. 如果启用`-pr`: 加载step-09-finish.md → 创建Pull Request
</workflow>
<state_variables>
**在所有步骤中持久化的变量:**
| 变量名 | 类型 | 描述 |
| ----------------------- | ------- | ------------------------------------------------------ |
| `{task_description}` | 字符串 | 待实现内容(已移除参数) |
| `{feature_name}` | 字符串 | 不含数字的短横线命名(例如: `add-auth-middleware`) |
| `{task_id}` | 字符串 | 带数字的完整标识符(例如: `01-add-auth-middleware`) |
| `{acceptance_criteria}` | 列表 | 成功标准(推断或显式定义) |
| `{auto_mode}` | 布尔值 | 跳过确认步骤,使用推荐选项 |
| `{examine_mode}` | 布尔值 | 自动进入对抗性审查环节 |
| `{save_mode}` | 布尔值 | 将输出保存至.claude/output/apex/ |
| `{test_mode}` | 布尔值 | 包含测试步骤(07-08) |
| `{economy_mode}` | 布尔值 | 不使用子Agent,仅直接调用工具 |
| `{branch_mode}` | 布尔值 | 验证当前不在主分支,必要时创建新分支 |
| `{pr_mode}` | 布尔值 | 在流程末尾创建Pull Request |
| `{interactive_mode}` | 布尔值 | 交互式配置参数 |
| `{resume_task}` | 字符串 | 待恢复的任务ID(如果提供了-r参数) |
| `{output_dir}` | 字符串 | 输出目录的完整路径 |
| `{branch_name}` | 字符串 | 创建的分支名称(如果启用branch_mode) |
</state_variables>
<entry_point>
**第一步操作:** 加载`steps/step-00-init.md`
step-00负责:
- 参数解析(-a, -x, -s, -r, --test)
- 恢复模式检测与任务查找
- 创建输出文件夹(如果启用save_mode)
- 创建00-context.md(如果启用save_mode)
- 初始化状态变量
初始化完成后,step-00将加载step-01-analyze.md。
</entry_point>
<step_files>
**渐进式加载 - 仅加载当前步骤:**
| 步骤 | 文件 | 用途 |
| ---- | ---------------------------- | ---------------------------------------------------- |
| 00 | `steps/step-00-init.md` | 解析参数、创建输出文件夹、初始化状态 |
| 01 | `steps/step-01-analyze.md` | 根据任务复杂度,使用1-10个并行Agent智能收集上下文 |
| 02 | `steps/step-02-plan.md` | 制定逐文件的实现策略 |
| 03 | `steps/step-03-execute.md` | 基于待办事项的实现 |
| 04 | `steps/step-04-validate.md` | 自我检查与验证 |
| 05 | `steps/step-05-examine.md` | 对抗性代码审查(可选) |
| 06 | `steps/step-06-resolve.md` | 问题修复(可选) |
| 07 | `steps/step-07-tests.md` | 测试分析与创建(如果启用--test) |
| 08 | `steps/step-08-run-tests.md` | 循环运行测试直至通过(如果启用--test) |
| 09 | `steps/step-09-finish.md` | 创建Pull Request(如果启用--pull-request) |
</step_files>
<execution_rules>
- **逐步骤加载** - 仅加载当前步骤的文件
- **重大决策前深度思考**
- **跨步骤持久化状态变量**
- **遵循每个步骤末尾的next_step指令**
- **如果`{save_mode}`=true则保存输出**(追加到对应步骤文件)
- **独立探索任务使用并行Agent**🧠 Smart Agent Strategy in Analyze Phase
🧠 分析阶段的智能Agent策略
The analyze phase (step-01) uses adaptive agent launching (unless economy_mode):
Available agents:
- - Find existing patterns, files, utilities
explore-codebase - - Research library docs (use when unfamiliar with API)
explore-docs - - Find approaches, best practices, gotchas
websearch
Launch 1-10 agents based on task complexity:
| Complexity | Agents | When |
|---|---|---|
| Simple | 1-2 | Bug fix, small tweak |
| Medium | 2-4 | New feature in familiar stack |
| Complex | 4-7 | Unfamiliar libraries, integrations |
| Major | 6-10 | Multiple systems, many unknowns |
BE SMART: Analyze what you actually need before launching. Don't over-launch for simple tasks, don't under-launch for complex ones.
</execution_rules>
<save_output_pattern>
When = true:
{save_mode}Step-00 runs to initialize all output files from directory.
scripts/setup-templates.shtemplates/Each step then:
- Run
scripts/update-progress.sh {task_id} {step_num} {step_name} "in_progress" - Append findings/outputs to the pre-created step file
- Run
scripts/update-progress.sh {task_id} {step_num} {step_name} "complete"
Template system benefits:
- Reduces token usage by ~75% (1,350 tokens saved per workflow)
- Templates in directory (not inline in steps)
templates/ - Scripts handle progress tracking automatically
- See for details
templates/README.md
</save_output_pattern>
<success_criteria>
- Each step loaded progressively
- All validation checks passing
- Outputs saved if enabled
{save_mode} - Tests passing if enabled
{test_mode} - Clear completion summary provided </success_criteria>
分析阶段(step-01)采用自适应Agent启动机制(经济型模式下除外):
可用Agent:
- - 查找现有代码模式、文件和工具
explore-codebase - - 研究库文档(不熟悉API时使用)
explore-docs - - 查找实现方案、最佳实践和注意事项
websearch
根据任务复杂度启动1-10个Agent:
| 复杂度 | Agent数量 | 适用场景 |
|---|---|---|
| 简单 | 1-2 | Bug修复、小调整 |
| 中等 | 2-4 | 熟悉技术栈的新功能开发 |
| 复杂 | 4-7 | 不熟悉的库、系统集成 |
| 重大 | 6-10 | 多系统交互、大量未知项 |
智能提示: 启动前先分析实际需求。简单任务不要过度启动Agent,复杂任务不要启动不足。
</execution_rules>
<save_output_pattern>
当=true时:
{save_mode}Step-00将运行从目录初始化所有输出文件。
scripts/setup-templates.shtemplates/每个步骤执行以下操作:
- 运行
scripts/update-progress.sh {task_id} {step_num} {step_name} "in_progress" - 将分析/输出结果追加到预创建的步骤文件
- 运行
scripts/update-progress.sh {task_id} {step_num} {step_name} "complete"
模板系统优势:
- 减少约75%的Token消耗(每个工作流节省约1350个Token)
- 模板存储在目录(而非步骤文件内联)
templates/ - 脚本自动处理进度跟踪
- 详情请查看
templates/README.md
</save_output_pattern>
<success_criteria>
- 所有步骤渐进式加载完成
- 所有验证检查通过
- 若启用则输出已保存
{save_mode} - 若启用则测试通过
{test_mode} - 提供清晰的完成总结 </success_criteria>