Claude Planner
Generate deterministic plans with Claude and hand back a strict JSON envelope for downstream execution.
Workflow
Capture inputs:
user_request: the exact task to plan.executor_constraints: tools, environment limits, and safety constraints for the executor.schema: load fromreferences/plan-schema.json.
Choose execution path based on context:
Path A — running inside Claude Code (you ARE Claude Code): Do NOT invoke
plan.shor any subprocess.CLAUDECODEis set, which blocks nested CLI invocations. Instead, act as the planner directly:- Load the schema from
references/plan-schema.json. - Apply the Prompt Contract below to generate the plan JSON in your response.
- Validate the output against the Validation Requirements below.
- Wrap it in the handoff envelope and return it. Do not wrap in markdown.
Path B — running as an external agent (bash, CI, orchestrator, etc.):
scripts/plan.sh \ --request "Implement feature X safely" \ --constraints "Use only local files, run tests before edits"The script calls
claude --printas a subprocess and emits the handoff JSON.- Load the schema from
Return the JSON output directly. Do not wrap it in markdown:
{"type":"plan","planner":"claude","plan":{...}}
Prompt Contract
Use these hard constraints when constructing the planner prompt:
- Output valid JSON only.
- Output no markdown, prose, or commentary.
- Use the provided schema as authoritative.
- Include unknown dependencies in
open_questions. - Still produce a best-effort plan if some details are unknown.
The script already enforces this and validates the returned structure.
Validation Requirements
Reject the plan when any check fails:
- Top-level keys do not match the schema exactly.
milestonesis missing or empty.- Any step misses
id. - Step IDs are duplicated.
- Required fields have invalid types.
CLI Notes (Path B only)
- Default Claude command:
claude --print. - Override command with
--cmd "claude-code --print"or environment variableCLAUDE_PLANNER_CMD. - Use
--prettyfor human-readable output. - Use
--raw-output-file <path>to debug malformed model output.
Files
scripts/claude_planner.py: build prompt, call Claude, parse JSON, validate schema, emit handoff object.scripts/plan.sh: portable shell wrapper.references/plan-schema.json: strict plan contract for prompt + validation.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.