thought-cabinet 0.0.4 → 0.1.0

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.
package/README.md CHANGED
@@ -1,18 +1,56 @@
1
1
  # Thought Cabinet
2
2
 
3
- A CLI tool for managing developer thoughts and notes across multiple repositories.
3
+ A CLI tool that integrates AI coding agents into structured development workflows through filesystem-based memory and context management.
4
4
 
5
- ## Overview
5
+ ## Why Thought Cabinet?
6
6
 
7
- Thought Cabinet provides a systematic way to organize and version-control your development notes, decisions, and ideas. It synchronizes thoughts across a dedicated git repository while keeping them separate from your code repositories.
7
+ AI coding agents like Claude Code are powerful but face key challenges:
8
8
 
9
- ## Features
9
+ - **Context limits**: Large codebases exceed model context windows
10
+ - **No persistent memory**: Agents forget learnings between sessions
11
+ - **Unstructured work**: Complex tasks benefit from planning before implementation
12
+ - **Isolation**: AI-generated knowledge isn't easily shared with teams
10
13
 
11
- - **Multi-repository support**: Manage thoughts for multiple projects from a single thoughts repository
12
- - **Profile support**: Use different thoughts repositories for different contexts (e.g., work, personal)
13
- - **Git integration**: Automatic git hooks prevent accidental commits and auto-sync thoughts
14
- - **Searchable index**: Hard links enable fast searching across all thoughts
15
- - **User separation**: Personal and shared thought spaces for team collaboration
14
+ Thought Cabinet solves these by providing:
15
+
16
+ - **Context offloading**: Research and plans are saved to disk, freeing model context
17
+ - **Filesystem memory**: Version-controlled thoughts persist across sessions
18
+ - **Structured workflows**: Slash commands guide agents through research plan → implement → validate
19
+ - **Team sharing**: Thoughts sync via git, enabling knowledge sharing
20
+
21
+ ## Core Concepts
22
+
23
+ ### Thoughts as Memory
24
+
25
+ The `thoughts/` directory is a filesystem-based memory system for AI agents:
26
+
27
+ ```
28
+ thoughts/
29
+ ├── {user}/ → Personal notes (your learnings, scratchpad)
30
+ ├── shared/ → Team-shared knowledge
31
+ │ ├── research/ → Codebase research documents
32
+ │ └── plans/ → Implementation plans
33
+ └── global/ → Cross-repository thoughts
34
+ ```
35
+
36
+ All thoughts are version-controlled via a dedicated git repository, separate from your code.
37
+
38
+ ### Structured Workflows
39
+
40
+ Instead of asking an AI to "implement feature X" directly, Thought Cabinet encourages a disciplined workflow:
41
+
42
+ 1. **Research** → Understand the codebase deeply
43
+ 2. **Plan** → Design the implementation with explicit phases
44
+ 3. **Implement** → Execute the plan systematically
45
+ 4. **Validate** → Verify against success criteria
46
+
47
+ ### Worktree Isolation
48
+
49
+ Each feature gets its own git worktree with a dedicated tmux session, enabling:
50
+
51
+ - Parallel development on multiple features
52
+ - Clean separation between research (main branch) and implementation (worktree)
53
+ - Easy cleanup and merge when done
16
54
 
17
55
  ## Installation
18
56
 
@@ -20,126 +58,320 @@ Thought Cabinet provides a systematic way to organize and version-control your d
20
58
  npm install -g thought-cabinet
21
59
  ```
22
60
 
23
- ## Quick Start
61
+ ## Claude Code Integration
24
62
 
25
- ### Initialize thoughts for a repository
63
+ Thought Cabinet provides slash commands, agents, and skills that integrate with Claude Code. Install them via `thc agent init`.
64
+
65
+ ### Installing Agent Configuration
26
66
 
27
67
  ```bash
28
68
  cd your-project
