@asifkibria/claude-code-toolkit 1.0.1 → 1.0.2
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 +217 -152
- package/dist/__tests__/scanner.test.js +101 -18
- package/dist/__tests__/scanner.test.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +23 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/scanner.d.ts +13 -6
- package/dist/lib/scanner.d.ts.map +1 -1
- package/dist/lib/scanner.js +132 -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"
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
### Option 2: CLI Tool
|
|
73
|
+
|
|
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,237 @@ cd claude-code-toolkit
|
|
|
76
87
|
npm install && npm run build && npm test
|
|
77
88
|
```
|
|
78
89
|
|
|
79
|
-
##
|
|
90
|
+
## CLI Commands
|
|
91
|
+
|
|
92
|
+
### `cct health` - Quick Health Check
|
|
80
93
|
|
|
81
|
-
|
|
94
|
+
Start here. Shows overall status and recommendations.
|
|
82
95
|
|
|
83
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
# Fix specific file
|
|
112
|
-
cct fix -f ~/.claude/projects/myproject/conversation.jsonl
|
|
125
|
+
-Users-me-projects-another/conversation2.jsonl
|
|
126
|
+
Line 45: 📎 document (~890 KB)
|
|
113
127
|
|
|
114
|
-
|
|
115
|
-
cct
|
|
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
|
|
128
|
+
Found 3 issue(s) in 2 file(s).
|
|
129
|
+
Run 'cct fix' to fix them.
|
|
119
130
|
```
|
|
120
131
|
|
|
121
|
-
|
|
132
|
+
### `cct fix` - Fix All Issues
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
Removes problematic content and creates backups.
|
|
124
135
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
| `health_check` | Quick health check with recommendations |
|
|
128
|
-
| `get_conversation_stats` | Detailed statistics about all conversations |
|
|
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 |
|
|
134
|
-
|
|
135
|
-
### CLI Commands
|
|
136
|
+
```bash
|
|
137
|
+
$ cct fix
|
|
136
138
|
|
|
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 |
|
|
139
|
+
Processing 23 file(s)...
|
|
146
140
|
|
|
147
|
-
|
|
141
|
+
✓ -Users-me-projects-myapp/conversation1.jsonl
|
|
142
|
+
Fixed 2 issue(s)
|
|
143
|
+
Backup: conversation1.jsonl.backup.2024-01-15T10-30-00
|
|
148
144
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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 |
|
|
145
|
+
✓ -Users-me-projects-another/conversation2.jsonl
|
|
146
|
+
Fixed 1 issue(s)
|
|
147
|
+
Backup: conversation2.jsonl.backup.2024-01-15T10-30-01
|
|
159
148
|
|
|
160
|
-
|
|
149
|
+
✓ Fixed 3 issue(s) in 2 file(s).
|
|
150
|
+
Restart Claude Code to apply changes.
|
|
151
|
+
```
|
|
161
152
|
|
|
162
|
-
###
|
|
153
|
+
### `cct stats` - Conversation Statistics
|
|
163
154
|
|
|
164
|
-
|
|
155
|
+
See what's using space and resources.
|
|
165
156
|
|
|
166
157
|
```bash
|
|
167
|
-
cct
|
|
168
|
-
|
|
158
|
+
$ cct stats --limit 5 --sort size
|
|
159
|
+
|
|
160
|
+
Conversation Statistics
|
|
161
|
+
|
|
162
|
+
Total: 23 conversations, 156.2 MB
|
|
163
|
+
Messages: 12,456, Images: 89, Documents: 23
|
|
164
|
+
Problematic content: 3
|
|
165
|
+
|
|
166
|
+
Top 5 by size:
|
|
167
|
+
|
|
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
|
+
...
|
|
169
173
|
```
|
|
170
174
|
|
|
171
|
-
###
|
|
175
|
+
### `cct backups` - List Backups
|
|
172
176
|
|
|
173
|
-
|
|
177
|
+
See all backup files.
|
|
174
178
|
|
|
175
179
|
```bash
|
|
176
|
-
cct
|
|
180
|
+
$ cct backups
|
|
181
|
+
|
|
182
|
+
Backup Files (5 files, 89.3 MB total)
|
|
183
|
+
|
|
184
|
+
conversation1.jsonl.backup.2024-01-15T10-30-00
|
|
185
|
+
Size: 23.4 MB, Created: 2024-01-15 10:30:00
|
|
186
|
+
...
|
|
177
187
|
```
|
|
178
188
|
|
|
179
|
-
###
|
|
189
|
+
### `cct restore <path>` - Restore from Backup
|
|
180
190
|
|
|
181
|
-
|
|
191
|
+
Undo a fix if needed.
|
|
182
192
|
|
|
183
193
|
```bash
|
|
184
|
-
cct
|
|
185
|
-
|
|
194
|
+
$ cct restore ~/.claude/projects/-Users-me-myapp/conversation.jsonl.backup.2024-01-15T10-30-00
|
|
195
|
+
|
|
196
|
+
✓ Restored /Users/me/.claude/projects/-Users-me-myapp/conversation.jsonl
|
|
197
|
+
Restart Claude Code to apply changes.
|
|
186
198
|
```
|
|
187
199
|
|
|
188
|
-
###
|
|
200
|
+
### `cct cleanup` - Delete Old Backups
|
|
189
201
|
|
|
190
|
-
|
|
202
|
+
Free up disk space.
|
|
191
203
|
|
|
192
204
|
```bash
|
|
193
|
-
|
|
194
|
-
cct cleanup --days 7
|
|
205
|
+
# Preview what would be deleted
|
|
206
|
+
$ cct cleanup --days 7 --dry-run
|
|
207
|
+
|
|
208
|
+
Would delete 3 backup(s):
|
|
209
|
+
conversation1.jsonl.backup.2024-01-01T00-00-00
|
|
210
|
+
conversation2.jsonl.backup.2024-01-02T00-00-00
|
|
211
|
+
conversation3.jsonl.backup.2024-01-03T00-00-00
|
|
212
|
+
|
|
213
|
+
Run without --dry-run to delete.
|
|
214
|
+
|
|
215
|
+
# Actually delete them
|
|
216
|
+
$ cct cleanup --days 7
|
|
217
|
+
|
|
218
|
+
✓ Deleted 3 backup(s)
|
|
195
219
|
```
|
|
196
220
|
|
|
221
|
+
## CLI Options Reference
|
|
222
|
+
|
|
223
|
+
| Option | Description |
|
|
224
|
+
|--------|-------------|
|
|
225
|
+
| `-f, --file <path>` | Target a specific file instead of all conversations |
|
|
226
|
+
| `-d, --dry-run` | Preview changes without making them |
|
|
227
|
+
| `--no-backup` | Skip creating backups when fixing (not recommended) |
|
|
228
|
+
| `--days <n>` | For cleanup: delete backups older than n days (default: 7) |
|
|
229
|
+
| `--limit <n>` | For stats: limit number of results (default: 10) |
|
|
230
|
+
| `--sort <field>` | For stats: sort by `size`, `messages`, `images`, or `modified` |
|
|
231
|
+
| `-h, --help` | Show help message |
|
|
232
|
+
| `-v, --version` | Show version |
|
|
233
|
+
|
|
234
|
+
## MCP Server Tools
|
|
235
|
+
|
|
236
|
+
When installed as an MCP server, these tools are available to Claude:
|
|
237
|
+
|
|
238
|
+
| Tool | Description |
|
|
239
|
+
|------|-------------|
|
|
240
|
+
| `health_check` | Quick health check with recommendations |
|
|
241
|
+
| `get_conversation_stats` | Detailed statistics about conversations |
|
|
242
|
+
| `scan_image_issues` | Scan for oversized content (images, PDFs, documents) |
|
|
243
|
+
| `fix_image_issues` | Fix detected issues with automatic backups |
|
|
244
|
+
| `list_backups` | List all backup files |
|
|
245
|
+
| `restore_backup` | Restore a conversation from backup |
|
|
246
|
+
| `cleanup_backups` | Delete old backups to free space |
|
|
247
|
+
|
|
197
248
|
## How It Works
|
|
198
249
|
|
|
199
|
-
1. **
|
|
200
|
-
2. **
|
|
201
|
-
3. **
|
|
202
|
-
|
|
203
|
-
|
|
250
|
+
1. **Locates** your Claude Code data in `~/.claude/projects/`
|
|
251
|
+
2. **Scans** conversation files (`.jsonl`) line by line
|
|
252
|
+
3. **Detects** oversized content:
|
|
253
|
+
- Images with base64 data >100KB
|
|
254
|
+
- PDFs with base64 data >100KB
|
|
255
|
+
- Documents with base64 data >100KB
|
|
256
|
+
- Text content >500KB
|
|
257
|
+
4. **Reports** findings with file paths, line numbers, and sizes
|
|
258
|
+
5. **Fixes** by replacing problematic content with placeholder text
|
|
259
|
+
6. **Backs up** original files before any modification
|
|
204
260
|
|
|
205
|
-
##
|
|
261
|
+
## Common Scenarios
|
|
262
|
+
|
|
263
|
+
### My Claude Code session is completely broken
|
|
206
264
|
|
|
207
265
|
```bash
|
|
208
|
-
#
|
|
209
|
-
|
|
266
|
+
cct scan # See what's wrong
|
|
267
|
+
cct fix # Fix it
|
|
268
|
+
# Restart Claude Code
|
|
269
|
+
```
|
|
210
270
|
|
|
211
|
-
|
|
212
|
-
npm run build
|
|
271
|
+
### I want to prevent issues before they happen
|
|
213
272
|
|
|
214
|
-
|
|
215
|
-
|
|
273
|
+
```bash
|
|
274
|
+
cct health # Quick check
|
|
275
|
+
```
|
|
216
276
|
|
|
217
|
-
|
|
218
|
-
npm run dev
|
|
277
|
+
### I accidentally uploaded a huge file
|
|
219
278
|
|
|
220
|
-
|
|
221
|
-
|
|
279
|
+
```bash
|
|
280
|
+
cct fix -f ~/.claude/projects/path/to/conversation.jsonl
|
|
222
281
|
```
|
|
223
282
|
|
|
224
|
-
|
|
283
|
+
### I want to undo a fix
|
|
225
284
|
|
|
226
|
-
|
|
285
|
+
```bash
|
|
286
|
+
cct backups # Find your backup
|
|
287
|
+
cct restore /path/to/backup # Restore it
|
|
288
|
+
```
|
|
227
289
|
|
|
228
|
-
|
|
229
|
-
- How to suggest features
|
|
230
|
-
- How to submit pull requests
|
|
231
|
-
- Code style and testing requirements
|
|
290
|
+
### My disk is filling up
|
|
232
291
|
|
|
233
|
-
|
|
292
|
+
```bash
|
|
293
|
+
cct cleanup --days 30 --dry-run # Preview
|
|
294
|
+
cct cleanup --days 30 # Delete
|
|
295
|
+
```
|
|
234
296
|
|
|
235
|
-
|
|
297
|
+
## Development
|
|
236
298
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
299
|
+
```bash
|
|
300
|
+
npm install # Install dependencies
|
|
301
|
+
npm run build # Build TypeScript
|
|
302
|
+
npm test # Run tests (38 tests)
|
|
303
|
+
npm run dev # Watch mode
|
|
304
|
+
npm run test:coverage # Coverage report
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Contributing
|
|
243
308
|
|
|
244
|
-
|
|
309
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
245
310
|
|
|
246
311
|
## License
|
|
247
312
|
|
|
248
313
|
MIT - see [LICENSE](LICENSE)
|
|
249
314
|
|
|
250
|
-
##
|
|
315
|
+
## Links
|
|
251
316
|
|
|
252
|
-
- [
|
|
253
|
-
- [
|
|
254
|
-
- [
|
|
317
|
+
- [npm package](https://www.npmjs.com/package/@asifkibria/claude-code-toolkit)
|
|
318
|
+
- [GitHub repository](https://github.com/asifkibria/claude-code-toolkit)
|
|
319
|
+
- [Original issue #2939](https://github.com/anthropics/claude-code/issues/2939)
|
|
255
320
|
|
|
256
321
|
---
|
|
257
322
|
|
|
258
|
-
**Made
|
|
323
|
+
**Made for the Claude Code community**
|