@asifkibria/claude-code-toolkit 1.0.1 → 1.0.7
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 +482 -150
- package/dist/__tests__/scanner.test.js +450 -18
- package/dist/__tests__/scanner.test.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +216 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +432 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/scanner.d.ts +194 -6
- package/dist/lib/scanner.d.ts.map +1 -1
- package/dist/lib/scanner.js +1339 -54
- package/dist/lib/scanner.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,73 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@asifkibria/claude-code-toolkit)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/asifkibria/claude-code-toolkit)
|
|
6
6
|
|
|
7
7
|
A comprehensive MCP server and CLI toolkit for maintaining, optimizing, and troubleshooting your Claude Code installation.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## The Problem This Solves
|
|
10
10
|
|
|
11
|
-
Claude Code
|
|
11
|
+
When you upload an oversized image, PDF, or document to Claude Code, it gets base64-encoded into your conversation history. That corrupted data then gets sent with **every future request**, causing API errors like:
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- **Become opaque** - Hard to understand what's using space
|
|
13
|
+
- `API Error: 400 - image dimensions exceed max allowed size`
|
|
14
|
+
- `PDF too large. Try reading the file a different way...`
|
|
15
|
+
- Various timeout and context errors
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
**The worst part?** Nothing works anymore. Not your next message. Not `/compact`. Your entire conversation is bricked.
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
The "official" fix is to clear your conversation and lose everything. This toolkit offers a better solution.
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
- Quick health checks with actionable recommendations
|
|
24
|
-
- Identify problematic files before they cause issues
|
|
25
|
-
- Track conversation sizes and growth
|
|
21
|
+
## What It Fixes
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
23
|
+
| Content Type | Detection Threshold | Replacement Message |
|
|
24
|
+
|-------------|---------------------|---------------------|
|
|
25
|
+
| Images | >100KB base64 | `[Image removed - exceeded size limit]` |
|
|
26
|
+
| PDFs | >100KB base64 | `[PDF removed - exceeded size limit]` |
|
|
27
|
+
| Documents | >100KB base64 | `[Document removed - exceeded size limit]` |
|
|
28
|
+
| Large Text | >500KB | `[Large text content removed - exceeded size limit]` |
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
- **Fix oversized images** - Resolve the infamous "image dimensions exceed max" error ([#2939](https://github.com/anthropics/claude-code/issues/2939))
|
|
34
|
-
- **Scan for issues** - Detect problems before they break your workflow
|
|
35
|
-
- **Restore from backups** - Recover when things go wrong
|
|
30
|
+
The toolkit surgically removes only the problematic content while preserving your entire conversation history, tool results, and context.
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
- Automatic backup creation before changes
|
|
39
|
-
- Clean up old backup files
|
|
40
|
-
- Free up disk space safely
|
|
32
|
+
## Quick Start
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
### Fix Your Broken Session Right Now
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
```bash
|
|
37
|
+
# Scan for issues
|
|
38
|
+
npx @asifkibria/claude-code-toolkit scan
|
|
45
39
|
|
|
46
|
-
|
|
40
|
+
# Fix them (creates backups automatically)
|
|
41
|
+
npx @asifkibria/claude-code-toolkit fix
|
|
42
|
+
```
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
# Using npx (no install needed)
|
|
50
|
-
claude mcp add --scope user toolkit -- npx -y @asifkibria/claude-code-toolkit claude-code-toolkit-server
|
|
44
|
+
Restart Claude Code. You're back.
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
### Install Globally (Recommended)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
53
49
|
npm install -g @asifkibria/claude-code-toolkit
|
|
54
|
-
|
|
50
|
+
|
|
51
|
+
# Use the short alias
|
|
52
|
+
cct health
|
|
53
|
+
cct scan
|
|
54
|
+
cct fix
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
## Installation Options
|
|
58
|
+
|
|
59
|
+
### Option 1: MCP Server (Let Claude Maintain Itself)
|
|
60
|
+
|
|
61
|
+
Add to Claude Code so you can literally ask Claude to check and fix its own issues:
|
|
58
62
|
|
|
59
63
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
claude mcp add --scope user toolkit -- npx -y @asifkibria/claude-code-toolkit claude-code-toolkit-server
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then just ask Claude:
|
|
68
|
+
- "Check your health"
|
|
69
|
+
- "Are there any issues with your conversation files?"
|
|
70
|
+
- "Fix any problems you find"
|
|
71
|
+
|
|
72
|
+
### Option 2: CLI Tool
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
```bash
|
|
75
|
+
# Global install
|
|
64
76
|
npm install -g @asifkibria/claude-code-toolkit
|
|
65
|
-
claude-code-toolkit health
|
|
66
77
|
|
|
67
|
-
#
|
|
68
|
-
|
|
78
|
+
# Or use npx (no install needed)
|
|
79
|
+
npx @asifkibria/claude-code-toolkit <command>
|
|
69
80
|
```
|
|
70
81
|
|
|
71
|
-
### From Source
|
|
82
|
+
### Option 3: From Source
|
|
72
83
|
|
|
73
84
|
```bash
|
|
74
85
|
git clone https://github.com/asifkibria/claude-code-toolkit.git
|
|
@@ -76,183 +87,504 @@ cd claude-code-toolkit
|
|
|
76
87
|
npm install && npm run build && npm test
|
|
77
88
|
```
|
|
78
89
|
|
|
79
|
-
##
|
|
90
|
+
## CLI Commands
|
|
80
91
|
|
|
81
|
-
###
|
|
92
|
+
### `cct health` - Quick Health Check
|
|
82
93
|
|
|
83
|
-
|
|
94
|
+
Start here. Shows overall status and recommendations.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
$ cct health
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
Health Check: ⚠ Issues Found
|
|
86
100
|
|
|
87
|
-
|
|
101
|
+
Conversations: 23
|
|
102
|
+
Total size: 156.2 MB
|
|
103
|
+
Backups: 5
|
|
104
|
+
Oversized content: 3
|
|
88
105
|
|
|
89
|
-
|
|
106
|
+
Largest: -Users-me-projects-myapp/abc123.jsonl
|
|
107
|
+
Size: 45.2 MB
|
|
90
108
|
|
|
91
|
-
|
|
109
|
+
Recommendation: Run 'cct fix' to fix 3 issue(s)
|
|
110
|
+
```
|
|
92
111
|
|
|
93
|
-
|
|
112
|
+
### `cct scan` - Scan for Issues (Dry Run)
|
|
94
113
|
|
|
95
|
-
|
|
114
|
+
Shows exactly what's wrong without making changes.
|
|
96
115
|
|
|
97
116
|
```bash
|
|
98
|
-
|
|
99
|
-
cct health
|
|
117
|
+
$ cct scan
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
cct stats
|
|
103
|
-
cct stats --limit 20 --sort messages
|
|
119
|
+
Scanning 23 file(s)...
|
|
104
120
|
|
|
105
|
-
|
|
106
|
-
|
|
121
|
+
-Users-me-projects-myapp/conversation1.jsonl
|
|
122
|
+
Line 142: 🖼️ image (~2.3 MB)
|
|
123
|
+
Line 856: 📄 pdf (~1.1 MB)
|
|
107
124
|
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
-Users-me-projects-another/conversation2.jsonl
|
|
126
|
+
Line 45: 📎 document (~890 KB)
|
|
127
|
+
|
|
128
|
+
Found 3 issue(s) in 2 file(s).
|
|
129
|
+
Run 'cct fix' to fix them.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `cct fix` - Fix All Issues
|
|
133
|
+
|
|
134
|
+
Removes problematic content and creates backups.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
$ cct fix
|
|
138
|
+
|
|
139
|
+
Processing 23 file(s)...
|
|
140
|
+
|
|
141
|
+
✓ -Users-me-projects-myapp/conversation1.jsonl
|
|
142
|
+
Fixed 2 issue(s)
|
|
143
|
+
Backup: conversation1.jsonl.backup.2024-01-15T10-30-00
|
|
110
144
|
|
|
111
|
-
|
|
112
|
-
|
|
145
|
+
✓ -Users-me-projects-another/conversation2.jsonl
|
|
146
|
+
Fixed 1 issue(s)
|
|
147
|
+
Backup: conversation2.jsonl.backup.2024-01-15T10-30-01
|
|
113
148
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
cct restore /path/to/backup.jsonl.backup.2024-01-01T00-00-00
|
|
117
|
-
cct cleanup --days 30 --dry-run
|
|
118
|
-
cct cleanup --days 30
|
|
149
|
+
✓ Fixed 3 issue(s) in 2 file(s).
|
|
150
|
+
Restart Claude Code to apply changes.
|
|
119
151
|
```
|
|
120
152
|
|
|
121
|
-
|
|
153
|
+
### `cct stats` - Conversation Statistics
|
|
122
154
|
|
|
123
|
-
|
|
155
|
+
See what's using space and resources.
|
|
124
156
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
| `scan_image_issues` | Scan for oversized images and other issues |
|
|
130
|
-
| `fix_image_issues` | Fix detected issues (creates backups) |
|
|
131
|
-
| `list_backups` | List all backup files with sizes and dates |
|
|
132
|
-
| `restore_backup` | Restore a conversation from backup |
|
|
133
|
-
| `cleanup_backups` | Delete old backup files to free space |
|
|
157
|
+
```bash
|
|
158
|
+
$ cct stats --limit 5 --sort size
|
|
159
|
+
|
|
160
|
+
Conversation Statistics
|
|
134
161
|
|
|
135
|
-
|
|
162
|
+
Total: 23 conversations, 156.2 MB
|
|
163
|
+
Messages: 12,456, Images: 89, Documents: 23
|
|
164
|
+
Problematic content: 3
|
|
136
165
|
|
|
137
|
-
|
|
138
|
-
| ---------------- | -------------------------------- |
|
|
139
|
-
| `health` | Quick health check |
|
|
140
|
-
| `stats` | Show conversation statistics |
|
|
141
|
-
| `scan` | Scan for issues (dry run) |
|
|
142
|
-
| `fix` | Fix all detected issues |
|
|
143
|
-
| `backups` | List backup files |
|
|
144
|
-
| `restore <path>` | Restore from backup |
|
|
145
|
-
| `cleanup` | Delete old backups |
|
|
166
|
+
Top 5 by size:
|
|
146
167
|
|
|
147
|
-
|
|
168
|
+
-Users-me-projects-myapp/abc123.jsonl
|
|
169
|
+
Size: 45.2 MB, Messages: 2,341
|
|
170
|
+
Images: 34, Documents: 12 (2 oversized)
|
|
171
|
+
Modified: 2024-01-15 10:30:00
|
|
172
|
+
...
|
|
173
|
+
```
|
|
148
174
|
|
|
149
|
-
|
|
150
|
-
| ------------------- | ---------------------------------------------- |
|
|
151
|
-
| `-f, --file <path>` | Target specific file |
|
|
152
|
-
| `-d, --dry-run` | Preview without making changes |
|
|
153
|
-
| `--no-backup` | Skip creating backups (not recommended) |
|
|
154
|
-
| `--days <n>` | For cleanup: delete backups older than n days |
|
|
155
|
-
| `--limit <n>` | For stats: limit number of results |
|
|
156
|
-
| `--sort <field>` | For stats: size, messages, images, or modified |
|
|
157
|
-
| `-h, --help` | Show help |
|
|
158
|
-
| `-v, --version` | Show version |
|
|
175
|
+
### `cct context` - Estimate Context Size
|
|
159
176
|
|
|
160
|
-
|
|
177
|
+
See how much context/tokens your conversations are using.
|
|
161
178
|
|
|
162
|
-
###
|
|
179
|
+
### `cct analytics` - Usage Analytics Dashboard
|
|
163
180
|
|
|
164
|
-
|
|
181
|
+
Get a comprehensive view of your Claude Code usage with activity trends, top projects, and tool statistics.
|
|
165
182
|
|
|
166
183
|
```bash
|
|
167
|
-
cct
|
|
168
|
-
|
|
184
|
+
$ cct analytics
|
|
185
|
+
|
|
186
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
187
|
+
║ USAGE ANALYTICS DASHBOARD ║
|
|
188
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
189
|
+
|
|
190
|
+
📊 OVERVIEW
|
|
191
|
+
──────────────────────────────────────────────────
|
|
192
|
+
Conversations: 23
|
|
193
|
+
Total Messages: 12,456
|
|
194
|
+
Total Tokens: ~2,345,678
|
|
195
|
+
Total Size: 156.2 MB
|
|
196
|
+
Active Projects: 8
|
|
197
|
+
Avg Msgs/Conv: 542
|
|
198
|
+
Avg Tokens/Conv: ~102,000
|
|
199
|
+
|
|
200
|
+
📈 ACTIVITY (Last 7 days)
|
|
201
|
+
──────────────────────────────────────────────────
|
|
202
|
+
Mon │█████████████████████████│ 234
|
|
203
|
+
Tue │████████████████░░░░░░░░░│ 156
|
|
204
|
+
Wed │██████████████████░░░░░░░│ 178
|
|
205
|
+
...
|
|
206
|
+
|
|
207
|
+
🏆 TOP PROJECTS (by messages)
|
|
208
|
+
──────────────────────────────────────────────────
|
|
209
|
+
-Users-me-myapp │███████████████│ 2,341
|
|
210
|
+
-Users-me-another-proj │████████░░░░░░░│ 1,234
|
|
211
|
+
...
|
|
212
|
+
|
|
213
|
+
🔧 TOP TOOLS
|
|
214
|
+
──────────────────────────────────────────────────
|
|
215
|
+
Read 1,234 (25%)
|
|
216
|
+
Edit 987 (20%)
|
|
217
|
+
Bash 654 (13%)
|
|
218
|
+
...
|
|
169
219
|
```
|
|
170
220
|
|
|
171
|
-
###
|
|
221
|
+
### `cct duplicates` - Find Duplicate Content
|
|
172
222
|
|
|
173
|
-
|
|
223
|
+
Scan for duplicate conversations and content (images, documents) that waste storage and context.
|
|
174
224
|
|
|
175
225
|
```bash
|
|
176
|
-
cct
|
|
226
|
+
$ cct duplicates
|
|
227
|
+
|
|
228
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
229
|
+
║ DUPLICATE DETECTION REPORT ║
|
|
230
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
231
|
+
|
|
232
|
+
📊 SUMMARY
|
|
233
|
+
──────────────────────────────────────────────────
|
|
234
|
+
Duplicate groups: 5
|
|
235
|
+
Duplicate images: 12
|
|
236
|
+
Duplicate documents: 3
|
|
237
|
+
Wasted space: 45.2 MB
|
|
238
|
+
|
|
239
|
+
📁 DUPLICATE CONVERSATIONS
|
|
240
|
+
──────────────────────────────────────────────────
|
|
241
|
+
[2 copies] Wasted: 12.5 MB
|
|
242
|
+
- -Users-me-myapp/conversation1.jsonl
|
|
243
|
+
- -Users-me-myapp-backup/conversation1.jsonl
|
|
244
|
+
|
|
245
|
+
🖼️ DUPLICATE CONTENT
|
|
246
|
+
──────────────────────────────────────────────────
|
|
247
|
+
🖼️ image [3 copies] ~2.1 MB wasted
|
|
248
|
+
- -Users-me-proj1/conv.jsonl:142
|
|
249
|
+
- -Users-me-proj1/conv.jsonl:856
|
|
250
|
+
... and 1 more locations
|
|
251
|
+
|
|
252
|
+
💡 RECOMMENDATIONS
|
|
253
|
+
──────────────────────────────────────────────────
|
|
254
|
+
- Review duplicate conversations and consider removing copies
|
|
255
|
+
- Same images appear multiple times in your conversations
|
|
177
256
|
```
|
|
178
257
|
|
|
179
|
-
###
|
|
258
|
+
### `cct archive` - Archive Old Conversations
|
|
180
259
|
|
|
181
|
-
|
|
260
|
+
Move inactive conversations to an archive directory to free up space.
|
|
182
261
|
|
|
183
262
|
```bash
|
|
184
|
-
cct
|
|
185
|
-
|
|
263
|
+
$ cct archive --days 60 --dry-run
|
|
264
|
+
|
|
265
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
266
|
+
║ CONVERSATION ARCHIVE REPORT ║
|
|
267
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
268
|
+
|
|
269
|
+
📊 SUMMARY
|
|
270
|
+
──────────────────────────────────────────────────
|
|
271
|
+
Eligible conversations: 8
|
|
272
|
+
Total size: 45.2 MB
|
|
273
|
+
|
|
274
|
+
📁 ARCHIVE CANDIDATES
|
|
275
|
+
──────────────────────────────────────────────────
|
|
276
|
+
...-Users-me-old-project/abc123.jsonl
|
|
277
|
+
65 days inactive, 234 msgs, 12.5 MB
|
|
278
|
+
...-Users-me-another-old/def456.jsonl
|
|
279
|
+
45 days inactive, 156 msgs, 8.2 MB
|
|
280
|
+
...
|
|
281
|
+
|
|
282
|
+
📋 DRY RUN - No changes made
|
|
283
|
+
──────────────────────────────────────────────────
|
|
284
|
+
Would archive: 8 conversations
|
|
285
|
+
Would free: 45.2 MB
|
|
286
|
+
Archive to: ~/.claude/archive
|
|
186
287
|
```
|
|
187
288
|
|
|
188
|
-
###
|
|
289
|
+
### `cct maintenance` - Scheduled Maintenance
|
|
290
|
+
|
|
291
|
+
Run automated maintenance checks and actions.
|
|
189
292
|
|
|
190
|
-
|
|
293
|
+
```bash
|
|
294
|
+
$ cct maintenance
|
|
295
|
+
|
|
296
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
297
|
+
║ MAINTENANCE REPORT ║
|
|
298
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
299
|
+
|
|
300
|
+
📊 STATUS
|
|
301
|
+
──────────────────────────────────────────────────
|
|
302
|
+
⚠ Needs Attention
|
|
303
|
+
|
|
304
|
+
📋 PENDING ACTIONS (dry run)
|
|
305
|
+
──────────────────────────────────────────────────
|
|
306
|
+
🔧 Oversized content detected
|
|
307
|
+
3 item(s) (~2.3 MB)
|
|
308
|
+
🗑️ Backups older than 7 days
|
|
309
|
+
5 item(s) (~89.3 MB)
|
|
310
|
+
📦 Conversations inactive for 60+ days
|
|
311
|
+
8 item(s) (~45.2 MB)
|
|
312
|
+
|
|
313
|
+
💡 RECOMMENDATIONS
|
|
314
|
+
──────────────────────────────────────────────────
|
|
315
|
+
- Run 'cct fix' to remove oversized content
|
|
316
|
+
- Run 'cct cleanup --days 7' to remove old backups
|
|
317
|
+
- Run 'cct archive --days 60' to archive inactive conversations
|
|
318
|
+
|
|
319
|
+
# Show scheduled maintenance setup
|
|
320
|
+
$ cct maintenance --schedule
|
|
321
|
+
|
|
322
|
+
# Run maintenance automatically
|
|
323
|
+
$ cct maintenance --auto
|
|
324
|
+
```
|
|
191
325
|
|
|
192
326
|
```bash
|
|
193
|
-
|
|
194
|
-
cct
|
|
327
|
+
# Summary of all conversations by context size
|
|
328
|
+
$ cct context
|
|
329
|
+
|
|
330
|
+
Context Usage Summary
|
|
331
|
+
|
|
332
|
+
Total conversations: 23
|
|
333
|
+
Combined tokens: ~1,234,567
|
|
334
|
+
|
|
335
|
+
Top 10 by context size:
|
|
336
|
+
|
|
337
|
+
-Users-me-projects-myapp/abc123.jsonl
|
|
338
|
+
~125,000 tokens (456 messages)
|
|
339
|
+
⚠ Context exceeds 100K tokens - consider archiving older messages
|
|
340
|
+
|
|
341
|
+
-Users-me-projects-another/def456.jsonl
|
|
342
|
+
~45,000 tokens (234 messages)
|
|
343
|
+
...
|
|
344
|
+
|
|
345
|
+
# Detailed breakdown for a specific file
|
|
346
|
+
$ cct context -f ~/.claude/projects/-Users-me-myapp/conversation.jsonl
|
|
347
|
+
|
|
348
|
+
Context Size Estimate
|
|
349
|
+
────────────────────────────────────────
|
|
350
|
+
Total: ~125,000 tokens
|
|
351
|
+
Messages: 456
|
|
352
|
+
|
|
353
|
+
Breakdown:
|
|
354
|
+
User messages: 12,500 tokens
|
|
355
|
+
Assistant messages: 85,000 tokens
|
|
356
|
+
Tool calls: 5,000 tokens
|
|
357
|
+
Tool results: 20,000 tokens
|
|
358
|
+
Images: 2,500 tokens
|
|
359
|
+
|
|
360
|
+
Largest message: Line 342 (assistant)
|
|
361
|
+
~8,500 tokens
|
|
362
|
+
|
|
363
|
+
Warnings:
|
|
364
|
+
⚠ Context exceeds 100K tokens - consider archiving older messages
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### `cct backups` - List Backups
|
|
368
|
+
|
|
369
|
+
See all backup files.
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
$ cct backups
|
|
373
|
+
|
|
374
|
+
Backup Files (5 files, 89.3 MB total)
|
|
375
|
+
|
|
376
|
+
conversation1.jsonl.backup.2024-01-15T10-30-00
|
|
377
|
+
Size: 23.4 MB, Created: 2024-01-15 10:30:00
|
|
378
|
+
...
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### `cct restore <path>` - Restore from Backup
|
|
382
|
+
|
|
383
|
+
Undo a fix if needed.
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
$ cct restore ~/.claude/projects/-Users-me-myapp/conversation.jsonl.backup.2024-01-15T10-30-00
|
|
387
|
+
|
|
388
|
+
✓ Restored /Users/me/.claude/projects/-Users-me-myapp/conversation.jsonl
|
|
389
|
+
Restart Claude Code to apply changes.
|
|
195
390
|
```
|
|
196
391
|
|
|
392
|
+
### `cct cleanup` - Delete Old Backups
|
|
393
|
+
|
|
394
|
+
Free up disk space.
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# Preview what would be deleted
|
|
398
|
+
$ cct cleanup --days 7 --dry-run
|
|
399
|
+
|
|
400
|
+
Would delete 3 backup(s):
|
|
401
|
+
conversation1.jsonl.backup.2024-01-01T00-00-00
|
|
402
|
+
conversation2.jsonl.backup.2024-01-02T00-00-00
|
|
403
|
+
conversation3.jsonl.backup.2024-01-03T00-00-00
|
|
404
|
+
|
|
405
|
+
Run without --dry-run to delete.
|
|
406
|
+
|
|
407
|
+
# Actually delete them
|
|
408
|
+
$ cct cleanup --days 7
|
|
409
|
+
|
|
410
|
+
✓ Deleted 3 backup(s)
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### `cct export` - Export Conversation
|
|
414
|
+
|
|
415
|
+
Export a conversation to markdown or JSON for backup, sharing, or archiving.
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# Export to markdown (default)
|
|
419
|
+
$ cct export -f ~/.claude/projects/-Users-me-myapp/conversation.jsonl
|
|
420
|
+
|
|
421
|
+
✓ Exported 156 messages to conversation.md
|
|
422
|
+
|
|
423
|
+
# Export to JSON
|
|
424
|
+
$ cct export -f conversation.jsonl --format json -o backup.json
|
|
425
|
+
|
|
426
|
+
✓ Exported 156 messages to backup.json
|
|
427
|
+
|
|
428
|
+
# Include tool results in export
|
|
429
|
+
$ cct export -f conversation.jsonl --with-tools
|
|
430
|
+
|
|
431
|
+
✓ Exported 156 messages to conversation.md
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Export formats:**
|
|
435
|
+
|
|
436
|
+
- **Markdown**: Human-readable format with headers, code blocks, and tool summaries
|
|
437
|
+
- **JSON**: Structured format with full message metadata for programmatic use
|
|
438
|
+
|
|
439
|
+
## CLI Options Reference
|
|
440
|
+
|
|
441
|
+
| Option | Description |
|
|
442
|
+
|--------|-------------|
|
|
443
|
+
| `-f, --file <path>` | Target a specific file instead of all conversations |
|
|
444
|
+
| `-o, --output <path>` | For export: output file path |
|
|
445
|
+
| `--format <type>` | For export: `markdown` or `json` (default: markdown) |
|
|
446
|
+
| `--with-tools` | For export: include tool results in output |
|
|
447
|
+
| `-d, --dry-run` | Preview changes without making them |
|
|
448
|
+
| `--no-backup` | Skip creating backups when fixing (not recommended) |
|
|
449
|
+
| `--days <n>` | For cleanup: delete backups older than n days (default: 7) |
|
|
450
|
+
| `--limit <n>` | For stats: limit number of results (default: 10) |
|
|
451
|
+
| `--sort <field>` | For stats: sort by `size`, `messages`, `images`, or `modified` |
|
|
452
|
+
| `-h, --help` | Show help message |
|
|
453
|
+
| `-v, --version` | Show version |
|
|
454
|
+
|
|
455
|
+
## MCP Server Tools
|
|
456
|
+
|
|
457
|
+
When installed as an MCP server, these tools are available to Claude:
|
|
458
|
+
|
|
459
|
+
| Tool | Description |
|
|
460
|
+
|------|-------------|
|
|
461
|
+
| `health_check` | Quick health check with recommendations |
|
|
462
|
+
| `get_conversation_stats` | Detailed statistics about conversations |
|
|
463
|
+
| `estimate_context_size` | Estimate token/context usage of conversations |
|
|
464
|
+
| `usage_analytics` | Usage analytics dashboard with trends and breakdowns |
|
|
465
|
+
| `find_duplicates` | Find duplicate conversations and content |
|
|
466
|
+
| `archive_conversations` | Archive old/inactive conversations |
|
|
467
|
+
| `run_maintenance` | Run maintenance checks and actions |
|
|
468
|
+
| `scan_image_issues` | Scan for oversized content (images, PDFs, documents) |
|
|
469
|
+
| `fix_image_issues` | Fix detected issues with automatic backups |
|
|
470
|
+
| `export_conversation` | Export conversation to markdown or JSON format |
|
|
471
|
+
| `list_backups` | List all backup files |
|
|
472
|
+
| `restore_backup` | Restore a conversation from backup |
|
|
473
|
+
| `cleanup_backups` | Delete old backups to free space |
|
|
474
|
+
|
|
197
475
|
## How It Works
|
|
198
476
|
|
|
199
|
-
1. **
|
|
200
|
-
2. **
|
|
201
|
-
3. **
|
|
202
|
-
|
|
203
|
-
|
|
477
|
+
1. **Locates** your Claude Code data in `~/.claude/projects/`
|
|
478
|
+
2. **Scans** conversation files (`.jsonl`) line by line
|
|
479
|
+
3. **Detects** oversized content:
|
|
480
|
+
- Images with base64 data >100KB
|
|
481
|
+
- PDFs with base64 data >100KB
|
|
482
|
+
- Documents with base64 data >100KB
|
|
483
|
+
- Text content >500KB
|
|
484
|
+
4. **Reports** findings with file paths, line numbers, and sizes
|
|
485
|
+
5. **Fixes** by replacing problematic content with placeholder text
|
|
486
|
+
6. **Backs up** original files before any modification
|
|
204
487
|
|
|
205
|
-
##
|
|
488
|
+
## Common Scenarios
|
|
489
|
+
|
|
490
|
+
### My Claude Code session is completely broken
|
|
206
491
|
|
|
207
492
|
```bash
|
|
208
|
-
#
|
|
209
|
-
|
|
493
|
+
cct scan # See what's wrong
|
|
494
|
+
cct fix # Fix it
|
|
495
|
+
# Restart Claude Code
|
|
496
|
+
```
|
|
210
497
|
|
|
211
|
-
|
|
212
|
-
npm run build
|
|
498
|
+
### I want to prevent issues before they happen
|
|
213
499
|
|
|
214
|
-
|
|
215
|
-
|
|
500
|
+
```bash
|
|
501
|
+
cct health # Quick check
|
|
502
|
+
```
|
|
216
503
|
|
|
217
|
-
|
|
218
|
-
npm run dev
|
|
504
|
+
### I accidentally uploaded a huge file
|
|
219
505
|
|
|
220
|
-
|
|
221
|
-
|
|
506
|
+
```bash
|
|
507
|
+
cct fix -f ~/.claude/projects/path/to/conversation.jsonl
|
|
222
508
|
```
|
|
223
509
|
|
|
224
|
-
|
|
510
|
+
### I want to undo a fix
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
cct backups # Find your backup
|
|
514
|
+
cct restore /path/to/backup # Restore it
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### My disk is filling up
|
|
518
|
+
|
|
519
|
+
```bash
|
|
520
|
+
cct cleanup --days 30 --dry-run # Preview
|
|
521
|
+
cct cleanup --days 30 # Delete
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### I want to save or share a conversation
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
cct export -f ~/.claude/projects/path/to/conversation.jsonl
|
|
528
|
+
# Creates conversation.md in current directory
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### My conversations are getting slow
|
|
225
532
|
|
|
226
|
-
|
|
533
|
+
```bash
|
|
534
|
+
cct context # See which conversations are using the most tokens
|
|
535
|
+
```
|
|
227
536
|
|
|
228
|
-
|
|
229
|
-
- How to suggest features
|
|
230
|
-
- How to submit pull requests
|
|
231
|
-
- Code style and testing requirements
|
|
537
|
+
### I want to see my usage patterns
|
|
232
538
|
|
|
233
|
-
|
|
539
|
+
```bash
|
|
540
|
+
cct analytics # Full usage dashboard with trends and stats
|
|
541
|
+
```
|
|
234
542
|
|
|
235
|
-
|
|
543
|
+
### I have duplicate content wasting space
|
|
236
544
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
545
|
+
```bash
|
|
546
|
+
cct duplicates # Find duplicate conversations and content
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### I want to clean up old conversations
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
cct archive --days 60 --dry-run # Preview what would be archived
|
|
553
|
+
cct archive --days 60 # Archive conversations inactive for 60+ days
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
### I want automated maintenance
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
cct maintenance # Check what needs attention
|
|
560
|
+
cct maintenance --auto # Automatically fix issues
|
|
561
|
+
cct maintenance --schedule # Get cron/launchd setup instructions
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Development
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
npm install # Install dependencies
|
|
568
|
+
npm run build # Build TypeScript
|
|
569
|
+
npm test # Run tests (70 tests)
|
|
570
|
+
npm run dev # Watch mode
|
|
571
|
+
npm run test:coverage # Coverage report
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
## Contributing
|
|
243
575
|
|
|
244
|
-
|
|
576
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
245
577
|
|
|
246
578
|
## License
|
|
247
579
|
|
|
248
580
|
MIT - see [LICENSE](LICENSE)
|
|
249
581
|
|
|
250
|
-
##
|
|
582
|
+
## Links
|
|
251
583
|
|
|
252
|
-
- [
|
|
253
|
-
- [
|
|
254
|
-
- [
|
|
584
|
+
- [npm package](https://www.npmjs.com/package/@asifkibria/claude-code-toolkit)
|
|
585
|
+
- [GitHub repository](https://github.com/asifkibria/claude-code-toolkit)
|
|
586
|
+
- [Original issue #2939](https://github.com/anthropics/claude-code/issues/2939)
|
|
255
587
|
|
|
256
588
|
---
|
|
257
589
|
|
|
258
|
-
**Made
|
|
590
|
+
**Made for the Claude Code community**
|