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>
<quick_start> Basic usage:
bash
/apex add authentication middleware
Recommended workflow (autonomous with save):
bash
/apex -a -s implement user registration
With adversarial review:
bash
/apex -a -x -s fix login bug
Flags:
  • -a
    (auto): Skip confirmations
  • -s
    (save): Save outputs to
    .claude/output/apex/
  • -x
    (examine): Include adversarial code review
  • -t
    (test): Create and run tests
  • -pr
    (pull-request): Create PR at end
See
<parameters>
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 |
Disable flags (turn OFF):
ShortLongDescription
-A
--no-auto
Disable auto mode
-X
--no-examine
Disable examine mode
-S
--no-save
Disable save mode
-T
--no-test
Disable test mode
-E
--no-economy
Disable economy mode
-B
--no-branch
Disable branch mode
-PR
--no-pull-request
Disable PR mode
</flags> <examples> ```bash
<objective> 采用APEX方法论执行系统化的实现工作流。该技能采用渐进式步骤加载以最小化上下文占用,并支持保存输出结果以便审查和恢复。 </objective>
<quick_start> 快速开始
bash
/apex add authentication middleware
推荐工作流(自主模式+保存):
bash
/apex -a -s implement user registration
包含对抗性审查:
bash
/apex -a -x -s fix login bug
参数说明:
  • -a
    (auto):跳过确认步骤
  • -s
    (save):将输出保存至
    .claude/output/apex/
  • -x
    (examine):包含对抗性代码审查
  • -t
    (test):创建并运行测试
  • -pr
    (pull-request):在流程末尾创建PR
完整参数列表请查看
<parameters>
部分。 </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交互式配置参数 |
禁用参数(关闭功能):
短参数长参数说明
-A
--no-auto
禁用自主模式
-X
--no-examine
禁用审查模式
-S
--no-save
禁用保存模式
-T
--no-test
禁用测试模式
-E
--no-economy
禁用经济型模式
-B
--no-branch
禁用分支模式
-PR
--no-pull-request
禁用PR模式
</flags> <examples> ```bash

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结构:**
```markdown

APEX 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:
  • explore-codebase
    - Find existing patterns, files, utilities
  • explore-docs
    - Research library docs (use when unfamiliar with API)
  • websearch
    - Find approaches, best practices, gotchas
Launch 1-10 agents based on task complexity:
ComplexityAgentsWhen
Simple1-2Bug fix, small tweak
Medium2-4New feature in familiar stack
Complex4-7Unfamiliar libraries, integrations
Major6-10Multiple 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
{save_mode}
= true:
Step-00 runs
scripts/setup-templates.sh
to initialize all output files from
templates/
directory.
Each step then:
  1. Run
    scripts/update-progress.sh {task_id} {step_num} {step_name} "in_progress"
  2. Append findings/outputs to the pre-created step file
  3. 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
    templates/
    directory (not inline in steps)
  • Scripts handle progress tracking automatically
  • See
    templates/README.md
    for details
</save_output_pattern>
<success_criteria>
  • Each step loaded progressively
  • All validation checks passing
  • Outputs saved if
    {save_mode}
    enabled
  • Tests passing if
    {test_mode}
    enabled
  • Clear completion summary provided </success_criteria>
分析阶段(step-01)采用自适应Agent启动机制(经济型模式下除外):
可用Agent:
  • explore-codebase
    - 查找现有代码模式、文件和工具
  • explore-docs
    - 研究库文档(不熟悉API时使用)
  • websearch
    - 查找实现方案、最佳实践和注意事项
根据任务复杂度启动1-10个Agent:
复杂度Agent数量适用场景
简单1-2Bug修复、小调整
中等2-4熟悉技术栈的新功能开发
复杂4-7不熟悉的库、系统集成
重大6-10多系统交互、大量未知项
智能提示: 启动前先分析实际需求。简单任务不要过度启动Agent,复杂任务不要启动不足。
</execution_rules>
<save_output_pattern>
{save_mode}
=true时:
Step-00将运行
scripts/setup-templates.sh
templates/
目录初始化所有输出文件。
每个步骤执行以下操作:
  1. 运行
    scripts/update-progress.sh {task_id} {step_num} {step_name} "in_progress"
  2. 将分析/输出结果追加到预创建的步骤文件
  3. 运行
    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>