29
- thoughtcabinet init
69
+ thc agent init
70
+ ```
71
+
72
+ This interactively installs to `.claude/`:
73
+ - **Commands** - Slash commands for workflow phases (`/research_codebase`, `/create_plan`, etc.)
74
+ - **Agents** - Specialized sub-agents for code analysis and research
75
+ - **Skills** - Extended capabilities like document generation
76
+ - **Settings** - Project permissions and configuration
77
+
78
+ Options:
79
+ ```bash
80
+ thc agent init --all # Copy all files without prompting
81
+ thc agent init --force # Overwrite existing .claude directory
82
+ thc agent init --name codebuddy # Use alternative agent (codebuddy)
83
+ ```
84
+
85
+ ### Slash Commands
86
+
87
+ These commands guide the AI through each phase of development:
88
+
89
+ | Command | Purpose |
90
+ |---------|---------|
91
+ | `/research_codebase` | Deep-dive into codebase, save findings to `thoughts/shared/research/` |
92
+ | `/create_plan` | Create implementation plan with phases and success criteria |
93
+ | `/iterate_plan` | Refine existing plans based on feedback |
94
+ | `/implement_plan` | Execute plan phase-by-phase with verification |
95
+ | `/validate_plan` | Verify implementation against plan's success criteria |
96
+
97
+ ### Context Offloading
98
+
99
+ AI agents have limited context windows. Thought Cabinet offloads context to the filesystem:
100
+
101
+ ```
102
+ ┌─────────────────┐ ┌─────────────────────────────┐
103
+ │ Model Context │ │ filesystem (thoughts/) │
104
+ ├─────────────────┤ ├─────────────────────────────┤
105
+ │ Current task │ ←── │ research/auth-system.md │
106
+ │ Active code │ │ plans/add-oauth.md │
107
+ │ Recent changes │ │ previous session learnings │
108
+ └─────────────────┘ └─────────────────────────────┘
30
109
  ```
31
110
 
32
- This will:
111
+ - `/research_codebase` writes comprehensive analysis to disk, then only the relevant sections are read when needed
112
+ - `/create_plan` produces detailed plans that persist across sessions
113
+ - The AI can reference previous research without re-exploring the entire codebase
33
114
 
34
- 1. Set up a global thoughts repository (default: `~/thoughts`)
35
- 2. Create directory structure for this project
36
- 3. Install git hooks for protection and auto-sync
37
- 4. Create symlinks in `thoughts/` directory
115
+ ### Filesystem-Based Memory
38
116
 
39
- ### Sync thoughts manually
117
+ Unlike conversation history that disappears, thoughts persist:
40
118
 
41
119
  ```bash
42
- thoughtcabinet sync
120
+ # Research from last week is still available
121
+ cat thoughts/shared/research/2024-01-05-payment-system.md
122
+
123
+ # Plans from past features inform new ones
124
+ ls thoughts/shared/plans/
125
+
126
+ # Personal learnings accumulate
127
+ cat thoughts/yourusername/gotchas.md
43
128
  ```
44
129
 
45
- ### Check status
130
+ All thoughts are git-tracked, so you can:
131
+ - Share knowledge with team members via `thc sync`
132
+ - See how understanding evolved over time
133
+ - Recover context even after months
134
+
135
+ ## The Worktree + tmux + Parallel Workflow
136
+
137
+ For complex features, Thought Cabinet enables a powerful parallel workflow:
138
+
139
+ ### Phase 1: Research & Planning (Main Branch)
46
140
 
47
141
  ```bash
48
- thoughtcabinet status
142
+ # In your main branch, start Claude Code
143
+ cd your-project
144
+ claude
145
+
146
+ # Research the codebase
147
+ > /research_codebase
148
+ > How does the authentication system work?
149
+
150
+ # Create an implementation plan
151
+ > /create_plan
152
+ > Add OAuth2 support based on the research
153
+
154
+ # Iterate until the plan is solid
155
+ > /iterate_plan thoughts/shared/plans/add-oauth.md
49
156
  ```
50
157
 
51
- ## Directory Structure
158
+ ### Phase 2: Create Worktree
52
159
 
53
- After initialization, your repository will have:
160
+ ```bash
161
+ # Create isolated worktree with tmux session
162
+ thc worktree add add-oauth
54
163
 
