claude-code-handoff 1.6.0 → 1.8.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 CHANGED
@@ -49,7 +49,7 @@ Instead of relying on lossy compression or starting from zero, **claude-code-han
49
49
 
50
50
  The workflow becomes: work until context is full → `/handoff` → `/clear` → `/resume` → continue with full context. No degradation, no amnesia. Just clean handoffs.
51
51
 
52
- **Auto-handoff** (since v1.4) monitors your context usage and **automatically triggers a handoff** when the transcript reaches a configurable threshold (default: **90%**) — so you never forget to save. Since v1.5, the threshold is configured as a **percentage of context** instead of fixed bytes, making it intuitive and portable across different setups.
52
+ **Auto-handoff** (beta, since v1.4) monitors your context usage and **automatically triggers a handoff** when the transcript reaches a configurable threshold (default: **90%**) — so you never forget to save. Since v1.5, the threshold is configured as a **percentage of context** instead of fixed bytes. **Disabled by default** — enable it with `/auto-handoff` when you're ready to try it.
53
53
 
54
54
  Session state is stored in `.claude/handoffs/` (gitignored) — each developer keeps their own context, no conflicts.
55
55
 
@@ -62,7 +62,7 @@ cd your-project
62
62
  npx claude-code-handoff
63
63
  ```
64
64
 
65
- That's it. Open Claude Code and your 6 commands are ready. Auto-handoff is enabled by default at 90%.
65
+ That's it. Open Claude Code and your 6 commands are ready. Auto-handoff is available but **disabled by default** (beta) — run `/auto-handoff` to enable it.
66
66
 
67
67
  ---
68
68
 
@@ -155,10 +155,12 @@ graph TD
155
155
 
156
156
  ---
157
157
 
158
- ## Auto-Handoff (Context Monitor)
158
+ ## Auto-Handoff (Context Monitor) — Beta
159
159
 
160
160
  The biggest risk with handoffs is **forgetting to save**. You're deep in a task, context fills up, and everything is lost. Auto-handoff eliminates this by monitoring your transcript size and **forcing Claude to save the handoff** before it's too late.
161
161
 
162
+ > **Note:** Auto-handoff is a beta feature and is **disabled by default**. Enable it with `/auto-handoff` inside Claude Code.
163
+
162
164
  ### How It Works
163
165
 
164
166
  A [Claude Code hook](https://docs.anthropic.com/en/docs/claude-code/hooks) runs after every Claude response (Stop event). It reads the **actual token count** from Claude's API usage data in the JSONL transcript and compares it against the 200K token context window. When the threshold is exceeded, it **blocks** Claude's next action and forces an immediate handoff save.
@@ -176,19 +178,34 @@ flowchart TD
176
178
  H --> I["User: /clear → /resume"]
177
179
  ```
178
180
 
181
+ ### Plan Selection
182
+
183
+ The context window varies by Claude plan. The hook adapts automatically based on your plan configuration:
184
+
185
+ | Plan | Context Window | Value |
186
+ |------|---------------|-------|
187
+ | **Pro / Max / Team** | 200K tokens | `MAX_CONTEXT_TOKENS=200000` (default) |
188
+ | **Enterprise** | 500K tokens | `MAX_CONTEXT_TOKENS=500000` |
189
+ | **Custom** | Any value | Set via `/auto-handoff` or env var |
190
+
191
+ Configure your plan via the `/auto-handoff` wizard or set the environment variable:
192
+ ```bash
193
+ export CLAUDE_MAX_CONTEXT=500000 # Enterprise
194
+ ```
195
+
179
196
  ### Threshold Configuration
180
197
 
181
- The threshold is configured as a **percentage of the 200K token context window**. The hook reads the **actual token count** from Claude's API usage data in the transcript — no guesswork, no byte-to-token estimation.
198
+ The threshold is configured as a **percentage of your plan's context window**. The hook reads the **actual token count** from Claude's API usage data in the transcript — no guesswork, no byte-to-token estimation.
182
199
 
183
- | Preset | Value | Triggers at | Best for |
184
- |--------|-------|-------------|----------|
185
- | **90% (default)** | `THRESHOLD_PERCENT=90` | 180K tokens | Maximizing context usage |
186
- | **80%** | `THRESHOLD_PERCENT=80` | 160K tokens | Balance between space and safety |
187
- | **75%** | `THRESHOLD_PERCENT=75` | 150K tokens | Short sessions, early handoff |
200
+ | Preset | Value | Triggers at (200K) | Triggers at (500K) | Best for |
201
+ |--------|-------|---------------------|---------------------|----------|
202
+ | **90% (default)** | `THRESHOLD_PERCENT=90` | 180K tokens | 450K tokens | Maximizing context usage |
203
+ | **80%** | `THRESHOLD_PERCENT=80` | 160K tokens | 400K tokens | Balance between space and safety |
204
+ | **75%** | `THRESHOLD_PERCENT=75` | 150K tokens | 375K tokens | Short sessions, early handoff |
188
205
 
189
206
  The calculation uses real data:
190
207
  ```
191
- MAX_CONTEXT_TOKENS = 200000 (Claude Code's context window)
208
+ MAX_CONTEXT_TOKENS = 200000 (or 500000 for Enterprise, or custom)
192
209
  THRESHOLD = MAX_CONTEXT_TOKENS × THRESHOLD_PERCENT / 100
193
210
 
194
211
  # The hook reads input_tokens from the last assistant message in the JSONL
@@ -197,31 +214,39 @@ THRESHOLD = MAX_CONTEXT_TOKENS × THRESHOLD_PERCENT / 100
197
214
 
198
215
  ### Three Ways to Configure
199
216
 
200
- **1. Environment variable** (per-session override):
217
+ **1. Environment variables** (per-session override):
201
218
  ```bash
202
- # Trigger at 80% instead of the default
203
- export CLAUDE_CONTEXT_THRESHOLD=80
219
+ export CLAUDE_MAX_CONTEXT=500000 # Enterprise plan (500K)
220
+ export CLAUDE_CONTEXT_THRESHOLD=80 # Trigger at 80%
204
221
  ```
205
222
 
206
223
  **2. Interactive wizard** (`/auto-handoff` command):
207
224
  ```
208
225
  you: /auto-handoff
209
- claude: Auto-handoff is ENABLED (threshold: 90%). What would you like to do?
210
- 1. Disable
211
- 2. Adjust threshold
226
+ claude: Auto-handoff is DISABLED (plan: Pro/Max/Team, threshold: 90%).
227
+ What would you like to do?
228
+ 1. Enable
229
+ 2. Enable with custom configuration
212
230
 
213
- you: [selects "Adjust threshold"]
231
+ you: [selects "Enable with custom configuration"]
232
+ claude: Which is your Claude plan?
233
+ 1. Pro / Max / Team — 200K tokens
234
+ 2. Enterprise — 500K tokens
235
+ 3. Other — Type a custom value
236
+
237
+ you: [selects plan]
214
238
  claude: Which threshold do you want?
215
- 1. 90% (Recommended) — Default, maximizes context usage
216
- 2. 80% — Balance between space and safety
217
- 3. 75% — Short sessions, saves handoff earlier
239
+ 1. 90% (Recommended)
240
+ 2. 80%
241
+ 3. 75%
218
242
  4. Other — Type a custom value
219
243
  ```
220
244
 
221
245
  **3. Edit the script directly**:
222
246
  ```bash
