Feature: Compact tool + customizable plan exit options

Resolved 💬 1 comment Opened May 18, 2026 by FirstFirstFirstFirst Closed Jun 16, 2026

Summary

Two related feature requests that would improve context management during plan-based workflows:

1. Compact tool — let Claude trigger compaction programmatically

Currently, /compact and /clear are harness-level CLI commands that only the user can invoke. Claude has no tool to trigger context compaction. This means:

  • After exiting plan mode, Claude cannot compact context before starting execution
  • Hooks on ExitPlanMode can run shell commands but cannot invoke /compact
  • Even with CLAUDE.md instructions like "compact before executing," Claude has no mechanism to do it

Proposed: Add a Compact tool (and optionally a Clear tool) that Claude can call like any other tool. This would enable workflows like:

  • Auto-compact after plan approval but before execution begins
  • Compact mid-task when context is getting large but hasn't hit the auto-compact threshold
  • Hook-driven compaction via PostToolUse on ExitPlanMode

2. Customizable plan exit options

When exiting plan mode, the UI shows fixed options:

1. Yes, and bypass permissions
2. Yes, manually approve edits
3. No, refine with Ultraplan on Claude Code on the web
4. Tell Claude what to change

Proposed: Allow users to configure additional plan exit options in settings.json, such as:

  • "Yes, and clear context first"
  • "Yes, and compact context first"
  • "Yes, and run in a worktree"

These could map to pre-execution actions. Example config:

{
  "planExitOptions": [
    {
      "label": "Yes, compact context first",
      "actions": ["compact"],
      "permissionMode": "default"
    }
  ]
}

Motivation

For complex tasks, plan mode generates significant context. By the time the plan is approved, a large portion of the context window is consumed by planning discussion. Users currently must manually run /compact after approval — an easy step to forget, and one that breaks flow.

A Compact tool would also enable hooks to trigger compaction at strategic points (e.g., after plan exit, after large research phases), making context management more autonomous.

Alternatives considered

  • PostToolUse hook on ExitPlanMode — works for shell commands but cannot invoke /compact since hooks can't trigger internal CLI commands
  • Reminder injection via hook — can echo a reminder to run /compact, but still requires manual user action
  • Waiting for auto-compaction — only triggers at the context limit, which is too late for optimal performance

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