Skip to main content

Terminal UI for targeted Claude Code context compaction — tag turns, generate /compact instructions, send via tmux.

Project description

clamp-cc

Python 3.11+ PyPI License: MIT

clamp-cc is a terminal UI for taking control of Claude Code's context compaction. Instead of letting /compact summarize everything blindly, you open the current session, tag the turns that matter like architectural decisions, open bugs, API contracts, things to drop and hit g to generate a targeted /compact instruction that tells Claude exactly what to keep, what to focus on, and what to throw away. Tags persist between sessions so you don't have to re-tag every time you open a project.


clamp-cc TUI


Install

macOS

pipx install clamp-cc

pipx is the recommended way to install CLI tools on macOS — it creates and manages the virtualenv for you automatically. If you don't have it: brew install pipx.

Alternatively, if you prefer managing your own environment:

python3.11 -m venv .venv
source .venv/bin/activate
pip install clamp-cc

Windows

Install pipx if you don't have it, then install clamp-cc:

pip install pipx
pipx install clamp-cc

Or manually with a virtualenv:

py -3.11 -m venv .venv
.venv\Scripts\activate
pip install clamp-cc

Note: tmux integration is not available on Windows. clamp-cc will always use the clipboard path when running on Windows. If you're using WSL, run clamp-cc inside the WSL terminal where tmux is available.

Windows Terminal is recommended over the legacy cmd.exe / PowerShell console as the TUI renders correctly there.

Usage

Session detection

Auto-detect from current directory — if you're inside a project that has a Claude Code session, clamp-cc picks it up automatically. If the project has more than one session, a session picker appears so you can choose which one to open:

cd ~/Github/my-project
clamp

Session picker

Use --all-sessions to always show the picker, even when there's only one session:

clamp --all-sessions

Project picker — if you're not in a recognized project directory, clamp-cc shows an interactive list of all your Claude Code projects sorted by most recently modified. Use arrow keys to navigate, Enter to open:

Project picker

Explicit session file — point directly at a .jsonl session file:

# macOS / Linux
clamp --session ~/.claude/projects/-Users-you-Github-myproject/abc123.jsonl

# Windows (PowerShell)
clamp --session $env:USERPROFILE\.claude\projects\-Users-you-Github-myproject\abc123.jsonl

Workflow

  1. Run clamp from your project directory
  2. Browse turns with arrow keys — the right panel shows the full content of the selected turn
  3. Tag turns using the keybindings below
  4. Hit g to generate the /compact instruction — it's copied to clipboard automatically
  5. Paste it into Claude Code, or use tmux integration to send it directly (see below)

Keybindings

Key Action
/ Navigate turns
p Tag as PIN — always survive compaction (green)
d Tag as DROP — explicitly discard (red)
a Tag as ARCH — architecture decision (yellow)
b Tag as BUG — open bug (yellow)
t Tag as TASK — task state (yellow)
c Tag as API — API contract (yellow)
Space Clear tag
g Generate /compact instruction (auto-copies to clipboard)
? Open tag reference / help screen
q Quit (asks for confirmation if any turns are tagged)

The token counter at the bottom updates live as you tag — shows total session tokens, pinned tokens, and tokens being dropped.

Tagging guide

Tag When to use it Example
PIN Decisions that can't be re-derived from the code, things Claude must never lose "We switched to Postgres because SQLite couldn't handle concurrent writes"
ARCH Design choices where the reasoning matters as much as the decision "Auth is stateless JWT, session state lives in Redis, here's why"
BUG Open issues you're mid-fix, enough context to pick back up without re-reading everything "Parser crashes on empty tool_use blocks, traced to line 47, not fixed yet"
TASK Current task state so the next session starts where this one left off "Finished the modal, next step is wiring the generator to the store"
API Contracts, schemas, and interfaces that other parts of the code depend on "GET /sessions returns {id, title, mtime}[], max 100 results, no pagination yet"
DROP Noise, dead ends, and superseded turns that will only confuse the summary Initial brainstorming that went nowhere, a refactor that got reverted

tmux integration

If you're running inside a tmux session, pressing g opens a pane picker instead of going straight to the clipboard modal. Select the pane running Claude Code, hit Enter, and clamp-cc fires the /compact instruction directly into that pane — no switching windows, no pasting.

Recommended setup — run Claude Code first, then split and open clamp-cc alongside it:

# in your existing tmux pane running Claude Code:
tmux split-window -h "cd ~/Github/my-project && clamp"

To skip tmux detection and always use the clipboard:

clamp --no-tmux

How the generated instruction looks

/compact Always preserve: ["use postgres, not sqlite — decided after..."],
["auth middleware rewrite is blocked on legal sign-off"].
Focus summary on: ["GET /sessions returns paginated list, max 100..."],
["open bug: parser crashes on empty tool_use blocks"].
Discard: ["initial brainstorm, superseded"], ["tangent about..."].
Summarize everything else aggressively.

Tag persistence

Tags are saved to ~/.claude/clamp_cc_tags.db as you work. When you reopen a session, your tags are restored automatically and the session title shows how many were recovered. Events older than 90 days are trimmed on each open.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clamp_cc-0.1.2.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clamp_cc-0.1.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file clamp_cc-0.1.2.tar.gz.

File metadata

  • Download URL: clamp_cc-0.1.2.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for clamp_cc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 07d4c03fb2a04b8b6aacc7a40651eb6f1925fa52ae0058455278f2fff8b3ac1b
MD5 306ab46b1930d853692ee2a69990ae3d
BLAKE2b-256 14430e7235eae226c265b05435fd03505209565a9773038a298fecd171475789

See more details on using hashes here.

File details

Details for the file clamp_cc-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: clamp_cc-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for clamp_cc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50b4ad201c6427a568fcb4c8a1d20d8ea950985acc563901a01a5e2bc0d3d0c8
MD5 011551fe12a485482bf9a9695bd4998f
BLAKE2b-256 402a77cd334bfe6f7b3cba3c283da431343153679404bfc176ac3dbbdde066c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page