223
- # In .claude/hooks/context-monitor.sh, change the default:
224
- THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90} # change 90 to your value
247
+ # In .claude/hooks/context-monitor.sh, change the defaults:
248
+ MAX_CONTEXT_TOKENS=${CLAUDE_MAX_CONTEXT:-200000} # change 200000 to your value
249
+ THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90} # change 90 to your value
225
250
  ```
226
251
 
227
252
  ### Safety Mechanisms
@@ -285,7 +310,8 @@ your-project/
285
310
  │ └── auto-handoff.md ← Auto-handoff trigger rules
286
311
  ├── hooks/
287
312
  │ ├── context-monitor.sh ← Stop hook (monitors context size)
288
- └── session-cleanup.sh ← SessionStart hook (cleans old flags)
313
+ ├── session-cleanup.sh ← SessionStart hook (cleans old flags)
314
+ │ └── .auto-handoff-disabled ← Disable flag (remove to enable)
289
315
  ├── settings.json ← Hook configuration
290
316
  └── handoffs/ ← Session state (gitignored)
291
317
  ├── _active.md ← Current workstream
@@ -560,7 +586,7 @@ rm -rf .claude/handoffs/ # ⚠️ deletes all session history
560
586
  A: Yes. Handoff files are gitignored, so each developer has their own session state. No conflicts.
561
587
 
562
588
  **Q: What happens if I forget to `/handoff` before `/clear`?**
563
- A: With auto-handoff enabled (default since v1.4), Claude will automatically save the handoff when the context reaches 90%. Without it, the context is lost for that session — the previous handoff is still there, but you won't have the latest session recorded.
589
+ A: If you've enabled auto-handoff (beta), Claude will automatically save the handoff when the context reaches the threshold. Without it, the context is lost for that session — the previous handoff is still there, but you won't have the latest session recorded.
564
590
 
565
591
  **Q: Can I have unlimited workstreams?**
566
592
  A: Yes. The `archive/` folder has no limit. Each workstream is a single `.md` file.
package/cli.js CHANGED
@@ -62,6 +62,8 @@ copyFile('hooks/context-monitor.sh', path.join(CLAUDE_DIR, 'hooks', 'context-mon
62
62
  copyFile('hooks/session-cleanup.sh', path.join(CLAUDE_DIR, 'hooks', 'session-cleanup.sh'));
63
63
  fs.chmodSync(path.join(CLAUDE_DIR, 'hooks', 'context-monitor.sh'), 0o755);
64
64
  fs.chmodSync(path.join(CLAUDE_DIR, 'hooks', 'session-cleanup.sh'), 0o755);
65
+ // Auto-handoff disabled by default (beta feature)
66
+ fs.writeFileSync(path.join(CLAUDE_DIR, 'hooks', '.auto-handoff-disabled'), '');
65
67
 
66
68
  // 5. Configure hooks in settings.json
67
69
  console.log(` ${YELLOW}[5/10]${NC} Configuring hooks in settings.json...`);
@@ -177,9 +179,8 @@ console.log(` ${CYAN}/switch-context${NC} Switch workstream`);
177
179
  console.log(` ${CYAN}/delete-handoff${NC} Delete handoff(s)`);
178
180
  console.log(` ${CYAN}/auto-handoff${NC} Toggle auto-handoff on/off`);
179
181
  console.log('');
180
- console.log(' Auto-handoff:');
181
- console.log(' Context monitor hook installed (triggers at 90% of context)');
182
- console.log(` Use ${CYAN}/auto-handoff${NC} to enable/disable or adjust threshold`);
182
+ console.log(` Auto-handoff: ${YELLOW}(beta — disabled by default)${NC}`);
183
+ console.log(` Use ${CYAN}/auto-handoff${NC} to enable and configure threshold`);
183
184
  console.log('');
184
185
  console.log(' Files:');
185
186
  console.log(' .claude/commands/ 6 command files');
@@ -1,6 +1,6 @@
1
1
  # Auto-Handoff
2
2
 
3
- Toggle the automatic handoff context monitor on/off and configure the threshold.
3
+ Toggle the automatic handoff context monitor on/off, configure threshold, and select your Claude plan.
4
4
 
5
5
  ## Instructions
6
6
 
@@ -10,28 +10,55 @@ Check if `.claude/hooks/.auto-handoff-disabled` exists:
10
10
  - If exists → currently DISABLED
11
11
  - If not exists → currently ENABLED
12
12
 
13
- Also read the current `THRESHOLD_PERCENT` value from `.claude/hooks/context-monitor.sh` (the default value in `THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-XX}`).
13
+ Also read from `.claude/hooks/context-monitor.sh`:
14
+ - `THRESHOLD_PERCENT` value (the default in `THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-XX}`)
15
+ - `MAX_CONTEXT_TOKENS` value (the default in `MAX_CONTEXT_TOKENS=${CLAUDE_MAX_CONTEXT:-XXXXXX}`)
16
+
17
+ Derive the plan name from MAX_CONTEXT_TOKENS:
18
+ - 200000 → "Pro/Max/Team"
19
+ - 500000 → "Enterprise"
20
+ - other → "Custom (XXXk)"
14
21
 
15
22
  ### Step 2: Present wizard
16
23
 
17
24
  Use AskUserQuestion:
18
- - Question: "Auto-handoff está [ATIVADO/DESATIVADO] (threshold: [XX]%). O que deseja fazer?"
25
+ - Question: "Auto-handoff está [ATIVADO/DESATIVADO] (plano: [PLAN], threshold: [XX]%). O que deseja fazer?"
19
26
  - Options based on current state:
20
- - If enabled: "Desativar" / "Ajustar threshold"
21
- - If disabled: "Ativar" / "Ativar com threshold customizado"
27
+ - If enabled: "Desativar" / "Ajustar threshold" / "Alterar plano"
28
+ - If disabled: "Ativar" / "Ativar com configuração customizada"
22
29
 
23
30
  ### Step 3: Execute
24
31
 
25
- - Toggle: create or delete `.claude/hooks/.auto-handoff-disabled`
26
- - Threshold: If user chose to adjust threshold, ask with AskUserQuestion:
27
- - Question: "Qual threshold deseja usar?"
28
- - Options:
29
- - "90% (Recomendado)" — Padrão, maximiza o uso do contexto
30
- - "80%" Equilíbrio entre espaço e segurança
31
- - "75%" — Para sessões curtas, salva handoff mais cedo
32
- - The user can also type a custom value via "Other"
33
- - Update the `THRESHOLD_PERCENT` default value in `context-monitor.sh` by changing `THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-XX}` to the chosen value
32
+ #### Toggle (Ativar/Desativar):
33
+ - Create or delete `.claude/hooks/.auto-handoff-disabled`
34
+
35
+ #### Ajustar threshold:
36
+ Ask with AskUserQuestion:
37
+ - Question: "Qual threshold deseja usar?"
38
+ - Options:
39
+ - "90% (Recomendado)" Padrão, maximiza o uso do contexto
40
+ - "80%" Equilíbrio entre espaço e segurança
41
+ - "75%" — Para sessões curtas, salva handoff mais cedo
42
+ - The user can also type a custom value via "Other"
43
+ - Update the `THRESHOLD_PERCENT` default value in `context-monitor.sh` by changing `THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-XX}` to the chosen value
44
+
45
+ #### Alterar plano:
46
+ Ask with AskUserQuestion:
47
+ - Question: "Qual seu plano do Claude?"
48
+ - Options:
49
+ - "Pro / Max / Team" — 200K tokens de contexto
50
+ - "Enterprise" — 500K tokens de contexto (Sonnet 4.5)
51
+ - The user can also type a custom value via "Other" (e.g., "1000000" for 1M API context)
52
+ - 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
+
54
+ #### Ativar com configuração customizada:
55
+ Run both "Alterar plano" and "Ajustar threshold" flows above, then delete `.claude/hooks/.auto-handoff-disabled`
34
56
 
35
57
  ### Step 4: Confirm
36
58
 
37
- Show current state after change.
59
+ Show current state after change:
60
+ ```
61
+ Auto-handoff: [ATIVADO/DESATIVADO]
62
+ Plano: [plan name] ([MAX_CONTEXT_TOKENS] tokens)
63
+ Threshold: [XX]% (triggers at [calculated tokens] tokens)
64
+ ```
@@ -9,8 +9,9 @@ if [ -f "$SCRIPT_DIR/.auto-handoff-disabled" ]; then
9
9
  exit 0
10
10
  fi
11
11
 
12
- # Contexto máximo do Claude Code (tokens)
13
- MAX_CONTEXT_TOKENS=200000
12
+ # Contexto máximo do Claude Code (tokens). Varia por plano:
13
+ # Pro/Max/Team: 200000 | Enterprise: 500000 | Custom: qualquer valor
14
+ MAX_CONTEXT_TOKENS=${CLAUDE_MAX_CONTEXT:-200000}
14
15
  # Threshold configurável (% do contexto). 90% padrão — maximiza uso do contexto
15
16
  THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90}
16
17
  THRESHOLD_TOKENS=$((MAX_CONTEXT_TOKENS * THRESHOLD_PERCENT / 100))
package/install.sh CHANGED
@@ -71,6 +71,8 @@ download_file "hooks/context-monitor.sh" "$CLAUDE_DIR/hooks/context-monitor.sh"
71
71
  download_file "hooks/session-cleanup.sh" "$CLAUDE_DIR/hooks/session-cleanup.sh"
72
72
  chmod +x "$CLAUDE_DIR/hooks/context-monitor.sh"
73
73
  chmod +x "$CLAUDE_DIR/hooks/session-cleanup.sh"
74
+ # Auto-handoff disabled by default (beta feature)
75
+ touch "$CLAUDE_DIR/hooks/.auto-handoff-disabled"
74
76
 
75
77
  # 5. Configure hooks in settings.json
76
78
  echo -e " ${YELLOW}[5/10]${NC} Configuring hooks in settings.json..."
@@ -306,9 +308,8 @@ echo -e " ${CYAN}/switch-context${NC} Switch workstream"
306
308
  echo -e " ${CYAN}/delete-handoff${NC} Delete handoff(s)"
307
309
  echo -e " ${CYAN}/auto-handoff${NC} Toggle auto-handoff on/off"
308
310
  echo ""
309
- echo -e " Auto-handoff:"
310
- echo -e " Context monitor hook installed (triggers at 90% of context)"
311
- echo -e " Use ${CYAN}/auto-handoff${NC} to enable/disable or adjust threshold"
311
+ echo -e " Auto-handoff: ${YELLOW}(beta — disabled by default)${NC}"
312
+ echo -e " Use ${CYAN}/auto-handoff${NC} to enable and configure threshold"
312
313
  echo ""
313
314
  echo -e " Files:"
314
315
  echo -e " .claude/commands/ 6 command files"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "claude-code-handoff",
3
- "version": "1.6.0",
4
- "description": "Session continuity for Claude Code — 5 slash commands to save, resume, delete, and switch workstreams across /clear",
3
+ "version": "1.8.0",
4
+ "description": "Session continuity for Claude Code — 6 slash commands to save, resume, delete, and switch workstreams across /clear",
5
5
  "bin": {
6
6
  "claude-code-handoff": "./cli.js"
7
7
  },