Add a megaplan step CLI command for managing plan steps without editing JSON directly. Subcommands: megaplan step add --plan NAME --after S3 'description' (inserts a new step with auto-generated ID), megaplan step remove --plan NAME S4 (removes a step and renumbers), megaplan step move --plan NAME S4 --after S2 (reorders steps). These operate on the plan markdown (plan_v*.md) by parsing ## Step N sections with fence-aware boundary detection. After editing, the command must preserve plan_v*.meta.json fields (questions, success_criteria, assumptions) and update the plan_versions record. The command resets the plan to STATE_PLANNED so it re-enters the critique loop after edits.
User notes and answers:
This was deferred from the plan template work. Key design issues identified: (1) versioning/state - edits should bump plan version and reset to STATE_PLANNED so it re-enters critique, (2) meta preservation - edited plans must carry forward questions/success_criteria/assumptions, (3) fence-aware section parsing - need a boundary finder that tracks fence state while returning original line numbers. The structural validator (validate_plan_structure in evaluation.py) and _strip_fenced_blocks already exist. Build on those.
Make sure to add the megaplan step command to instructions.md (the orchestrator-facing docs) and to the CLI help text. Also update the skill file at ~/.claude/skills/megaplan/instructions.md if it exists. The command should be documented alongside the existing override commands since it's a plan-editing tool.
code
Plan:
# Implementation Plan: `megaplan step` CLI for plan step management
Overview
Add a megaplan step command with add, remove, and move subcommands that operate directly on plan markdown files (plan_v*.md). The command parses ## Step N: sections with fence-aware boundary detection, performs the requested edit, preserves plan_v*.meta.json fields, bumps the plan version via plan_versions, and resets state to STATE_PLANNED so the plan re-enters the critique loop.
Current repo shape: The CLI (cli.py) uses argparse with subparsers. Commands dispatch through COMMAND_HANDLERS (line 310). Plan markdown is parsed for validation in () using (line 83). Plan versioning uses and records in . The handler (line 1073) already implements the state-reset-to-PLANNED pattern we need. Meta JSON carries , , , and .
Assistant
{"flags":[{"id":"version-bump-semantic","concern":"The plan does not pin the edited-plan versioning rule tightly enough. In this repo, next_plan_artifact_name is used with the current iteration to create same-iteration subversions like plan_v1a.md; unless megaplan step explicitly increments state[\"iteration\"] for every edit, edits from can violate the requirement to bump the plan version.","category":"correctness","severity_hint":"likely-significant","evidence":" keeps the same iteration on rerun and then calls (), and asserts with iteration still ()."},{"id":"step-add-validator-contract","concern":" is underspecified against the existing validator. The proposed CLI only takes a free-form description, but every step currently has to include at least one numbered substep and one backticked file reference; without defining the exact inserted scaffold or adding file input, can generate a plan that fails structural validation immediately.","category":"completeness","severity_hint":"likely-significant","evidence":" requires each section to contain numbered substeps and a backticked reference (). The planned CLI shape is ."},{"id":"skill-doc-path-mismatch","concern":"The documentation/update step is not aligned with the repo's actual installed skill path. The repo-managed global setup writes , not , so the plan should distinguish the bundled source doc from any best-effort manual sync of an external file.","category":"completeness","severity_hint":"likely-minor","evidence":" installs and (). The user note mentions , which is not the repo-managed path."}],"verified_flag_ids":[],"disputed_flag_ids":[]}
User
Assistant
{"flags":[{"id":"version-bump-semantic","concern":"The plan now hardcodes same-iteration subversioning for megaplan step, but that is not aligned with the stated requirement that step edits should bump the plan version. Reusing handle_plan's rerun behavior is a repo pattern for re-running the planner in STATE_PLANNED, not clear justification for a new direct-edit command.","category":"correctness","severity_hint":"likely-significant","evidence":"The updated plan explicitly says state[\"iteration\"] is not incremented and success criterion 4 now requires unchanged iteration. In the repo, the cited behavior comes from reruns () and (), which cover worker-generated replanning rather than direct step editing. The original idea/user notes say edits should 'bump plan version'."},{"id":"structure-pass-vs-warning","concern":"The plan is internally inconsistent about structural validation. It says edited plans must pass structural validation before commit, but the proposed commit helper only raises on the missing-step error and would still write a new plan version when reports other structure failures.","category":"correctness","severity_hint":"likely-significant","evidence":" can report missing , missing /, missing numbered substeps, and missing backticked file references (). Step 2 bullet 5 of the plan says should raise only for the 'critical step-section issue' and otherwise persist fresh , which contradicts the plan's own key constraint that structural validation must pass before committing."}],"verified_flag_ids":["step-add-validator-contract","skill-doc-path-mismatch"],"disputed_flag_ids":[]}
evaluation.py:95
validate_plan_structure
_strip_fenced_blocks
next_plan_artifact_name
plan_versions
handlers.py:290
_override_replan
questions
success_criteria
assumptions
structure_warnings
Key constraints:
Section parsing must be fence-aware (code blocks can contain ## headers)
After edit, structural validation must pass before committing the new version
Meta fields carry forward from the previous version
State resets to STATE_PLANNED with last_gate cleared (same as replan)
Scope: Medium — this is the core primitive everything else depends on.
Implementparse_plan_sections(plan_text: str) -> list[PlanSection] at megaplan/evaluation.py:93 (after _strip_fenced_blocks). PlanSection is a simple dataclass: id (e.g. "S1"), heading (full heading text), start_line (0-based, inclusive), end_line (exclusive), body (raw text of section including heading).
Reuse the fence-tracking pattern from _strip_fenced_blocks (line 83–92) but instead of stripping, track inside_fence state while scanning for ^##\s+Step\s+\d+:\s+ boundaries. Only match headings when inside_fence is False.
Also capture non-step sections (Overview, Execution Order, etc.) as PlanSection(id=None, ...) so we can reconstruct the full document after edits.
Addreassemble_plan(sections: list[PlanSection]) -> str that joins sections back into a complete markdown document, preserving original whitespace.
Addrenumber_steps(sections: list[PlanSection]) -> list[PlanSection] that updates both id fields and heading text to reflect sequential Step 1, Step 2, ... numbering.
python
@dataclass
class PlanSection:
id: str | None # "S1", "S2", ... or None for non-step sections
heading: str # "## Step 1: Audit the code"
start_line: int
end_line: int
body: str # Full text including heading
Addhandle_step(root, args) -> StepResponse at end of megaplan/handlers.py. This dispatches to _step_add, _step_remove, _step_move based on args.step_action.
_step_add(plan_dir, state, args): Parse latest plan, create a new section with auto-generated ID and the user's description text, insert it after the --after step (or append after last step if omitted). Renumber, reassemble, validate structure, then commit.
_step_remove(plan_dir, state, args): Parse latest plan, remove the named step section. Renumber, reassemble, validate structure, then commit. Reject if it would leave zero steps.
_step_move(plan_dir, state, args): Parse latest plan, extract the named step, insert it after the --after target. Renumber, reassemble, validate structure, then commit.
Common "commit" logic shared by all three: bump version via next_plan_artifact_name, write new plan_v{N}.md, copy forward meta fields from previous version's .meta.json (questions, success_criteria, assumptions) into new .meta.json, append to plan_versions, reset state to STATE_PLANNED, clear last_gate, record the edit in history, save state. Use validate_plan_structure on the result; raise CliError if the edit breaks structure.
Step 3: Wire CLI parser and dispatch (megaplan/cli.py)
Scope: Small
Add a step subparser at megaplan/cli.py:301 (before the override_parser block):
python
step_parser = subparsers.add_parser("step", help="Add, remove, or move plan steps")
step_sub = step_parser.add_subparsers(dest="step_action", required=True)
add_p = step_sub.add_parser("add")
add_p.add_argument("--plan")
add_p.add_argument("--after", help="Step ID to insert after, e.g. S3")
add_p.add_argument("description")
remove_p = step_sub.add_parser("remove")
remove_p.add_argument("--plan")
remove_p.add_argument("step_id", help="Step ID to remove, e.g. S4")
move_p = step_sub.add_parser("move")
move_p.add_argument("--plan")
move_p.add_argument("step_id", help="Step ID to move, e.g. S4")
move_p.add_argument("--after", required=True, help="Step ID to place after, e.g. S2")
Add"step": handle_step to COMMAND_HANDLERS dict (line 310).
Importhandle_step from megaplan.handlers alongside existing imports (line 30).
Step 4: Update exports and state machine (megaplan/__init__.py, megaplan/_core.py)
Scope: Small
Addhandle_step to megaplan/__init__.py exports (line 24–37, 44–67).
Updateinfer_next_steps in megaplan/_core.py:403 to include "step" as an available action when state is STATE_PLANNED, STATE_CRITIQUED, STATE_GATED, or STATE_FINALIZED — matching the same states _override_replan allows, plus STATE_PLANNED itself (you should be able to edit a plan that's already planned).
Step 5: Test section parser and step commands (tests/test_evaluation.py, tests/test_megaplan.py)
Scope: Medium
Unit tests in tests/test_evaluation.py:
test_parse_plan_sections_basic — parse a standard plan, verify section count, IDs, boundaries.
test_parse_plan_sections_fenced — verify code blocks containing ## Step headers are not treated as section boundaries.
test_renumber_steps — verify renumbering after removal/insertion.
test_step_add — add a step to a planned plan, verify new plan file, meta carryforward, state reset.
test_step_remove — remove a middle step, verify renumbering and version bump.
test_step_move — move a step, verify order and renumbering.
test_step_remove_last_step_rejected — removing the only step raises CliError.
test_step_invalid_state — step commands fail on terminal states.
test_step_preserves_meta — verify questions/success_criteria/assumptions carry from old meta to new meta.
Execution Order
Step 1 first — section parser is the foundation, and unit tests validate it independently.
Step 3 next — wire CLI so we can manually test the shape of parsed args.
Step 2 after — implement handlers that use the parser and produce real plan files.
Step 4 — export wiring and state machine updates.
Step 5 last — full test suite once everything is connected.
Validation Order
Run tests/test_evaluation.py after Step 1 to validate the parser in isolation.
Run tests/test_megaplan.py after Step 4 to validate end-to-end flow.
Final pass: python -m pytest tests/ for full suite.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-03-23T07:04:18Z",
"hash": "sha256:dbd83db89867b000fb077a2e5f4513f38a21813d7ce39b0b5664b35952562f81",
"questions": [
"Should megaplan step be allowed when the plan is in states beyond STATE_PLANNED (e.g., STATE_GATED, STATE_FINALIZED)? The user notes say 'reset to STATE_PLANNED', implying yes. The plan assumes it mirrors _override_replan's allowed states (gated, finalized, critiqued) plus planned itself. Confirm?",
"Should step IDs in the CLI be 'S1'/'S2' style or just plain numbers '1'/'2'? The idea says 'S3', 'S4' \u2014 the plan uses that convention. Is that the preferred format?",
"For step add --after, if --after is omitted, should the new step be appended after the last existing step (before Execution/Validation Order sections)? The plan assumes yes."
],
"success_criteria": [
"A megaplan step add --plan NAME --after S3 'description' command inserts a new step section into the plan markdown, renumbers all steps, and writes a new versioned plan file",
"A megaplan step remove --plan NAME S4 command removes the step, renumbers remaining steps, and rejects removal of the last step",
"A megaplan step move --plan NAME S4 --after S2 command relocates the step and renumbers",
"All three subcommands bump plan version, carry forward meta.json fields (questions, success_criteria, assumptions), reset state to STATE_PLANNED, and clear last_gate",
"Section parser correctly handles code blocks containing ## Step headings (fence-aware)",
"parse_plan_sections round-trips: reassemble(parse(text)) == text for all well-formed plans",
"Structural validation runs on the edited plan before committing \u2014 invalid edits raise CliError",
"Existing test suite continues to pass"
],
"assumptions": [
"Step IDs use the 'S1', 'S2' format as shown in the idea, mapped to '## Step 1:', '## Step 2:' headings",
"Edits from any of the _override_replan-allowed states (planned, critiqued, gated, finalized) are permitted, resetting to STATE_PLANNED",
"The --after flag for step add is optional; omitting it appends the new step after the last existing step section",
"The new plan version uses the next iteration number (same as revise), not a sub-version like 'v1a'",
"Non-step sections (Overview, Execution Order, etc.) are preserved in place during add/remove/move operations",
"The step description provided to add is used as the heading text after 'Step N: ', with a minimal body placeholder",
"PlanSection dataclass lives in evaluation.py alongside the existing validation code since it's closely related to _strip_fenced_blocks and validate_plan_structure"
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered `## Step N:` sections with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`. Missing structure should be flagged as category `completeness` with severity_hint `likely-significant`.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.
Add a megaplan step CLI command for managing plan steps without editing JSON directly. Subcommands: megaplan step add --plan NAME --after S3 'description' (inserts a new step with auto-generated ID), megaplan step remove --plan NAME S4 (removes a step and renumbers), megaplan step move --plan NAME S4 --after S2 (reorders steps). These operate on the plan markdown (plan_v*.md) by parsing ## Step N sections with fence-aware boundary detection. After editing, the command must preserve plan_v*.meta.json fields (questions, success_criteria, assumptions) and update the plan_versions record. The command resets the plan to STATE_PLANNED so it re-enters the critique loop after edits.
User notes and answers:
This was deferred from the plan template work. Key design issues identified: (1) versioning/state - edits should bump plan version and reset to STATE_PLANNED so it re-enters critique, (2) meta preservation - edited plans must carry forward questions/success_criteria/assumptions, (3) fence-aware section parsing - need a boundary finder that tracks fence state while returning original line numbers. The structural validator (validate_plan_structure in evaluation.py) and _strip_fenced_blocks already exist. Build on those.
Make sure to add the megaplan step command to instructions.md (the orchestrator-facing docs) and to the CLI help text. Also update the skill file at ~/.claude/skills/megaplan/instructions.md if it exists. The command should be documented alongside the existing override commands since it's a plan-editing tool.
code
Plan:
# Implementation Plan: `megaplan step` CLI for plan step management
Overview
Add a megaplan step command with add, remove, and move subcommands that operate directly on plan markdown files (plan_v*.md). The command parses ## Step N: sections with fence-aware boundary detection, performs the requested edit, preserves plan_v*.meta.json fields, bumps the plan version via plan_versions, and resets state to STATE_PLANNED so the plan re-enters the critique loop.
Current repo shape: The CLI (cli.py) uses argparse with subparsers. Commands dispatch through COMMAND_HANDLERS (megaplan/cli.py:310). Plan markdown is parsed for validation in validate_plan_structure (megaplan/evaluation.py:95) using _strip_fenced_blocks (megaplan/evaluation.py:83). Plan versioning uses next_plan_artifact_name (megaplan/handlers.py:290) and plan_versions records. The _override_replan handler (megaplan/handlers.py:1073) implements the state-reset-to-PLANNED pattern. Meta JSON carries questions, success_criteria, assumptions, and structure_warnings.
Key constraints:
Section parsing must be fence-aware (code blocks can contain ## headers).
After edit, structural validation must pass before committing the new version.
Meta fields carry forward from the previous version.
State resets to STATE_PLANNED with last_gate cleared (same as replan).
Versioning rule:megaplan step edits use same-iteration subversioning via next_plan_artifact_name(plan_dir, state["iteration"]), producing files like plan_v1a.md if plan_v1.md already exists. The iteration counter is NOT incremented — iteration bumps belong to worker-generated content (plan/revise). This matches the existing handle_plan rerun pattern (megaplan/handlers.py:434-435, 442-445) and is consistent with test_plan_rerun_keeps_iteration_and_uses_same_iteration_subversion (tests/test_megaplan.py:128-140).
Step add scaffold:step add generates a minimal validator-compliant section body containing one numbered substep placeholder and one backticked file reference, so the result passes validate_plan_structure without additional user input:
markdown
## Step N: User's description
**Scope:** Small
1. **TODO** Fill in implementation details (`path/to/file`).
Scope: Medium — this is the core primitive everything else depends on.
Implementparse_plan_sections(plan_text: str) -> list[PlanSection] after _strip_fenced_blocks (megaplan/evaluation.py:93). PlanSection is a simple dataclass with fields: id ("S1" or None for non-step sections), heading (full heading text), start_line (0-based inclusive), end_line (exclusive), body (raw text including heading).
Reuse the fence-tracking pattern from _strip_fenced_blocks (megaplan/evaluation.py:83-92) but instead of stripping, track inside_fence state while scanning for ^##\s+Step\s+\d+:\s+ and ^##\s+ boundaries. Only match headings when inside_fence is False. Non-step ## headings (Overview, Execution Order, etc.) become sections with id=None. Content before the first ## heading (the H1 title + any preamble) becomes a leading section with id=None, heading="".
Addreassemble_plan(sections: list[PlanSection]) -> str that joins section.body values back into a complete markdown document.
Addrenumber_steps(sections: list[PlanSection]) -> list[PlanSection] that updates id fields and heading text (## Step 1: ... → ## Step 2: ...) for step sections only, preserving non-step sections unchanged. Uses re.sub(r"^##\s+Step\s+\d+:", f"## Step {n}:", heading) on each step section's heading and first line of body.
python
@dataclass
class PlanSection:
id: str | None # "S1", "S2", ... or None for non-step sections
heading: str # "## Step 1: Audit the code" or "" for preamble
start_line: int
end_line: int
body: str # Full text including heading line
Addhandle_step(root, args) -> StepResponse at end of megaplan/handlers.py. Dispatches to _step_add, _step_remove, _step_move based on args.step_action.
_step_add(plan_dir, state, args): Parse latest plan via parse_plan_sections. Build a scaffold section:
python
body = f"## Step 0: {description}\n**Scope:** Small\n1. **TODO** Fill in implementation details (`path/to/file`).\n\n"
section = PlanSection(id="S0", heading=f"## Step 0: {description}", start_line=0, end_line=0, body=body)
Insert after the --after step (or after the last step section if --after omitted). Renumber, reassemble, validate, commit.
_step_remove(plan_dir, state, args): Parse latest plan, find and remove the named step section. Reject if only one step remains. Renumber, reassemble, validate, commit.
_step_move(plan_dir, state, args): Parse latest plan, extract the named step, insert it after the --after target. Renumber, reassemble, validate, commit.
Common "commit" helper_commit_step_edit(plan_dir, state, plan_text, action_summary):
Use next_plan_artifact_name(plan_dir, state["iteration"]) for same-iteration subversioning (produces plan_v1a.md etc.). Do NOT increment state["iteration"].
Run validate_plan_structure(plan_text) — raise CliError("structure_error", ...) if the critical step-section issue is present.
Write new plan_v{N}*.md.
Read previous plan_v*.meta.json, carry forward questions, success_criteria, assumptions into new meta. Set structure_warnings from the fresh validation. Add "step_edit": action_summary field.
Append to state["plan_versions"] with the new file and hash.
Set state["current_state"] = STATE_PLANNED, clear state["last_gate"].
Record edit in state["history"] via append_history.
Step 3: Wire CLI parser and dispatch (megaplan/cli.py)
Scope: Small
Add a step subparser at megaplan/cli.py:301 (before the override_parser block):
python
step_parser = subparsers.add_parser("step", help="Add, remove, or move plan steps")
step_sub = step_parser.add_subparsers(dest="step_action", required=True)
add_p = step_sub.add_parser("add")
add_p.add_argument("--plan")
add_p.add_argument("--after", help="Step ID to insert after, e.g. S3")
add_p.add_argument("description")
remove_p = step_sub.add_parser("remove")
remove_p.add_argument("--plan")
remove_p.add_argument("step_id", help="Step ID to remove, e.g. S4")
move_p = step_sub.add_parser("move")
move_p.add_argument("--plan")
move_p.add_argument("step_id", help="Step ID to move, e.g. S4")
move_p.add_argument("--after", required=True, help="Step ID to place after, e.g. S2")
Add"step": handle_step to COMMAND_HANDLERS dict (megaplan/cli.py:310).
Importhandle_step from megaplan.handlers alongside existing imports (megaplan/cli.py:30).
Step 4: Update exports and state machine (megaplan/__init__.py, megaplan/_core.py)
Scope: Small
Addhandle_step to megaplan/__init__.py exports (imports at line 24-37, __all__ at line 44-67).
Updateinfer_next_steps in megaplan/_core.py:403: include "step" as an available action when state is STATE_PLANNED, STATE_CRITIQUED, STATE_GATED, or STATE_FINALIZED. For STATE_PLANNED, append to the existing ["plan", "critique"] list. For the others, append to their existing lists.
Add a ## Step Editing section after the ## Replan section (megaplan/data/instructions.md:53), documenting the three subcommands with usage examples:
markdown
## Step Editing
Use `megaplan step` to add, remove, or move plan steps without editing markdown by hand.
```bash
megaplan step add --plan <name> --after S3 'Implement caching layer'
megaplan step remove --plan <name> S4
megaplan step move --plan <name> S4 --after S2
After any step edit the plan re-enters the critique loop at the current iteration.
code
Add the three megaplan step commands to the ## Commands block (megaplan/data/instructions.md:61-77).
Runmegaplan setup (or manually copy) to propagate changes to the skill file at ~/.claude/skills/megaplan/ since instructions.md is the source for that file (megaplan/cli.py:141-147).
Step 6: Test section parser and step commands (tests/test_evaluation.py, tests/test_megaplan.py)
Scope: Medium
Unit tests in tests/test_evaluation.py:
test_parse_plan_sections_basic — parse a standard plan, verify section count, IDs, boundaries.
test_parse_plan_sections_fenced — code blocks containing ## Step headers are not treated as section boundaries.
test_renumber_steps — verify renumbering after removal/insertion.
test_step_add — add a step to a planned plan, verify new plan file uses subversion naming (e.g. plan_v1a.md), iteration unchanged, meta carryforward, state reset to STATE_PLANNED.
test_step_add_scaffold_passes_validation — the generated scaffold section passes validate_plan_structure.
test_step_remove — remove a middle step, verify renumbering and subversion bump.
test_step_move — move a step, verify order and renumbering.
test_step_remove_last_step_rejected — removing the only step raises CliError.
test_step_invalid_state — step commands fail on terminal states (STATE_DONE, STATE_ABORTED).
test_step_preserves_meta — verify questions/success_criteria/assumptions carry from old meta to new meta.
Execution Order
Step 1 first — section parser is the foundation, unit-testable in isolation.
Step 3 next — wire CLI so we can verify parsed args shape.
Step 2 after — implement handlers that use the parser and produce real plan files.
Step 4 — export wiring and state machine updates.
Step 5 — documentation updates (depends on finalized CLI shape from Steps 2-3).
Step 6 last — full test suite once everything is connected.
Validation Order
Run tests/test_evaluation.py after Step 1 to validate the parser in isolation.
Run tests/test_megaplan.py after Step 4 to validate end-to-end flow.
Run megaplan setup after Step 5 to verify skill file propagation.
Final pass: python -m pytest tests/ for full suite.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-03-23T07:10:48Z",
"hash": "sha256:76d5e3eec7eee42d7d2c8bea8f2ef6a65589a4f5e927916060343a2dc7aaa75d",
"changes_summary": "Addressed two significant flags: (1) Pinned versioning rule to same-iteration subversioning via next_plan_artifact_name \u2014 iteration is NOT incremented, matching handle_plan rerun behavior and existing test assertions. (2) Defined exact scaffold for step add with a numbered substep and backticked file placeholder so generated sections pass validate_plan_structure. Also added Step 5 for documentation updates per user notes (instructions.md and skill file propagation), and added test_step_add_scaffold_passes_validation test case.",
"flags_addressed": [
"version-bump-semantic",
"step-add-validator-contract"
],
"questions": [],
"success_criteria": [
"A megaplan step add --plan NAME --after S3 'description' command inserts a new validator-compliant step section into the plan markdown, renumbers all steps, and writes a new subversioned plan file (e.g. plan_v1a.md)",
"A megaplan step remove --plan NAME S4 command removes the step, renumbers remaining steps, and rejects removal of the last step",
"A megaplan step move --plan NAME S4 --after S2 command relocates the step and renumbers",
"All three subcommands use same-iteration subversioning (next_plan_artifact_name), carry forward meta.json fields (questions, success_criteria, assumptions), reset state to STATE_PLANNED, and clear last_gate \u2014 without incrementing state['iteration']",
"Section parser correctly handles code blocks containing ## Step headings (fence-aware)",
"parse_plan_sections round-trips: reassemble(parse(text)) == text for all well-formed plans",
"Structural validation runs on the edited plan before committing \u2014 invalid edits raise CliError",
"The step add scaffold passes validate_plan_structure (contains numbered substep and backticked file reference)",
"instructions.md and skill files document the new megaplan step commands",
"Existing test suite continues to pass"
],
"assumptions": [
"Step IDs use the 'S1', 'S2' format as shown in the idea, mapped to '## Step 1:', '## Step 2:' headings",
"Edits from planned, critiqued, gated, or finalized states are permitted, resetting to STATE_PLANNED",
"The --after flag for step add is optional; omitting it appends the new step after the last existing step section",
"Step edits use same-iteration subversioning (plan_v1a.md) via next_plan_artifact_name, not iteration increment \u2014 consistent with plan rerun behavior",
"Non-step sections (Overview, Execution Order, etc.) are preserved in place during add/remove/move operations",
"The step add scaffold uses a minimal template: Scope line, one numbered TODO substep with backticked placeholder path",
"PlanSection dataclass lives in evaluation.py alongside the existing validation code"
],
"structure_warnings": [],
"delta_from_previous_percent": 65.91
}
code
Plan structure warnings from validator:
[]
Existing flags:
[
{
"id": "version-bump-semantic",
"concern": "The plan does not pin the edited-plan versioning rule tightly enough. In this repo, next_plan_artifact_name is used with the current iteration to create same-iteration subversions like plan_v1a.md; unless megaplan step explicitly increments state[\"iteration\"] for every edit, edits from STATE_PLANNED can violate the requirement to bump the plan version.",
"status": "addressed",
"severity": "significant"
},
{
"id": "step-add-validator-contract",
"concern": "step add is underspecified against the existing validator. The proposed CLI only takes a free-form description, but every step currently has to include at least one numbered substep and one backticked file reference; without defining the exact inserted scaffold or adding file input, add can generate a plan that fails structural validation immediately.",
"status": "addressed",
"severity": "significant"
},
{
"id": "skill-doc-path-mismatch",
"concern": "The documentation/update step is not aligned with the repo's actual installed skill path. The repo-managed global setup writes ~/.claude/skills/megaplan/SKILL.md, not instructions.md, so the plan should distinguish the bundled source doc from any best-effort manual sync of an external file.",
"status": "open",
"severity": "minor"
}
]
code
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered `## Step N:` sections with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`. Missing structure should be flagged as category `completeness` with severity_hint `likely-significant`.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.