Pick the model with one keypress when a session opens, no /model needed.

A Claude Code mod that lets you pick the model with one keypress the moment a session opens. No more typing /model.
Model: claude-fable-5-1. Press a digit to switch.
1: Fable 2: Opus 3: Sonnet 4: Haiku 5: GLM-5.3 Flash Beta 6: GLM-5.3 744B 0: Keep
(The last two: the model rows another mod — intility-inference — keeps in the settings file. See Customise.)
Press a digit on the empty prompt and the mod runs /model <alias> for you. Press 0 to keep what you have. The band goes away either way.
At the prompt of a terminal session:
/plugin install model-picker --marketplace alfredtm/claude-model-picker
Answer y to add the marketplace, then pick a scope (user is the usual one). The mod is active right away and in every session after.
1 to 4 switch the model. 0 keeps the current one./pick-model brings the band back later in the session.Headless runs (claude -p) never show it.
Set a model the mod switches to on every interactive start, before you press anything. Handy when something else (managed settings, say) resets the model between sessions.
Open /config, find Default model under model-picker and enter whatever /model accepts: opus, sonnet, a full id like claude-opus-5-5. Or put it in ~/.claude/settings.json by hand:
{
"pluginConfigs": {
"model-picker@alfredtm": {
"options": { "defaultModel": "opus" }
}
}
}
(The key is the plugin's name as claude plugin list prints it; a --plugin-dir checkout is plain model-picker.)
The band still shows, with the default marked, so a digit overrides it for the session. Leave the option empty to keep whatever the session opened on.
Beside the four built-ins, the band carries every model row in the user settings.json's modelPicker.options — the same rows /model shows, so whatever keeps them there rides the band with a digit of its own: a hand-edited lineup, or a mod that maintains one (intility-inference writes its GLM models there, and they appear beside the Claude models). replaceBuiltInOptions: true shows the rows alone. The rows are read when a session opens and when /pick-model is run, from the user settings file only, and the band stops at nine choices — 0 keeps — because the digits run out.
The built-ins themselves live in one list at the top of hooks/choices.ts:
export const BUILT_INS: Choice[] = [
{ hotkey: '1', label: 'Fable', value: 'fable' },
...
]
value is whatever /model accepts: an alias like opus or a full model id.
Run it from a checkout without installing:
claude --plugin-dir /path/to/claude-model-picker
Edits to the hooks module hot-reload in that session. Check and test with:
claude plugin validate .
claude plugin test .
After the mod has loaded once, tsc -p . type-checks it against the declarations Claude Code lays down in .claude-plugin/types/.
MIT
hooks/register.tsx 112 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import { BUILT_INS, choicesFromSettings } from './choices'
5
6const isShown = atom({ plugin: 'model-picker', key: 'isShown' } as const, false)
7const current = atom({ plugin: 'model-picker', key: 'current' } as const, '')
8const choices = atom({ plugin: 'model-picker', key: 'choices' } as const, BUILT_INS)
9
10// The band's models from the settings file: the built-ins plus the
11// model rows its modelPicker carries — the same rows /model shows, so
12// whatever keeps them there (a hand-edited lineup, intility-inference
13// with the GLM models) rides the band with a digit each. Read once a
14// session and on /pick-model, never on render — that happens at every
15// prompt. A fault leaves the band exactly as it was.
16async function readChoices($: EngineInterface): Promise<void> {
17 try {
18 const home = await $.env.get('HOME')
19 if (home === undefined) return
20 const dir = (await $.env.get('CLAUDE_CONFIG_DIR')) ?? `${home}/.claude`
21 const text = await $.fs.read(`${dir}/settings.json`)
22 await update($, choices, () => choicesFromSettings(text))
23 } catch {}
24}
25
26export const register: Register = (on, options) => {
27 // The `defaultModel` option from /config (or settings.json `pluginConfigs`):
28 // what `/model` is run with on every interactive start. Empty means leave
29 // the session on whatever it opened with.
30 const defaultModel = typeof options.defaultModel === 'string' ? options.defaultModel.trim() : ''
31
32 on('session.start', async ($, e, next) => {
33 await $.command.register({
34 name: 'pick-model',
35 description: 'Show the model picker band above the prompt',
36 })
37
38 if (e.isInteractive) {
39 await readChoices($)
40 await update($, current, () => '')
41 await update($, isShown, () => true)
42
43 if (defaultModel) {
44 try {
45 await $.command.run({ command: 'model', args: defaultModel })
46 } catch (error) {
47 $.ui.toast(`model-picker: default model ${defaultModel}: ${error instanceof Error ? error.message : String(error)}`)
48 }
49 }
50
51 void $.session.model().then(model => update($, current, () => model))
52 }
53
54 return next(e)
55 })
56
57 on('command.run', { command: 'pick-model' }, async $ => {
58 await readChoices($)
59 const model = await $.session.model()
60 await update($, current, () => model)
61 await update($, isShown, () => true)
62
63 return { text: 'Model picker shown above the prompt.' }
64 })
65
66 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
67 if (e.props.hasSurvey || !(await read($, isShown))) {
68 return next(e)
69 }
70
71 const { Box, Button, Text } = $.ui.resolve(e)
72 const model = await read($, current)
73
74 const pick = async (value: string) => {
75 await update($, isShown, () => false)
76 try {
77 await $.command.run({ command: 'model', args: value })
78 } catch (error) {
79 $.ui.toast(`model-picker: ${error instanceof Error ? error.message : String(error)}`)
80 }
81 }
82
83 return (
84 <Box flexDirection="column">
85 <Text dimColor>
86 Model{model ? `: ${model}` : ''}.
87 {defaultModel ? ` Default on start: ${defaultModel}.` : ''} Press a digit to switch.
88 </Text>
89 <Box gap={1}>
90 {(await read($, choices)).map(choice => (
91 <Button
92 key={choice.value}
93 hotkey={choice.hotkey}
94 label={choice.value === defaultModel ? `${choice.label} (default)` : choice.label}
95 plain
96 onPress={() => void pick(choice.value)}
97 />
98 ))}
99 <Button
100 key="keep"
101 hotkey="0"
102 label="Keep"
103 plain
104 dimColor
105 onPress={() => void update($, isShown, () => false)}
106 />
107 </Box>
108 </Box>
109 )
110 })
111}
112hooks/choices.ts 66 lines1// choices.ts — the band's models, chosen.
2//
3// The built-ins are the mod's own four. Beside them go the model rows
4// the user keeps in settings.json's modelPicker — the same rows /model
5// shows, whatever wrote them: a hand-edited lineup, or a mod that
6// maintains one (intility-inference keeps the GLM models there, so
7// they land on the band beside the Claude ones, a digit each). Pure:
8// the settings text comes in, the choice list goes out; the file is
9// read in register.tsx.
10
11export interface Choice {
12 hotkey: string
13 label: string
14 value: string
15}
16
17// The four the band always had, in the order drawn.
18export const BUILT_INS: Choice[] = [
19 { hotkey: '1', label: 'Fable', value: 'fable' },
20 { hotkey: '2', label: 'Opus', value: 'opus' },
21 { hotkey: '3', label: 'Sonnet', value: 'sonnet' },
22 { hotkey: '4', label: 'Haiku', value: 'haiku' },
23]
24
25// The digits run out at nine — 0 keeps the model — so the band cannot
26// hold more than nine choices.
27const MAX = 9
28
29// The choice list a settings.json's text makes: the built-ins plus its
30// model rows — the rows alone when they replace the built-ins —
31// deduped by value, capped at nine, hotkeys in draw order. Text that
32// is missing, not JSON, or not an object leaves the built-ins alone: a
33// settings file the mod cannot read is not one it has an opinion
34// about.
35export function choicesFromSettings(text: string | undefined): Choice[] {
36 let settings: unknown
37 try {
38 settings = text === undefined ? undefined : JSON.parse(text)
39 } catch {
40 return BUILT_INS
41 }
42 if (typeof settings !== 'object' || settings === null || Array.isArray(settings)) return BUILT_INS
43
44 const picker = (settings as { modelPicker?: unknown }).modelPicker
45 if (typeof picker !== 'object' || picker === null || Array.isArray(picker)) return BUILT_INS
46
47 const rows = (picker as { options?: unknown }).options
48 const replace = (picker as { replaceBuiltInOptions?: unknown }).replaceBuiltInOptions === true
49 if (!Array.isArray(rows)) return BUILT_INS
50
51 const seen = new Set(BUILT_INS.map(c => c.value))
52 const extra: Choice[] = []
53 for (const row of rows) {
54 const model = (row as { model?: unknown } | null)?.model
55 if (typeof model !== 'string' || model === '' || seen.has(model)) continue
56 seen.add(model)
57 const label = (row as { label?: unknown })?.label
58 extra.push({ hotkey: '', label: typeof label === 'string' && label !== '' ? label : model, value: model })
59 }
60
61 const list = [...(replace ? [] : BUILT_INS), ...extra].slice(0, MAX)
62 // never an empty band — a lineup that replaces the built-ins with
63 // nothing it can read is not one to follow into silence
64 return list.length > 0 ? list.map((c, i) => ({ ...c, hotkey: String(i + 1) })) : BUILT_INS
65}
66types/index.d.ts 9 lines1export type ModelPickerCurrent = string
2export type ModelPickerChoice = { hotkey: string; label: string; value: string }
3
4declare module 'claude-code' {
5 interface PluginState {
6 'model-picker': { isShown: boolean; current: ModelPickerCurrent; choices: ModelPickerChoice[] }
7 }
8}
9