164
+ # This creates:
165
+ # - New git worktree at ../your-project-add-oauth/
166
+ # - Dedicated tmux session (thc-add-oauth)
167
+ # - Thoughts initialized and synced in worktree
55
168
  ```
56
- your-project/
57
- └── thoughts/
58
- ├── yourusername/ → Your personal notes for this project
59
- ├── shared/ → Team-shared notes for this project
60
- ├── global/ → Cross-project thoughts
61
- │ ├── yourusername/ - Your personal cross-repo notes
62
- │ └── shared/ - Team cross-repo notes
63
- └── searchable/ → Hard links for searching
169
+
170
+ ### Phase 3: Parallel Implementation (Worktree)
171
+
172
+ In the worktree's tmux session:
173
+
174
+ ```bash
175
+ # Start Claude Code in the worktree
176
+ claude
177
+
178
+ # Implement the plan (the plan persists from main branch!)
179
+ > /implement_plan thoughts/shared/plans/add-oauth.md
180
+
181
+ # Validate against success criteria
182
+ > /validate_plan thoughts/shared/plans/add-oauth.md
64
183
  ```
65
184
 
66
- ## Commands
185
+ **Parallel work**: While implementation runs, you can continue other work in the main branch. Multiple worktrees can run simultaneously.
67
186
 
68
- ### Basic Commands
187
+ ### Phase 4: Merge & Cleanup
69
188
 
70
- - `thoughtcabinet init` - Initialize thoughts for current repository
71
- - `thoughtcabinet sync` - Manually sync thoughts to repository
72
- - `thoughtcabinet status` - Show status of thoughts repository
73
- - `thoughtcabinet config` - View or edit configuration
74
- - `thoughtcabinet destroy` - Remove thoughts setup from current repository
189
+ ```bash
190
+ # Back in main branch
191
+ thc worktree merge add-oauth
192
+
193
+ # This:
194
+ # - Rebases the feature branch
195
+ # - Fast-forward merges to target
196
+ # - Cleans up worktree and tmux session
197
+ # - Syncs thoughts
198
+ ```
75
199
 
76
- ### Profile Commands
200
+ ### Workflow Diagram
77
201
 
78
- Profiles allow you to use different thoughts repositories for different contexts:
202
+ ```
203
+ Main Branch Worktree (parallel)
204
+
205
+ ├── /research_codebase
206
+ │ └── writes to thoughts/shared/research/
207
+
208
+ ├── /create_plan
209
+ │ └── writes to thoughts/shared/plans/
210
+
211
+ ├── /iterate_plan (until ready)
212
+
213
+ ├── thc worktree add ──────────────────┐
214
+ │ │
215
+ │ (continue other work here) ├── /implement_plan
216
+ │ │ └── reads plan, writes code
217
+ │ │
218
+ │ ├── /validate_plan
219
+ │ │ └── verifies success criteria
220
+ │ │
221
+ ├── thc worktree merge ←───────────────┘
222
+
223
+
224
+ ```
79
225
 
80
- - `thoughtcabinet profile create <name>` - Create a new profile
81
- - `thoughtcabinet profile list` - List all profiles
82
- - `thoughtcabinet profile show <name>` - Show profile details
83
- - `thoughtcabinet profile delete <name>` - Delete a profile
226
+ ## Quick Start
84
227
 
85
- Use a profile with:
228
+ ### Initialize Thoughts
86
229
 
87
230
  ```bash
88
- thoughtcabinet init --profile work
231
+ cd your-project
232
+ thc init
89
233
  ```
90
234
 
91
- ## Configuration
235
+ This sets up:
236
+ - A global thoughts repository (default: `~/thoughts`)
237
+ - Directory structure for this project
238
+ - Git hooks for protection and auto-sync
239
+ - Symlinks in `thoughts/` directory
92
240
 
93
- Configuration is stored in `~/.config/thought-cabinet/config.json`.
241
+ ### Basic Usage
94
242
 
95
- View configuration:
243
+ ```bash
244
+ # Edit thoughts directly
245
+ vim thoughts/yourusername/notes.md
246
+
247
+ # Sync changes
248
+ thc sync
249
+
250
+ # Check status
251
+ thc status
252
+ ```
253
+
254
+ ### Worktree Commands
96
255
 
97
256
  ```bash
98
- thoughtcabinet config
257
+ # Create worktree with tmux session
258
+ thc worktree add feature-name
259
+
260
+ # List active worktrees
261
+ thc worktree list
262
+
263
+ # Merge and cleanup
264
+ thc worktree merge feature-name
99
265
  ```
100
266
 
101
- Edit configuration:
267
+ ## CLI Commands
268
+
269
+ ### Agent Configuration
102
270
 
103
271
  ```bash
104
- thoughtcabinet config --edit
272
+ thc agent init # Install Claude Code slash commands, agents, and skills
273
+ thc agent init --all # Install all without prompting
274
+ thc agent init --force # Overwrite existing configuration
105
275
  ```
106
276
 
107
- ## Git Hooks
277
+ ### Thoughts Management
108
278
 
109
- Thought Cabinet installs two git hooks:
279
+ ```bash
280
+ thc init # Initialize thoughts for current repository
281
+ thc sync # Sync thoughts to repository
282
+ thc status # Show status of thoughts repository
283
+ thc destroy # Remove thoughts setup from repository
284
+ thc prune # Clean up stale repository mappings
285
+ ```
110
286
 
111
- 1. **pre-commit**: Prevents accidental commits of the `thoughts/` directory
112
- 2. **post-commit**: Auto-syncs thoughts after each code commit
287
+ ### Worktree Management
113
288
 
114
- ## Searching Thoughts
289
+ ```bash
290
+ thc worktree add <name> # Create worktree + tmux session
291
+ thc worktree list # List worktrees and sessions
292
+ thc worktree merge <name> # Merge and cleanup worktree
293
+ ```
115
294
 
116
- The `thoughts/searchable/` directory contains hard links to all accessible thought files. This allows search tools to find content without following symlinks:
295
+ ### Profiles
296
+
297
+ Use different thoughts repositories for different contexts (work, personal):
117
298
 
118
299
  ```bash
