agent-army

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Agent Army

Agent军团

Architecture

架构

Commander
 |
 |-- Layer 1: Team (3 to 50+, each = own 1M context)
 |    |
 |    |-- Agent A (1M) -- Sub-agent A1 (own context), A2 (own context), ...
 |    |-- Agent B (1M) -- Sub-agent B1 (own context), B2 (own context), ...
 |    |-- Agent C (1M) -- Sub-agent C1 (own context), C2 (own context), ...
 |    |-- ... (no cap)
Commander
 |
 |-- Layer 1: Team (3 to 50+, each = own 1M context)
 |    |
 |    |-- Agent A (1M) -- Sub-agent A1 (own context), A2 (own context), ...
 |    |-- Agent B (1M) -- Sub-agent B1 (own context), B2 (own context), ...
 |    |-- Agent C (1M) -- Sub-agent C1 (own context), C2 (own context), ...
 |    |-- ... (no cap)

Layer 1 Prompt Template

第一层提示词模板

This is what spawned agents actually see. It is the most important section in this skill.
You are [AGENT_NAME], specialist on [DOMAIN].

Objective: [One sentence]
Approved patterns: [Exact values -- hex codes, class names, etc.]
Forbidden patterns: [What to remove/avoid]
Your files: [Absolute paths with line counts]
Rules: [Constraints]. Skip files already using approved patterns. Flag issues outside your files in "Flags for Commander" -- do NOT fix them.

CRITICAL: You MUST use the Agent tool to spawn the sub-agents listed below. Do NOT do the work yourself. Do NOT skip spawning. Deploy ALL sub-agents in a single message with multiple Agent tool calls.

Sub-agents:
- "[NAME]": [files with line counts]
- "[NAME]": [files with line counts]

Pass each sub-agent: objective, their files, approved/forbidden patterns, rules, report format. After all complete, aggregate reports and verify no forbidden patterns remain.
这是被生成的Agent实际会看到的内容,是本技能中最重要的部分。
You are [AGENT_NAME], specialist on [DOMAIN].

Objective: [One sentence]
Approved patterns: [Exact values -- hex codes, class names, etc.]
Forbidden patterns: [What to remove/avoid]
Your files: [Absolute paths with line counts]
Rules: [Constraints]. Skip files already using approved patterns. Flag issues outside your files in "Flags for Commander" -- do NOT fix them.

CRITICAL: You MUST use the Agent tool to spawn the sub-agents listed below. Do NOT do the work yourself. Do NOT skip spawning. Deploy ALL sub-agents in a single message with multiple Agent tool calls.

Sub-agents:
- "[NAME]": [files with line counts]
- "[NAME]": [files with line counts]

Pass each sub-agent: objective, their files, approved/forbidden patterns, rules, report format. After all complete, aggregate reports and verify no forbidden patterns remain.

Layer 2 Prompt Template

第二层提示词模板

You are [SUB_AGENT_NAME], working under [TEAM_MEMBER_NAME].

Objective: [One sentence]
Files you own: [Absolute paths with line counts -- only touch these]
Approved/Forbidden patterns: [Exact values to use and remove]
Rules: [Constraints]. Skip files already correct. Flag issues outside your files -- do NOT fix them.

Report when done: Files Modified (file: N replacements), Files Skipped (already correct), Flags for Commander, Issues Encountered, Status (COMPLETE/PARTIAL/FAILED).
<mandatory-rules>
You are [SUB_AGENT_NAME], working under [TEAM_MEMBER_NAME].

Objective: [One sentence]
Files you own: [Absolute paths with line counts -- only touch these]
Approved/Forbidden patterns: [Exact values to use and remove]
Rules: [Constraints]. Skip files already correct. Flag issues outside your files -- do NOT fix them.

Report when done: Files Modified (file: N replacements), Files Skipped (already correct), Flags for Commander, Issues Encountered, Status (COMPLETE/PARTIAL/FAILED).
<mandatory-rules>

MANDATORY RULES

强制规则

  1. EVERY Layer 1 agent MUST spawn 2+ sub-agents. No exceptions. If deploying without sub-agents, STOP and restructure.
  2. NEVER silently reduce army size. Match the user's chosen tier.
  3. Report as agents complete:
    [Agent N/M complete] name: X files modified, Y flags
  4. Show the army plan before deploying (Full Mode). Quick Mode: compose plan internally, skip confirmation.
  5. Sub-agent deployment instructions go INSIDE the Layer 1 brief. If missing, sub-agents will not exist.
  6. Build check after every wave. If it fails, trigger a fix wave.
  7. "Keep going" / "don't stop" = continuous mode. Launch new agents as each completes. Do not wait. Do not ask.
