Skip to content

feat(plan): persist plans with step-by-step execution#526

Open
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:feat/plan-command-mvp2
Open

feat(plan): persist plans with step-by-step execution#526
12britz wants to merge 1 commit into
mpfaffenberger:mainfrom
12britz:feat/plan-command-mvp2

Conversation

@12britz

@12britz 12britz commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

feat(plan): Persist plans with step-by-step execution

Summary

Replaces the bare-prompt /plan command with a full planning workflow: structured checklist plans saved to .claude/plan.md, terminal display, editor integration, step-by-step LLM execution with auto-checkoff, and manual tracking.

Changes Made

New file: code_puppy/command_line/plan_manager.py

Core module for plan file I/O, step parsing, execution prompt building, and editor support.

  • PlanManager class manages .claude/plan.md
  • Parses - [ ] / - [x] checklist items with 1-based indexing
  • mark_step_done(N) toggles completion in the file
  • build_run_prompt([N]) generates LLM prompts for executing one or all pending steps
  • edit_in_editor() opens the plan in $EDITOR / $VISUAL (creates template if missing)
  • create_template() returns a bare-bones plan skeleton
  • show_formatted() displays the plan with a progress header

Modified: code_puppy/command_line/core_commands.py

Replaced the simple prompt wrapper with a full subcommand handler:

Subcommand Action
/plan <goal> LLM explores codebase, outputs structured checklist, saves to .claude/plan.md
/plan show Displays current plan with (N/M steps complete)
/plan edit Opens .claude/plan.md in $EDITOR
/plan run [N] Sends one or all pending steps to LLM for execution
/plan mark <N> Toggles step N done/undone

Added alias p/p works as shorthand.

Modified: code_puppy/cli_runner.py

Added _process_plan_step_markers() — intercepts PLAN_STEP_DONE: N in LLM responses and auto-checks the corresponding step in the plan file. Runs after every turn (main loop + continuation loop).

Modified: code_puppy/help_system/help_content.py

Updated /plan help entry with new syntax and examples.

New file: tests/command_line/test_plan_manager.py

28 tests covering PlanManager: I/O, step parsing, mark-done/undone, display formatting, editor launch (with mocked subprocess), execution prompt builders, and marker stripping.

Modified: tests/command_line/test_core_commands_full_coverage.py

6 tests for the new plan command subcommands: show (with/without plan), edit, mark, goal prompt, and usage error.

Testing

pytest tests/command_line/test_plan_manager.py -v      # 28 passed
pytest tests/command_line/test_core_commands_full_coverage.py -v  # 55 passed
pytest tests/command_line/ -v                           # 1960 passed (no regressions)

Technical Details

  • Prompt engineering: The plan prompt explicitly allows Write tool for .claude/plan.md while blocking other modifications
  • Step execution: build_run_prompt() includes the full plan for context plus a ## Pending steps section with only unchecked items
  • Auto-checkoff: The PLAN_STEP_DONE: N marker is stripped from the user-visible response after processing
  • Editor fallback: Uses $VISUAL$EDITORnano in that order; open -t is not used (runs $EDITOR directly)
  • No permission mode: Execution guard is prompt-based only (the LLM is instructed not to modify files during /plan, but doesn't enforce via a permission mode)

Files Modified

File Status
code_puppy/command_line/plan_manager.py New
code_puppy/command_line/core_commands.py Modified (+100 / -18)
code_puppy/cli_runner.py Modified (+35)
code_puppy/help_system/help_content.py Modified (+10 / -6)
tests/command_line/test_plan_manager.py New (28 tests)
tests/command_line/test_core_commands_full_coverage.py Modified (+79 / -1)

Replaces the bare-prompt /plan command with a full planning workflow:
structured checklist plans saved to .claude/plan.md, terminal display,
editor integration, step-by-step LLM execution with auto-checkoff, and
manual tracking.

New file: code_puppy/command_line/plan_manager.py
- PlanManager class for plan file I/O, step parsing, execution prompts
- Parses - [ ] / - [x] checklist items with 1-based indexing
- mark_step_done(N) toggles completion in the file
- build_run_prompt([N]) generates LLM prompts for step execution
- edit_in_editor() opens plan in  /
- show_formatted() displays plan with progress header

Modified: code_puppy/command_line/core_commands.py
- /plan <goal> | show | edit | run [N] | mark <N> subcommands
- Added alias 'p'

Modified: code_puppy/cli_runner.py
- _process_plan_step_markers() intercepts PLAN_STEP_DONE: N markers
  in LLM responses and auto-checks steps in the plan file

Tests: test_plan_manager.py (28) + test_core_commands_full_coverage (56)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant