huashu-agent-swarm
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInfinite Agent Loop - 无限Agent蜂群模式
Infinite Agent Loop - Infinite Agent Swarm Mode
受Nicholas Carlini用16个Claude实例自主构建C编译器的启发。 没有master agent,纯git自组织,每个agent独立认领任务、写代码、推送。
Inspired by Nicholas Carlini using 16 Claude instances to independently build a C compiler. No master agent, pure Git self-organization, each agent independently claims tasks, writes code, and pushes.
触发条件
Trigger Conditions
当用户提到「蜂群模式」「多agent并行」「infinite loop」「agent swarm」「启动蜂群」时使用此技能。
Use this skill when users mention "swarm mode", "multi-agent parallel", "infinite loop", "agent swarm", "start swarm".
前置要求
Prerequisites
- tmux()
brew install tmux - claude CLI(已安装)
- git 仓库(已有或新建)
- tmux ()
brew install tmux - claude CLI (installed)
- Git repository (existing or newly created)
使用流程
Usage Process
Step 1: 描述项目
Step 1: Describe the Project
用户告诉我:
- 项目目录路径(必须是git仓库)
- 项目目标和总体描述
- 初始任务列表(或让agent自行拆解)
- agent数量(默认8个)
- 代码规范和测试命令
Users tell me:
- Project directory path (must be a Git repository)
- Project goals and overall description
- Initial task list (or let agents break down tasks automatically)
- Number of agents (default: 8)
- Code specifications and test commands
Step 2: 初始化项目
Step 2: Initialize the Project
bash
bash SKILL_DIR/scripts/setup_project.sh <项目目录>这会在项目中创建:
- - 从模板生成,需要我根据用户需求定制
AGENT_PROMPT.md - - 初始任务清单
TASKS.md - - 任务认领目录
current_tasks/ - - 日志目录
agent_logs/
然后我根据 定制 ,填入项目具体信息。
references/agent-prompt-template.mdAGENT_PROMPT.mdbash
bash SKILL_DIR/scripts/setup_project.sh <project directory>This will create in the project:
- - Generated from template, needs to be customized according to user requirements
AGENT_PROMPT.md - - Initial task list
TASKS.md - - Task claim directory
current_tasks/ - - Log directory
agent_logs/
Then I customize based on , filling in specific project information.
AGENT_PROMPT.mdreferences/agent-prompt-template.mdStep 3: 启动蜂群
Step 3: Start the Swarm
bash
bash SKILL_DIR/scripts/start_swarm.sh <agent数量> <项目目录>这会:
- 为每个agent创建 git worktree(共享.git对象库,不浪费磁盘)
- 创建 tmux session,每个pane一个agent
- 每个agent进入无限循环:pull → 认领任务 → 执行 → push → 下一个
bash
bash SKILL_DIR/scripts/start_swarm.sh <number of agents> <project directory>This will:
- Create a git worktree for each agent (shares .git object library, no disk waste)
- Create a tmux session, one agent per pane
- Each agent enters an infinite loop: pull → claim task → execute → push → next
Step 4: 打开观测台
Step 4: Open the Dashboard
bash
python3 SKILL_DIR/scripts/dashboard.py <项目目录> 8420- 实时查看所有agent状态、git log、任务进度
- 查看每个agent的最新日志
- 输入框直接发送指令给agent(写入HUMAN_INPUT.md)
- 一键停止所有agent
也可以用命令行监控:
bash
undefinedbash
python3 SKILL_DIR/scripts/dashboard.py <project directory> 8420Open http://localhost:8420 in browser, you can:
- View real-time status of all agents, git log, task progress
- View the latest logs of each agent
- Send instructions directly to agents via input box (writes to HUMAN_INPUT.md)
- Stop all agents with one click
You can also monitor via command line:
bash
undefined终端状态
Terminal status
bash SKILL_DIR/scripts/status.sh <项目目录>
bash SKILL_DIR/scripts/status.sh <project directory>
发送指令
Send instructions
bash SKILL_DIR/scripts/send_input.sh <项目目录> "你的指令"
bash SKILL_DIR/scripts/send_input.sh <project directory> "your instruction"
直接进入tmux观察
Directly enter tmux to observe
tmux attach -t swarm-<项目名>
undefinedtmux attach -t swarm-<project name>
undefinedStep 5: 停止
Step 5: Stop
bash
bash SKILL_DIR/scripts/stop_swarm.sh <项目目录>自动停止所有agent + 合并分支 + 清理worktrees。
bash
bash SKILL_DIR/scripts/stop_swarm.sh <project directory>Automatically stops all agents + merges branches + cleans up worktrees.
核心机制
Core Mechanisms
Git自组织协调
Git Self-Organization Coordination
- 每个agent通过 文件认领任务
current_tasks/*.lock - 通过 了解全局进度
TASKS.md - 通过 了解其他agent的工作
git log - 冲突由agent自行解决
- Each agent claims tasks via files
current_tasks/*.lock - Understands global progress through
TASKS.md - Learns about other agents' work through
git log - Conflicts are resolved by agents themselves
Git Worktree隔离
Git Worktree Isolation
- 不用多份clone,用 实现隔离
git worktree - 所有worktree共享同一个 对象库
.git - 每个agent在自己的worktree独立工作
- No multiple clones, uses for isolation
git worktree - All worktrees share the same object library
.git - Each agent works independently in its own worktree
无限循环
Infinite Loop
- 每个agent完成一个session后自动开始下一个
- 通过 获取其他agent的最新成果
git pull - 通过 sleep 间隔避免API限流
- Each agent automatically starts the next session after completing one
- Gets the latest results from other agents via
git pull - Uses sleep intervals to avoid API rate limits
关键配置
Key Configurations
| 参数 | 默认值 | 说明 |
|---|---|---|
| agent数量 | 8 | 可在启动时指定 |
| sleep间隔 | 5秒 | agent_loop.sh中可调 |
| 模型 | claude-opus-4-6 | agent_loop.sh中可调 |
| Parameter | Default Value | Description |
|---|---|---|
| Number of agents | 8 | Specifiable at startup |
| Sleep interval | 5 seconds | Adjustable in agent_loop.sh |
| Model | claude-opus-4-6 | Adjustable in agent_loop.sh |
风险和应对
Risks and Countermeasures
| 风险 | 应对 |
|---|---|
| API限流 | sleep间隔 + 可调agent数量 |
| 合并冲突 | AGENT_PROMPT指导小粒度commit |
| 死循环无用功 | 日志监控 + 停止条件 |
| 磁盘空间 | stop_swarm.sh自动清理 |
| 成本失控 | 可在AGENT_PROMPT中限制session数 |
花叔出品 | AI Native Coder · 独立开发者 公众号「花叔」| 30万+粉丝 | AI工具与效率提升 代表作:小猫补光灯(AppStore付费榜Top1)·《一本书玩转DeepSeek》
| Risk | Countermeasure |
|---|---|
| API rate limits | Sleep intervals + adjustable number of agents |
| Merge conflicts | AGENT_PROMPT guides small-grained commits |
| Infinite loop of useless work | Log monitoring + stop conditions |
| Disk space issues | stop_swarm.sh automatically cleans up |
| Uncontrolled costs | Limit number of sessions in AGENT_PROMPT |
Produced by Uncle Hua | AI Native Coder · Independent Developer Official Account "Uncle Hua" | 300,000+ followers | AI Tools & Efficiency Improvement Masterpieces: Kitten Fill Light (Top 1 in AppStore Paid Charts) · "Mastering DeepSeek in One Book"