forge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseForge
Forge
Delegate complex, multi-step development work to an autonomous agent that builds and verifies code.
将复杂的多步骤开发工作委托给可构建并验证代码的自主Agent。
When to Use Forge
何时使用Forge
Use forge when:
- The task targets a different repo ()
-C ~/other-project - The work is complex enough to benefit from autonomous agent execution with verification
- You have spec files describing outcomes to implement
- You want to run multiple specs in parallel
Don't use forge when:
- The task is a simple edit you can make directly
- The user is asking a question, not requesting implementation
- The work is in the current file / current repo and straightforward
使用Forge的场景:
- 任务针对其他仓库()
-C ~/other-project - 工作足够复杂,可通过带验证的自主Agent执行获益
- 你拥有描述待实现结果的spec文件
- 你需要并行运行多个spec
不应使用Forge的场景:
- 任务是可直接完成的简单编辑操作
- 用户只是提出问题,而非要求实现功能
- 工作内容位于当前文件/当前仓库,且简单直接
Commands
命令
forge run
forge run
bash
forge run "add auth middleware" # Simple task
forge run --spec specs/auth.md "implement this" # With spec file
forge run --spec-dir ./specs/ -P "implement all" # Parallel specs
forge run -C ~/other-repo "fix the login bug" # Target different repo
forge run --rerun-failed -P "fix failures" # Rerun failed specs
forge run --resume <session-id> "continue" # Resume interrupted session
forge "quick task" # Shorthand (no 'run')Important flags:
- -- Spec file. Prompt becomes additional context.
-s, --spec <path> - -- Directory of specs. Each
-S, --spec-dir <path>runs separately..md - -- Run specs concurrently (auto-tuned concurrency).
-P, --parallel - -- Run first N specs sequentially, then parallelize.
--sequential-first <n> - -- Target repo directory.
-C, --cwd <path> - -- Auto-split tmux pane with live logs.
-w, --watch - -- Preview tasks and estimate cost without executing.
--dry-run
Run for all flags.
forge run --helpbash
forge run "add auth middleware" # Simple task
forge run --spec specs/auth.md "implement this" # With spec file
forge run --spec-dir ./specs/ -P "implement all" # Parallel specs
forge run -C ~/other-repo "fix the login bug" # Target different repo
forge run --rerun-failed -P "fix failures" # Rerun failed specs
forge run --resume <session-id> "continue" # Resume interrupted session
forge "quick task" # Shorthand (no 'run')重要参数:
- -- Spec文件,提示信息将作为额外上下文。
-s, --spec <path> - -- Spec文件目录,每个
-S, --spec-dir <path>文件将单独运行。.md - -- 并行运行spec(自动调优并发数)。
-P, --parallel - -- 先顺序运行前N个spec,再并行运行剩余部分。
--sequential-first <n> - -- 目标仓库目录。
-C, --cwd <path> - -- 自动拆分tmux面板以显示实时日志。
-w, --watch - -- 预览任务并估算成本,不实际执行。
--dry-run
运行查看所有参数。
forge run --helpforge audit
forge audit
Reviews codebase against specs. Produces new spec files for remaining work — feed them back into .
forge run --spec-dirbash
forge audit specs/ # Audit, output to specs/audit/
forge audit specs/ -o ./remediation/ # Custom output dir
forge audit specs/ -C ~/target-repo # Different repo对照spec审查代码库,为未完成的工作生成新的spec文件,可将其传入继续执行。
forge run --spec-dirbash
forge audit specs/ # Audit, output to specs/audit/
forge audit specs/ -o ./remediation/ # Custom output dir
forge audit specs/ -C ~/target-repo # Different repoforge review
forge review
Reviews recent git changes for bugs and quality issues.
bash
forge review # Review main...HEAD
forge review HEAD~5...HEAD # Specific range
forge review --dry-run -o findings.md # Report only, write to file审查近期的Git变更,查找Bug和质量问题。
bash
forge review # Review main...HEAD
forge review HEAD~5...HEAD # Specific range
forge review --dry-run -o findings.md # Report only, write to fileforge watch
forge watch
Live-tail session logs with colored output. Auto-exits when session completes.
bash
forge watch # Watch latest session
forge watch <session-id> # Watch specific session实时跟踪会话日志并显示彩色输出,会话完成后自动退出。
bash
forge watch # Watch latest session
forge watch <session-id> # Watch specific sessionforge status
forge status
bash
forge status # Latest run
forge status --all # All runs
forge status -n 5 # Last 5 runsbash
forge status # Latest run
forge status --all # All runs
forge status -n 5 # Last 5 runsRecipes
使用方案
Spec-driven development
基于Spec的开发
bash
undefinedbash
undefined1. Write specs as .md files (see references/writing-specs.md)
1. Write specs as .md files (see references/writing-specs.md)
2. Run them in parallel
2. Run them in parallel
forge run --spec-dir ./specs/ -P "implement all specs"
forge run --spec-dir ./specs/ -P "implement all specs"
3. Rerun any failures
3. Rerun any failures
forge run --rerun-failed -P "fix failures"
forge run --rerun-failed -P "fix failures"
4. Check results
4. Check results
forge status
undefinedforge status
undefinedFoundation specs first, then parallelize
先执行基础Spec,再并行运行
Number-prefix specs for ordering. Foundations run sequentially before the parallel phase:
bash
forge run --spec-dir ./specs/ -P --sequential-first 2 "implement"为Spec文件添加数字前缀以指定顺序,基础Spec将在并行阶段前顺序执行:
bash
forge run --spec-dir ./specs/ -P --sequential-first 2 "implement"Runs 01-.md, 02-.md sequentially, then 03+ in parallel
Runs 01-.md, 02-.md sequentially, then 03+ in parallel
undefinedundefinedAudit-then-fix loop
审计-修复循环
bash
forge audit specs/ -C ~/project # Find gaps
forge run --spec-dir specs/audit/ -P -C ~/project "fix remaining"bash
forge audit specs/ -C ~/project # Find gaps
forge run --spec-dir specs/audit/ -P -C ~/project "fix remaining"Resume or fork after interruption
中断后恢复或分支
bash
forge run --resume <session-id> "continue" # Pick up where you left off
forge run --fork <session-id> "try different approach" # Branch from that pointbash
forge run --resume <session-id> "continue" # Pick up where you left off
forge run --fork <session-id> "try different approach" # Branch from that pointDeep-Dive References
深度参考
| Reference | Load when |
|---|---|
| writing-specs.md | Writing spec files for forge to execute |
| parallel-execution.md | Tuning concurrency, understanding cost, monitoring parallel runs |
| 参考文档 | 适用场景 |
|---|---|
| writing-specs.md | 编写供Forge执行的spec文件时 |
| parallel-execution.md | 调优并发数、了解成本、监控并行运行时 |