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