119
- cd your-project
120
- grep -r "TODO" thoughts/searchable/
300
+ thc profile create <name> # Create a new profile
301
+ thc profile list # List all profiles
302
+ thc init --profile work # Initialize with specific profile
121
303
  ```
122
304
 
123
- **Important**: Always reference files by their canonical path (e.g., `thoughts/yourusername/todo.md`) rather than the searchable path.
305
+ ### Configuration
124
306
 
125
- ## Best Practices
307
+ ```bash
308
+ thc config # View configuration
309
+ thc config --edit # Edit configuration
310
+ ```
311
+
312
+ Configuration is stored in `~/.config/thought-cabinet/config.json`.
313
+
314
+ ## Hooks
126
315
 
127
- 1. Use `yourusername/` for personal, repository-specific notes
128
- 2. Use `shared/` for team documentation that should be version-controlled
129
- 3. Use `global/yourusername/` for cross-repository personal notes
130
- 4. Use `global/shared/` for cross-repository team documentation
131
- 5. Run `thoughtcabinet sync` before sharing important updates
132
- 6. Never commit the `thoughts/` directory to your code repository
316
+ ### Custom Hooks
133
317
 
134
- ## Migration from hlyr
318
+ Configure hooks in `.thought-cabinet/hooks.json` to run commands on events:
135
319
 
136
- If you're migrating from the hlyr thoughts system:
320
+ ```json
321
+ {
322
+ "hooks": {
323
+ "PostWorktreeAdd": [
324
+ {
325
+ "hooks": [
326
+ { "type": "command", "command": "npm install", "timeout": 300 }
327
+ ]
328
+ }
329
+ ]
330
+ }
331
+ }
332
+ ```
333
+
334
+ **Available events:**
335
+ - `PreWorktreeAdd`, `PostWorktreeAdd` - Worktree creation
336
+ - `PreWorktreeMerge`, `PostWorktreeMerge` - Worktree merge
337
+ - `PostThoughtsInit`, `PostThoughtsDestroy`, `PostThoughtsSync` - Thoughts lifecycle
338
+
339
+ ### Git Hooks
137
340
 
138
- 1. The configuration format is compatible
139
- 2. Your existing thoughts repository will work as-is
140
- 3. Run `thoughtcabinet init` in your repositories
141
- 4. Old git hooks will be automatically updated
341
+ Automatically installed git hooks:
342
+ - **pre-commit**: Prevents accidental commits of `thoughts/` directory
343
+ - **post-commit**: Auto-syncs thoughts after each commit
344
+
345
+ ## Directory Structure
346
+
347
+ ```
348
+ your-project/
349
+ └── thoughts/
350
+ ├── yourusername/ → Personal notes for this project
351
+ ├── shared/ → Team-shared notes
352
+ │ ├── research/ → Codebase research documents
353
+ │ └── plans/ → Implementation plans
354
+ ├── global/ → Cross-project thoughts
355
+ └── searchable/ → Hard links for grep/ripgrep
356
+ ```
357
+
358
+ ## Best Practices
359
+
360
+ **For AI-assisted development:**
361
+ - Always run `/research_codebase` before planning complex features
362
+ - Use `/create_plan` to make implementation explicit and verifiable
363
+ - Implement in worktrees for maximum throughput
364
+ - Run `/validate_plan` before merging to catch deviations
365
+
366
+ **General tips:**
367
+ - Run `thc sync` frequently to share knowledge
368
+ - Use `thc prune` to clean up stale mappings
142
369
 
143
370
  ## License
144
371
 
145
372
  Apache-2.0
373
+
374
+ ## Credits
375
+
376
+ - the name "Thought Cabinet" is from CRPG [Disco Elysium](https://en.wikipedia.org/wiki/Disco_Elysium) created by Robert Kurvitz, Aleksander Rostov, Helen Hindpere and others
377
+ - the thoughts system is based on [humanlayer](https://github.com/humanlayer/humanlayer)