validate_plan
Validate forge plan JSON files before execution to detect structural errors, dependency cycles, and potential file conflicts, ensuring plans run correctly without spawning workers.
Instructions
Structurally validate a forge plan JSON file before any worker spawns. Checks: required-field schema (id, title, objective, files, verify, doneWhen on every module), DAG cycle detection via Kahn's algorithm, references to unknown dependsOn modules, file-overlap warnings between modules that could run in parallel (which would cause worktree merge conflicts), and verify-command existence on PATH (commands are checked via execFileSync('which', [firstWord]) to avoid shell injection via crafted verify strings). Catches plans that would fail at runtime and reports concrete errors before any worker is spawned.
Behaviour:
READ-ONLY for the plan file. Emits a
plan_validationevent to the current run's JSONL log.No authentication, no network, no rate limits.
Never throws to the caller — every problem is returned as an entry in the
errors[]orwarnings[]arrays.planPathis optional; when omitted, the most recently modified file in.forge/plans/is used.
Use when:
Immediately after the planner agent writes a plan to disk, and before the orchestrator enters Phase 1b (plan approval).
Debugging why a plan's execution order looks wrong — file-overlap warnings usually explain "two parallel workers clobbered each other" bug reports.
A human is hand-editing a plan file and wants a pre-flight check.
Do NOT use for:
Executing a plan — this tool is dry-run only.
Validating a single module's build output — use
validateinstead.Inspecting attempt counts or retry history — use
iteration_statewithaction: "get".
Returns: { valid: bool, errors[], warnings[] }. valid is true iff
errors[] is empty. Errors halt execution (cycles, missing required
fields, commands not found on PATH). Warnings are advisory (file
overlap between parallel modules).
Example: validate_plan({ planPath: ".forge/plans/add-auth.json" }) → { "valid": true, "errors": [], "warnings": [ { "type": "file_overlap", "modules": ["m2", "m3"], "files": ["src/config.mjs"], "message": "Modules m2 and m3 both modify src/config.mjs but could run in parallel. Consider adding a dependency edge." } ] }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| planPath | No | Path to a plan JSON file. If omitted, reads the most recent plan from .forge/plans/. |