@coo-quack/do-not-compact 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/.claude-plugin/plugin.json +11 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/hooks/hooks.json +18 -0
- package/hooks/reload-claude-md.sh +45 -0
- package/package.json +19 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "do-not-compact",
|
|
3
|
+
"description": "Reload CLAUDE.md files into context after conversation compaction",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "coo-quack"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/coo-quack/do-not-compact",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": ["compaction", "claude-md", "context", "hooks"]
|
|
11
|
+
}
|
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 coo-quack
|
|
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,26 @@
|
|
|
1
|
+
# Don't Compact CLAUDE.md
|
|
2
|
+
|
|
3
|
+
Claude Code plugin that reloads CLAUDE.md files into context after conversation compaction.
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
When Claude Code compacts the conversation to stay within context limits, the contents of CLAUDE.md files (user instructions, project rules, git conventions, etc.) may be lost or summarized. This can cause Claude to forget important rules like commit message conventions or coding standards.
|
|
8
|
+
|
|
9
|
+
## Solution
|
|
10
|
+
|
|
11
|
+
This plugin hooks into the `SessionStart` event with a `compact` matcher. After compaction, it collects all CLAUDE.md files from the directory hierarchy and injects them back into context as `additionalContext`.
|
|
12
|
+
|
|
13
|
+
Files collected (in order):
|
|
14
|
+
1. `~/.claude/CLAUDE.md` (user global instructions)
|
|
15
|
+
2. `~/CLAUDE.md` and parent directories up to cwd (project hierarchy)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @coo-quack/do-not-compact
|
|
21
|
+
claude plugin install @coo-quack/do-not-compact
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Requirements
|
|
25
|
+
|
|
26
|
+
- `jq` must be installed and available in PATH
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Reload CLAUDE.md files after context compaction to preserve instructions",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": "compact",
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/reload-claude-md.sh\"",
|
|
11
|
+
"timeout": 10,
|
|
12
|
+
"statusMessage": "Reloading CLAUDE.md..."
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Reload CLAUDE.md files after compaction and inject as additionalContext
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
INPUT=$(cat)
|
|
6
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd')
|
|
7
|
+
|
|
8
|
+
CONTEXT=""
|
|
9
|
+
|
|
10
|
+
# ~/.claude/CLAUDE.md
|
|
11
|
+
if [[ -f "$HOME/.claude/CLAUDE.md" ]]; then
|
|
12
|
+
CONTEXT+="--- ~/.claude/CLAUDE.md ---"$'\n'
|
|
13
|
+
CONTEXT+="$(cat "$HOME/.claude/CLAUDE.md")"$'\n\n'
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Collect CLAUDE.md files from cwd up to $HOME
|
|
17
|
+
dir="$CWD"
|
|
18
|
+
claude_files=()
|
|
19
|
+
while [[ "$dir" != "/" && "$dir" != "$HOME" ]]; do
|
|
20
|
+
if [[ -f "$dir/CLAUDE.md" ]]; then
|
|
21
|
+
claude_files+=("$dir/CLAUDE.md")
|
|
22
|
+
fi
|
|
23
|
+
dir=$(dirname "$dir")
|
|
24
|
+
done
|
|
25
|
+
if [[ -f "$HOME/CLAUDE.md" ]]; then
|
|
26
|
+
claude_files+=("$HOME/CLAUDE.md")
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Output in top-down order (reverse of collected order)
|
|
30
|
+
for (( i=${#claude_files[@]}-1; i>=0; i-- )); do
|
|
31
|
+
f="${claude_files[$i]}"
|
|
32
|
+
CONTEXT+="--- $f ---"$'\n'
|
|
33
|
+
CONTEXT+="$(cat "$f")"$'\n\n'
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
if [[ -n "$CONTEXT" ]]; then
|
|
37
|
+
jq -n --arg ctx "$CONTEXT" '{
|
|
38
|
+
hookSpecificOutput: {
|
|
39
|
+
hookEventName: "SessionStart",
|
|
40
|
+
additionalContext: $ctx
|
|
41
|
+
}
|
|
42
|
+
}'
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
exit 0
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coo-quack/do-not-compact",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Claude Code plugin that reloads CLAUDE.md files into context after conversation compaction",
|
|
5
|
+
"homepage": "https://github.com/coo-quack/do-not-compact",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/coo-quack/do-not-compact.git"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"files": [
|
|
13
|
+
".claude-plugin/",
|
|
14
|
+
"hooks/",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"CHANGELOG.md"
|
|
18
|
+
]
|
|
19
|
+
}
|