Skip to content

Commit 3fbd4f6

Browse files
committed
Add Session Memory Optimizer and Large File Handler plugins
Two plugins for better Claude Code session management: 1. **session-memory-optimizer**: Health monitoring, context pruning guidance, and checkpoints for long coding sessions. - /session-status - View session health - /session-checkpoint - Save session state - /session-optimize - Get optimization recommendations 2. **large-file-handler**: Prevent crashes from large files with smart blocking, size warnings, and chunking guidance. - PreToolUse hook blocks dangerous files (.db, .sqlite, >50MB) - /file-check, /file-chunk, /scan-large-files commands Both from: https://github.com/ojallington
1 parent e5856f9 commit 3fbd4f6

File tree

3 files changed

+273
-0
lines changed

3 files changed

+273
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ Install or disable them dynamically with the `/plugin` command — enabling you
6060
- [claude-desktop-extension](./plugins/claude-desktop-extension)
6161
- [lyra](./plugins/lyra)
6262
- [model-context-protocol-mcp-expert](./plugins/model-context-protocol-mcp-expert)
63+
- [large-file-handler](./plugins/large-file-handler)
6364
- [problem-solver-specialist](./plugins/problem-solver-specialist)
65+
- [session-memory-optimizer](./plugins/session-memory-optimizer)
6466
- [studio-coach](./plugins/studio-coach)
6567
- [ultrathink](./plugins/ultrathink)
6668

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Large File Handler
2+
3+
Prevent Claude Code crashes and context exhaustion when encountering large files. Provides smart blocking, size warnings, and chunking guidance.
4+
5+
## Problem Solved
6+
7+
Claude Code can crash or hang when attempting to read:
8+
- Files > 50MB (system freeze reported in GitHub #1452)
9+
- Database files (.db, .sqlite)
10+
- Large binary files
11+
- Files exceeding the 25K token read limit
12+
13+
This plugin intercepts file reads and:
14+
- **Blocks** dangerous files before they crash your session
15+
- **Warns** about large files that may exhaust context
16+
- **Guides** you on how to safely read large files in chunks
17+
18+
## Features
19+
20+
### PreToolUse Hook
21+
22+
Automatically intercepts `Read` tool calls and checks:
23+
- File size (warns at 10MB, blocks at 50MB)
24+
- File extension (blocks databases, archives, binaries)
25+
- PDF size (blocks PDFs > 5MB)
26+
27+
### Commands
28+
29+
- `/file-check <path>` - Check if a file is safe to read
30+
- `/file-chunk <path> [focus]` - Get chunking strategy for large files
31+
- `/scan-large-files [dir]` - Find problematic files in a directory
32+
33+
### Skill
34+
35+
Provides guidance on:
36+
- Using offset/limit parameters for chunked reading
37+
- Alternative approaches for different file types
38+
- .claudeignore best practices
39+
40+
## Installation
41+
42+
```bash
43+
claude plugin marketplace add aimakemoney/aimakemoney
44+
claude plugin install large-file-handler@aimakemoney-plugins
45+
```
46+
47+
Or from GitHub:
48+
```bash
49+
claude plugins add github:ojallington/large-file-handler
50+
```
51+
52+
## Usage
53+
54+
### Check a specific file
55+
```
56+
/file-check path/to/large-file.log
57+
```
58+
59+
### Get chunking strategy
60+
```
61+
/file-chunk path/to/large-file.log
62+
/file-chunk path/to/large-file.log focus=end
63+
/file-chunk path/to/large-file.log focus=search:ERROR
64+
```
65+
66+
### Scan directory for issues
67+
```
68+
/scan-large-files
69+
/scan-large-files path/to/directory
70+
```
71+
72+
### Reading large files safely
73+
74+
Instead of reading an entire large file:
75+
```
76+
Read large-file.log # May crash!
77+
```
78+
79+
Use chunked reading:
80+
```
81+
Read large-file.log with offset=0 limit=500 # First 500 lines
82+
Read large-file.log with offset=9500 limit=500 # Last 500 lines
83+
```
84+
85+
Or search first:
86+
```bash
87+
grep -n "ERROR" large-file.log | tail -20
88+
```
89+
Then read around the specific line numbers.
90+
91+
## File Type Handling
92+
93+
| File Type | Status | Alternative |
94+
|-----------|--------|-------------|
95+
| Text < 10MB | Safe | Read directly |
96+
| Text 10-50MB | Warning | Use chunking |
97+
| Text > 50MB | Blocked | grep/head/tail |
98+
| .db/.sqlite | Blocked | sqlite3 CLI |
99+
| .zip/.tar/.gz | Blocked | Extract first |
100+
| PDF < 5MB | Warning | May work |
101+
| PDF > 5MB | Blocked | pdftotext |
102+
| .exe/.dll/.so | Blocked | Not readable |
103+
104+
## Suggested .claudeignore
105+
106+
```gitignore
107+
# Databases
108+
*.db
109+
*.sqlite
110+
*.sqlite3
111+
112+
# Archives
113+
*.zip
114+
*.tar
115+
*.gz
116+
*.7z
117+
118+
# Large generated
119+
*.min.js
120+
*.bundle.js
121+
package-lock.json
122+
123+
# Dependencies
124+
node_modules/
125+
vendor/
126+
.venv/
127+
128+
# Build output
129+
dist/
130+
build/
131+
.next/
132+
133+
# Logs
134+
*.log
135+
logs/
136+
```
137+
138+
## License
139+
140+
MIT
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Session Memory Optimizer
2+
3+
A Claude Code plugin that solves performance degradation in long coding sessions.
4+
5+
## The Problem
6+
7+
Claude Code experiences significant performance degradation after 2-5 hours of continuous work:
8+
- Response times increase noticeably
9+
- Context confusion (mixing up details from different files)
10+
- Repetition (asking about things already discussed)
11+
- Pro Max subscribers ($199/mo) getting worse results than expected
12+
13+
This is documented across GitHub issues #7769, #10881, #4511 with 15+ reactions each.
14+
15+
## The Solution
16+
17+
This plugin provides proactive session management:
18+
19+
1. **Health Monitoring** - Know when optimization is needed
20+
2. **Smart Checkpoints** - Save/restore session context summaries
21+
3. **Optimization Guidance** - What to prune vs. preserve
22+
4. **PreCompact Hook** - Automatic optimization hints during compaction
23+
24+
## Installation
25+
26+
```bash
27+
# From GitHub
28+
claude plugins add github:aimakemoney/session-memory-optimizer
29+
30+
# Local development
31+
claude --plugin-dir /path/to/session-memory-optimizer
32+
```
33+
34+
## Commands
35+
36+
### `/session-status`
37+
Display current session health metrics and recommendations.
38+
39+
```
40+
SESSION HEALTH DASHBOARD
41+
========================
42+
Duration: 3h 45m
43+
Health Status: 🟡 MODERATE
44+
Last Checkpoint: None
45+
46+
Recommendation: Consider creating a checkpoint with /session-checkpoint
47+
```
48+
49+
### `/session-checkpoint <name>`
50+
Save current session context as a compressed checkpoint.
51+
52+
```bash
53+
/session-checkpoint before-refactor
54+
/session-checkpoint end-of-day
55+
/session-checkpoint feature-complete
56+
```
57+
58+
Captures:
59+
- Active files and current task
60+
- Key decisions and their rationale
61+
- Established patterns/conventions
62+
- Pending TODOs and blockers
63+
64+
### `/session-restore [name]`
65+
Restore context from a previously saved checkpoint.
66+
67+
```bash
68+
/session-restore # List available checkpoints
69+
/session-restore before-refactor # Restore specific checkpoint
70+
```
71+
72+
### `/session-optimize`
73+
Analyze session context and provide optimization recommendations.
74+
75+
Shows:
76+
- What's safe to prune (old outputs, resolved errors)
77+
- What must be preserved (active task, decisions, errors)
78+
- Estimated context reduction
79+
- Specific `/compact` command to run
80+
81+
## Automatic Features
82+
83+
### PreCompact Hook
84+
When Claude Code auto-compacts, this plugin injects guidance to:
85+
- Preserve current task, decisions, active files, unresolved errors
86+
- Aggressively compress old outputs, resolved issues, dead-end explorations
87+
88+
### Session Start
89+
Notifies you of available checkpoints from previous sessions.
90+
91+
### Session End
92+
Auto-saves a quick checkpoint for sessions longer than 30 minutes.
93+
94+
## Best Practices
95+
96+
1. **Check health every 2 hours**: `/session-status`
97+
2. **Checkpoint at milestones**: `/session-checkpoint <milestone>`
98+
3. **Read files on demand**: Not preemptively
99+
4. **Summarize completed work**: Before moving on
100+
5. **Compact with focus**: Guide what to preserve
101+
102+
## File Structure
103+
104+
```
105+
session-memory-optimizer/
106+
├── .claude-plugin/
107+
│ └── plugin.json
108+
├── commands/
109+
│ ├── session-status.md
110+
│ ├── session-checkpoint.md
111+
│ ├── session-restore.md
112+
│ └── session-optimize.md
113+
├── hooks/
114+
│ ├── hooks.json
115+
│ └── scripts/
116+
├── skills/
117+
│ └── context-management/
118+
├── scripts/
119+
│ ├── checkpoint-manager.py
120+
│ └── health-calculator.py
121+
└── data/
122+
└── checkpoints/
123+
```
124+
125+
## License
126+
127+
MIT License - See LICENSE file.
128+
129+
## Contributing
130+
131+
Issues and PRs welcome at: https://github.com/aimakemoney/session-memory-optimizer

0 commit comments

Comments
 (0)