Openforge
Staged, multi-model PRD execution for OpenClaw. Write a PRD with phased sections, model routing, and validation gates — OpenForge executes it across local an...
Like a lobster shell, security has layers — review code before you run it.
License
SKILL.md
OpenForge v2
PRD-to-implementation pipeline for OpenClaw.
OpenForge takes a structured PRD (Product Requirements Document) and executes it through staged phases: parallel where possible, with model routing, quality gates, and automatic review-to-fix loops. No Python, no custom agent registration, no install step — runs entirely through native OpenClaw tools (sessions_spawn, exec, read, write).
What OpenForge Does
- Parses a PRD markdown file into phases and tasks
- Spawns sub-agents for phases that can run in parallel
- Routes each task to the right model tier (Haiku → Sonnet/GPT → Opus)
- Gates each phase: pass/fail check after completion
- Auto-fixes: when a review phase finds issues, a fix agent is spawned and the review re-runs (up to 3 cycles)
- Escalates when retries are exhausted or a gate fails hard
What OpenForge Does NOT Do
- Does not run a CLI — it IS the agent execution loop
- Does not sandbox agent actions or enforce file-scope restrictions at OS level
- Does not protect against malicious PRDs (treat PRDs like code)
- Does not require or manage custom agent registration
- Does not guarantee secret scanning — don't put secrets in PRDs
PRD Format
A PRD is a markdown file. OpenForge reads it top-to-bottom and extracts phases.
Minimal PRD
# PRD: My Feature
## Objective
Build a CSV export endpoint for the API.
## Phases
### Phase: scaffold [parallel]
**Model:** sonnet
**Tasks:**
- Create the route handler in `src/routes/export.ts`
- Write the CSV serializer in `src/lib/csv.ts`
**Gate:** `npm run build` must pass
### Phase: test [depends: scaffold]
**Model:** sonnet
**Tasks:**
- Write unit tests for the CSV serializer
- Write integration test for the export endpoint
**Gate:** `npm test` must pass
### Phase: review [depends: test]
**Model:** opus
**Type:** review
**Tasks:**
- Review the full implementation for correctness, edge cases, and security
- Check error handling on malformed input
**Gate:** Review must find zero blocking issues
PRD Fields
| Field | Required | Values | Meaning |
|---|---|---|---|
Model: | No | haiku, sonnet, gpt, opus | Model tier for this phase |
Type: | No | impl, review, extract | Phase type; controls prompting style |
[parallel] | No | Flag in phase header | Phase can run alongside other [parallel] phases |
depends: | No | Phase name(s) | This phase waits for named phases to complete |
Gate: | No | Shell command or description | Must pass before next phase starts |
Max-Retries: | No | Integer (default: 2) | Gate failure retries before escalation |
Phase Types
impl(default) — implementation work; agent writes code, files, configsreview— evaluative; agent produces a structured findings report; triggers auto-fix loop if issues foundextract— lightweight parsing or summarization; routed to Haiku
Model Routing
| Alias | Maps To | Use For |
|---|---|---|
haiku | claude-haiku / cheapest available | Extraction, parsing, structured output |
sonnet | claude-sonnet | Implementation, research, multi-file work |
gpt | gpt-4o or equivalent | Alternative implementation path |
opus | claude-opus | Judgment, review, final quality gate |
OpenForge maps these aliases to whatever models are configured in your OpenClaw instance. If a model alias isn't available, Sonnet is used as the safe fallback.
Execution Protocol
When OpenForge is triggered, follow this exact sequence:
Step 1 — Parse the PRD
Read the PRD file. Extract:
- Title and objective
- All phases in order, with their model, type, dependencies, gate, and task list
- Identify which phases are
[parallel]and which havedepends:constraints
Build a dependency graph. Phases with no depends: and tagged [parallel] can be spawned simultaneously.
Step 2 — Pre-flight check
Before spawning anything:
- Confirm the PRD has at least one phase
- Confirm all
depends:references name real phases - Confirm the working directory exists (if specified)
- If any check fails: halt and report the problem clearly
Step 3 — Execute phases
For each wave of phases (phases whose dependencies are all satisfied):
If multiple phases are [parallel]: spawn them as sub-agents simultaneously using sessions_spawn. Pass each sub-agent:
- The full PRD context
- Its specific phase tasks
- The model to use
- The gate command (if any)
- The working directory
If a phase has depends:: wait for all named phases to complete before spawning.
Sequential phases (no [parallel] tag): run one at a time in declaration order.
Step 4 — Gate evaluation
After each phase completes:
- If a gate command is specified, run it with
exec - If it passes (exit 0): mark phase complete, proceed
- If it fails: retry the phase up to
Max-Retriestimes (default: 2), passing the failure output as context - If retries exhausted: escalate to Corbin and halt
Step 5 — Review-to-fix loop
For phases with Type: review:
- The review agent produces a structured findings report
- Parse the report for blocking/required issues
- If issues exist:
- Spawn a fix sub-agent (same model tier as the implementation phase, or Sonnet default) with the findings as context
- After fix agent completes, re-run the review phase
- Repeat up to 3 cycles
- If issues persist after 3 cycles: escalate with full findings history
- If no blocking issues: mark review phase complete
Review agent prompt structure:
You are performing a structured code review.
Context:
{phase tasks and objective}
Working directory: {cwd}
Produce a report in this exact format:
## Findings
### Blocking
- [issue description] — [file:line if known]
### Required Changes
- [issue description]
### Suggestions
- [issue description]
### Summary
PASS | FAIL
If PASS: no Blocking or Required Changes items.
If FAIL: at least one Blocking or Required Changes item exists.
Fix agent prompt structure:
You are implementing fixes identified in a code review.
Review findings:
{findings report}
Fix all Blocking and Required Changes items. Do not change anything not listed.
Working directory: {cwd}
When complete, summarize what you changed.
Step 6 — Completion
When all phases pass their gates:
- Write a completion summary to
.openforge/run-{timestamp}.mdin the working directory (if a cwd was specified) - Report success with phase outcomes and any escalations that occurred
- If any phases were skipped or escalated, report them explicitly
Sub-agent Prompting
When spawning a sub-agent for a phase, include:
You are executing Phase: {phase_name} of an OpenForge PRD run.
## Objective
{PRD objective}
## Your Tasks
{task list}
## Working Directory
{cwd or "not specified — use judgment"}
## Prior Phase Outputs
{summaries from completed phases, if any}
## Gate
After completing your tasks, the following command will be run to validate your work:
{gate command or "none"}
## Constraints
- Only modify files relevant to your tasks
- Do not expose credentials, API keys, or secrets
- Write a brief summary of what you did when complete
## Model
You are running as: {model alias}
Escalation Protocol
Escalate to the human (Corbin / operator) when:
- A gate fails after all retries are exhausted
- A review-to-fix loop hits 3 cycles without reaching PASS
- The PRD has structural errors that prevent execution
- A phase sub-agent returns an error that can't be recovered
- A phase declares
escalate: trueexplicitly
Escalation message format:
⚠️ OpenForge Escalation
PRD: {title}
Phase: {phase_name}
Reason: {specific failure reason}
What happened:
{summary of attempts}
Gate output (if applicable):
{last gate failure output, truncated to 500 chars}
Recommended next step:
{specific suggestion — fix the gate command, revise the PRD, or manual intervention}
Security Constraints
- Never include secrets, API keys, or credentials in PRDs. OpenForge passes PRD content to sub-agents verbatim.
- PRD files are trusted input. Treat them like code. Don't execute PRDs from untrusted sources.
- Sub-agents run with the same permissions as the parent agent. OpenForge does not add a sandbox layer.
- Gate commands are run with
exec. Review gate commands before running against production systems. - OpenForge writes one artifact (
.openforge/run-{timestamp}.md) to the working directory. No other writes are made by the orchestrator itself.
Example: Full Parallel PRD
# PRD: Auth Refactor
## Objective
Replace the custom session cookie system with JWT-based auth.
## Phases
### Phase: research [parallel]
**Model:** haiku
**Type:** extract
**Tasks:**
- Read `src/auth/` and summarize all current auth entry points
- List all routes that call `req.session`
### Phase: design [parallel]
**Model:** opus
**Type:** review
**Tasks:**
- Design the JWT strategy: token structure, expiry policy, refresh approach
- Identify migration risks
### Phase: implement [depends: research, design]
**Model:** sonnet
**Tasks:**
- Implement JWT middleware in `src/auth/jwt.ts`
- Replace session calls in all routes identified in research phase
- Update `src/auth/index.ts` to export new middleware
**Gate:** `npm run build && npm test`
**Max-Retries:** 3
### Phase: security-review [depends: implement]
**Model:** opus
**Type:** review
**Tasks:**
- Review JWT implementation for common vulnerabilities (alg confusion, weak secret, missing expiry check)
- Review token storage and transmission
**Gate:** Review must find zero Blocking issues
In this PRD:
researchanddesignrun in parallel (no dependencies, both tagged[parallel])implementwaits for both, then runs with Sonnetsecurity-reviewruns last with Opus, triggers auto-fix loop if issues are found
Limitations (v2)
- Parallel phase results are collected via sub-agent completion events — if a sub-agent times out, that phase's output may be missing
- Review-to-fix loops use the same working directory; if the fix agent introduces regressions, OpenForge will catch them at the gate but won't automatically revert
- Gate commands run in the working directory with no isolation — avoid destructive commands (e.g.,
rm -rf) - No persistent run state across sessions — if the parent agent session ends mid-run, the run cannot be resumed (sub-agents completing after session end will still announce results but the orchestrator won't act on them)
- Model alias resolution depends on your OpenClaw instance's configured models; if
opusisn't available, Sonnet will be used silently
Quick Reference
| What you want | How to trigger |
|---|---|
| Run a PRD | "Run this PRD: [paste or path]" |
| Dry-run (plan only) | "Plan this PRD without executing" |
| Run a single phase | "Run only the implement phase of this PRD" |
| Skip a phase | Add Skip: true to the phase header |
| Force a model | Add Model: opus to any phase |
| Cap retries | Add Max-Retries: 1 to a phase |
| Parallel phases | Add [parallel] to phase header |
Files
2 totalComments
Loading comments…
