BrainDrive Forge is a production-grade, file-based agent loop for autonomous coding. Each iteration starts fresh, reads the same on-disk state, emits structured events, and completes exactly one story at a time.
Forge treats files and git as memory, not the model context:
- PRD (JSON) defines stories, gates, and status
- Loop executes one story per iteration
- State persists in
.forge/ - Events are written to
.forge/events.jsonl
Install and run Forge from anywhere:
npm i -g braindrive-forge
braindrive-forge prd # launches an interactive prompt
braindrive-forge run 1 # one Forge runForge will look for templates in this order:
.agents/forge/in the current project (if present)- Bundled defaults shipped with this repo
State and logs always go to .forge/ in the project.
braindrive-forge installThis creates .agents/forge/ in the current repo so you can customize prompts and loop behavior. During install, you’ll be asked if you want to add the required skills.
braindrive-forge install --skillsYou’ll be prompted for agent (codex/claude/droid/opencode) and local vs global install. Skills installed: commit, dev-browser, prd.
If you skipped skills during braindrive-forge install, you can run braindrive-forge install --skills anytime.
- Create your PRD (JSON) or generate one:
braindrive-forge prd
Requires the prd skill (install via braindrive-forge install --skills).
Use a markdown/text file instead of an interactive prompt:
braindrive-forge prd --prompt ./spec.md
Example prompt text:
A lightweight uptime monitor (Hono app), deployed on Cloudflare, with email alerts via AWS SES
Default output (agent chooses a short filename in .agents/tasks/):
.agents/tasks/prd-<short>.json
- Run one build iteration:
braindrive-forge run 1 # one Forge run
No-commit dry run:
braindrive-forge run 1 --no-commit # one Forge run
Override PRD output for braindrive-forge prd:
braindrive-forge prd --out .agents/tasks/prd-api.json
Optional human overview (generated from JSON):
braindrive-forge overview
This writes a tiny overview alongside the PRD: prd-<slug>.overview.md.
PRD story status fields are updated automatically by the loop:
open→ selectablein_progress→ locked by a running loop (withstartedAt)done→ completed (withcompletedAt)
If a loop crashes and a story stays in_progress, you can set STALE_SECONDS in .agents/forge/config.sh to allow Forge to automatically reopen stalled stories.
braindrive-forge pause "Taking a break"
braindrive-forge resume
braindrive-forge inspect STORY-07
braindrive-forge replay iter-12You can point Forge at a different PRD JSON file via CLI flags:
braindrive-forge run 1 --prd .agents/tasks/prd-api.json # one Forge runOptional progress override:
braindrive-forge run 1 --progress .forge/progress-api.md # one Forge runIf multiple PRD JSON files exist in .agents/tasks/ and you omit --prd, Forge will prompt you to choose.
Optional config file (if you installed templates):
.agents/forge/config.sh
Set AGENT_CMD in .agents/forge/config.sh to switch agents:
AGENT_CMD="codex exec --yolo -"
AGENT_CMD="claude -p --dangerously-skip-permissions \"\$(cat {prompt})\""
AGENT_CMD="droid exec --skip-permissions-unsafe -f {prompt}"
AGENT_CMD="opencode run \"$(cat {prompt})\""
Or override per run:
braindrive-forge prd --agent=codex
braindrive-forge run 1 --agent=codex # one Forge run
braindrive-forge run 1 --agent=claude # one Forge run
braindrive-forge run 1 --agent=droid # one Forge run
braindrive-forge run 1 --agent=opencode # one Forge run
If the CLI isn’t installed, Forge prints install hints:
codex -> npm i -g @openai/codex
claude -> curl -fsSL https://claude.ai/install.sh | bash
droid -> curl -fsSL https://app.factory.ai/cli | sh
opencode -> curl -fsSL https://opencode.ai/install.sh | bash
project.json— high-level project snapshotstories/— one JSON file per storyiterations/— per-iteration metadata JSONlogs/— raw agent output per iterationevents.jsonl— structured event logprogress.md— append-only progress logguardrails.md— “Signs” (lessons learned)activity.log— activity + timing logerrors.log— repeated failures and notes
.agents/forgeis portable and can be copied between repos..forgeis per-project state.- Use
{prompt}inAGENT_CMDwhen agent needs a file path instead of stdin. - Examples: see
examples/commands.md. - OpenCode server mode: For faster performance with OpenCode, run
opencode servein a separate terminal and uncomment theAGENT_OPENCODE_CMDlines in.agents/forge/agents.shto use--attach http://localhost:4096. This avoids cold boot on every run.
Dry-run smoke tests (no agent required):
npm testFast agent health check (real agent call, minimal output):
npm run test:pingOptional integration test (requires agents installed):
FORGE_INTEGRATION=1 npm testFull real-agent loop test:
npm run test:realInspired by Ralph: https://github.com/iannuttall/ralph
