You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: sweep CLAUDE.md, README, roadmap, guide for /compact
CLAUDE.md tree gains agent/compaction.rs, slash/compact.rs,
chat/blocks/compacted.rs and notes Entry::Compact alongside the other
JSONL variants. README slash-command list and the user-guide table both
gain /compact. The roadmap moves the manual half of context compression
from Current Focus to Working Today and renames the deferred half to
"Auto-Compaction" with the threshold-math notes.
- Turn interruption (Esc / Ctrl+C) plus mid-turn queued follow-up prompts that splice into the same turn between tool calls, with double-press Ctrl+C exit confirmation
|`/clear` (aliases `/new`, `/reset`) | Start a fresh session. The previous one stays resumable via `ox -c`. |
12
+
|`/compact [<instructions>]`| Compress the conversation into a summary; trailing text steers the focus. |
12
13
|`/config`| Open the resolved configuration and its layered file paths in a read-only modal. |
13
14
|`/delete <id-prefix>`| Delete a saved session by id prefix, with a Y/N confirm modal before the unlink. |
14
15
|`/diff`| Show `git diff HEAD` plus untracked files in chat, capped at 64 KB. |
@@ -27,14 +28,24 @@ Double the leading slash. Typing `//etc` sends the literal `/etc`.
27
28
28
29
## Mid-Turn Behavior
29
30
30
-
State-mutating commands (`/clear`, `/delete`, `/init`, and the typed-arg forms of `/effort`, `/model`, `/rename`, `/resume`, `/theme`) wait for the current turn to finish. Read-only commands and the bare modal-opening forms run anytime.
31
+
State-mutating commands (`/clear`, `/compact`, `/delete`, `/init`, and the typed-arg forms of `/effort`, `/model`, `/rename`, `/resume`, `/theme`) wait for the current turn to finish. Read-only commands and the bare modal-opening forms run anytime.
31
32
32
33
## Model and Effort
33
34
34
35
Bare `/model` and `/effort` open pickers; both apply on Enter, cancel on Esc.
35
36
36
37
`/model <id>` accepts aliases (`opus`, `sonnet`, `haiku` — append `[1m]` for the 1M-context variants), full ids, or any unique suffix or substring. Haiku has no effort tier, so `/effort` on Haiku errors with a recovery hint. See [Configuration](configuration.md) for tier defaults.
37
38
39
+
## Compaction
40
+
41
+
`/compact` streams a one-shot summarization request through the live model, then replaces the in-memory transcript with a single boundary block: a header (`Compacted N messages → 1 summary`) plus the rendered summary. The next prompt continues from the summary rather than the full prior chat.
42
+
43
+
`/compact <instructions>` appends free-text focus instructions to the rubric (e.g., `/compact focus on the build error and how we fixed it`). Useful when only a slice of the work matters going forward.
44
+
45
+
The summary lands in the JSONL as a `compact` boundary entry plus a synthetic continuation message. Resuming the session via `ox -c` shows only the post-compact tail; the pre-compact transcript stays on disk for archival but is not replayed in chat. The file-change tracker resets on compact, so any `Edit` after a `/compact` requires a fresh `Read`. Queued prompts survive the compaction.
46
+
47
+
`/compact` refuses on sessions with fewer than 4 messages, when the model returns an empty summary, or while a turn is in flight (it waits for the current reply to finish first).
48
+
38
49
## Sessions
39
50
40
51
`/rename` opens a modal pre-filled with the current title; `/rename <title>` sets it directly. The chosen title sticks and replaces the auto-generated AI title for the rest of the session.
- Autocomplete popup on typing `/`, with ranked filter, Tab completion, and arg-mode completion for commands with curated rosters (`/model`, `/effort`, `/theme`).
68
68
- Mid-session swaps (`/model`, `/effort`, `/rename`, `/resume`, `/theme`) are session-only, and no slash command writes user config files.
69
69
- Destructive ops (`/delete <id-prefix>`, or Ctrl+D / Delete inside the `/resume` picker) gate behind a Y/N confirm modal. Only finalized sessions can be deleted.
70
70
- Modal UI primitive: focus-grabbing overlays above the input for picker, slider, editor, and read-only kv-overview forms; nested modals layer cleanly. Esc / Ctrl+C cancels any modal.
71
71
72
+
### Context Compression
73
+
74
+
- Manual `/compact [instructions]` streams a one-shot summarization through the live model and replaces the in-memory transcript with a synthetic continuation. Optional trailing instructions steer the focus.
75
+
- Persisted as a dedicated `compact` JSONL boundary plus the synthetic post-compact message; resume sees only the post-compact tail.
76
+
- File tracker resets on compact — Edits after `/compact` require a fresh Read.
77
+
72
78
### Authentication & Configuration
73
79
74
80
- Anthropic API key via `ANTHROPIC_API_KEY` or config file.
@@ -83,15 +89,15 @@ The direction is simple:
83
89
- Project-level allowlists to auto-approve trusted commands.
84
90
- Plan mode: read-only review of the agent's proposed changes before any tool runs.
85
91
86
-
### Context Compression
92
+
### Auto-Compaction
87
93
88
-
-Summarize older messages when approaching the context limit so long sessions keep responding.
94
+
-Fire `/compact` automatically when the running token usage approaches the model's context window. Threshold math (effective context window minus reserved-output buffer), per-turn check at sampling boundaries, single-turn circuit breaker, and a config knob for opt-out.
Persistence stance: `/model`, `/effort`, and `/theme` mutate session state only, and restart returns to user-declared config. Cross-session persistence will land as an **explicit subcommand** writing to a user-opted-in path, never as a silent merge into a `~/.claude.json`-style mega-file.
0 commit comments