Skip to content

feat: checkpoint, plan mode, compact, and utility commands#19

Open
mxh1999 wants to merge 8 commits intoSafeRL-Lab:mainfrom
mxh1999:main
Open

feat: checkpoint, plan mode, compact, and utility commands#19
mxh1999 wants to merge 8 commits intoSafeRL-Lab:mainfrom
mxh1999:main

Conversation

@mxh1999
Copy link
Copy Markdown
Contributor

@mxh1999 mxh1999 commented Apr 6, 2026

Summary

Adds 10 new slash commands, 2 agent tools, and a checkpoint system, bringing feature coverage from ~35% to ~50% of Claude Code.

Checkpoint system (checkpoint/ package)

  • Auto-snapshots conversation state and file changes after each turn
  • /checkpoint to list, /checkpoint <id> to rewind (files + conversation), /checkpoint clear
  • /rewind alias; 100-snapshot sliding window; initial snapshot at session start
  • Throttling: skip when no files changed and no new messages
  • File backups use copy-on-write; snapshots capture post-edit state

Plan mode (slash commands + agent tools)

  • /plan <desc> enters read-only analysis mode (user-driven)
  • EnterPlanMode / ExitPlanMode tools let the agent autonomously enter/exit plan mode for complex tasks
  • Claude can only write to a dedicated plan file (.nano_claude/plans/{session_id}.md)
  • All other writes silently blocked with helpful message
  • System prompt guides agent to use plan mode for multi-file tasks
  • Plan tools auto-approved in all permission modes

Compact command

  • /compact [focus] manually triggers conversation compaction
  • Focus instructions guide the LLM summarizer on what to preserve
  • Auto-compact and manual compact both restore plan file context after compaction

Utility commands

  • /init — create CLAUDE.md template in cwd
  • /export [filename] — export conversation as markdown (default) or JSON
  • /copy — copy last assistant response to clipboard (Windows/macOS/Linux)
  • /status — show version, model, provider, permissions, session, token usage, context %
  • /doctor — diagnose installation health: Python, git, API key + live connectivity test, optional deps, CLAUDE.md, checkpoint disk usage, permission mode

Docs

  • README: feature table, slash command reference, permission modes, directory tree
  • Contributor guide: checkpoint package, test list
  • System prompt: planning section with EnterPlanMode/ExitPlanMode guidance

New files

  • checkpoint/ package: types.py, store.py, hooks.py, __init__.py
  • tests/test_checkpoint.py — 24 unit tests
  • tests/e2e_checkpoint.py — 10-step lifecycle test
  • tests/e2e_plan_mode.py — 10-step permission test (slash commands)
  • tests/e2e_plan_tools.py — 8-step tool lifecycle test (EnterPlanMode/ExitPlanMode)
  • tests/e2e_compact.py — 9-step compaction test
  • tests/e2e_commands.py — 9-step init/export/copy/status test

Modified files

  • agent.pyplan permission mode, silent denial, auto-approve plan tools
  • context.pybuild_system_prompt(config) with plan mode injection + planning section
  • compaction.py — focus instructions, plan context restore, manual_compact()
  • nano_claude.py — 10 new commands, checkpoint init, auto-snapshot, doctor diagnostics
  • tools.py — checkpoint hooks, EnterPlanMode/ExitPlanMode tool registration
  • README.md, docs/contributor_guide.md

Test plan

  • pytest tests/test_checkpoint.py — 24 passed
  • pytest tests/test_compaction.py — 21 passed (no regressions)
  • python tests/e2e_checkpoint.py — 10/10 passed
  • python tests/e2e_plan_mode.py — 10/10 passed (slash commands)
  • python tests/e2e_plan_tools.py — 8/8 passed (agent tools)
  • python tests/e2e_compact.py — 9/9 passed
  • python tests/e2e_commands.py — 9/9 passed
  • /doctor live tested with valid key, invalid key, and no key

🤖 Generated with Claude Code

mxh1999 and others added 7 commits April 6, 2026 22:00
Auto-snapshots conversation state and file changes after each turn.
Users can list, restore, and clear checkpoints via /checkpoint and /rewind
slash commands. File backups use copy-on-write with incremental snapshots
(MAX_SNAPSHOTS=100 sliding window). Also adds reference/ to .gitignore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… throttling

- make_snapshot now backs up files as they are AFTER the turn completes,
  fixing a bug where rewind would delete newly created files instead of
  restoring them
- Add initial snapshot at session start for rewinding to blank state
- Throttle: skip snapshot when no files changed and no new messages
- Add e2e test covering the full 10-step lifecycle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a two-phase planning workflow:
- /plan <desc> enters plan mode (read-only except plan file)
- /plan done exits and restores original permissions
- Plan files persist at .nano_claude/plans/{session_id}.md
- System prompt injects plan mode guidance when active
- Writes to non-plan files are silently blocked with helpful message

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add checkpoint and plan mode to feature table, slash command reference,
permission modes table, and directory tree. Update contributor guide
with checkpoint package docs and test file list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…estore

- /compact [focus] manually triggers conversation compaction
- Focus instructions guide the LLM summarizer on what to preserve
- Auto-compact and manual compact both restore plan file context
  after compaction when in plan mode
- 9-step e2e test with mocked LLM calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- /init creates a CLAUDE.md template in cwd (refuses if exists)
- /export exports conversation as markdown or JSON
- /copy copies last assistant response to clipboard (cross-platform)
- /status shows version, model, permissions, session, token usage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Checks Python version, git, API keys with live connectivity test
(validates key against actual API), optional dependencies (rich,
Pillow, sounddevice, faster-whisper), CLAUDE.md presence, checkpoint
disk usage, and permission mode. Cross-platform safe output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mxh1999 mxh1999 changed the title feat: checkpoint system + plan mode feat: checkpoint, plan mode, compact, and utility commands Apr 6, 2026
Agent can now autonomously enter/exit plan mode:
- EnterPlanMode: switches to read-only mode, creates plan file
- ExitPlanMode: presents plan for user approval, restores permissions
- Both tools auto-approved in all permission modes (including manual)
- System prompt guides agent to use plan mode for complex tasks
- 8-step e2e test covering full tool lifecycle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chauncygu added a commit that referenced this pull request Apr 6, 2026
…lity commands

- Add v3.05.6 news entry with full feature descriptions (PR #19 by mxh1999)
- Update TOC: add Checkpoint System and Plan Mode sections
- Update Features table: add checkpoint/plan mode rows, plan permission mode, 36 slash commands, 27 tools
- Update permission system table: add plan mode row
- Add all 19 new slash commands to the REPL command reference table
- Add Checkpoint System section with commands, example, and storage details
- Add Plan Mode section: slash command workflow, agent tool workflow, commands table
- Update Context Compression section: document /compact with focus instructions
- Update Project Structure: add checkpoint/ package and new test files (263+ tests)
- Update "Where ClawSpring wins" comparison: mention checkpoint and plan mode
- Update Claude Code comparison table: slash commands 23→36, built-in tools 25→27

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chauncygu
Copy link
Copy Markdown
Contributor

chauncygu commented Apr 6, 2026

Hi, thanks again for the great PR, we’ve merged it.

There were a few merge conflicts on our side, so we handled the final merge manually. Really appreciate your contribution and the work you put into this!

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.

2 participants