</mandatory-rules>
  1. 每个第一层Agent必须生成2个以上的Sub-agent,无例外。如果部署时没有Sub-agent,请立即停止并重新调整结构。
  2. 绝对不能悄悄缩减军团规模,必须匹配用户选择的档位。
  3. 当Agent完成任务时按以下格式上报:
    [Agent N/M complete] name: X files modified, Y flags
  4. 部署前展示军团计划(完整模式);快速模式:内部生成计划,无需确认。
  5. Sub-agent部署指令必须写在第一层Agent的任务说明内部,如果缺失,Sub-agent将无法生成。
  6. 每轮执行后都要进行构建检查,如果失败,触发修复轮次。
  7. "Keep going" / "don't stop" = 持续模式,每个Agent完成后立即启动新的Agent,无需等待,无需询问。
</mandatory-rules>

Army Size

军团规模

Confirm tier before starting. Present this table:
| Tier | Agents | Total with Sub-agents | Est. Tokens |
|------|--------|----------------------|-------------|
| Conservative | 3 | ~9 | ~200-500K |
| Standard | 5-10 | ~15-30 | ~500K-1.5M |
| Aggressive | 10-20 | ~30-60 | ~1.5-4M |
| Maximum | 20-50+ | ~60-100+ | ~4M+ |
| Custom | You pick | You pick | Varies |

Token estimates vary by task complexity. Pick a tier or enter a custom number:
Default to Standard if user says "just do it." Tier question applies to BOTH Quick and Full modes.
After recon (Step 3), recommend a specific number based on what you found. Example: "Found 35 files across 6 domains. I recommend Aggressive tier: 8 Layer 1 agents with 2-3 sub-agents each (~22 total, ~2M tokens). Want to adjust?"
开始前确认档位,向用户展示下表:
| Tier | Agents | Total with Sub-agents | Est. Tokens |
|------|--------|----------------------|-------------|
| Conservative | 3 | ~9 | ~200-500K |
| Standard | 5-10 | ~15-30 | ~500K-1.5M |
| Aggressive | 10-20 | ~30-60 | ~1.5-4M |
| Maximum | 20-50+ | ~60-100+ | ~4M+ |
| Custom | You pick | You pick | Varies |

Token estimates vary by task complexity. Pick a tier or enter a custom number:
如果用户说"just do it"则默认使用标准档。档位确认规则同时适用于快速模式和完整模式。
摸排(第3步)完成后,根据摸排结果推荐具体的数量。示例:"Found 35 files across 6 domains. I recommend Aggressive tier: 8 Layer 1 agents with 2-3 sub-agents each (~22 total, ~2M tokens). Want to adjust?"

Deployment Gate

部署准入检查

Output this checklist in your response before deploying. Do NOT skip it. Do NOT just check it mentally.
DEPLOYMENT GATE:
[ ] Every L1 brief contains "You MUST spawn N sub-agents"
[ ] Every sub-agent named with specific files assigned
[ ] Every file owned by exactly one sub-agent
[ ] L1 briefs include full sub-agent deployment instructions
[ ] Tier matches user's selection
All must PASS. If any FAIL: fix the plan first.
部署前在响应中输出以下检查清单,不得跳过,不得仅在内部核对。
DEPLOYMENT GATE:
[ ] Every L1 brief contains "You MUST spawn N sub-agents"
[ ] Every sub-agent named with specific files assigned
[ ] Every file owned by exactly one sub-agent
[ ] L1 briefs include full sub-agent deployment instructions
[ ] Tier matches user's selection
所有项必须通过,如有任何一项不通过,请先调整计划。

Protocol

执行流程

Mode: If scope is clear and specific (file paths, exact changes), skip to Step 3. Otherwise start at Step 1.
模式: 如果范围清晰明确(文件路径、具体修改内容),直接跳到第3步,否则从第1步开始。

Step 1: Intake (Full Mode)

第1步:信息收集(完整模式)

Confirm with user:
  1. Goal (one sentence)
  2. Scope (files, directories, or "everything")
  3. Constraints (don't touch X, match Y style)
  4. Tier (show table above)
If user already provided context, confirm in one line: "Goal: [X]. Scope: [Y]. Tier: [Z]. Starting."
向用户确认:
  1. 目标(一句话描述)
  2. 范围(文件、目录或"全部内容")
  3. 约束(不能修改X、匹配Y风格等)
  4. 档位(展示上述表格)
如果用户已经提供了上下文,用一句话确认:"Goal: [X]. Scope: [Y]. Tier: [Z]. Starting."

Step 2: Git Checkpoint

第2步:Git检查点

  1. Run
    git status
    . Warn if uncommitted changes.
  2. Create checkpoint:
    git checkout -b agent-army/checkpoint-{timestamp}
    , switch back.
  3. No git repo? Warn user and get confirmation.
  1. 运行
    git status
    ,如果有未提交的变更则发出警告。
  2. 创建检查点:
    git checkout -b agent-army/checkpoint-{timestamp}
    ,然后切回原分支。
  3. 没有Git仓库?向用户发出警告并获取确认。

Step 3: Recon

第3步:摸排

  1. Scan -- Grep, Glob, Read to find all affected files
  2. Count units of work
  3. wc -l
    each file. Flag 500+ line files as heavy (assign solo)
  4. Classify into domains (by directory, imports, file type, naming pattern)
  5. Identify shared dependencies (foundation files -- handle first)
  6. Identify build command (check package.json, Makefile, etc.)
Output scope report:
Files: N | Heavy: [list] | Domains: [list] | Shared deps: [list] | Build cmd: [cmd]
  1. 扫描——通过Grep、Glob、读取操作找出所有受影响的文件
  2. 统计工作单元数量
  3. 对每个文件执行
    wc -l
    统计行数,标记500行以上的文件为大文件(单独分配)
  4. 按目录、导入、文件类型、命名模式分类到不同领域
  5. 识别共享依赖(基础文件——优先处理)
  6. 识别构建命令(检查package.json、Makefile等)
输出范围报告:
Files: N | Heavy: [list] | Domains: [list] | Shared deps: [list] | Build cmd: [cmd]

Step 4: Compose

第4步:编排组建

  1. Foundation Agent for shared deps (runs first, before parallel wave)
  2. Layer 1: 1 agent per domain. Split large domains across multiple agents.
  3. Layer 2: 2+ sub-agents per L1 agent based on file weight
  4. Name every agent. Assign every file to exactly one sub-agent.
Output army plan. Full Mode: pause for "Proceed?" Quick Mode: show one-line summary, deploy.
  1. 优先为共享依赖配置基础Agent(先执行,早于并行批次)
  2. 第一层:每个领域配置1个Agent,大型领域拆分给多个Agent处理
  3. 第二层:根据文件重量为每个第一层Agent配置2个以上的Sub-agent
  4. 为每个Agent命名,每个文件恰好分配给一个Sub-agent
输出军团计划。完整模式:暂停等待用户回复"Proceed?";快速模式:展示一行总结后直接部署。

Step 5: Deploy

第5步:部署

  1. Foundation Agent first (if needed). Wait for completion.
  2. Launch ALL Layer 1 agents in parallel (
    run_in_background: true
    , single message).
  3. L1 agents spawn L2 sub-agents in parallel (per their brief).
  4. Report each completion:
    [Agent N/M complete] name: results
  1. 优先启动基础Agent(如有需要),等待其完成。
  2. 并行启动所有第一层Agent(
    run_in_background: true
    ,单条消息触发)。
  3. 第一层Agent根据其任务说明并行生成第二层Sub-agent。
  4. 每个Agent完成后上报结果:
    [Agent N/M complete] name: results

Step 6: Verify

第6步:校验

  1. Re-scan for remaining violations (same searches as Step 3)
  2. Run build command
  3. Resolve cross-team flags
  4. Output army report:
Agents: N total | Files modified: N | Skipped: N | Build: PASS/FAIL | Flags: [list] | Rollback: git checkout agent-army/checkpoint-{timestamp}
  1. 重新扫描是否有剩余违规项(和第3步使用相同的搜索规则)
  2. 执行构建命令
  3. 解决跨团队标记的问题
  4. 输出军团报告:
Agents: N total | Files modified: N | Skipped: N | Build: PASS/FAIL | Flags: [list] | Rollback: git checkout agent-army/checkpoint-{timestamp}

Waves

执行波次

After Wave 1: build + re-scan. If clean, done. If issues remain, deploy Wave 2 (fix wave). If still issues, Wave 3 (propagate to tests/docs). Max 3 waves. Pause for user approval before each.
第1波完成后:执行构建+重新扫描,如果没有问题则结束;如果仍有问题,部署第2波(修复波);如果还有问题,部署第3波(同步到测试/文档),最多3波。每波部署前都需要暂停获取用户批准。

Shared Scratchpad (optional)

共享暂存区(可选)

For complex multi-wave tasks, write
.army-state.md
after Wave 1: files modified, flags, issues, decisions. Wave 2 agents read it directly for full context. Skip for single-wave tasks.
针对复杂的多波次任务,第1波完成后写入
.army-state.md
:修改的文件、标记的问题、遇到的问题、决策内容。第2波的Agent直接读取该文件获取完整上下文,单波次任务可跳过。

Report Format

报告格式

Every agent returns:
undefined
每个Agent返回内容如下:
undefined

Report: [Name]

Report: [Name]

Files Modified: [file: N replacements] Files Skipped: [file: reason] Flags for Commander: [issue or "None"] Issues: [issue or "None"] Status: COMPLETE / PARTIAL / FAILED
undefined
Files Modified: [file: N replacements] Files Skipped: [file: reason] Flags for Commander: [issue or "None"] Issues: [issue or "None"] Status: COMPLETE / PARTIAL / FAILED
undefined

Error Handling

错误处理

  • Sub-agent fails: L1 agent retries or spawns replacement
  • L1 agent fails: Commander spawns replacement with same brief
  • Build failure: compare against checkpoint, diagnose, fix wave
  • Sub-agent执行失败:第一层Agent重试或生成新的替代Sub-agent
  • 第一层Agent执行失败:指挥官生成相同任务说明的替代Agent
  • 构建失败:和检查点版本对比,诊断问题,触发修复波