@asifkibria/claude-code-toolkit 1.0.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/CONTRIBUTING.md +187 -0
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/dist/__tests__/scanner.test.d.ts +2 -0
- package/dist/__tests__/scanner.test.d.ts.map +1 -0
- package/dist/__tests__/scanner.test.js +409 -0
- package/dist/__tests__/scanner.test.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +389 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +514 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/scanner.d.ts +50 -0
- package/dist/lib/scanner.d.ts.map +1 -0
- package/dist/lib/scanner.js +369 -0
- package/dist/lib/scanner.js.map +1 -0
- package/package.json +63 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Contributing to Claude Code Toolkit
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This project aims to be a community-driven toolkit for maintaining and optimizing Claude Code installations.
|
|
4
|
+
|
|
5
|
+
## Ways to Contribute
|
|
6
|
+
|
|
7
|
+
### 1. Report Issues
|
|
8
|
+
- Use GitHub Issues to report bugs
|
|
9
|
+
- Include your OS, Node.js version, and Claude Code version
|
|
10
|
+
- Provide steps to reproduce the issue
|
|
11
|
+
- Include error messages and logs if applicable
|
|
12
|
+
|
|
13
|
+
### 2. Suggest Features
|
|
14
|
+
- Open a GitHub Issue with the "enhancement" label
|
|
15
|
+
- Describe the problem you're trying to solve
|
|
16
|
+
- Explain your proposed solution
|
|
17
|
+
- Consider how it fits with existing tools
|
|
18
|
+
|
|
19
|
+
### 3. Submit Code
|
|
20
|
+
|
|
21
|
+
#### Getting Started
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Fork and clone the repository
|
|
25
|
+
git clone https://github.com/YOUR_USERNAME/claude-code-toolkit.git
|
|
26
|
+
cd claude-code-toolkit
|
|
27
|
+
|
|
28
|
+
# Install dependencies
|
|
29
|
+
npm install
|
|
30
|
+
|
|
31
|
+
# Build
|
|
32
|
+
npm run build
|
|
33
|
+
|
|
34
|
+
# Run tests
|
|
35
|
+
npm test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Development Workflow
|
|
39
|
+
|
|
40
|
+
1. Create a feature branch: `git checkout -b feature/my-feature`
|
|
41
|
+
2. Make your changes
|
|
42
|
+
3. Add tests for new functionality
|
|
43
|
+
4. Ensure all tests pass: `npm test`
|
|
44
|
+
5. Build successfully: `npm run build`
|
|
45
|
+
6. Commit with conventional commits: `git commit -m "feat: add new feature"`
|
|
46
|
+
7. Push and create a Pull Request
|
|
47
|
+
|
|
48
|
+
#### Code Style
|
|
49
|
+
|
|
50
|
+
- Use TypeScript for all new code
|
|
51
|
+
- Follow existing code patterns
|
|
52
|
+
- Add JSDoc comments for public functions
|
|
53
|
+
- Keep functions focused and small
|
|
54
|
+
- Handle errors gracefully
|
|
55
|
+
|
|
56
|
+
#### Testing Requirements
|
|
57
|
+
|
|
58
|
+
- All new features must have tests
|
|
59
|
+
- Maintain or improve code coverage
|
|
60
|
+
- Test edge cases and error conditions
|
|
61
|
+
- Use descriptive test names
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Run tests
|
|
65
|
+
npm test
|
|
66
|
+
|
|
67
|
+
# Run tests in watch mode
|
|
68
|
+
npm run test:watch
|
|
69
|
+
|
|
70
|
+
# Check coverage
|
|
71
|
+
npm run test:coverage
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Commit Message Format
|
|
75
|
+
|
|
76
|
+
We use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
type(scope): description
|
|
80
|
+
|
|
81
|
+
[optional body]
|
|
82
|
+
|
|
83
|
+
[optional footer]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Types:
|
|
87
|
+
- `feat`: New feature
|
|
88
|
+
- `fix`: Bug fix
|
|
89
|
+
- `docs`: Documentation only
|
|
90
|
+
- `style`: Code style (formatting, etc.)
|
|
91
|
+
- `refactor`: Code refactoring
|
|
92
|
+
- `test`: Adding or updating tests
|
|
93
|
+
- `chore`: Maintenance tasks
|
|
94
|
+
|
|
95
|
+
Examples:
|
|
96
|
+
```
|
|
97
|
+
feat(scanner): add support for detecting corrupted JSON
|
|
98
|
+
fix(cli): handle missing projects directory gracefully
|
|
99
|
+
docs: update installation instructions
|
|
100
|
+
test(scanner): add edge case tests for nested images
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Improve Documentation
|
|
104
|
+
|
|
105
|
+
- Fix typos or unclear explanations
|
|
106
|
+
- Add examples and use cases
|
|
107
|
+
- Translate to other languages
|
|
108
|
+
- Write tutorials or blog posts
|
|
109
|
+
|
|
110
|
+
## Adding New Tools
|
|
111
|
+
|
|
112
|
+
When adding a new tool to the toolkit:
|
|
113
|
+
|
|
114
|
+
1. **Plan the feature**
|
|
115
|
+
- Open an issue to discuss the approach
|
|
116
|
+
- Get feedback from maintainers
|
|
117
|
+
|
|
118
|
+
2. **Implement in the scanner library** (`src/lib/scanner.ts`)
|
|
119
|
+
- Add core functionality as exported functions
|
|
120
|
+
- Keep it framework-agnostic
|
|
121
|
+
|
|
122
|
+
3. **Add MCP tool** (`src/index.ts`)
|
|
123
|
+
- Add tool definition in `ListToolsRequestSchema` handler
|
|
124
|
+
- Implement handler in `CallToolRequestSchema` switch
|
|
125
|
+
|
|
126
|
+
4. **Add CLI command** (`src/cli.ts`)
|
|
127
|
+
- Add command handler function
|
|
128
|
+
- Update help text
|
|
129
|
+
- Add to main switch
|
|
130
|
+
|
|
131
|
+
5. **Write tests** (`src/__tests__/`)
|
|
132
|
+
- Unit tests for library functions
|
|
133
|
+
- Integration tests if needed
|
|
134
|
+
|
|
135
|
+
6. **Update documentation**
|
|
136
|
+
- Add to README.md
|
|
137
|
+
- Update tool reference tables
|
|
138
|
+
|
|
139
|
+
## Project Structure
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
src/
|
|
143
|
+
├── index.ts # MCP server entry point
|
|
144
|
+
├── cli.ts # CLI entry point
|
|
145
|
+
├── lib/
|
|
146
|
+
│ └── scanner.ts # Core library functions
|
|
147
|
+
└── __tests__/
|
|
148
|
+
└── scanner.test.ts
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Pull Request Process
|
|
152
|
+
|
|
153
|
+
1. Update the README.md with details of changes if applicable
|
|
154
|
+
2. Update the CHANGELOG.md (if we have one)
|
|
155
|
+
3. Ensure CI passes (tests, build, lint)
|
|
156
|
+
4. Get at least one code review approval
|
|
157
|
+
5. Squash and merge with a clear commit message
|
|
158
|
+
|
|
159
|
+
## Code of Conduct
|
|
160
|
+
|
|
161
|
+
### Our Standards
|
|
162
|
+
|
|
163
|
+
- Be respectful and inclusive
|
|
164
|
+
- Welcome newcomers and help them get started
|
|
165
|
+
- Accept constructive criticism gracefully
|
|
166
|
+
- Focus on what's best for the community
|
|
167
|
+
|
|
168
|
+
### Unacceptable Behavior
|
|
169
|
+
|
|
170
|
+
- Harassment, discrimination, or personal attacks
|
|
171
|
+
- Trolling or inflammatory comments
|
|
172
|
+
- Publishing others' private information
|
|
173
|
+
- Other unprofessional conduct
|
|
174
|
+
|
|
175
|
+
## Questions?
|
|
176
|
+
|
|
177
|
+
- Open a GitHub Discussion for general questions
|
|
178
|
+
- Tag maintainers in issues if you need help
|
|
179
|
+
- Join the community chat (if available)
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
Thank you for helping make Claude Code better for everyone!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asif Kibria
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Claude Code Toolkit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@asifkibria/claude-code-toolkit)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/asifkibria/claude-code-toolkit)
|
|
6
|
+
|
|
7
|
+
A comprehensive MCP server and CLI toolkit for maintaining, optimizing, and troubleshooting your Claude Code installation.
|
|
8
|
+
|
|
9
|
+
## Why This Toolkit?
|
|
10
|
+
|
|
11
|
+
Claude Code stores conversation history, tool results, and context in local files. Over time, these can:
|
|
12
|
+
|
|
13
|
+
- **Grow large** - Slowing down startup and responses
|
|
14
|
+
- **Contain errors** - Corrupted data blocking API calls
|
|
15
|
+
- **Accumulate clutter** - Old backups and orphaned files
|
|
16
|
+
- **Become opaque** - Hard to understand what's using space
|
|
17
|
+
|
|
18
|
+
This toolkit gives you visibility and control over your Claude Code data.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
### Health Monitoring
|
|
23
|
+
- Quick health checks with actionable recommendations
|
|
24
|
+
- Identify problematic files before they cause issues
|
|
25
|
+
- Track conversation sizes and growth
|
|
26
|
+
|
|
27
|
+
### Conversation Analytics
|
|
28
|
+
- View detailed statistics (messages, tool uses, images)
|
|
29
|
+
- Find your largest conversations
|
|
30
|
+
- Sort by size, activity, or modification date
|
|
31
|
+
|
|
32
|
+
### Troubleshooting Tools
|
|
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
|
|
36
|
+
|
|
37
|
+
### Maintenance Utilities
|
|
38
|
+
- Automatic backup creation before changes
|
|
39
|
+
- Clean up old backup files
|
|
40
|
+
- Free up disk space safely
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
### As MCP Server (Recommended)
|
|
45
|
+
|
|
46
|
+
Add to Claude Code so you can ask Claude to maintain itself:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Using npx (no install needed)
|
|
50
|
+
claude mcp add --scope user toolkit -- npx -y @asifkibria/claude-code-toolkit claude-code-toolkit-server
|
|
51
|
+
|
|
52
|
+
# Or install globally first
|
|
53
|
+
npm install -g @asifkibria/claude-code-toolkit
|
|
54
|
+
claude mcp add --scope user toolkit -- claude-code-toolkit-server
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### As CLI Tool
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Using npx
|
|
61
|
+
npx @asifkibria/claude-code-toolkit health
|
|
62
|
+
|
|
63
|
+
# Or install globally
|
|
64
|
+
npm install -g @asifkibria/claude-code-toolkit
|
|
65
|
+
claude-code-toolkit health
|
|
66
|
+
|
|
67
|
+
# Short alias
|
|
68
|
+
cct health
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### From Source
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://github.com/asifkibria/claude-code-toolkit.git
|
|
75
|
+
cd claude-code-toolkit
|
|
76
|
+
npm install && npm run build && npm test
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
### Inside Claude Code (MCP)
|
|
82
|
+
|
|
83
|
+
Once installed as an MCP server, just ask Claude:
|
|
84
|
+
|
|
85
|
+
> "Check my Claude Code health"
|
|
86
|
+
|
|
87
|
+
> "Show me my conversation statistics"
|
|
88
|
+
|
|
89
|
+
> "Scan for any issues"
|
|
90
|
+
|
|
91
|
+
> "Fix the problems you found"
|
|
92
|
+
|
|
93
|
+
> "Clean up old backups older than 30 days"
|
|
94
|
+
|
|
95
|
+
### Command Line
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Quick health check - start here!
|
|
99
|
+
cct health
|
|
100
|
+
|
|
101
|
+
# View conversation statistics
|
|
102
|
+
cct stats
|
|
103
|
+
cct stats --limit 20 --sort messages
|
|
104
|
+
|
|
105
|
+
# Scan for issues (dry run)
|
|
106
|
+
cct scan
|
|
107
|
+
|
|
108
|
+
# Fix all detected issues
|
|
109
|
+
cct fix
|
|
110
|
+
|
|
111
|
+
# Fix specific file
|
|
112
|
+
cct fix -f ~/.claude/projects/myproject/conversation.jsonl
|
|
113
|
+
|
|
114
|
+
# Manage backups
|
|
115
|
+
cct backups
|
|
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
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Tool Reference
|
|
122
|
+
|
|
123
|
+
### MCP Tools
|
|
124
|
+
|
|
125
|
+
| Tool | Description |
|
|
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
|
+
|
|
137
|
+
| Command | Description |
|
|
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 |
|
|
146
|
+
|
|
147
|
+
### CLI Options
|
|
148
|
+
|
|
149
|
+
| Option | Description |
|
|
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 |
|
|
159
|
+
|
|
160
|
+
## Common Issues This Solves
|
|
161
|
+
|
|
162
|
+
### "Image dimensions exceed max allowed size"
|
|
163
|
+
|
|
164
|
+
This error poisons your conversation context, making all subsequent requests fail - even `/compact`. The toolkit detects and fixes these oversized images automatically.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cct scan # See what's wrong
|
|
168
|
+
cct fix # Fix it
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### "My Claude Code is slow to start"
|
|
172
|
+
|
|
173
|
+
Large conversation files slow everything down. Use stats to find the culprits:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
cct stats --sort size --limit 5
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### "I accidentally broke something"
|
|
180
|
+
|
|
181
|
+
Backups are created automatically before any fix. Restore anytime:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
cct backups # Find your backup
|
|
185
|
+
cct restore /path/to/backup # Restore it
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### "My disk is filling up"
|
|
189
|
+
|
|
190
|
+
Clean up old backups:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
cct cleanup --days 7 --dry-run # Preview
|
|
194
|
+
cct cleanup --days 7 # Delete
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## How It Works
|
|
198
|
+
|
|
199
|
+
1. **Scans** `~/.claude/projects/` for conversation files (`.jsonl`)
|
|
200
|
+
2. **Analyzes** each message for issues (oversized images, malformed data)
|
|
201
|
+
3. **Reports** findings with actionable recommendations
|
|
202
|
+
4. **Fixes** issues by replacing problematic content with placeholders
|
|
203
|
+
5. **Backs up** original files before any modifications
|
|
204
|
+
|
|
205
|
+
## Development
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Install dependencies
|
|
209
|
+
npm install
|
|
210
|
+
|
|
211
|
+
# Build
|
|
212
|
+
npm run build
|
|
213
|
+
|
|
214
|
+
# Run tests (30 tests)
|
|
215
|
+
npm test
|
|
216
|
+
|
|
217
|
+
# Watch mode for development
|
|
218
|
+
npm run dev
|
|
219
|
+
|
|
220
|
+
# Test coverage
|
|
221
|
+
npm run test:coverage
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Contributing
|
|
225
|
+
|
|
226
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on:
|
|
227
|
+
|
|
228
|
+
- How to report issues
|
|
229
|
+
- How to suggest features
|
|
230
|
+
- How to submit pull requests
|
|
231
|
+
- Code style and testing requirements
|
|
232
|
+
|
|
233
|
+
## Roadmap
|
|
234
|
+
|
|
235
|
+
Future features under consideration:
|
|
236
|
+
|
|
237
|
+
- [ ] Conversation export (markdown, JSON)
|
|
238
|
+
- [ ] Context size estimation
|
|
239
|
+
- [ ] Duplicate detection
|
|
240
|
+
- [ ] Conversation archiving
|
|
241
|
+
- [ ] Usage analytics dashboard
|
|
242
|
+
- [ ] Automatic scheduled maintenance
|
|
243
|
+
|
|
244
|
+
Have an idea? [Open an issue](https://github.com/asifkibria/claude-code-toolkit/issues)!
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
MIT - see [LICENSE](LICENSE)
|
|
249
|
+
|
|
250
|
+
## Related Resources
|
|
251
|
+
|
|
252
|
+
- [Claude Code Documentation](https://docs.anthropic.com/claude-code)
|
|
253
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
254
|
+
- [Claude Code GitHub Issues](https://github.com/anthropics/claude-code/issues)
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
**Made with care for the Claude Code community**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/scanner.test.ts"],"names":[],"mappings":""}
|