claw-forge CLI
claw-forge is a multi-provider autonomous coding agent harness.
Agents run in parallel, claim features from a dependency DAG, and keep working
until every feature passes — or you stop them.
GitHub: https://github.com/clawinfra/claw-forge
PyPI: https://pypi.org/project/claw-forge/
Install
CODEBLOCK0
Full Workflow
1 — Bootstrap a project
CODEBLOCK1
Creates:
- -
CLAUDE.md — agent instructions (stack-aware) - INLINECODE1 — slash commands (
/create-spec, etc.) - INLINECODE3 — provider pool config
- INLINECODE4 — API key template
2 — Write a spec
Create app_spec.txt (plain text) or app_spec.xml (structured XML):
CODEBLOCK2
Or use the Claude slash command inside Claude Code: INLINECODE7
3 — Plan: parse spec → feature DAG
CODEBLOCK3
- - Decomposes spec into atomic features
- Assigns dependency edges (A must pass before B starts)
- Writes task graph to INLINECODE8
- Uses Opus by default (planning is the most critical step)
CODEBLOCK4
4 — Run agents
CODEBLOCK5
Default: 5 parallel coding agents, reads claw-forge.yaml.
CODEBLOCK6
5 — Check progress
CODEBLOCK7
Shows: passing/failing/running/pending feature counts, recommended next action.
6 — Open the Kanban UI
CODEBLOCK8
Opens a browser-based Kanban board at http://localhost:8888.
Shows real-time agent activity, feature status, costs, and logs.
All Commands
| Command | Purpose |
|---|
| INLINECODE11 | Bootstrap project (CLAUDE.md, config, slash commands) |
| INLINECODE12 |
Parse spec → feature DAG in state DB |
|
run | Run agents until all features pass |
|
status | Show progress and recommended next action |
|
ui | Launch Kanban UI at localhost:8888 |
|
dev | Start API + Vite dev server (for UI development) |
|
add <spec> | Add features to an existing project (brownfield) |
|
pause | Drain mode: finish in-flight, start no new agents |
|
resume | Resume after pause |
|
fix <desc> | Fix a bug using RED→GREEN reproduce-first protocol |
|
merge | Squash-merge a feature branch to target |
|
input | Answer pending human-input questions interactively |
|
pool-status | Show provider pool health and current routing |
|
state | Start the AgentStateService REST + WebSocket API |
Config: claw-forge.yaml
CODEBLOCK9
Edit Modes
str_replace (default)
Standard exact-text matching. Works well with capable models (Sonnet, Opus).
hashline (recommended for weaker models)
Content-addressed line tagging. Each line gets a 3-char hash prefix.
Model references lines by hash — immune to whitespace/indentation drift.
Benchmark: 6.7% → 68.3% success rate improvement on Grok Code Fast.
CODEBLOCK10
Brownfield (add to existing project)
CODEBLOCK11
Bug Fix Protocol
CODEBLOCK12
Common Patterns
Quick greenfield project
CODEBLOCK13
Cost-optimised run
CODEBLOCK14
Multi-provider failover
CODEBLOCK15
YOLO overnight run
claw-forge run --yolo --concurrency 8
# Come back in the morning — all features should be passing
Tips
- - Planning quality = outcome quality. Don't skimp on the planning model. Use Opus for
plan. - More concurrency ≠ always better. Each agent needs context. 3–5 is usually the sweet spot.
--edit-mode hashline dramatically helps weaker/cheaper models that struggle with exact text matching.claw-forge status tells you exactly what to do next — trust it.claw-forge ui is the best way to monitor long runs — live logs per agent, cost tracking, dependency graph.- Provider API keys go in
.env (never commit). .env.example is the template.
技能名称: claw-forge-cli
详细描述:
claw-forge CLI
claw-forge 是一个多提供商自主编码代理工具集。
代理并行运行,从依赖DAG中认领功能,并持续工作直到每个功能通过测试——或者你手动停止它们。
GitHub: https://github.com/clawinfra/claw-forge
PyPI: https://pypi.org/project/claw-forge/
安装
bash
pip install claw-forge
或(推荐):
uv pip install claw-forge
完整工作流程
1 — 初始化项目
bash
cd my-project
claw-forge init
创建以下文件:
- - CLAUDE.md — 代理指令(技术栈感知)
- .claude/ — 斜杠命令(/create-spec 等)
- claw-forge.yaml — 提供商池配置
- .env.example — API密钥模板
2 — 编写规格说明
创建 appspec.txt(纯文本)或 appspec.xml(结构化XML):
text
项目:我的应用
技术栈:Python, FastAPI, SQLite
认证:
仪表盘:
或者在Claude Code中使用Claude斜杠命令:/create-spec
3 — 规划:解析规格说明 → 功能DAG
bash
claw-forge plan app_spec.txt
- - 将规格说明分解为原子功能
- 分配依赖边(A必须通过后B才能开始)
- 将任务图写入 .claw-forge/state.db
- 默认使用Opus(规划是最关键的步骤)
bash
如果更关注成本,使用Sonnet
claw-forge plan app_spec.txt --model claude-sonnet-4-6
4 — 运行代理
bash
claw-forge run
默认:5个并行编码代理,读取 claw-forge.yaml。
bash
更高并发
claw-forge run --concurrency 8
指定特定模型
claw-forge run --model claude-opus-4-6
YOLO模式 — 跳过人工输入关卡,最大速度,激进重试
claw-forge run --yolo
预览而不执行
claw-forge run --dry-run
使用hashline编辑模式(对较弱模型效果更好 — 基准测试从6.7%提升到68.3%)
claw-forge run --edit-mode hashline
5 — 检查进度
bash
claw-forge status
显示:通过/失败/运行中/待处理的功能计数,以及推荐的下一步操作。
6 — 打开看板界面
bash
claw-forge ui
在 http://localhost:8888 打开基于浏览器的看板。
实时显示代理活动、功能状态、成本和日志。
所有命令
| 命令 | 用途 |
|---|
| init | 初始化项目(CLAUDE.md、配置、斜杠命令) |
| plan <spec> |
解析规格说明 → 状态数据库中的功能DAG |
| run | 运行代理直到所有功能通过 |
| status | 显示进度和推荐的下一步操作 |
| ui | 在localhost:8888启动看板界面 |
| dev | 启动API + Vite开发服务器(用于界面开发) |
| add
| 向现有项目添加功能(棕地开发) |
| pause | 排空模式:完成进行中的任务,不启动新代理 |
| resume | 暂停后恢复 |
| fix | 使用RED→GREEN先重现后修复协议修复Bug |
| merge | 将功能分支压缩合并到目标分支 |
| input | 交互式回答待处理的人工输入问题 |
| pool-status | 显示提供商池健康状态和当前路由 |
| state | 启动AgentStateService REST + WebSocket API |
配置:claw-forge.yaml
yaml
提供商池 — 有多少密钥就添加多少
providers:
anthropic-primary:
type: anthropic
apikey: ${ANTHROPICAPI_KEY}
priority: 1
enabled: true
max_rpm: 50
model: claude-sonnet-4-6
anthropic-backup:
type: anthropic
apikey: ${ANTHROPICAPIKEY2}
priority: 2
enabled: true
max_rpm: 30
model: claude-sonnet-4-6
池路由策略
pool:
strategy: priority # priority | roundrobin | leastcost
模型别名(在 --model 标志中使用)
model_aliases:
fast: claude-haiku-4-5
smart: claude-opus-4-6
default: claude-sonnet-4-6
Git集成
git:
enabled: true
merge_strategy: auto # auto | squash | merge
编辑模式
str_replace(默认)
标准精确文本匹配。适用于能力强的模型(Sonnet、Opus)。
hashline(推荐用于较弱模型)
内容寻址行标记。每行获得一个3字符的哈希前缀。
模型通过哈希引用行 — 不受空格/缩进漂移影响。
基准测试:在Grok Code Fast上成功率从6.7%提升到68.3%。
bash
claw-forge run --edit-mode hashline
棕地开发(添加到现有项目)
bash
编写新增规格说明
cat > additions_spec.xml << EOF
name>my-appname>
toadd>
- 添加OAuth2 Google登录
- 为认证端点添加速率限制
toadd>
EOF
claw-forge add additions_spec.xml
Bug修复协议
bash
先重现:代理编写失败测试,然后修复它
claw-forge fix 邮箱包含大写字母时登录失败
常见模式
快速绿地项目
bash
mkdir my-api && cd my-api
claw-forge init
编写 app_spec.txt
claw-forge plan app_spec.txt
claw-forge run --concurrency 3
claw-forge status
成本优化运行
bash
混合廉价+昂贵:池中使用廉价模型处理简单任务
claw-forge run --model claude-haiku-4-5 --concurrency 10
多提供商故障转移
bash
在 claw-forge.yaml 中添加多个提供商
池在遇到速率限制或错误时自动故障转移
claw-forge pool-status # 检查健康状态
claw-forge run # 自动故障转移运行
YOLO通宵运行
bash
claw-forge run --yolo --concurrency 8
早上回来 — 所有功能应该都已通过
提示
- - 规划质量 = 结果质量。 不要在规划模型上吝啬。对 plan 使用Opus。
- 更高的并发 ≠ 总是更好。 每个代理都需要上下文。3–5通常是最佳点。
- --edit-mode hashline 能显著帮助那些在精确文本匹配上挣扎的较弱/更便宜的模型。
- claw-forge status 准确告诉你下一步该做什么 — 相信它。
- claw-forge ui 是监控长时间运行的最佳方式 — 每个代理的实时日志、成本跟踪、依赖图。
- 提供商API密钥放在 .env 中(切勿提交)。.env.example 是模板。