Raises the main loop to the configured effort (default xhigh) while in plan mode, by rewriting each request; the session effort setting is never touched…

<!-- Stable deep link, shared outside the repo: #demo. Keep the id. --> <a id="demo"></a><img src="../assets/brewmods/plan-effort-bottle.gif" width="260" alt="ASCII glass fermenter, bubbling; the tape label reads xhigh · batch 04"> <img src="../assets/brewmods/plan-effort.gif" width="800" alt="Claude Code terminal, session effort high: Shift+Tab into plan mode shows no row, the first prompt shows a toast and a teal plan-mode row (Claude Code's plan-mode colour) above the prompt, and Shift+Tab out removes the row.">
<h1 align="center">Plan-mode effort</h1>
<a href="https://github.com/kochetkov-ma/claude-brewcode/stargazers"><img src="https://badgen.net/github/stars/kochetkov-ma/claude-brewcode?icon=github&label=stars" alt="GitHub stars"></a> <img src="https://img.shields.io/badge/Claude_Code-2.1.301%2B-d97706" alt="Requires Claude Code 2.1.301+"> <img src="https://img.shields.io/badge/type-mod-8b5cf6" alt="Claude Code mod"> <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT">
Runs alongside brewmod-placeholders: the plan-mode row sits above its band. Part of the brewcode mods.
❗ Update Claude Code first: the mods need Claude Code 2.1.301 or newer. Check with
claude --version; if it is lower, runclaude update, then restart Claude Code (exit, runclaude).
claude plugin marketplace add https://github.com/kochetkov-ma/claude-brewcode && claude plugin install brewmod-plan-effort@claude-brewcode
Then run /reload-plugins.
claude update # Claude Code 2.1.301+ first, then restart Claude Code
claude plugin marketplace update claude-brewcode && claude plugin update brewmod-plan-effort@claude-brewcode
claude --plugin-dir ./brewmod-plan-effort # dev mode, no install
node on the PATH (runs the bundled command hook hooks/mode.mjs)./brewtools:plugin-update.| You do | You get |
|---|---|
Shift+Tab twice from the default mode (manual mode on → accept edits on → plan mode on), or /plan | Nothing shows at the keypress itself: Claude Code gives mods no live mode signal, so the mod learns plan mode at the first prompt or tool batch. From that prompt on, requests run at xhigh, a row in Claude Code's plan-mode colour (teal) appears above the prompt, and a toast shows once per plan visit |
Shift+Tab out of plan mode | The row disappears at once (about 0.1 s), because the hint line Claude Code draws names the mode just left. The next request is already at your session effort. The status line keeps showing your session effort: the mod raises effort per request and never changes the session setting |
Shift+Tab back into plan mode, then a prompt | A second plan visit: the row and the toast show again |
| Approve the plan | The next request is back at your session effort, nothing to undo |
/plan-effort max | Plan-mode level set to max, same as the planEffort option in /config; the row updates to the new level |
| Where | Text | When |
|---|---|---|
| Toast, 5 s | brewmod-plan-effort: plan mode · effort raised to xhigh | Once per plan visit (leaving and re-entering plan mode starts a new one), only when the mod raised the effort |
| No row | Default or any other mode; before the first prompt of a plan visit; after Shift+Tab out of plan mode |
In plan mode the row above the prompt, drawn in Claude Code's plan-mode colour (the planMode theme colour: teal on a dark theme, a darker teal on a light one), and the session line of the /plan-effort status block follow the session effort:
| Session effort | Row above the prompt | session line |
|---|---|---|
Below planEffort (here high) | plan mode · effort xhigh for this mode · change: /plan-effort <level> | high -> raised to xhigh in plan mode |
At or above planEffort (here max) | plan mode · effort max, already >= xhigh | max not raised, session already >= plan effort |
| None: the model takes no effort level | plan mode · effort not raised: model takes no effort level | none not raised, model takes no effort level |
A number (here 3) | plan mode · effort not raised: 3 is not an effort level | 3 not raised, 3 is not an effort level |
| No request seen yet | no row | n/a until the next request |
Claude Code adds the brewmod-plan-effort: prefix to the toast and to the first line of command output; the mod supplies the text after it.
The row stays through turns and typing, sits above any other prompt-area UI and steps aside while a survey is open. With brewmod-placeholders loaded, it stays visible above the placeholders band in either load order. It uses one of the rows the band would otherwise get, so the band below keeps its full layout and does not overflow in fullscreen.
/plan-effort prints a status block:
status
plan effort xhigh (medium | high | xhigh | max)
session high -> raised to xhigh in plan mode
mode now plan
/plan-effort <level> set the plan-mode effort
/plan-effort show this status
plan effort shows the configured level and the allowed levels; mode now is one of:
mode now | Meaning |
|---|---|
plan (or the other mode name from the state file) | Mode recorded at the last prompt or tool batch |
unknown until the next prompt | No state file yet |
plan mode left (Shift+Tab); known at the next prompt | You left plan mode by Shift+Tab; the new mode is learned at the next prompt |
| Command | Result | |||
|---|---|---|---|---|
/plan-effort (also status) | The status block above | |||
/plan-effort help | The status block under the head help · in plan mode, main-session requests below the plan effort are sent at it; never lowered; subagents and the session effort setting are left alone | |||
| `/plan-effort <medium\ | high\ | xhigh\ | max>` | Sets planEffort and prints plan effort: <old> -> <new> plus the status rows |
/plan-effort <other word> | Prints unknown '<arg>' plus the status rows |
/config has one option, planEffort (default xhigh). In claude -p there is no /config row: the command prints plan effort: cannot set it here (no /config row, e.g. under -p) · set: /config in an interactive session, or settings.json pluginConfigs.
/effort setting is never written, and subagents keep their own effort.planEffort stays as it is.classic.* hooks.Shift+Tab behaviour 78 of 78 checks over 10 sessions, both mod load orders, 120x40 and 80x24 terminals. Row colour and the placeholders band beside it: 225 of 225 cases of the 6.9.5 live run with both mods loaded (the row in terminal colour 38;5;73 on a dark theme). Unit tests: 71 pass. Earlier measurement on 2.1.300: plan mode sent 4 xhigh requests, default mode 0, on Team-org and Max profiles. Full results.xhigh on all 6 plan-mode requests. Measurement and limits.hooks/mode.mjs, a bundled command hook on UserPromptSubmit and PostToolBatch, writes the main loop's permission_mode to <plugin root>/.state/mode-<session_id>.json; turn.step reads it.planEffort.Full detail: Technical details. Background: anthropics/claude-code#91444.
Docs | Project page | Source | All mods | Release notes
Author: Maksim Kochetkov | License: MIT
hooks/register.ts 146 lines1// SPDX-License-Identifier: MIT
2// Copyright (c) 2025-2026 Maksim Kochetkov
3
4import type { Register } from 'claude-code'
5import type { PlanSeen } from '../types'
6
7const RANK = ['low', 'medium', 'high', 'xhigh', 'max'] as const
8const LEVELS = ['medium', 'high', 'xhigh', 'max'] as const
9const SESSION_ID = /^[A-Za-z0-9_-]+$/
10// Live CC 2.1.301: a Shift+Tab out of plan draws one hint 'plan mode on (shift+tab to cycle)', in plan it reads '(shift+tab to cycle)'
11const LEFT_PLAN = /^plan mode on\b/
12const NONE = 'none'
13const USAGE = '/plan-effort <level> set the plan-mode effort\n/plan-effort show this status'
14const HEADLESS = 'plan effort: cannot set it here (no /config row, e.g. under -p) · set: /config in an interactive session, or settings.json pluginConfigs'
15const HELP = 'help · in plan mode, main-session requests below the plan effort are sent at it; never lowered; subagents and the session effort setting are left alone'
16const session = { plugin: 'brewmod-plan-effort', key: 'session' } as const
17const toasted = { plugin: 'brewmod-plan-effort', key: 'toasted' } as const
18const plan = { plugin: 'brewmod-plan-effort', key: 'plan' } as const
19const rank = (v: unknown): number => RANK.findIndex((r) => r === v)
20
21type ModeFile = { mode: string; ts: number }
22
23// Pure: state-file text -> {mode, ts}; missing or corrupt input is undefined (fail open)
24const modeOf = (text: unknown): ModeFile | undefined => {
25 if (typeof text !== 'string') return undefined
26 try {
27 const j = JSON.parse(text) as { mode?: unknown; ts?: unknown } | null
28 return typeof j?.mode === 'string' ? { mode: j.mode, ts: typeof j.ts === 'number' ? j.ts : 0 } : undefined
29 } catch {
30 return undefined
31 }
32}
33
34// Pure: a left-plan hint holds until mode.mjs writes a newer file; a ts-less file (ts 0) never holds it
35const isLeftNow = (file: ModeFile | undefined, seen: PlanSeen | undefined): boolean => file !== undefined && file.ts > 0 && seen?.isLeft === true && seen.ts === file.ts
36const isPlanNow = (file: ModeFile | undefined, seen: PlanSeen | undefined): boolean => file?.mode === 'plan' && !isLeftNow(file, seen)
37
38// Pure: why a non-level session effort is never raised
39const noLevel = (s: string): string => (s === NONE ? 'model takes no effort level' : `${s} is not an effort level`)
40
41// Pure: the row above the prompt; undefined = no row
42const rowText = (isPlan: boolean, planEffort: string, sess: string | undefined): string | undefined => {
43 if (!isPlan || sess === undefined) return undefined
44 const have = rank(sess)
45 if (have < 0) return `plan mode · effort not raised: ${noLevel(sess)}`
46 return have < rank(planEffort) ? `plan mode · effort ${planEffort} for this mode · change: /plan-effort <level>` : `plan mode · effort ${sess}, already >= ${planEffort}`
47}
48
49// Pure: head line (the engine glues the plugin name to it) + aligned status rows + usage
50const block = (head: string, planEffort: string, levels: readonly string[], sess: string | undefined, mode: string): string => {
51 const have = rank(sess)
52 const s =
53 sess === undefined
54 ? 'n/a until the next request'
55 : have < 0
56 ? `${sess.padEnd(7)}not raised, ${noLevel(sess)}`
57 : `${sess.padEnd(7)}${have < rank(planEffort) ? `-> raised to ${planEffort} in plan mode` : 'not raised, session already >= plan effort'}`
58 return [head, `plan effort ${planEffort.padEnd(7)}(${levels.join(' | ')})`, `session ${s}`, `mode now ${mode}`, USAGE].join('\n')
59}
60
61export const register: Register = (on, options) => {
62 // Re-fires after every reload (a config set reloads the module): register is idempotent
63 on('session.start', async ($, e, next) => {
64 await $.command.register({ name: 'plan-effort', description: 'Show or set the plan-mode effort', argumentHint: '[status|help|medium|high|xhigh|max]' }).catch(() => undefined)
65 return next(e)
66 })
67
68 on('command.run', { command: 'plan-effort' }, async ($, e, next) => {
69 const words = e.args.trim().split(/\s+/).filter((w) => w !== '')
70 if (words[0] === 'set') words.shift()
71 const arg = words[0]?.toLowerCase()
72 const rows = await $.config.list().catch(() => [])
73 const row = rows.find((r) => r.key.endsWith('.planEffort') && r.provider.plugin.startsWith($.plugin.name))
74 const levels = row?.options ?? LEVELS
75 let target = typeof row?.value === 'string' ? row.value : String(options.planEffort)
76 const sid = await $.session.id()
77 const file = typeof sid === 'string' && SESSION_ID.test(sid) ? modeOf(await $.fs.read(`${$.plugin.root}/.state/mode-${sid}.json`).catch(() => undefined)) : undefined
78 const seen = (await $.state.get(plan).catch(() => undefined))?.value
79 const left = isLeftNow(file, seen)
80 const mode = file === undefined ? 'unknown until the next prompt' : left ? 'plan mode left (Shift+Tab); known at the next prompt' : file.mode
81 const held = (await $.state.get(session).catch(() => undefined))?.value
82 const status = (head = 'status'): string => block(head, target, levels, held, mode)
83 if (arg === undefined || arg === 'status') return { text: status() }
84 if (arg === 'help') return { text: status(HELP) }
85 if (!levels.includes(arg)) return { text: status(`unknown '${words[0]}'`) }
86 const res = row === undefined ? undefined : await $.config.set({ key: row.key, value: arg }).catch(() => undefined)
87 if (res === undefined) return { text: status(HEADLESS) }
88 if (res.deny !== undefined) return { text: `${res.deny}\n${USAGE}` }
89 const old = target
90 target = arg
91 return { text: status(`plan effort: ${old} -> ${arg}`) }
92 })
93
94 // Raise only (lower/equal, numeric, absent efforts and subagent steps untouched); mode = hooks/mode.mjs state file (works on org-managed installs too)
95 // One-shot toast per plan visit; session/toasted/plan live in $.state, so a reload neither repeats nor loses them
96 on('turn.step', async function* ($, e, next) {
97 const main = e.agentId === undefined
98 const wanted = rank(options.planEffort)
99 const have = rank(e.effort)
100 let target: (typeof RANK)[number] | undefined
101 if (main) {
102 const sid = await $.session.id()
103 // no read unless the id is path-safe (same check as mode.mjs)
104 const file = typeof sid === 'string' && SESSION_ID.test(sid) ? modeOf(await $.fs.read(`${$.plugin.root}/.state/mode-${sid}.json`).catch(() => undefined)) : undefined
105 const seen = (await $.state.get(plan).catch(() => undefined))?.value
106 const isPlan = isPlanNow(file, seen)
107 if (have >= 0 && have < wanted && isPlan) target = RANK[wanted]
108 const sess = e.effort === undefined ? NONE : String(e.effort)
109 if ((await $.state.get(session).catch(() => undefined))?.value !== sess) await $.state.set(session, sess).catch(() => undefined)
110 const isLeft = isLeftNow(file, seen)
111 // no file = not plan (fail open), so a vanished file drops the row too
112 const now = { isPlan, ts: file?.ts ?? 0, isLeft }
113 if (seen === undefined ? file !== undefined : seen.ts !== now.ts || seen.isPlan !== now.isPlan || seen.isLeft !== now.isLeft) await $.state.set(plan, now).catch(() => undefined)
114 const shown = (await $.state.get(toasted).catch(() => undefined))?.value === true
115 if (target !== undefined && !shown) {
116 $.ui.toast(`plan mode · effort raised to ${target}`, { timeoutMs: 5000 })
117 await $.state.set(toasted, true).catch(() => undefined)
118 } else if (shown && !isPlan) await $.state.set(toasted, false).catch(() => undefined)
119 }
120 return yield* next(target === undefined ? e : { ...e, effort: target })
121 })
122
123 // Shift+Tab out of plan mode: drop the row and end the toast's visit; a draw cannot write state, so a timer does, unless a step wrote since the draw
124 on('ui.render', { component: 'PromptHint' }, async ($, e, next) => {
125 const r = LEFT_PLAN.test(e.props.hint) ? await $.state.get(plan).catch(() => undefined) : undefined
126 const ts = r?.value?.isPlan === true ? r.value.ts : undefined
127 if (r !== undefined && ts !== undefined) {
128 $.clock.after(0, () => void $.state.set(plan, { isPlan: false, ts, isLeft: true }, { ifVersion: r.version }).then((w) => (w.isSet ? $.state.set(toasted, false) : undefined)).catch(() => undefined))
129 }
130 return next(e)
131 })
132
133 // Persistent plan-mode row above whatever the plugins beneath draw; yields to a survey
134 // The row takes one of maxRows: hooks beneath get one fewer, so a band sized to it never scrolls under the row
135 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
136 if (e.props.hasSurvey) return next(e)
137 const seen = (await $.state.get(plan).catch(() => undefined))?.value
138 const sess = (await $.state.get(session).catch(() => undefined))?.value
139 const text = rowText(seen?.isPlan === true, String(options.planEffort), sess)
140 if (text === undefined) return next(e)
141 const below = await next({ ...e, props: { ...e.props, maxRows: Math.max(1, e.props.maxRows - 1) } })
142 const { Box, Text } = $.ui.resolve(e)
143 return Box({ flexDirection: 'column', children: [Text({ color: 'planMode', wrap: 'truncate-end', children: text }), below] })
144 })
145}
146types/index.d.ts 10 lines1export type Effort = string
2// Plan mode as last decided from the state file (ts); isLeft = a Shift+Tab hint ended it since
3export type PlanSeen = { isPlan: boolean; ts: number; isLeft: boolean }
4
5declare module 'claude-code' {
6 interface PluginState {
7 'brewmod-plan-effort': { session: Effort; toasted: boolean; plan: PlanSeen }
8 }
9}
10