Stash prompts for later and pop them back into the input box. Instant, no model call.

Stash prompts for later and pop them back into the input box. A Claude Code mod: instant, no model call, works while Claude is busy, and the stashed text never reaches the model.
A message you type while Claude is working is queued. Claude reads it during the current turn or right after it, so it becomes part of the work in progress. That's right for "also update the docs", and Claude often does those things anyway.
Stash is for prompts you don't want sent yet:
In Claude Code:
/plugin install pstash --marketplace maxsoldev/pstash
| Command | Does |
|---|---|
/stash <text> | Saves the text |
/stash pop | Pastes the newest stash into the input box |
/stash yank | Same as pop, but keeps it in the stash |
/stash | Opens the picker |
1. Stash a prompt. Type /stash and the prompt you want to send later.

2. It's saved. Press Enter: the prompt is stashed and the footer count goes up. The stashed text stays out of the chat and out of the model's context.

3. Pop it back. /stash pop pastes the newest stash into the input box, ready to edit or send.

Or pick one. Bare /stash lists everything: 1-9 or ↑↓ highlight a prompt. Then p or Enter pastes it, y pastes it and keeps it, x deletes it. Esc closes. The bottom right shows the version that runs, with · local for a --plugin-dir copy.

One JSON file per project, shared by all sessions: ~/.pstash/<project path with non-alphanumerics as ->.json. Set PSTASH_DIR to move it.
{
"version": 1,
"project": "/Users/max/app",
"items": [
{
"id": "lx2k9a3f",
"text": "how does the retry logic decide when to give up...",
"at": "2026-10-11T14:20:00.000Z",
"from": "claude"
}
]
}
Items are newest first, capped at 100, without duplicates. Each change re-reads the file, so sessions don't overwrite each other, and a file that doesn't parse is never overwritten. Any tool that follows this format can share the stash.
What it sends, and where. Nothing. Stashes stay on your machine in ~/.pstash/. The mod makes no network calls and no model calls.
Which programs it runs. None.
What it changes in your prompts. Nothing. It submits no prompts and adds nothing to yours.
What it changes in the chat. In the record of a /stash run it blanks the command's arguments, so the stashed text never reaches Claude. Claude only sees /stash and the short output line, like stashed · 3.
What it reads. The HOME and PSTASH_DIR environment variables, to find the stash folder, and the session's project root, to pick the file. Its own plugin.json, for the version in the picker.
What each hook does.
session.start: adds the /stash command, loads the stash count and reads the version.command.run for stash: saves, pops, yanks or opens the picker.session.append for command rows: blanks the arguments of a /stash run.prompt.submit, turn.start, turn.complete: notice a /stash run outside a turn, so its spinner can be hidden. Prompts pass through unchanged.ui.render for Spinner: draws the spinner blank while /stash runs outside a turn.ui.render for SessionMode: adds stash n to the footer.ui.render for its pane: draws the picker.ui.focus for its pane: keeps the highlight on the prompts, so p, y and x always know which one to act on.With Task:
task check # tsc, tests, validate --strict
task dev # Claude Code with this checkout instead of the installed pstash
task prod # update the installed pstash from GitHub, then start Claude Code
task shots # re-shoot the screenshots in docs/
task dev uses claude --plugin-dir ., which replaces the installed pstash for that session only. Plain claude still uses the installed copy.
hooks/register.tsx 312 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Item, StashFile } from '../types'
5import { add, empty, fileName, parse, preview, remove, serialize } from './stash'
6
7const PANE = 'pstash'
8const SHOWN = 12
9const NOT_PASTED = 'could not paste into the prompt; kept it'
10const items = atom({ plugin: 'pstash', key: 'items' } as const, [] as Item[])
11// True while a /stash run is under way, so its spinner can be blanked.
12const isRunning = atom({ plugin: 'pstash', key: 'isRunning' } as const, false)
13// The id of the picker row that holds the focus ring, for `p`, `y` and `x`.
14const focused = atom({ plugin: 'pstash', key: 'focused' } as const, null as string | null)
15// `v0.2.0`, plus ` · local` for a copy not installed from a marketplace.
16const label = atom({ plugin: 'pstash', key: 'label' } as const, '')
17
18// The transcript row of a `/stash ...` run, and the args in it to blank out.
19const STASH_ROW = /<command-name>\/?(?:pstash:)?stash<\/command-name>/
20const STASH_PROMPT = /^\s*\/(?:pstash:)?stash(?:\s|$)/
21const ARGS = /<command-args>[\s\S]*?<\/command-args>/g
22
23type $ = EngineInterface
24
25/** `$PSTASH_DIR`, else `~/.pstash`, plus this project's file name. */
26async function location($: $): Promise<{ path: string; project: string }> {
27 const dir = (await $.env.get('PSTASH_DIR')) ?? `${await $.env.get('HOME')}/.pstash`
28 const project = await $.session.root()
29 return { path: `${dir.replace(/\/$/, '')}/${fileName(project)}`, project }
30}
31
32/** Reads the file fresh each time, so other sessions' changes are never lost. */
33async function load($: $): Promise<StashFile> {
34 const { path, project } = await location($)
35 if (!(await $.fs.exists(path))) return empty(project)
36 try {
37 return parse(await $.fs.read(path), project)
38 } catch (error) {
39 throw new Error(`${path} is unreadable (${String(error)}); fix or delete it`)
40 }
41}
42
43async function change($: $, edit: (file: StashFile) => StashFile): Promise<StashFile> {
44 const { path } = await location($)
45 const file = edit(await load($))
46 await $.fs.write(path, serialize(file))
47 await show($, file.items)
48 return file
49}
50
51async function show($: $, list: Item[]): Promise<void> {
52 await update($, items, () => list)
53}
54
55// Each command answers with one short line: a run that prints nothing has its
56// row removed again, which flickers the screen.
57
58async function stash($: $, text: string): Promise<string> {
59 const now = await $.clock.now()
60 const item: Item = {
61 id: `${now.toString(36)}${Math.random().toString(36).slice(2, 6)}`,
62 text,
63 at: new Date(now).toISOString(),
64 from: 'claude',
65 }
66 const file = await change($, f => add(f, item))
67 return `stashed · ${file.items.length}`
68}
69
70/** Pastes at the cursor first and removes only once the box took it; `keep` leaves it stashed. */
71async function pop($: $, item: Item, keep = false): Promise<string> {
72 const isOpen = (await $.ui.panes()).some(pane => pane.id === PANE)
73 if (isOpen) await $.ui.close({ id: PANE })
74 const filled = await $.prompt.fill({ text: item.text, mode: 'insert' })
75 if (!filled.isFilled) return NOT_PASTED
76 if (keep) return `pasted · kept, ${(await load($)).items.length} stashed`
77 const file = await change($, f => remove(f, item.id))
78 return `pasted · ${file.items.length} left`
79}
80
81async function popNewest($: $, keep = false): Promise<string> {
82 const newest = (await load($)).items[0]
83 return newest === undefined ? 'nothing stashed' : pop($, newest, keep)
84}
85
86/** The highlighted picker row, else the first, with its index. */
87async function focusedItem($: $): Promise<{ at: number; target: Item | undefined }> {
88 const list = await read($, items)
89 const id = await read($, focused)
90 const at = Math.max(0, list.findIndex(item => item.id === id))
91 return { at, target: list[at] }
92}
93
94function reportPop($: $, pending: Promise<string>): void {
95 pending.then(
96 text => text === NOT_PASTED && $.ui.toast(text),
97 error => failed($, error),
98 )
99}
100
101async function openPicker($: $): Promise<string> {
102 const file = await load($)
103 await show($, file.items)
104 if (file.items.length === 0) return 'nothing stashed · /stash <text> to add'
105 const rows = Math.min(file.items.length, SHOWN) + 1
106 await $.ui.open({ id: PANE, title: 'Stash', focus: true, closeOnEscape: true, rows })
107 return `${file.items.length} stashed`
108}
109
110/** Deletes the highlighted row (else the first) and moves the ring to the row now in its place. */
111async function deleteFocused($: $): Promise<void> {
112 const { at, target } = await focusedItem($)
113 if (target === undefined) return
114 const file = await change($, f => remove(f, target.id))
115 const next = file.items[Math.min(at, file.items.length - 1)]
116 if (next === undefined) return $.ui.close({ id: PANE })
117 await ring($, next.id)
118}
119
120/** Puts the ring on row `id`. A hotkey press leaves the ring on its own button once the press ends. */
121async function ring($: $, id: string): Promise<void> {
122 await update($, focused, () => id)
123 $.clock.after(30, () => void $.ui.focus({ requestId: PANE, key: `pop-${id}` }))
124}
125
126/** Pops (or with `keep`, yanks) the highlighted row; a toast tells when the box refused it. */
127function actOnFocused($: $, keep: boolean): void {
128 focusedItem($).then(
129 ({ target }) => target && reportPop($, pop($, target, keep)),
130 error => failed($, error),
131 )
132}
133
134/** Reads this copy's version off its plugin.json; installed copies live in the plugins cache. */
135async function versionLabel($: $): Promise<string> {
136 const manifest = JSON.parse(String(await $.fs.read(`${$.plugin.root}/.claude-plugin/plugin.json`)))
137 const version = typeof manifest.version === 'string' ? `v${manifest.version}` : ''
138 const isInstalled = $.plugin.root.includes('/.claude/plugins/')
139 return isInstalled ? version : `${version} · local`
140}
141
142/** Fills the session's state from disk: the count, the rows and the version label. */
143async function fill($: $): Promise<void> {
144 await load($).then(file => show($, file.items), error => failed($, error))
145 // Provenance only: a missing or odd manifest just leaves the label empty.
146 await versionLabel($).then(text => update($, label, () => text), () => undefined)
147}
148
149function message(error: unknown): string {
150 return `pstash: ${error instanceof Error ? error.message : String(error)}`
151}
152
153function failed($: $, error: unknown): void {
154 $.ui.toast(message(error), { timeoutMs: 8000 })
155}
156
157export const register: Register = on => {
158 on('session.start', async ($, e, next) => {
159 await $.command.register({
160 name: 'stash',
161 description: 'Stash a prompt for later; bare /stash picks one to paste back',
162 argumentHint: '[text | pop | yank]',
163 immediate: true,
164 })
165 $.ui.status(undefined) // clears the line 0.1.0 pinned
166 await update($, isRunning, () => false) // a reload mid-run leaves it set
167 await fill($)
168 return next(e)
169 })
170
171 // `/clear` starts a new session with empty state and no `session.start`.
172 on('classic.SessionStart', { source: 'clear' }, async ($, e, next) => {
173 await fill($)
174 return next(e)
175 })
176
177 // Claude Code draws its "thinking" spinner while any command runs; the
178 // flag is set as early as the prompt is seen, so the first frame is blank too.
179 let isTurn = false
180 on('turn.start', async ($, e, next) => {
181 isTurn = true
182 return next(e)
183 })
184 on('turn.complete', async ($, e, next) => {
185 isTurn = false
186 return next(e)
187 })
188 on('prompt.submit', async ($, e, next) => {
189 if (STASH_PROMPT.test(e.text)) await update($, isRunning, () => true)
190 return next(e)
191 })
192
193 on('command.run', { command: 'stash' }, async ($, e) => {
194 const args = e.args.trim()
195 await update($, isRunning, () => true)
196 try {
197 if (args === '') return { text: await openPicker($) }
198 if (args === 'pop') return { text: await popNewest($) }
199 if (args === 'yank') return { text: await popNewest($, true) }
200 return { text: await stash($, args) }
201 } catch (error) {
202 return { text: message(error) }
203 } finally {
204 await update($, isRunning, () => false)
205 }
206 })
207
208 on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
209 if (isTurn || !(await read($, isRunning))) return next(e)
210 const { Text } = $.ui.resolve(e)
211 return <Text> </Text>
212 })
213
214 // Keep stashed text out of the conversation (the screen draws the same row).
215 on('session.append', { door: 'command' }, ($, e, next) => {
216 const textOf = (b: { type: string; text?: unknown }) =>
217 b.type === 'text' && typeof b.text === 'string' ? b.text : undefined
218 const isStash = e.message.content.some(b => STASH_ROW.test(textOf(b) ?? ''))
219 if (!isStash) return next(e)
220 const content = e.message.content.map(b => {
221 const text = textOf(b)
222 return text === undefined ? b : { ...b, text: text.replace(ARGS, '<command-args></command-args>') }
223 })
224 return next({ ...e, message: { ...e.message, content } })
225 })
226
227 // The count, as a dim mode label at the right of the prompt footer.
228 on('ui.render', { component: 'SessionMode' }, async ($, e, next) => {
229 const count = (await read($, items)).length
230 if (count === 0) return next(e)
231 return next({ ...e, props: { ...e.props, modes: [...e.props.modes, `stash ${count}`] } })
232 })
233
234 // The ring stays on the rows: never on a digit, the p/y/x controls or the close mark.
235 on('ui.focus', { requestId: PANE }, async ($, e, next) => {
236 const element = e.element ?? ''
237 if (element.startsWith('sel-')) {
238 // A row's digit sits just before it, so an arrow lands there on its way
239 // up from its own row (go on to the row above) or down from the one above.
240 const list = await read($, items)
241 const at = list.findIndex(item => `sel-${item.id}` === element)
242 const isUp = list[at]?.id === (await read($, focused))
243 const target = list[isUp ? Math.max(0, at - 1) : at]
244 if (target === undefined) return { deny: 'rows only' }
245 await update($, focused, () => target.id)
246 return next({ ...e, element: `pop-${target.id}` })
247 }
248 if (!element.startsWith('pop-')) {
249 const id = await read($, focused)
250 return id === null ? { deny: 'rows only' } : next({ ...e, element: `pop-${id}` })
251 }
252 await update($, focused, () => element.slice('pop-'.length))
253 return next(e)
254 })
255
256 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
257 const { Box, Button, Text } = $.ui.resolve(e)
258 const list = await read($, items)
259 const version = await read($, label)
260 const width = Math.max(10, e.props.bodyColumns - 8)
261 if (list.length === 0) return <Text dimColor>Nothing stashed.</Text>
262
263 return (
264 <Box flexDirection="column">
265 {list.map((item, i) => (
266 <Box key={`row-${item.id}`}>
267 {i < 9 ? (
268 <Button
269 key={`sel-${item.id}`}
270 plain
271 dimColor
272 hotkey={String(i + 1)}
273 label=" "
274 onPress={() => ring($, item.id).catch(error => failed($, error))}
275 />
276 ) : (
277 <Text>{' '}</Text>
278 )}
279 <Button
280 key={`pop-${item.id}`}
281 plain
282 {...(i === 0 ? { autoFocus: true as const } : {})}
283 onPress={() => reportPop($, pop($, item))}
284 >
285 {preview(item.text, width)}
286 </Button>
287 </Box>
288 ))}
289 <Box>
290 <Text dimColor>1-9 select · ↑↓ move · </Text>
291 <Button key="pop" plain dimColor hotkey="p" label="pop" onPress={() => actOnFocused($, false)} />
292 <Text dimColor> · </Text>
293 <Button key="yank" plain dimColor hotkey="y" label="yank" onPress={() => actOnFocused($, true)} />
294 <Text dimColor> · </Text>
295 <Button
296 key="delete"
297 plain
298 dimColor
299 hotkey="x"
300 label="delete"
301 onPress={() => deleteFocused($).catch(error => failed($, error))}
302 />
303 <Text dimColor> · esc close</Text>
304 <Box flexGrow={1} justifyContent="flex-end">
305 <Text dimColor>{version}</Text>
306 </Box>
307 </Box>
308 </Box>
309 )
310 })
311}
312hooks/stash.ts 63 lines1// The stash file format and the operations on it. No engine calls here:
2// any harness can read and write the same files.
3import type { Item, StashFile } from '../types'
4
5export const LIMIT = 100
6
7/** `/Users/max/app` -> `-Users-max-app.json`, one file per project. */
8export function fileName(project: string): string {
9 return `${project.replace(/[^A-Za-z0-9]/g, '-')}.json`
10}
11
12export function empty(project: string): StashFile {
13 return { version: 1, project, items: [] }
14}
15
16/** Parses a stash file; throws on anything it does not recognise, so a bad file is never overwritten. */
17export function parse(text: string, project: string): StashFile {
18 const data: unknown = JSON.parse(text)
19 if (!isRecord(data) || data.version !== 1 || !Array.isArray(data.items)) {
20 throw new Error('not a pstash v1 file')
21 }
22 const items = data.items.filter(isItem)
23 return { version: 1, project: typeof data.project === 'string' ? data.project : project, items }
24}
25
26export function serialize(file: StashFile): string {
27 return `${JSON.stringify(file, null, 2)}\n`
28}
29
30/** Puts `item` first; an item with the same text moves up instead of repeating. */
31export function add(file: StashFile, item: Item): StashFile {
32 const rest = file.items.filter(one => one.text !== item.text)
33 return { ...file, items: [item, ...rest].slice(0, LIMIT) }
34}
35
36export function remove(file: StashFile, id: string): StashFile {
37 return { ...file, items: file.items.filter(one => one.id !== id) }
38}
39
40/** First line of `text`, cut to `width` cells with an ellipsis. */
41export function preview(text: string, width: number): string {
42 const lines = text.trim().split('\n')
43 const first = lines[0] ?? ''
44 const more = lines.length > 1 ? ' …' : ''
45 const room = Math.max(1, width - more.length)
46 const cut = first.length > room ? `${first.slice(0, room - 1)}…` : first
47 return cut + more
48}
49
50function isRecord(value: unknown): value is Record<string, unknown> {
51 return typeof value === 'object' && value !== null && !Array.isArray(value)
52}
53
54function isItem(value: unknown): value is Item {
55 return (
56 isRecord(value) &&
57 typeof value.id === 'string' &&
58 typeof value.text === 'string' &&
59 typeof value.at === 'string' &&
60 typeof value.from === 'string'
61 )
62}
63types/index.d.ts 12 lines1/** One stashed prompt, as kept in the stash file. */
2export type Item = { id: string; text: string; at: string; from: string }
3
4/** The stash file of one project: `~/.pstash/<encoded project path>.json`. */
5export type StashFile = { version: 1; project: string; items: Item[] }
6
7declare module 'claude-code' {
8 interface PluginState {
9 pstash: { items: Item[]; isRunning: boolean; focused: string | null; label: string }
10 }
11}
12