claude-code-tools 1.0.6__py3-none-any.whl → 1.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. claude_code_tools/__init__.py +1 -1
  2. claude_code_tools/action_rpc.py +16 -10
  3. claude_code_tools/aichat.py +793 -51
  4. claude_code_tools/claude_continue.py +4 -0
  5. claude_code_tools/codex_continue.py +48 -0
  6. claude_code_tools/export_session.py +9 -5
  7. claude_code_tools/find_claude_session.py +36 -12
  8. claude_code_tools/find_codex_session.py +33 -18
  9. claude_code_tools/find_session.py +30 -16
  10. claude_code_tools/gdoc2md.py +220 -0
  11. claude_code_tools/md2gdoc.py +549 -0
  12. claude_code_tools/search_index.py +83 -9
  13. claude_code_tools/session_menu_cli.py +1 -1
  14. claude_code_tools/session_utils.py +3 -3
  15. claude_code_tools/smart_trim.py +18 -8
  16. claude_code_tools/smart_trim_core.py +4 -2
  17. claude_code_tools/tmux_cli_controller.py +35 -25
  18. claude_code_tools/trim_session.py +28 -2
  19. claude_code_tools-1.4.1.dist-info/METADATA +1113 -0
  20. {claude_code_tools-1.0.6.dist-info → claude_code_tools-1.4.1.dist-info}/RECORD +30 -24
  21. {claude_code_tools-1.0.6.dist-info → claude_code_tools-1.4.1.dist-info}/entry_points.txt +2 -0
  22. docs/local-llm-setup.md +286 -0
  23. docs/reddit-aichat-resume-v2.md +80 -0
  24. docs/reddit-aichat-resume.md +29 -0
  25. docs/reddit-aichat.md +79 -0
  26. docs/rollover-details.md +67 -0
  27. node_ui/action_config.js +3 -3
  28. node_ui/menu.js +67 -113
  29. claude_code_tools/session_tui.py +0 -516
  30. claude_code_tools-1.0.6.dist-info/METADATA +0 -685
  31. {claude_code_tools-1.0.6.dist-info → claude_code_tools-1.4.1.dist-info}/WHEEL +0 -0
  32. {claude_code_tools-1.0.6.dist-info → claude_code_tools-1.4.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1113 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-code-tools
3
+ Version: 1.4.1
4
+ Summary: Collection of tools for working with Claude Code
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: claude-agent-sdk>=0.1.6
8
+ Requires-Dist: click>=8.0.0
9
+ Requires-Dist: commitizen>=4.8.3
10
+ Requires-Dist: fire>=0.5.0
11
+ Requires-Dist: mcp>=1.13.0
12
+ Requires-Dist: pytest>=9.0.1
13
+ Requires-Dist: pyyaml>=6.0
14
+ Requires-Dist: rich>=13.0.0
15
+ Requires-Dist: tantivy>=0.22.0
16
+ Requires-Dist: tqdm>=4.67.1
17
+ Provides-Extra: dev
18
+ Requires-Dist: commitizen>=3.0.0; extra == 'dev'
19
+ Provides-Extra: gdocs
20
+ Requires-Dist: google-api-python-client>=2.0.0; extra == 'gdocs'
21
+ Requires-Dist: google-auth-oauthlib>=1.0.0; extra == 'gdocs'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # claude-code-tools
25
+
26
+ [![claude-code-tools](https://img.shields.io/github/v/release/pchalasani/claude-code-tools?filter=v*&label=claude-code-tools&color=blue)](https://pypi.org/project/claude-code-tools/)
27
+ [![aichat-search](https://img.shields.io/github/v/release/pchalasani/claude-code-tools?filter=rust-v*&label=aichat-search&color=orange)](https://github.com/pchalasani/claude-code-tools/releases?q=rust)
28
+
29
+ Collection of tools I built for productivity with
30
+ Claude Code, Codex-CLI, and similar CLI coding agents:
31
+ CLI commands, skills, agents, hooks, plugins.
32
+
33
+
34
+ <div align="center">
35
+
36
+ <table>
37
+ <tr>
38
+ <td align="center">
39
+ <a href="#quick-start">
40
+ <img src="assets/card-quickstart.svg" alt="quick start" width="300"/>
41
+ </a>
42
+ </td>
43
+ <td align="center">
44
+ <a href="#claude-code-plugins">
45
+ <img src="assets/card-plugins.svg" alt="plugins" width="300"/>
46
+ </a>
47
+ </td>
48
+ </tr>
49
+ </table>
50
+
51
+ <table>
52
+ <tr>
53
+ <td align="center">
54
+ <a href="#aichat-session-management">
55
+ <img src="assets/card-aichat.svg" alt="aichat" width="200"/>
56
+ </a>
57
+ </td>
58
+ <td align="center">
59
+ <a href="#tmux-cli-terminal-automation">
60
+ <img src="assets/card-tmux.svg" alt="tmux-cli" width="200"/>
61
+ </a>
62
+ </td>
63
+ <td align="center">
64
+ <a href="#lmsh-experimental">
65
+ <img src="assets/card-lmsh.svg" alt="lmsh" width="200"/>
66
+ </a>
67
+ </td>
68
+ </tr>
69
+ <tr>
70
+ <td align="center">
71
+ <a href="#vault">
72
+ <img src="assets/card-vault.svg" alt="vault" width="200"/>
73
+ </a>
74
+ </td>
75
+ <td align="center">
76
+ <a href="#env-safe">
77
+ <img src="assets/card-env-safe.svg" alt="env-safe" width="200"/>
78
+ </a>
79
+ </td>
80
+ <td align="center">
81
+ <a href="#claude-code-safety-hooks">
82
+ <img src="assets/card-safety.svg" alt="safety" width="200"/>
83
+ </a>
84
+ </td>
85
+ </tr>
86
+ <tr>
87
+ <td align="center">
88
+ <a href="#status-line">
89
+ <img src="assets/card-statusline.svg" alt="statusline" width="200"/>
90
+ </a>
91
+ </td>
92
+ <td align="center">
93
+ <a href="#google-docs-tools">
94
+ <img src="assets/card-gdocs.svg" alt="gdocs" width="200"/>
95
+ </a>
96
+ </td>
97
+ <td align="center">
98
+ <a href="#using-claude-code-with-open-weight-anthropic-api-compatible-llm-providers">
99
+ <img src="assets/card-alt.svg" alt="alt" width="200"/>
100
+ </a>
101
+ </td>
102
+ </tr>
103
+ </table>
104
+
105
+ <table>
106
+ <tr>
107
+ <td align="center">
108
+ <a href="#development">
109
+ <img src="assets/card-dev.svg" alt="development" width="300"/>
110
+ </a>
111
+ </td>
112
+ <td align="center">
113
+ <a href="LICENSE">
114
+ <img src="assets/card-license.svg" alt="license" width="300"/>
115
+ </a>
116
+ </td>
117
+ </tr>
118
+ </table>
119
+
120
+ </div>
121
+
122
+ ---
123
+
124
+ <a id="quick-start"></a>
125
+ ## 🚀 Quick Start
126
+
127
+ **Prerequisites:** Node.js 16+ (required for action menus)
128
+
129
+ **Step 1:** Install the Python package (includes Node.js UI components):
130
+ ```bash
131
+ uv tool install claude-code-tools
132
+ ```
133
+
134
+ **Step 2:** Install the Rust-based search engine (powers both human TUI and agent search).
135
+ Choose **one** of these methods:
136
+
137
+ - **Homebrew** (macOS/Linux): `brew install pchalasani/tap/aichat-search`
138
+ - **Cargo**: `cargo install aichat-search` (compiles from source, ~5 min)
139
+ - **Pre-built binary**: Download from [Releases](https://github.com/pchalasani/claude-code-tools/releases) (look for `rust-v*` releases)
140
+
141
+ That's it! No `npm install` needed — the Python package includes pre-installed Node.js dependencies.
142
+
143
+ Without `aichat-search`, search won't work, but other `aichat` commands (resume, trim, rollover, etc.) still function.
144
+
145
+ ### What You Get
146
+
147
+ Four commands are installed:
148
+
149
+ | Command | Description |
150
+ |---------|-------------|
151
+ | [`aichat`](#aichat-session-management) | Continue work with session lineage and truncation, avoiding compaction;<br>fast (Rust/Tantivy) full-text session search TUI for humans, CLI for agents |
152
+ | [`tmux-cli`](#tmux-cli-terminal-automation) | Terminal automation for AI agents ("Playwright for terminals") |
153
+ | [`vault`](#vault) | Encrypted .env backup and sync |
154
+ | [`env-safe`](#env-safe) | Safe .env inspection without exposing values |
155
+
156
+ <a id="claude-code-plugins"></a>
157
+
158
+ ### Claude Code Plugins
159
+
160
+ <details>
161
+ <summary>📦 <b>Click to expand plugin details</b></summary>
162
+
163
+ This repo also provides plugins for the
164
+ [Claude Code marketplace](https://code.claude.com/docs/en/discover-plugins):
165
+
166
+ | Plugin | Description |
167
+ |--------|-------------|
168
+ | `aichat` | hooks (`>resume`), commands, skills, agents for continuing session work and fast full-text search of sessions|
169
+ | `tmux-cli` | Terminal automation skill for interacting with other tmux panes |
170
+ | `workflow` | Work logging, code walk-through, issue specs, UI testing |
171
+ | `safety-hooks` | Prevent destructive git/docker/rm commands |
172
+
173
+ **Install the plugins:**
174
+
175
+ First, add the marketplace (from terminal or within a Claude Code session):
176
+
177
+ ```bash
178
+ claude plugin marketplace add pchalasani/claude-code-tools # CLI
179
+ /plugin marketplace add pchalasani/claude-code-tools # in-session
180
+ ```
181
+
182
+ This creates the `cctools-plugins` plugin group. Then install plugins from it:
183
+
184
+ ```bash
185
+ # CLI
186
+ claude plugin install "aichat@cctools-plugins"
187
+ claude plugin install "tmux-cli@cctools-plugins"
188
+ claude plugin install "workflow@cctools-plugins"
189
+ claude plugin install "safety-hooks@cctools-plugins"
190
+
191
+ # Or in-session
192
+ /plugin install aichat@cctools-plugins
193
+ /plugin install tmux-cli@cctools-plugins
194
+ /plugin install workflow@cctools-plugins
195
+ /plugin install safety-hooks@cctools-plugins
196
+ ```
197
+
198
+ You can also use `/plugin` without arguments to launch a TUI for browsing and installing.
199
+
200
+ <a id="aichat-plugin-details"></a>
201
+
202
+ #### aichat Plugin Details
203
+
204
+ The `aichat` plugin provides:
205
+
206
+ | Type | Name | What it does |
207
+ |------|------|--------------|
208
+ | Hook | `>resume` | Type `>resume` (or `>continue`, `>handoff`) to trigger session handoff flow |
209
+ | Skill | `/session-search` | Search past sessions (for agents without sub-agent support, e.g. Codex) |
210
+ | Skill | `/recover-context` | Extract context from parent sessions into current conversation |
211
+ | Agent | `session-searcher` | Sub-agent to search/retrieve context from past sessions |
212
+
213
+ #### tmux-cli Plugin Details
214
+
215
+ The `tmux-cli` plugin provides:
216
+
217
+ | Type | Name | What it does |
218
+ |------|------|--------------|
219
+ | Skill | `/tmux-cli` | Interact with CLI apps/agents in other tmux panes |
220
+
221
+ #### safety-hooks Plugin Details
222
+
223
+ The `safety-hooks` plugin provides hooks that block or require approval for dangerous operations:
224
+
225
+ | Hook | What it blocks/modifies |
226
+ |------|------------------------|
227
+ | `rm` protection | Blocks `rm -rf` on critical paths, requires approval for others |
228
+ | `git add` protection | Blocks `git add -A`, requires approval for modified files |
229
+ | `git checkout` protection | Warns before discarding uncommitted changes |
230
+ | `git commit` protection | Blocks commits without user review |
231
+ | `.env` protection | Blocks all read/write/edit of `.env` files; suggests `env-safe` CLI |
232
+ | File length limit | Blocks reading files >500 lines to prevent context bloat |
233
+
234
+ #### Workflow Plugin Details
235
+
236
+ The `workflow` plugin provides:
237
+
238
+ | Skill/Agent | What it does |
239
+ |-------------|--------------|
240
+ | `/code-walk-thru` | Walk through files in your editor to explain code or show changes |
241
+ | `/log-work` | Log work progress to `WORKLOG/YYYYMMDD.md` |
242
+ | `/make-issue-spec` | Create task specs at `issues/YYYYMMDD-topic.md` |
243
+ | `ui-tester` agent | Browser-based UI testing via Chrome DevTools MCP |
244
+
245
+ </details>
246
+
247
+ ---
248
+
249
+ <a id="aichat-session-management"></a>
250
+ # 💬 aichat — Session Search, and Continuation without Compaction
251
+
252
+ ## Why I built this
253
+
254
+ This probably belongs in a blog post or reddit post, but I think knowing the thought process and motivation helps understand what the `aichat` command-group does and why it might be useful to you.
255
+ (For those wondering, this section is one
256
+ of the few parts of the entire repo that is 100% hand-crafted since I just cannot
257
+ trust today's LLMs to write just the way I want.)
258
+
259
+ <details>
260
+ <summary>📖 <b>Click to expand the full background</b></summary>
261
+
262
+ #### Compaction is lossy: instead, clone the session and truncate long tool-results and older assistant messages
263
+
264
+ So, here's how this all started. Session compaction is
265
+ **lossy:** there are very often situations where compaction loses important details,
266
+ so I wanted to find ways to continue my work without compaction.
267
+ A typical scenario is this -- I am at 90% context usage, and I wish I can go on a bit longer to finish the current work-phase. So I thought,
268
+ > I wish I could **truncate** some long tool results (e.g. file reads or API results) or older assistant messages (can include write/edit tool-calls) and clear out some context to continue my work.
269
+
270
+ This lead to the [`aichat trim`](#three-resume-strategies) utility. It provides two variants:
271
+
272
+ - a "blind" [`trim`](#three-resume-strategies) mode that truncates all tool-results longer than a threshold (default 500 chars), and optionally all-but-recent assistant messages (which may include long write/edit tool-calls)
273
+ -- all user-configurable. This can free up 40-60% context, depending on what's been going on in the session.
274
+
275
+ - a [`smart-trim`](#three-resume-strategies) mode that uses a headless Claude/Codex
276
+ agent to determine which
277
+ messages can be safely truncated in order to continue the current work. The precise
278
+ truncation criteria can be customized (e.g. the user may want to continue some
279
+ prior work rather than the current task).
280
+
281
+
282
+ Both of these modes *clone* the current session before truncation, and inject two
283
+ types of [*lineage*](#lineage-nothing-is-lost):
284
+ - *Session-lineage* is injected into the first user message: a chronological listing
285
+ of sessions from which the current session was derived. This allows the (sub-) agent
286
+ to extract needed context from ancestor sessions, either when prompted by the user,
287
+ or on its own initiative.
288
+ - Each truncated message also carries a pointer to the specific message index in the parent session so full details can always be looked up if needed.
289
+
290
+ #### A cleaner alternative: Start new session with lineage and context summary
291
+
292
+ Session trimming can be a quick way to clear out context in order to continue the current task for a bit longer, but after a couple of trims, does not yield as much benefit. But the lineage-injection lead to a different idea to avoid compaction:
293
+
294
+ > Create a fresh session, inject parent-session lineage into the first user message, along with instructions to extract (using sub-agents if available) context of the latest
295
+ task from the parent session, or skip context extraction and leave it to the user to extract context once the session starts.
296
+
297
+ This is the idea behind the [`aichat rollover`](#three-resume-strategies) functionality, which is the variant I use the most frequently, and I use this
298
+ instead of first trimming a session. I usually choose
299
+ to skip the summarization (this is the `quick` rollover option in the TUI) so that
300
+ the new session starts quickly and I can instruct Claude-Code/Codex-CLI to extract
301
+ needed context (usually from the latest chat session shown in the lineage), as shown
302
+ in the [demo video](#resume-demo-video) below.
303
+
304
+ #### A hook to simplify continuing work from a session
305
+
306
+ I wanted to make it seamless to pick any of the above three task continuation modes, when inside a Claude Code session, so I set up a `UserPromptSubmit` [hook](#resume-options) (via the `aichat` plugin) that is triggered when the user types `>resume` (or `>continue` or `>handoff`). When I am close to full context usage,
307
+ I type `>resume`, and the hook script copies the current session id into the clipboard and shows instructions asking the user to run
308
+ `aichat resume <pasted-session-id>`; this launches a TUI that offering options to choose
309
+ one of the above [session resumption modes](#three-resume-strategies).
310
+ See the [demo video](#resume-demo-video) below.
311
+
312
+ #### Fast full-text session search for humans/agents to find prior work context
313
+
314
+ The above session resumption methods are useful to continue your work from the
315
+ *current* session, but often you want to continue work that was done in an
316
+ *older* Claude-Code/Codex-CLI session. This is why I added this:
317
+
318
+ > Super-fast Rust/Tantivy-based [full-text search](#aichat-search--find-and-select-sessions) of all sessions across Claude-Code and
319
+ Codex-CLI, with a pleasant self-explanatory TUI for humans, and a CLI mode for Agents
320
+ to find past work. (The Rust/Tantivy-based search and TUI was inspired by the excellent
321
+ TUI in the [zippoxer/recall](https://github.com/zippoxer/recall) repo).
322
+
323
+ Users can launch the search TUI using [`aichat search ...`](#aichat-search--find-and-select-sessions) and (sub-)
324
+ [agents can run](#agent-access-to-history-the-session-searcher-sub-agent)
325
+ `aichat search ... --json` and get results in JSONL format
326
+ for quick analysis and filtering using `jq` which of course CLI agents are
327
+ great at using. There is a corresponding *skill* called `session-search` and a *sub-agent* called `session-searcher`, both
328
+ available via the `aichat` [plugin](#claude-code-plugins).
329
+ For example in Claude Code,
330
+ users can recover context of some older work by simply saying something like:
331
+
332
+ > Use your session-searcher sub-agent to recover the context of how we worked on
333
+ connecting the Rust search TUI with the node-based Resume Action menus.
334
+
335
+ </details>
336
+
337
+ ## Overview
338
+
339
+
340
+ `aichat` is your unified CLI command-group for managing Claude Code and Codex sessions.
341
+ Two main capabilities are available:
342
+
343
+ 1. **Resume with lineage** — Continue sessions when context fills up, preserving
344
+ links to parent sessions, avoiding lossy compaction.
345
+
346
+ 2. **Search** — *Full-text search* across all sessions with a fast Rust/Tantivy-based
347
+ TUI for humans, and CLI (with `--json` flag for jsonl output) for Codex or Claude (sub)
348
+ Agent to search for past work. (Note that Claude Code's built-in search is not full-text
349
+ ; it only searches the ad-hoc session titles created by CC, or renamed sessions).
350
+
351
+ Examples:
352
+
353
+ ```bash
354
+ aichat resume <session_id> # Resume specific session with trim/rollover options
355
+ aichat resume # Resume latest session with trim/rollover options
356
+ aichat search "topic" # Find sessions by keyword: for humans
357
+ aichat search "langroid mcp" --json # fast full-text search with jsonl output for agents
358
+ ```
359
+
360
+ For detailed CLI options, run:
361
+ ```bash
362
+ aichat --help # See all subcommands
363
+ aichat <subcommand> --help # Help for specific subcommand
364
+ ```
365
+
366
+ > [!NOTE]
367
+ > Most `aichat` commands accept `--claude-home` and `--codex-home` to override
368
+ > the default session directories (`~/.claude` and `~/.codex`). You can also set
369
+ > the `CLAUDE_CONFIG_DIR` and `CODEX_HOME` environment variables.
370
+
371
+ ---
372
+
373
+ <a id="resume-options"></a>
374
+ ## Resume Options — Continuing work in a trimmed or fresh session, with lineage.
375
+
376
+
377
+ You have three ways to access the resume functionality:
378
+
379
+ **1. In-session trigger** — This is likely to be used the most frequently: while already in a Claude Code session, when you're close to filling up context, type:
380
+
381
+ ```bash
382
+ >resume # or >continue, >handoff; MUST include the ">" at the start
383
+ ```
384
+
385
+ This triggers a `UserPromptSubmit` hook that blocks handling by Claude-Code
386
+ (hence no further tokens consumed), copies the current session ID to your
387
+ clipboard, and shows instructions to quit Claude Code and run `aichat resume <paste>`.
388
+ This is a quick escape hatch when context is filling up — no need to manually find the
389
+ session ID.
390
+
391
+ *Requires the `aichat` plugin. See [Claude Code Plugins](#claude-code-plugins)
392
+ for installation.*
393
+
394
+
395
+ <a id="resume-demo-video"></a>
396
+
397
+ https://github.com/user-attachments/assets/310dfa5b-a13b-4a2b-aef8-f73954ef8fe9
398
+
399
+
400
+
401
+ **2. [Search TUI](#aichat-search--find-and-select-sessions)** — Run `aichat search`, select a session, then choose a resume
402
+ action from the menu.
403
+
404
+ **3. Direct CLI** — Use these commands directly:
405
+
406
+ ```bash
407
+ aichat resume abc123 # Resume specific session
408
+ aichat resume # Auto-find latest for this project
409
+ ```
410
+
411
+
412
+ ---
413
+
414
+
415
+ ### Three Resume Strategies
416
+
417
+ > [!TIP]
418
+ > It's highly recommended to turn off auto-compaction when using `aichat resume`.
419
+ > - **Claude Code:** Use the `/config` command to disable auto-compaction
420
+ > - **Codex CLI:** Set `model_auto_compact_token_limit = 0` in `~/.codex/config.toml`
421
+
422
+ When you access the resume menu using any of the above 3 mechanisms, you will
423
+ be presented with 3 resume strategies, as described below.
424
+ All strategies create a new session with **lineage** — links back to
425
+ parent sessions that the agent (or preferable a sub-agent if available)
426
+ can reference at any time.
427
+
428
+ **1. Trim + Resume**
429
+
430
+ Truncates large tool call results and assistant messages to free up space.
431
+ Quick and deterministic — you control what gets cut. The default is to trim
432
+ *all* tool results longer than 500 characters, and *none* of the
433
+ assistant messages. This can
434
+ often free up 30-50% of context when applied the first time to a normal session
435
+ (depending on what's in the session). A quick way to extend a session a bit
436
+ longer without lossy compaction.
437
+
438
+ The TUI lets you specify:
439
+
440
+ - Which tool types to truncate (e.g., bash, read, edit, or all)
441
+ - Length threshold in characters (default: 500)
442
+ - How many assistant messages to truncate
443
+ (N => first N, or -N => all except last N; defaults to 0).
444
+ For example to truncate all except the last 10 assistant messages, use `-10`.
445
+
446
+ Same options available via CLI: `aichat trim --help`
447
+
448
+ **2. Smart Trim + Resume**
449
+
450
+ Uses headless (non-interactive) Claude/Codex agent to analyze the session and
451
+ strategically identify what can user/assistant messages or tool results can
452
+ be safely truncated without affecting the *last* task being worked on. Slower than
453
+ deterministic trim, but smarter and more selective.
454
+
455
+ The TUI lets you specify:
456
+
457
+ - Message types to never trim (default: user messages)
458
+ - How many recent messages to always preserve (default: 10)
459
+ - Minimum content threshold for extraction (default: 200 chars)
460
+ - Custom instructions for what to prioritize when truncating
461
+
462
+ Same options available via CLI: `aichat smart-trim --help`
463
+
464
+ **3. Rollover**
465
+
466
+ The trim strategies work well once or twice but eventually stop freeing much
467
+ context. *Rollover* is a better alternative after a couple of trim iterations,
468
+ or directly from a normal session. This strategy hands off work to a fresh
469
+ session, injecting *session-lineage* pointers and an optional agent-generated summary of the current task. The session lineage pointers are a chronologically ordered
470
+ list of session jsonl file paths, of the parent session, parent's parent, and so on,
471
+ all the way back to the original session.
472
+ The new session typically starts with 15-20% context usage,
473
+ and the agent or sub-agent can retrieve details from ancestor sessions on demand,
474
+ either if prompted by the user, or on its own when looking up prior work.
475
+
476
+
477
+ The TUI lets you specify:
478
+
479
+ - Which agent (Claude or Codex) to resume with — start in Claude Code, hand off
480
+ to Codex for heavy refactoring, then back to Claude Code for finishing touches
481
+ - Rollover type:
482
+ - **Quick rollover** — Just preserves lineage pointers, no context extraction.
483
+ Fast, but you'll need to ask the agent to look up prior work as needed.
484
+ If you install the `aichat` [plugin](#claude-code-plugins), you'll have access
485
+ to the `/recover-context` command — the agent reads parent sessions and pulls
486
+ relevant context into the current conversation.
487
+ - **Rollover with context** — Uses a headless Claude/Codex agent to extract summary
488
+ of current work into the new session.
489
+ - Custom context recovery instructions (e.g., "focus on the authentication changes")
490
+ — only available when using "Rollover with context"
491
+
492
+ Same options available via CLI: `aichat rollover --help` (use `--quick` for
493
+ quick mode, `-p "prompt"` for custom extraction instructions)
494
+
495
+ ### Lineage: Nothing Is Lost
496
+
497
+ Unlike compaction (which permanently loses information), all strategies preserve
498
+ the complete parent session:
499
+
500
+ - **Lineage chain** — file paths of all ancestor sessions
501
+ - **On-demand retrieval** — agent can read any past session when needed
502
+
503
+ ```
504
+ Original Session (abc123)
505
+ └─► Trimmed/Rollover 1 (def456)
506
+ └─► Trimmed/Rollover 2 (ghi789)
507
+ └─► ... chain continues
508
+ ```
509
+
510
+ See [here](docs/rollover-details.md) for details on how rollover works.
511
+
512
+ ---
513
+
514
+ ## aichat search — Find and Select Sessions
515
+
516
+ Uses Tantivy (Rust full-text search) to provide fast search across all your Claude and Codex sessions.
517
+
518
+ Here's what it looks like:
519
+
520
+ ![aichat search demo](demos/aichat-search-asciinema.gif)
521
+
522
+ ```bash
523
+ aichat search # Interactive TUI for current project
524
+ aichat search "langroid MCP" # Pre-fill search query
525
+ aichat search -g # Global search (all projects)
526
+ aichat search --json -g "error" # JSONL output for CLI-agents
527
+ ```
528
+
529
+ **How it works:**
530
+
531
+ - **Auto-indexing:** Sessions are automatically indexed on startup—no manual
532
+ export or build steps needed.
533
+ - **Self-explanatory TUI for humans:** Filter by session type, agent, date range, and more. All options are visible in the UI.
534
+ - **CLI options:** All search options are available as command-line arguments. Run
535
+ `aichat search --help` for details.
536
+ - **JSON mode for Agents:** Use `--json` for JSONL output that CLI-agents can process with
537
+ `jq` or other tools. See [Session-Searcher sub-agent](#agent-access-to-history-the-session-searcher-sub-agent), which is available
538
+ when you install the `aichat` plugin mentioned above.
539
+
540
+ **Session type filters:**
541
+
542
+ By default, search includes original, trimmed, and rollover sessions (but not
543
+ sub-agents). Use flags to customize:
544
+
545
+ ```bash
546
+ aichat search # Default: original + trimmed + rollover
547
+ aichat search --sub-agent # Add sub-agents to defaults
548
+ aichat search --no-original # Exclude originals (show trimmed + rollover)
549
+ aichat search --no-trimmed # Exclude trimmed (show original + rollover)
550
+ aichat search --sub-agent --no-rollover # Add sub-agents, exclude rollovers
551
+ ```
552
+
553
+ **Subtractive flags** (exclude from defaults): `--no-original`, `--no-trimmed`,
554
+ `--no-rollover`
555
+
556
+ **Additive flag** (add to defaults): `--sub-agent`
557
+
558
+ ---
559
+
560
+ ## Conceptual Flow: Search → Select → Actions
561
+
562
+ The typical workflow:
563
+
564
+ 1. **Search** — Use `aichat search` to find sessions by keywords, date, or filters
565
+ 2. **Select** — Choose a session from the results
566
+ 3. **Actions** — Perform operations on the selected session
567
+
568
+ After selecting a session, you see the **actions menu**. This is equivalent to
569
+ running `aichat <session-id>` or `aichat menu <session-id>` directly.
570
+
571
+ **Session ID formats** (accepted by most commands):
572
+
573
+ - Full path: `~/.claude/projects/.../abc123.jsonl`
574
+ - Full ID: `abc123-def456-789-...`
575
+ - Partial ID: `abc123` (if unique)
576
+
577
+ ---
578
+
579
+ ## Session Actions
580
+
581
+ After selecting a session, the action menu offers:
582
+
583
+ - **Show path / Copy / Export** — File operations
584
+ - **Query** — Ask questions about the session using a headless Claude-Code/Codex agent
585
+ - **Resume options** — Various strategies for continuing work (see below)
586
+
587
+ ---
588
+
589
+
590
+ ### Agent Access to History; the Session-Searcher sub-agent
591
+
592
+ Your agent can search across all historical sessions using the JSON output
593
+ mode:
594
+
595
+ ```bash
596
+ aichat search --json -g "error handling" # Returns JSONL for programmatic use
597
+ aichat search --json --by-time # Sort by last-modified time
598
+ ```
599
+
600
+ This enables agents to find and retrieve context from any past session in the
601
+ lineage, either on their own initiative or when you prompt them to look up
602
+ historical context.
603
+
604
+ Installing the `aichat` plugin mentioned above provides two ways to search past sessions:
605
+
606
+ - **`Session-Searcher` sub-agent** (Claude Code) — A sub-agent with instructions to
607
+ search a known session file if clear from context, or use `aichat search --json`
608
+ to search past sessions. E.g. in Claude Code you can say:
609
+ > From past sessions, recover details of our work on task-termination specification.
610
+
611
+ - **`session-search` skill** (Claude Code, Codex CLI) — A skill that invokes the same
612
+ search functionality. Useful for CLI agents like Codex that don't yet support sub-agents.
613
+ E.g. you can say:
614
+ > Use your session-search skill to find our work on error handling.
615
+
616
+ ---
617
+
618
+ ## All Subcommands
619
+
620
+ | Command | Description |
621
+ |---------|-------------|
622
+ | `aichat search [query]` | Full-text search TUI across all sessions |
623
+ | `aichat menu [session]` | Interactive action menu for a session |
624
+ | `aichat resume [session]` | Resume options (resume, clone, trim, rollover) |
625
+ | `aichat info [session]` | Show session metadata, path, and lineage |
626
+ | `aichat export [session]` | Export session to text |
627
+ | `aichat copy [session]` | Copy session file to new location |
628
+ | `aichat query [session] [question]` | Query session with AI |
629
+ | `aichat clone [session]` | Clone session and resume the clone |
630
+ | `aichat rollover [session]` | Hand off to fresh session with lineage |
631
+ | `aichat lineage [session]` | Show parent lineage chain |
632
+ | `aichat trim [session]` | Trim large tool outputs |
633
+ | `aichat smart-trim [session]` | AI-powered trimming (EXPERIMENTAL) |
634
+ | `aichat delete [session]` | Delete with confirmation |
635
+ | `aichat find-original [session]` | Trace back to original session |
636
+ | `aichat find-derived [session]` | Find all derived sessions |
637
+
638
+ **Index management:**
639
+
640
+ | Command | Description |
641
+ |---------|-------------|
642
+ | `aichat build-index` | Manually rebuild the search index |
643
+ | `aichat clear-index` | Clear the index for a fresh rebuild |
644
+ | `aichat index-stats` | Show index statistics and reconciliation |
645
+
646
+ The search index is powered by [Tantivy](https://github.com/quickwit-oss/tantivy)
647
+ (Rust full-text search). You typically don't need to manage it manually:
648
+
649
+ - **Auto-updates**: Index updates incrementally on every `aichat` command
650
+ - **Version rebuilds**: Index rebuilds automatically when the tool version changes
651
+ - **Manual rebuild**: Use `aichat clear-index && aichat build-index` if needed
652
+
653
+ Run `aichat <command> --help` for options
654
+
655
+ <a id="tmux-cli-terminal-automation"></a>
656
+ # 🎮 tmux-cli — Terminal Automation
657
+
658
+ > **Note**: While the description below focuses on Claude Code, tmux-cli works with any CLI coding agent.
659
+
660
+ ![tmux-cli demo](demos/tmux-cli-demo-short.gif)
661
+
662
+ **Think Playwright for terminals** - Terminal automation for AI agents.
663
+
664
+ tmux-cli enables Claude Code to programmatically control terminal applications:
665
+ test interactive scripts, debug with pdb, launch and interact with other CLI agents.
666
+
667
+ **Important**: You don't need to learn tmux-cli commands. Claude Code handles
668
+ everything automatically—just describe what you want.
669
+
670
+ **Works anywhere**: Automatically handles both local tmux panes and remote sessions.
671
+
672
+ ### Why tmux-cli instead of vanilla tmux?
673
+
674
+ Vanilla tmux can do everything tmux-cli does. The problem is that LLMs frequently make
675
+ mistakes with raw tmux: forgetting the Enter key, not adding delays between text and
676
+ Enter (causing race conditions with fast CLI apps), or incorrect escaping. `tmux-cli`
677
+ bakes in defaults that address these: Enter is sent automatically with a 1-second delay
678
+ (configurable), pane targeting accepts simple numbers instead of `session:window.pane`,
679
+ and there's built-in `wait_idle` to detect when a CLI is ready for input.
680
+
681
+ ## Tmux-cli skill
682
+
683
+ To make it easier to have Claude-Code use this command, there's a **tmux-cli plugin** in this repo; once you install it, you can simply say "use your tmux-cli skill to get help from Codex running in tmux pane 3".
684
+
685
+ For detailed instructions, see [docs/tmux-cli-instructions.md](docs/tmux-cli-instructions.md) and [Claude Code tmux tutorials](docs/claude-code-tmux-tutorials.md).
686
+
687
+ All of this assumes you're familiar and comfortable with tmux, and (like me) run
688
+ all CLI coding sessions inside tmux sessions.
689
+
690
+
691
+ ## What Claude Code Can Do With tmux-cli
692
+
693
+ 1. **Test Interactive Scripts** - CC can run and interact with scripts that
694
+ require user input, answering prompts automatically based on your instructions.
695
+
696
+ 2. **UI Development & Testing** - CC can launch web servers and coordinate with
697
+ browser automation tools to test your applications.
698
+
699
+ 3. **Interactive Debugging** - CC can use debuggers (pdb, node inspect, gdb) to
700
+ step through code, examine variables, and help you understand program flow.
701
+
702
+ 4. **Claude-to-Claude Communication** - CC can launch another Claude Code instance
703
+ to get specialized help or code reviews.
704
+
705
+
706
+ Claude Code can find out how to use tmux-cli through its built-in help.
707
+ You just describe what you want, and CC handles the technical details.
708
+
709
+ For complete command reference, see [docs/tmux-cli-instructions.md](docs/tmux-cli-instructions.md).
710
+
711
+
712
+
713
+ <a id="lmsh-experimental"></a>
714
+ # 🚀 lmsh (Experimental)
715
+
716
+ Natural language shell - type what you want in plain English, get an editable command.
717
+
718
+ ```bash
719
+ # Direct usage - translate, edit, execute, then enter interactive mode
720
+ $ lmsh "show me all python files modified today"
721
+ find . -name "*.py" -mtime 0 # <-- Edit before running
722
+
723
+ # Or interactive mode
724
+ $ lmsh
725
+ lmsh> show recent docker containers
726
+ docker ps -n 5 # <-- Edit before running
727
+ ```
728
+
729
+ **Features:**
730
+ - Rust-based for instant startup (<1ms binary load time)
731
+ - Translates natural language to shell commands using Claude Code CLI
732
+ - Commands are editable before execution - full control
733
+ - Preserves your shell environment
734
+
735
+ **Note:** Requires Claude Code CLI (`claude` command) to be installed. The translation adds ~2-3s due to Claude Code CLI startup.
736
+
737
+ **Installation:**
738
+ ```bash
739
+ # Install from crates.io (easiest, requires Rust)
740
+ cargo install lmsh
741
+
742
+ # Or build from source
743
+ cd lmsh && cargo build --release
744
+ cp target/release/lmsh ~/.cargo/bin/
745
+ # Or: make lmsh-install
746
+ ```
747
+
748
+ See [docs/lmsh.md](docs/lmsh.md) for details.
749
+
750
+ <a id="status-line"></a>
751
+ ## 📊 Status Line
752
+
753
+ A custom status line script for Claude Code is available at
754
+ [`scripts/statusline.sh`](scripts/statusline.sh). It displays model name,
755
+ project directory, git branch, git status indicators, and a context window
756
+ progress bar that changes color as you approach the limit.
757
+
758
+ ![green](demos/statusline-green.png)
759
+ ![yellow](demos/statusline-yellow.png)
760
+ ![orange](demos/statusline-orange.png)
761
+ ![red](demos/statusline-red.png)
762
+
763
+ To use it, copy the script and configure Claude Code:
764
+
765
+ ```bash
766
+ cp scripts/statusline.sh ~/.claude/
767
+ chmod +x ~/.claude/statusline.sh
768
+ ```
769
+
770
+ Add to `~/.claude/settings.json`:
771
+
772
+ ```json
773
+ {
774
+ "statusLine": {
775
+ "type": "command",
776
+ "command": "~/.claude/statusline.sh"
777
+ }
778
+ }
779
+ ```
780
+
781
+ Requires `jq` and a [Nerd Font](https://www.nerdfonts.com/) for powerline symbols.
782
+
783
+ <a id="vault"></a>
784
+ # 🔐 vault
785
+
786
+ Centralized encrypted backup for .env files across all your projects using SOPS.
787
+
788
+ ```bash
789
+ vault sync # Smart sync (auto-detect direction)
790
+ vault encrypt # Backup .env to ~/Git/dotenvs/
791
+ vault decrypt # Restore .env from centralized vault
792
+ vault list # Show all project backups
793
+ vault status # Check sync status for current project
794
+ ```
795
+
796
+ ### Key Features
797
+
798
+ - Stores all encrypted .env files in `~/Git/dotenvs/`
799
+ - Automatic sync direction detection
800
+ - GPG encryption via SOPS
801
+ - Timestamped backups for safety
802
+
803
+ For detailed documentation, see [docs/vault-documentation.md](docs/vault-documentation.md).
804
+
805
+ <a id="env-safe"></a>
806
+ # 🔍 env-safe
807
+
808
+ Safely inspect .env files without exposing sensitive values. Designed for Claude Code and other automated tools that need to work with environment files without accidentally leaking secrets.
809
+
810
+ ```bash
811
+ env-safe list # List all environment variable keys
812
+ env-safe list --status # Show keys with defined/empty status
813
+ env-safe check API_KEY # Check if a specific key exists
814
+ env-safe count # Count total, defined, and empty variables
815
+ env-safe validate # Validate .env file syntax
816
+ env-safe --help # See all options
817
+ ```
818
+
819
+ ### Key Features
820
+
821
+ - **No Value Exposure** - Never displays actual environment values
822
+ - **Safe Inspection** - Check which keys exist without security risks
823
+ - **Syntax Validation** - Verify .env file format is correct
824
+ - **Status Checking** - See which variables are defined vs empty
825
+ - **Claude Code Integration** - Works with protection hooks to provide safe alternative
826
+
827
+ ### Why env-safe?
828
+
829
+ The [`safety-hooks` plugin](#claude-code-safety-hooks) in this repo blocks Claude Code from directly accessing .env files — no reading, writing, or editing allowed. This prevents both accidental exposure of API keys and unintended modifications. The `env-safe` command provides the only approved way for Claude Code to inspect environment configuration safely, while any modifications must be done manually outside of Claude Code.
830
+
831
+
832
+ <a id="claude-code-safety-hooks"></a>
833
+ # 🛡️ Claude Code Safety Hooks
834
+
835
+ This repository includes a comprehensive set of safety hooks that enhance Claude
836
+ Code's behavior and prevent dangerous operations.
837
+
838
+ ### Key Safety Features
839
+
840
+ - **File Deletion Protection** - Blocks `rm` commands, enforces TRASH directory
841
+ pattern
842
+ - **Git Commit Protection** - Requires user approval before any git commit
843
+ (uses Claude Code's permission prompt UI)
844
+ - **Git Add Protection** - Smart staging control:
845
+ - Hard blocks: `git add .`, `git add ../`, `git add *`, `git add -A/--all`
846
+ - New files: Allowed without permission
847
+ - Modified files: Requires user approval (permission prompt)
848
+ - Directories: Uses dry-run to detect files, asks permission if modified files
849
+ - **Environment Security** - Blocks all .env file operations (read/write/edit),
850
+ suggests `env-safe` command for safe inspection
851
+ - **Context Management** - Blocks reading files >500 lines to prevent context
852
+ bloat
853
+ - **Command Enhancement** - Enforces ripgrep (`rg`) over grep for better
854
+ performance
855
+
856
+ ### Installation
857
+
858
+ Install the `safety-hooks` plugin as described in
859
+ [Claude Code Plugins](#claude-code-plugins).
860
+
861
+ ### Available Hooks
862
+
863
+ - `bash_hook.py` - Main hook that orchestrates all bash command checks
864
+ - `git_commit_block_hook.py` - User permission prompt for git commits
865
+ - `git_add_block_hook.py` - Smart staging: blocks dangerous patterns, prompts
866
+ for modified files
867
+ - `env_file_protection_hook.py` - Blocks all .env file operations
868
+ - `file_size_conditional_hook.py` - Prevents reading huge files
869
+ - `grep_block_hook.py` - Enforces ripgrep usage
870
+ - `notification_hook.sh` - Sends ntfy.sh notifications
871
+
872
+ For complete documentation, see [hooks/README.md](hooks/README.md).
873
+
874
+ <a id="using-claude-code-with-open-weight-anthropic-api-compatible-llm-providers"></a>
875
+ ## 🤖 Using Claude Code with Open-weight Anthropic API-compatible LLM Providers
876
+
877
+ You can use Claude Code with alternative LLMs served via Anthropic-compatible
878
+ APIs, e.g. Kimi-k2, GLM4.5 (from zai), Deepseek-v3.1, [MiniMax-M2.1](https://platform.minimax.io/docs/guides/text-ai-coding-tools).
879
+ Add these functions to your shell config (.bashrc/.zshrc):
880
+
881
+ ```bash
882
+ kimi() {
883
+ (
884
+ export ANTHROPIC_BASE_URL=https://api.moonshot.ai/anthropic
885
+ export ANTHROPIC_AUTH_TOKEN=$KIMI_API_KEY
886
+ claude "$@"
887
+ )
888
+ }
889
+
890
+ zai() {
891
+ (
892
+ export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
893
+ export ANTHROPIC_AUTH_TOKEN=$Z_API_KEY
894
+ claude "$@"
895
+ )
896
+ }
897
+
898
+ dseek() {
899
+ (
900
+ export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
901
+ export ANTHROPIC_AUTH_TOKEN=${DEEPSEEK_API_KEY}
902
+ export ANTHROPIC_MODEL=deepseek-chat
903
+ export ANTHROPIC_SMALL_FAST_MODEL=deepseek-chat
904
+ claude "$@"
905
+ )
906
+ }
907
+
908
+ ccmm() {
909
+ (
910
+ export ANTHROPIC_BASE_URL=https://api.minimax.io/anthropic
911
+ export ANTHROPIC_AUTH_TOKEN=$MINIMAX_API_KEY
912
+ export API_TIMEOUT_MS=3000000
913
+ export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
914
+ export ANTHROPIC_MODEL=MiniMax-M2.1
915
+ export ANTHROPIC_SMALL_FAST_MODEL=MiniMax-M2.1
916
+ export ANTHROPIC_DEFAULT_SONNET_MODEL=MiniMax-M2.1
917
+ export ANTHROPIC_DEFAULT_OPUS_MODEL=MiniMax-M2.1
918
+ export ANTHROPIC_DEFAULT_HAIKU_MODEL=MiniMax-M2.1
919
+ claude "$@"
920
+ )
921
+ }
922
+ ```
923
+
924
+ After adding these functions:
925
+ - Set your API keys: `export KIMI_API_KEY=your-kimi-key`,
926
+ `export Z_API_KEY=your-z-key`, `export DEEPSEEK_API_KEY=your-deepseek-key`,
927
+ `export MINIMAX_API_KEY=your-minimax-key`
928
+ - Run `kimi` to use Claude Code with the Kimi K2 LLM
929
+ - Run `zai` to use Claude Code with the GLM-4.5 model
930
+ - Run `dseek` to use Claude Code with the DeepSeek model
931
+ - Run `ccmm` to use Claude Code with the MiniMax M2.1 model
932
+
933
+ The functions use subshells to ensure the environment variables don't affect
934
+ your main shell session, so you could be running multiple instances of Claude Code,
935
+ each using a different LLM.
936
+
937
+ ### Using Claude Code and Codex with Local LLMs
938
+
939
+ You can run **Claude Code** and **OpenAI Codex CLI** with local models using
940
+ [llama.cpp](https://github.com/ggml-org/llama.cpp)'s server for fully offline usage.
941
+
942
+ - **Claude Code** uses the Anthropic-compatible `/v1/messages` endpoint with models
943
+ like GPT-OSS-20B, Qwen3-Coder-30B, Qwen3-Next-80B, and Nemotron-3-Nano
944
+ - **Codex CLI** uses the OpenAI-compatible `/v1/chat/completions` endpoint with GPT-OSS
945
+
946
+ For complete setup instructions including llama-server commands, config files, and
947
+ command-line options for switching models, see
948
+ **[docs/local-llm-setup.md](docs/local-llm-setup.md)**.
949
+
950
+ <a id="google-docs-tools"></a>
951
+ ## 📝 Google Docs Tools (md2gdoc, gdoc2md)
952
+
953
+ I work in Markdown but often need to collaborate with teammates via Google Docs.
954
+ The problem: uploading a Markdown file to Google Drive with proper formatting
955
+ is a pain. You have to:
956
+
957
+ 1. Upload the `.md` file to Google Drive
958
+ 2. Click "Open in Google Docs" to trigger conversion
959
+ 3. This creates a *new* document with proper formatting
960
+ 4. Delete the original raw `.md` file
961
+ 5. Rename the new document
962
+
963
+ `md2gdoc` reduces this to one command. `gdoc2md` does the reverse.
964
+
965
+ ### Installation
966
+
967
+ These tools require additional dependencies. Install with the `gdocs` extra:
968
+
969
+ ```bash
970
+ uv tool install 'claude-code-tools[gdocs]'
971
+ ```
972
+
973
+ ### First-Time Setup (One-Time)
974
+
975
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
976
+ 2. Create/select a project and enable the **Google Drive API**
977
+ 3. Go to **APIs & Services** → **Credentials** → **Create Credentials** →
978
+ **OAuth client ID**
979
+ 4. Choose **Desktop app**, then download the JSON file
980
+ 5. Save it as `.gdoc-credentials.json` in your project directory
981
+ 6. First run will open browser for OAuth consent (one-time per project)
982
+
983
+ Credentials are project-specific (`.gdoc-credentials.json` and `.gdoc-token.json`
984
+ in the current directory), so different projects can use different Google
985
+ accounts.
986
+
987
+ ### md2gdoc — Markdown to Google Docs
988
+
989
+ Upload Markdown files as native Google Docs:
990
+
991
+ ```bash
992
+ md2gdoc report.md # Upload to root of Drive
993
+ md2gdoc report.md --folder "Perf/Reports" # Upload to specific folder
994
+ md2gdoc report.md --name "Q4 Summary" # Upload with custom name
995
+ ```
996
+
997
+ If a file with the same name exists, `--on-existing` controls behavior:
998
+ - `ask` (default): prompt for action
999
+ - `version`: auto-add suffix (`report-1`, `report-2`, etc.)
1000
+ - `overwrite`: replace existing file
1001
+
1002
+ Features:
1003
+
1004
+ - Native markdown conversion (same quality as manual upload + "Open in Docs")
1005
+ - Follows Drive shortcuts to shared folders
1006
+ - Conflict detection with version suffix or overwrite options
1007
+ - Creates folders if they don't exist
1008
+
1009
+ ### gdoc2md — Google Docs to Markdown
1010
+
1011
+ Download Google Docs as Markdown files:
1012
+
1013
+ ```bash
1014
+ gdoc2md "My Document" # Download from root
1015
+ gdoc2md "My Document" --folder "PNL/Reports" # Download from folder
1016
+ gdoc2md "My Document" -o report.md # Save with custom name
1017
+ gdoc2md --list --folder PNL # List docs in folder
1018
+ ```
1019
+
1020
+ <a id="development"></a>
1021
+ ## 🛠️ Development
1022
+
1023
+ ### Architecture
1024
+
1025
+ The `aichat` command has three layers:
1026
+
1027
+ - **Python** (`claude_code_tools/`) - CLI entry points, backend logic, session parsing
1028
+ - **Rust** (`rust-search-ui/`) - Search TUI with Tantivy full-text search
1029
+ - **Node.js** (`node_ui/`) - Action menus (resume, export, trim, etc.)
1030
+
1031
+ Flow: Python CLI (`aichat search`) invokes Rust binary → Rust TUI for search →
1032
+ user selects session → hands off to Node.js menus → menus call Python backend.
1033
+
1034
+ ### Prerequisites
1035
+
1036
+ - **UV** - `curl -LsSf https://astral.sh/uv/install.sh | sh`
1037
+ - **Rust/Cargo** - `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
1038
+ - **Node.js 16+** - Required for action menus
1039
+
1040
+ ### Setup
1041
+
1042
+ ```bash
1043
+ git clone https://github.com/pchalasani/claude-code-tools
1044
+ cd claude-code-tools
1045
+ uv venv --python 3.11
1046
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
1047
+ uv sync
1048
+ cd node_ui && npm install && cd ..
1049
+ make install # Python (editable mode)
1050
+ make aichat-search-install # Rust binary
1051
+ ```
1052
+
1053
+ ### Testing Changes
1054
+
1055
+ - **Python**: No action needed (editable mode - changes apply immediately)
1056
+ - **Node.js**: No action needed (runs directly from `node_ui/`)
1057
+ - **Rust**: Run `make aichat-search-install` to rebuild and install
1058
+
1059
+ ### Publishing (Python Package)
1060
+
1061
+ For releasing to PyPI:
1062
+
1063
+ ```bash
1064
+ make all-patch # Bump patch, push, GitHub release, build
1065
+ make all-minor # Bump minor, push, GitHub release, build
1066
+ make all-major # Bump major, push, GitHub release, build
1067
+ uv publish # Publish to PyPI (after any of the above)
1068
+ ```
1069
+
1070
+ These commands automatically:
1071
+
1072
+ 1. Run `make prep-node` to ensure `node_ui/node_modules/` is up-to-date
1073
+ 2. Bump version → push to GitHub → create GitHub release
1074
+ 3. Build package (includes `node_modules/` so users don't need `npm install`)
1075
+
1076
+ Then run `uv publish` to upload to PyPI.
1077
+
1078
+ **Note:** Users need Node.js 16+ installed to run `aichat` action menus, but
1079
+ they do NOT need npm — the package includes pre-installed dependencies.
1080
+
1081
+ ### Publishing (Rust Binaries)
1082
+
1083
+ ```bash
1084
+ make aichat-search-publish # Bump version and publish to crates.io
1085
+ make lmsh-publish # Bump version and publish to crates.io
1086
+ ```
1087
+
1088
+ ### Contributing
1089
+
1090
+ 1. Fork the repository
1091
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
1092
+ 3. Make your changes
1093
+ 4. Test thoroughly
1094
+ 5. Commit your changes
1095
+ 6. Push to your fork
1096
+ 7. Open a Pull Request
1097
+
1098
+ ### Available Make Commands
1099
+
1100
+ Run `make help` for full list. Key commands:
1101
+
1102
+ | Command | Description |
1103
+ |---------|-------------|
1104
+ | `make install` | Install Python in editable mode |
1105
+ | `make aichat-search-install` | Build and install Rust binary |
1106
+ | `make prep-node` | Install node_modules (auto-runs before publish) |
1107
+ | `make all-patch/minor/major` | Bump + push + build (for PyPI) |
1108
+ | `make aichat-search-publish` | Publish Rust binary to crates.io |
1109
+
1110
+ <a id="license"></a>
1111
+ ## 📄 License
1112
+
1113
+ MIT