claude-code - 💡(How to fix) Fix Feature: Compact tool + customizable plan exit options

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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

Root Cause

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

Code Example

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

---

{
  "planExitOptions": [
    {
      "label": "Yes, compact context first",
      "actions": ["compact"],
      "permissionMode": "default"
    }
  ]
}
RAW_BUFFERClick to expand / collapse

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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature: Compact tool + customizable plan exit options