claude-code-handoff 1.8.1 → 1.9.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/README.md +3 -3
- package/cli.js +5 -4
- package/commands/auto-handoff.md +7 -5
- package/hooks/context-monitor.sh +2 -2
- package/install.sh +4 -4
- package/package.json +1 -1
- package/uninstall.sh +1 -0
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90} # change 90 to your value
|
|
|
253
253
|
|
|
254
254
|
- **One-shot trigger**: A flag file in `/tmp` (per session ID) prevents infinite loops — the hook triggers exactly once per session, even if Claude's handoff response pushes the transcript further
|
|
255
255
|
- **Session cleanup**: A `SessionStart` hook automatically cleans up stale flag files older than 24 hours
|
|
256
|
-
- **
|
|
256
|
+
- **Opt-in design**: Auto-handoff only runs when `.claude/hooks/.auto-handoff-enabled` exists (created by `/auto-handoff`). No file = disabled by default
|
|
257
257
|
- **Non-destructive**: The hook only blocks and instructs — it never modifies files directly. Claude performs the actual handoff save
|
|
258
258
|
|
|
259
259
|
### What Happens When It Triggers
|
|
@@ -311,7 +311,7 @@ your-project/
|
|
|
311
311
|
├── hooks/
|
|
312
312
|
│ ├── context-monitor.sh ← Stop hook (monitors context size)
|
|
313
313
|
│ ├── session-cleanup.sh ← SessionStart hook (cleans old flags)
|
|
314
|
-
│ └── .auto-handoff-
|
|
314
|
+
│ └── .auto-handoff-enabled ← Enable flag (created by /auto-handoff)
|
|
315
315
|
├── settings.json ← Hook configuration
|
|
316
316
|
└── handoffs/ ← Session state (gitignored)
|
|
317
317
|
├── _active.md ← Current workstream
|
|
@@ -604,7 +604,7 @@ A: Absolutely. They're plain markdown. You can add notes, reorder next steps, or
|
|
|
604
604
|
A: The threshold is a percentage of Claude Code's 200K token context window. At 90% (default), the hook triggers at 180K tokens. The hook reads the **actual token count** from Claude's API usage data — not file size estimates. You can set any value from 1-100 via env var (`CLAUDE_CONTEXT_THRESHOLD=80`) or the `/auto-handoff` command.
|
|
605
605
|
|
|
606
606
|
**Q: Can I disable auto-handoff?**
|
|
607
|
-
A: Yes. Run `/auto-handoff` and select "Disable", or manually
|
|
607
|
+
A: Yes. Run `/auto-handoff` and select "Disable", or manually delete `.claude/hooks/.auto-handoff-enabled`. Without this file, auto-handoff is off.
|
|
608
608
|
|
|
609
609
|
**Q: What if auto-handoff triggers too early/late?**
|
|
610
610
|
A: Adjust the threshold. If it triggers too early, increase to 95%. If you're running out of context before it triggers, lower to 80% or 75%. Use `/auto-handoff` to change it interactively.
|
package/cli.js
CHANGED
|
@@ -90,11 +90,12 @@ if (isReinstall) {
|
|
|
90
90
|
console.log(` Preserved max context: ${CYAN}${savedMaxContext} tokens${NC}`);
|
|
91
91
|
}
|
|
92
92
|
fs.writeFileSync(monitorPath, content);
|
|
93
|
-
// Don't touch .auto-handoff-disabled — preserve user's on/off choice
|
|
94
|
-
} else {
|
|
95
|
-
// Fresh install: auto-handoff disabled by default (beta feature)
|
|
96
|
-
fs.writeFileSync(path.join(CLAUDE_DIR, 'hooks', '.auto-handoff-disabled'), '');
|
|
97
93
|
}
|
|
94
|
+
// Auto-handoff is opt-in: disabled by default (no file = disabled)
|
|
95
|
+
// User enables via /auto-handoff which creates .auto-handoff-enabled
|
|
96
|
+
// Clean up legacy disabled flag if present
|
|
97
|
+
const legacyDisabled = path.join(CLAUDE_DIR, 'hooks', '.auto-handoff-disabled');
|
|
98
|
+
if (fs.existsSync(legacyDisabled)) fs.unlinkSync(legacyDisabled);
|
|
98
99
|
|
|
99
100
|
// 5. Configure hooks in settings.json
|
|
100
101
|
console.log(` ${YELLOW}[5/10]${NC} Configuring hooks in settings.json...`);
|
package/commands/auto-handoff.md
CHANGED
|
@@ -6,9 +6,9 @@ Toggle the automatic handoff context monitor on/off, configure threshold, and se
|
|
|
6
6
|
|
|
7
7
|
### Step 1: Check current state
|
|
8
8
|
|
|
9
|
-
Check if `.claude/hooks/.auto-handoff-
|
|
10
|
-
- If exists → currently
|
|
11
|
-
- If not exists → currently
|
|
9
|
+
Check if `.claude/hooks/.auto-handoff-enabled` exists:
|
|
10
|
+
- If exists → currently ENABLED
|
|
11
|
+
- If not exists → currently DISABLED (default)
|
|
12
12
|
|
|
13
13
|
Also read from `.claude/hooks/context-monitor.sh`:
|
|
14
14
|
- `THRESHOLD_PERCENT` value (the default in `THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-XX}`)
|
|
@@ -30,7 +30,9 @@ Use AskUserQuestion:
|
|
|
30
30
|
### Step 3: Execute
|
|
31
31
|
|
|
32
32
|
#### Toggle (Ativar/Desativar):
|
|
33
|
-
-
|
|
33
|
+
- Ativar: create `.claude/hooks/.auto-handoff-enabled`
|
|
34
|
+
- Desativar: delete `.claude/hooks/.auto-handoff-enabled`
|
|
35
|
+
- Also delete legacy `.claude/hooks/.auto-handoff-disabled` if it exists
|
|
34
36
|
|
|
35
37
|
#### Ajustar threshold:
|
|
36
38
|
Ask with AskUserQuestion:
|
|
@@ -52,7 +54,7 @@ Ask with AskUserQuestion:
|
|
|
52
54
|
- Update the `MAX_CONTEXT_TOKENS` default value in `context-monitor.sh` by changing `MAX_CONTEXT_TOKENS=${CLAUDE_MAX_CONTEXT:-XXXXXX}` to the chosen value
|
|
53
55
|
|
|
54
56
|
#### Ativar com configuração customizada:
|
|
55
|
-
Run both "Alterar plano" and "Ajustar threshold" flows above, then
|
|
57
|
+
Run both "Alterar plano" and "Ajustar threshold" flows above, then create `.claude/hooks/.auto-handoff-enabled`
|
|
56
58
|
|
|
57
59
|
### Step 4: Confirm
|
|
58
60
|
|
package/hooks/context-monitor.sh
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
# Detecta quando o contexto está próximo do limite e força o salvamento do handoff.
|
|
4
4
|
# Usado como hook "Stop" do Claude Code.
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Auto-handoff is opt-in: only runs if explicitly enabled
|
|
7
7
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
if [ -f "$SCRIPT_DIR/.auto-handoff-
|
|
8
|
+
if [ ! -f "$SCRIPT_DIR/.auto-handoff-enabled" ]; then
|
|
9
9
|
exit 0
|
|
10
10
|
fi
|
|
11
11
|
|
package/install.sh
CHANGED
|
@@ -95,11 +95,11 @@ if [ "$IS_REINSTALL" = true ]; then
|
|
|
95
95
|
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh.bak"
|
|
96
96
|
echo -e " Preserved max context: ${CYAN}${SAVED_MAX_CONTEXT} tokens${NC}"
|
|
97
97
|
fi
|
|
98
|
-
# Don't touch .auto-handoff-disabled — preserve user's on/off choice
|
|
99
|
-
else
|
|
100
|
-
# Fresh install: auto-handoff disabled by default (beta feature)
|
|
101
|
-
touch "$CLAUDE_DIR/hooks/.auto-handoff-disabled"
|
|
102
98
|
fi
|
|
99
|
+
# Auto-handoff is opt-in: disabled by default (no file = disabled)
|
|
100
|
+
# User enables via /auto-handoff which creates .auto-handoff-enabled
|
|
101
|
+
# Clean up legacy disabled flag if present
|
|
102
|
+
rm -f "$CLAUDE_DIR/hooks/.auto-handoff-disabled"
|
|
103
103
|
|
|
104
104
|
# 5. Configure hooks in settings.json
|
|
105
105
|
echo -e " ${YELLOW}[5/10]${NC} Configuring hooks in settings.json..."
|
package/package.json
CHANGED
package/uninstall.sh
CHANGED
|
@@ -50,6 +50,7 @@ rm -f "$CLAUDE_DIR/rules/auto-handoff.md"
|
|
|
50
50
|
echo -e " ${YELLOW}[3/6]${NC} Removing hooks..."
|
|
51
51
|
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
52
52
|
rm -f "$CLAUDE_DIR/hooks/session-cleanup.sh"
|
|
53
|
+
rm -f "$CLAUDE_DIR/hooks/.auto-handoff-enabled"
|
|
53
54
|
rm -f "$CLAUDE_DIR/hooks/.auto-handoff-disabled"
|
|
54
55
|
rmdir "$CLAUDE_DIR/hooks" 2>/dev/null || true
|
|
55
56
|
|