whetstone-cli 3.18.0

Installer and CLI for Claude Code token optimization (Headroom + RTK + Memory)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What This Is

Whetstone is a Rust CLI that installs and configures three token optimization tools for Claude Code:

- **Headroom** — HTTP proxy between Claude Code and the Anthropic API (50-90% context compression)
- **RTK** — Hook that rewrites CLI commands to compress output before entering context (60-90% savings)
- **Memory** — Persistent project memory via ICM (embedded SQLite). ICM owns its own skills, hooks, and CLI, installed by `icm init --mode standard`.

Single binary distribution. Users run `whetstone setup` from inside a git project. Global tools (Headroom, RTK) install once; the memory provider and version-pinned manifest are configured per-project.

**Bundled assets** in this repo (v3 ships only slash commands and the DB schema — skills, rules, and hook scripts are no longer vendored):
- `assets/commands/` — slash command `.md` files (copied to project's `.claude/commands/`)
- `assets/db/schema.sql` — SQLite schema for session database

## Commands

<!-- AUTO-GENERATED: commands -->
| Command | Description |
|---------|-------------|
| `just run <args>` | Run whetstone with arguments |
| `just build` | Build debug binary |
| `just build-release` | Build optimized release binary |
| `just test` | Run all tests |
| `just test-one <name>` | Run a single test by name |
| `just lint` | Format check + clippy |
| `just fix` | Auto-format + clippy fix |
| `just check` | Check compilation without binaries |
| `just release-check` | Release quality gate (fmt + clippy + test) |
| `just release <level>` | Bump version, create release branch + PR |
| `just release-dry-run <level>` | Preview release without changes |
| `just info` | Show project and toolchain versions |
| `just loc` | Show lines of code |
| `just clean` | Remove build artifacts |
| `just deps` | Show dependency tree |
| `just audit` | Audit dependencies for vulnerabilities |
<!-- AUTO-GENERATED: end -->

## CLI Reference

<!-- AUTO-GENERATED: cli -->
```
whetstone                              # Default: headroom wrap claude (auto-selects newest available Opus; falls back to claude-opus-5-5)
whetstone setup [--full] [--headroom-extras EXTRAS]
whetstone project uninstall            # Remove whetstone files from this project
whetstone global uninstall             # Remove global binaries, RTK, Headroom
whetstone claude [args...]
whetstone code [args...]               # Alias for claude
whetstone proxy [args...]
whetstone rtk [args...]
whetstone version
whetstone dashboard                    # TUI: installed tool versions vs pinned floors
whetstone settings                     # Interactive layered settings (global/project)
whetstone doctor [--fix]               # Check dependencies + ~/.claude/settings.json, report drift
whetstone install-tools [--force]      # Install/repair headroom, rtk, claude code, memory provider
whetstone migrate [--dry-run] [-y] [--rollback ID]   # v2 → v3 migration (reversible)
whetstone stats                        # Token savings across RTK + Headroom
whetstone update [--full]
whetstone release patch|minor|major|set X.Y.Z
whetstone release-publish patch|minor|major|set X.Y.Z # Deprecated
whetstone changelog-sync [--input F] [--output F] [--limit N]  # regen site/src/changelog.js
whetstone db init|add-session|add-insight|search|get-sessions|...
whetstone memory consolidate [--dry-run]   # drain stray project-local .headroom stores into ~/.headroom
```
<!-- AUTO-GENERATED: end -->

`--headroom-extras` accepts: `all` (default = `proxy,code,mcp`), `none`, or comma-separated like `proxy,code`.

`--memory` is a global flag (e.g. `whetstone --memory`, `whetstone --memory claude`). It enables Headroom persistent cross-session memory by passing `--memory` to the proxy whetstone spawns. Memory on/off is part of the per-config fingerprint (see Architecture below), so a session that wants memory never fights one that doesn't — each gets its own proxy, and there is no restart/replace prompt to resolve the conflict. It can also be set persistently per-project or globally via `whetstone settings` (Headroom Memory).

`whetstone doctor` checks the managed dependencies (headroom, rtk, claude
code, and the project's memory provider) before it looks at hooks: a tool that
is missing or no longer runnable is offered for reinstall in interactive runs,
reported with a pointer to `whetstone install-tools` otherwise, and reinstalled
without prompting under `--fix`. A repaired tool's own `init` is re-run so its
hooks come back before the settings checks look for them.
`whetstone install-tools` drives the same repair path directly, also installing
`uv` if it went missing, restoring the `~/.local/bin/whetstone` symlink, and
resyncing `tool_versions` in the project manifest.

Doctor also runs a **startup check**: if a proxy is already answering on
`127.0.0.1:8787` that counts as proof, otherwise whetstone spawns a throwaway
`headroom proxy` on a free port (same args/env as a real launch, killed after a
6s grace window) and reports headroom's own error if it exits. This catches the
case every other check misses — headroom installed, current, and complete, but
dead on arrival because its own `~/.headroom/settings.json` asks for a flag the
current rollout channel rejects. When the error names such a flag, doctor maps
it back to the settings key and offers to remove it (prompt when interactive,
automatic under `--fix`, backing the file up first), then re-runs the check.
Note the fast path's blind spot: a proxy still running from before a settings
change reports OK even though the next start would fail.

Headroom is checked by *extras* as well as version: whetstone reads uv's
receipt (`$UV_TOOL_DIR`/`~/.local/share/uv/tools/headroom-ai/uv-receipt.toml`)
and treats an install missing any requested extra as needing repair, so a bare
`headroom-ai` can't pass as healthy while `headroom proxy`/`headroom mcp` are
absent. Both commands default to `--headroom-extras all`
(`headroom-ai[proxy,code,mcp]`); pass the same value you set up with if you
deliberately installed a smaller set. An install uv didn't record (e.g. pip)
reports unknown extras and is left alone.

`whetstone settings` also exposes **Anthropic API URL** — a custom upstream Anthropic API URL for the Headroom proxy. When set (per-project or globally), whetstone exports it as `ANTHROPIC_TARGET_API_URL` before launching Headroom, so the whetstone-spawned proxy targets that upstream (mirrors Headroom's `proxy --anthropic-api-url` flag). An externally-set `ANTHROPIC_TARGET_API_URL` env var takes precedence over the stored setting.

`whetstone settings` also exposes **Edit Mode** — the Claude Code `--permission-mode` (`acceptEdits`, `default`, `plan`, `bypassPermissions`) whetstone injects into `headroom wrap claude`. Stored per-project (`permission_mode` in `.claude/whetstone.json`) or globally, project-over-global. When unset (**Off**), whetstone injects no flag and Claude Code uses its own default; an explicit `--permission-mode` on the command line always wins.

`whetstone settings` also exposes **Headroom Savings Profile** — the Headroom compression profile (`coding`, `agent-90`, `balanced`, `general`) whetstone exports as `HEADROOM_SAVINGS_PROFILE` before launching Headroom, so the spawned proxy and the exec'd `headroom wrap claude` read the same profile (keeping them in agreement and part of the per-config proxy fingerprint). Stored per-project (`savings_profile` in `.claude/whetstone.json`) or globally, project-over-global. When unset (**Off**/None), whetstone exports nothing and Headroom falls back to its own default (`agent-90`); an externally-set `HEADROOM_SAVINGS_PROFILE` env var takes precedence over the stored setting.

`whetstone settings` also exposes **Tool Search** — a boolean that, when **On**, exports `ENABLE_TOOL_SEARCH=1` before launching so Claude Code turns on deferred-tool search. This is a Claude Code concern (exported into the environment the exec'd `headroom wrap claude` passes to Claude Code), *not* a Headroom one, so it is not part of the per-config proxy fingerprint. Stored per-project (`enable_tool_search` in `.claude/whetstone.json`) or globally, project-over-global (a project value of `false` overrides a global `true`). When **Off**, whetstone exports nothing, so any externally-set `ENABLE_TOOL_SEARCH` passes through untouched.

On launch, whetstone (`src/model_update.rs`) also warns when the model it is about to run came from an `api_model` pin that the models list has retired or superseded — the message names the model, whether the pin is the project's (`.claude/whetstone.json`) or global (`~/.whetstone/settings.json`), and what to move to. This is a plain `[WARN]` line, not the modal, so it also reaches non-interactive launches, projects without a v3 manifest, and pins whose model family no longer exists. "No longer in the models list" is only ever claimed from a *live* list; the static roster in `src/settings.rs` holds the current generation only, so an offline launch can report "superseded" but never "retired".

On launch, whetstone (`src/model_update.rs`) checks the 12h-cached Anthropic models list for a model newer than the one this project runs — or a brand-new model family — and shows a full-screen modal offering to pin it as the project default (`api_model`), use it for one session, or dismiss it permanently (recorded in the manifest's top-level `dismissed_models`). The prompt is skipped when non-interactive, offline, not a v3 project, or when `--model` was passed explicitly.

On an interactive launch, whetstone (`src/update_notify.rs`) replaces the
update banner with a full-screen modal listing outdated components from the
12h version cache (whetstone, headroom, rtk, claude code, ICM): **update now**
(runs `whetstone update`, then re-execs the new binary if whetstone itself
changed), **later**, or **skip these versions** (recorded as `name@version` in
`~/.cache/whetstone/update-state.json`, so a newer release is offered again).
It also spawns a hidden `whetstone update-watch <pid>` in its own process
group; because exec keeps the pid, it lives exactly as long as the session,
refreshes the cache hourly (cache age dedupes across sessions), and sends one
desktop notification (`notify-send` / `osascript`) per new version. The watcher
never installs — swapping headroom/claude under a live session or a shared
proxy isn't safe — it only says to restart.

whetstone also supports `headroom_env` — a map of any Headroom launch knobs in
`.claude/whetstone.json` (project) or `~/.whetstone/settings.json` (global),
with precedence: external `HEADROOM_*` env vars > project map > global map >
whetstone defaults (`HEADROOM_PORT` reserved, wins always). `whetstone settings`
surfaces several of these map keys as named free-text knobs — **Headroom Target
Ratio** (`HEADROOM_TARGET_RATIO`), **Headroom Budget** (`HEADROOM_BUDGET`),
**Headroom Rollout Channel** (`HEADROOM_ROLLOUT_CHANNEL`), and **Headroom Output
Shaper** (`HEADROOM_OUTPUT_SHAPER`) — each stored as an ordinary `headroom_env`
entry, so they follow the same precedence and become part of the per-config
proxy fingerprint like any other applied `HEADROOM_*` var.

`whetstone settings` also exposes **Headroom Semantic Cache**
(`HEADROOM_CACHE_ENABLED`) — Headroom replays a cached response for a
byte-identical request, which saves tokens but means a retry cannot produce a
fresh generation. Like **Headroom Beacon** this is an *opt-out*: the TUI reads
**On** while the key is unset (Headroom's own default), and switching it **Off**
writes `HEADROOM_CACHE_ENABLED=0`, so the bar never shows "On" while a value is
quietly stored. It is an ordinary `headroom_env` entry, so it follows the same
precedence and joins the proxy fingerprint — a session with caching off gets its
own proxy rather than sharing one that caches. Turn it off when debugging
model-output quality, where a replayed response masks whether a retry would
differ.

## Architecture

```
User → Claude Code
         ├── Bash calls → [RTK Hook] → rtk <cmd> → compressed output
         ├── Context    → [Headroom Proxy :8787] → Anthropic API
         └── Memory     → [ICM, embedded SQLite] → persistent context
```

Whetstone runs one Headroom proxy per distinct resolved config (savings profile, telemetry, memory, upstream URL, and the `HEADROOM_*` apply set — see the "Global Headroom memory root" bullet below), reusing a live proxy only when a session's config fingerprint matches exactly. There is no memory-conflict prompt: memory on/off is part of that fingerprint, so a session that wants memory and one that doesn't simply get separate proxies instead of racing to replace each other's.

**Setup flow** (`whetstone setup`, orchestrated by `src/setup.rs`). Setup first self-updates and offers v2→v3 migration; if the terminal is interactive it runs `src/wizard.rs`, otherwise the headless sequence below:
1. Resolve assets; preflight-check dependencies (python, git, curl, uv)
2. Install Headroom via `uv tool install "headroom-ai[EXTRAS]"` (extras configurable)
3. Install RTK from GitHub (detects name collision with Rust Type Kit)
4. Shell profile: set `ANTHROPIC_BASE_URL` + ensure `~/.local/bin` on PATH
5. Self-install binary to `~/.local/bin/whetstone`
6. Prompt for memory provider (ICM or Skip)
7. If a provider was chosen, `complete_setup`: copy slash commands, install the provider binary, run tool integrations (`src/integrations.rs`), run `doctor`, write the `.claude/whetstone.json` manifest, generate `STACK-SETUP.md`

**Hook system** — v3 no longer hand-writes `~/.claude/settings.json`. Whetstone delegates to each tool's own installer (`src/integrations.rs`), which writes its own hook entries; `whetstone doctor` reports drift.

| What Fires | Installed by |
|-----------|--------------|
| PreToolUse (Bash) — RTK rewrites the command | `rtk init --auto-patch` |
| ICM slash commands, CLAUDE.md block, session hooks | `icm init --mode standard` |

## Source Layout

<!-- AUTO-GENERATED: source-layout -->
```
src/
├── main.rs          # Entry: parse CLI, dispatch subcommands
├── cli.rs           # clap derive structs for all subcommands
├── setup.rs         # whetstone setup orchestrator (headless path)
├── wizard.rs        # Interactive setup wizard
├── uninstall.rs     # Interactive component removal
├── wrapper.rs       # claude/proxy/rtk exec wrappers; proxy + model resolution
├── claude_code.rs   # Claude Code launch/detection helpers
├── integrations.rs  # Delegates to `rtk init` / `icm init` (tool-managed hooks)
├── migrate.rs       # v2 → v3 migration + reversible rollback
├── doctor.rs        # Check dependencies + settings.json, repair/report drift
├── dashboard.rs     # TUI: installed tool versions vs pinned floors
├── settings.rs      # Interactive layered global/project settings TUI
├── stats.rs         # Token-savings summary (RTK + Headroom)
├── tools.rs         # Managed-dependency inventory: presence checks, repair, install-tools
├── update.rs        # 12h-cached remote version check + self-update
├── release.rs       # Release preflight, version bump, and PR creation
├── changelog.rs     # CHANGELOG.md parsing / site changelog sync
├── db.rs            # SQLite ops for session/memory database
├── memory.rs        # MemoryProvider enum (ICM, Skip)
├── memory_consolidate.rs # Drain stray project-local .headroom stores into ~/.headroom
├── config.rs        # ProjectSettings/GlobalSettings + .claude/whetstone.json manifest
├── shell.rs         # Shell profile detection, env var injection
├── preflight.rs     # Dependency checks (python, git, curl, uv)
├── headroom.rs      # Headroom install/upgrade (extras configurable)
├── rtk.rs           # RTK install/upgrade + collision detection
├── version.rs       # Semver parse, compare, bump
└── ui.rs            # Colored output, interactive prompts
```
<!-- AUTO-GENERATED: end -->

## Key Design Decisions

- **Single Rust binary**: replaces ~1200 lines Bash + ~460 lines Python
- **Idempotent**: setup skips already-installed components; safe to rerun
- **Absolute paths in hooks**: avoids PATH/shell-state issues
- **Global tools, per-project config**: RTK/Headroom installed globally; memory provider and version-pinned manifest are per-project
- **Per-config proxy registry**: whetstone runs one proxy per distinct resolved config, keyed by a fingerprint (savings profile, telemetry, memory, upstream URL, and the non-memory-path `HEADROOM_*` apply set) over entries in `~/.whetstone/proxies.json` (`src/proxy_registry.rs`). Two sessions that would spawn a byte-identical proxy share it; anything that differs — including memory on vs. off — gets its own. Port `8787` is only a best-effort launch-order anchor so a bare `claude` launch and doctor's fast path still find a proxy there when nothing else has claimed it; it is not a fixed single-proxy port. The memory DB path itself stays out of the fingerprint (see below), so it can't fracture reuse on its own.
- **No rate limiting on a whetstone proxy**: every proxy whetstone spawns (and a bare `whetstone proxy`) gets `--no-rate-limit` — a local proxy only fronts this machine's Claude Code sessions, which the upstream API already throttles. The flag is gated on one `headroom proxy --help` probe (`ProxyFlagSupport` in `src/wrapper.rs`, which answers for every optional flag from a single probe), so an older headroom that doesn't know it still starts.
- **Global Headroom memory root**: whetstone pins `HEADROOM_MEMORY_DB_PATH` to `~/.headroom/memory.db` so per-project memory DBs live under `~/.headroom/memories/projects/` instead of accumulating in whichever project launched the proxy — unaffected by per-config proxy reuse above. `wrap_claude` auto-consolidates any stray project-local `.headroom` store into that root (never overwriting global data; seed DBs migrate all-or-nothing), and `whetstone memory consolidate [--dry-run]` runs it explicitly (`src/memory_consolidate.rs`)
- **Tool-managed hooks**: v3 delegates `~/.claude/settings.json` hook entries to `rtk init` / `icm init`; whetstone never hand-merges them (`doctor` reports drift, `migrate` archives before touching state)
- **Layered settings**: `GlobalSettings` (`~/.whetstone/settings.json`) and per-project `ProjectSettings` (in `.claude/whetstone.json`) resolve with project-over-global precedence
- **rusqlite bundled**: statically links SQLite, no system dependency
- **Asset resolution**: `WHETSTONE_ASSETS` env → `<binary_dir>/../assets/` → `~/.whetstone/assets/`

## Rust Conventions

- `anyhow::Result` for error propagation with context
- `ui::fail()` for fatal errors (calls `process::exit(1)`)
- Unix `CommandExt::exec` for wrapper commands (replaces process)
- Non-interactive fallback: `dialoguer::Confirm` with TTY detection
- `console::style` for colored output

<!-- rtk-instructions v2 -->
# RTK (Rust Token Killer) - Token-Optimized Commands

## Golden Rule

**Always prefix commands with `rtk`**. If RTK has a dedicated filter, it uses it. If not, it passes through unchanged. This means RTK is always safe to use.

**Important**: Even in command chains with `&&`, use `rtk`:
```bash
# ❌ Wrong
git add . && git commit -m "msg" && git push

# ✅ Correct
rtk git add . && rtk git commit -m "msg" && rtk git push
```

## RTK Commands by Workflow

### Build & Compile (80-90% savings)
```bash
rtk cargo build         # Cargo build output
rtk cargo check         # Cargo check output
rtk cargo clippy        # Clippy warnings grouped by file (80%)
rtk tsc                 # TypeScript errors grouped by file/code (83%)
rtk lint                # ESLint/Biome violations grouped (84%)
rtk prettier --check    # Files needing format only (70%)
rtk next build          # Next.js build with route metrics (87%)
```

### Test (60-99% savings)
```bash
rtk cargo test          # Cargo test failures only (90%)
rtk go test             # Go test failures only (90%)
rtk jest                # Jest failures only (99.5%)
rtk vitest              # Vitest failures only (99.5%)
rtk playwright test     # Playwright failures only (94%)
rtk pytest              # Python test failures only (90%)
rtk rake test           # Ruby test failures only (90%)
rtk rspec               # RSpec test failures only (60%)
rtk test <cmd>          # Generic test wrapper - failures only
```

### Git (59-80% savings)
```bash
rtk git status          # Compact status
rtk git log             # Compact log (works with all git flags)
rtk git diff            # Compact diff (80%)
rtk git show            # Compact show (80%)
rtk git add             # Ultra-compact confirmations (59%)
rtk git commit          # Ultra-compact confirmations (59%)
rtk git push            # Ultra-compact confirmations
rtk git pull            # Ultra-compact confirmations
rtk git branch          # Compact branch list
rtk git fetch           # Compact fetch
rtk git stash           # Compact stash
rtk git worktree        # Compact worktree
```

Note: Git passthrough works for ALL subcommands, even those not explicitly listed.

### GitHub (26-87% savings)
```bash
rtk gh pr view <num>    # Compact PR view (87%)
rtk gh pr checks        # Compact PR checks (79%)
rtk gh run list         # Compact workflow runs (82%)
rtk gh issue list       # Compact issue list (80%)
rtk gh api              # Compact API responses (26%)
```

### JavaScript/TypeScript Tooling (70-90% savings)
```bash
rtk pnpm list           # Compact dependency tree (70%)
rtk pnpm outdated       # Compact outdated packages (80%)
rtk pnpm install        # Compact install output (90%)
rtk npm run <script>    # Compact npm script output
rtk npx <cmd>           # Compact npx command output
rtk prisma              # Prisma without ASCII art (88%)
rtk uv run <cmd>        # Compact uv project command output
```

### Files & Search (60-75% savings)
```bash
rtk ls <path>           # Tree format, compact (65%)
rtk read <file>         # Code reading with filtering (60%)
rtk grep <pattern>      # Search grouped by file (75%). Format flags (-c, -l, -L, -o, -Z) run raw.
rtk find <pattern>      # Find grouped by directory (70%)
```

### Analysis & Debug (70-90% savings)
```bash
rtk err <cmd>           # Filter errors only from any command
rtk log <file>          # Deduplicated logs with counts
rtk json <file>         # JSON structure without values
rtk deps                # Dependency overview
rtk env                 # Environment variables compact
rtk summary <cmd>       # Smart summary of command output
rtk diff                # Ultra-compact diffs
```

### Infrastructure (85% savings)
```bash
rtk docker ps           # Compact container list
rtk docker images       # Compact image list
rtk docker logs <c>     # Deduplicated logs
rtk kubectl get         # Compact resource list
rtk kubectl logs        # Deduplicated pod logs
```

### Network (65-70% savings)
```bash
rtk curl <url>          # Compact HTTP responses (70%)
rtk wget <url>          # Compact download output (65%)
```

### Meta Commands
```bash
rtk gain                # View token savings statistics
rtk gain --history      # View command history with savings
rtk discover            # Analyze Claude Code sessions for missed RTK usage
rtk proxy <cmd>         # Run command without filtering (for debugging)
rtk init                # Add RTK instructions to CLAUDE.md
rtk init --global       # Add RTK to ~/.claude/CLAUDE.md
```

## Token Savings Overview

| Category | Commands | Typical Savings |
|----------|----------|-----------------|
| Tests | vitest, playwright, cargo test | 90-99% |
| Build | next, tsc, lint, prettier | 70-87% |
| Git | status, log, diff, add, commit | 59-80% |
| GitHub | gh pr, gh run, gh issue | 26-87% |
| Package Managers | pnpm, npm, npx | 70-90% |
| Files | ls, read, grep, find | 60-75% |
| Infrastructure | docker, kubectl | 85% |
| Network | curl, wget | 65-70% |

Overall average: **60-90% token reduction** on common development operations.
<!-- /rtk-instructions -->

<!-- icm:start -->
## Persistent memory (ICM) — MANDATORY

This project uses [ICM](https://github.com/rtk-ai/icm) for persistent memory across sessions.
You MUST use it actively. Not optional.

### Recall (before starting work)
```bash
icm recall "query"                        # search memories
icm recall "query" -t "topic-name"        # filter by topic
icm recall-context "query" --limit 5      # formatted for prompt injection
```

### Store — MANDATORY triggers
You MUST call `icm store` when ANY of the following happens:
1. **Error resolved** → `icm store -t errors-resolved -c "description" -i high -k "keyword1,keyword2"`
2. **Architecture/design decision** → `icm store -t decisions-{project} -c "description" -i high`
3. **User preference discovered** → `icm store -t preferences -c "description" -i critical`
4. **Significant task completed** → `icm store -t context-{project} -c "summary of work done" -i high`
5. **Conversation exceeds ~20 tool calls without a store** → store a progress summary

Do this BEFORE responding to the user. Not after. Not later. Immediately.

Do NOT store: trivial details, info already in CLAUDE.md, ephemeral state (build logs, git status).

### Other commands
```bash
icm update <id> -c "updated content"     # edit memory in-place
icm health                                # topic hygiene audit
icm topics                                # list all topics
```
<!-- icm:end -->