Skip to content

Latest commit

 

History

History
83 lines (53 loc) · 2.15 KB

File metadata and controls

83 lines (53 loc) · 2.15 KB

Better Compact for Claude Code

Better Compact staged context pruning.

CLI npm version /better-compact:compact

Edited and maintained by Claude. Provided as-is.

Claude Code slash command for the Better Compact CLI.

Install

Install the CLI:

npm install -g @better-compact/cli

Add this repository as a Claude Code marketplace:

claude plugin marketplace add AshishKumar4/better-compact
claude plugin install better-compact@better-compact

Use

Launch Claude Code through the wrapper:

better-compact claude --run

In a long session:

/better-compact:compact

Exit with Ctrl-D. The wrapper compacts the closed session and reopens it.

Without the wrapper, the command prints the one-shot command to run after exit:

better-compact claude <session-id> --resume

Other CLI modes

better-compact claude <session-id> --keep-tokens 40000
better-compact claude <session-id> --from-backup
better-compact claude <session-id> --aggressive

See the CLI README for all options.

Legacy cleanup

Remove an old local-proxy configuration with:

better-compact install claude-code

The command is a no-op on a fresh installation.

Architecture

The plugin does not edit the live session. /better-compact:compact writes a queue marker for the current session and asks the user to exit.

better-compact claude --run checks the queue after Claude Code exits, compacts the transcript through the CLI, then reopens the same session.

Claude Code rebuilds its context state from the transcript on resume. This is why compaction runs after exit instead of through a request hook.

License

AGPL-3.0-or-later