SLOPSHOPPER

where-am-i

A live recap above the prompt: the session's goal, what Claude is doing right now, what's next and what waits on you. Folds to one line; /where for a longer…

bandguardcommandpromptmodeltimer
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · where-am-i
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /where ⎿ where-am-i: OK ◆ fix the failing auth test and add an audit log call ▸ ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
◆ fix the failing auth test and add an audit log call ▸ ⟨Claude Code's own drawing⟩
README

where-am-i

A Claude Code mod that keeps a one-glance recap above the prompt: the session's goal, what Claude is doing right now, what's next, and what waits on you. Made for coming back to a session after a break, or keeping several in your head.

Adapted from hamzafer/claude-code-mods (commit e687416) by Hamza Zafar, MIT licensed. See LICENSE. Changed here: a new aligned layout, the live activity with a working dot, the goal shown from your first message before any recap, elapsed time and turn count, folding, no model call for trivial turns, and no dependency on other mods.

◆ Goal   Rebuild the context-cache panel as rings        12m · 4 turns  ▾
  Now    ● editing hooks/panel-svg.ts
  You    ⏳ choose whether to keep the card background

Between turns, Now shows what was just done (✓) and Next the next step. Folded:

◆ Rebuild the context-cache panel as rings  ·  ● editing hooks/panel-svg.ts  ▸

Install

/plugin install where-am-i@arhun-plugins

How it works

  • While Claude works, Now follows its tool calls live ("editing hooks/view.tsx", "running the tests"). No model call for that.
  • After each turn, one small Haiku call rewrites the recap from your message, the tools used and the reply. A turn with no tools and a short reply (a thank-you, a quick answer) skips it.
  • Until the first recap, your latest message stands in as the goal, dimmed.
  • The time beside the goal counts from when that goal was set; a new goal restarts it.

Commands

  • /where: a longer recap in a few bullets, from the last messages.
  • /where-collapse: fold it to one line, or open it again (the same as the chevron). Kept across sessions.
Source 4 files
hooks/register.tsx 166 lines
1// where-am-i: a live recap above the prompt (goal, now, next, what waits on you), plus /where.
2// Adapted from hamzafer/claude-code-mods (MIT).
3
4import { atom, read, update } from 'claude-code'
5import type { EngineInterface, Register } from 'claude-code'
6
7import type { WhereRecap } from '../types'
8import { describe, isTrivial, LONG_SYSTEM, parseRecap, SUMMARY_SYSTEM } from './recap'
9import { renderBand } from './view'
10
11export { clip, describe, isTrivial, parseRecap } from './recap'
12
13const MODEL = 'haiku'
14const MAX_LOG = 20
15
16// Held by the host, so the recap survives a hot reload of this file.
17const recap = atom({ plugin: 'where-am-i', key: 'recap' } as const, null as WhereRecap | null)
18const live = atom({ plugin: 'where-am-i', key: 'live' } as const, '')
19const prompt = atom({ plugin: 'where-am-i', key: 'prompt' } as const, '')
20const since = atom({ plugin: 'where-am-i', key: 'since' } as const, null as number | null)
21const turns = atom({ plugin: 'where-am-i', key: 'turns' } as const, 0)
22const collapsed = atom({ plugin: 'where-am-i', key: 'isCollapsed' } as const, false)
23const tick = atom({ plugin: 'where-am-i', key: 'tick' } as const, 0)
24
25async function toggleCollapsed($: EngineInterface): Promise<boolean> {
26  const isCollapsed = !(await read($, collapsed))
27  await update($, collapsed, () => isCollapsed)
28  await $.store.set('isCollapsed', isCollapsed)
29  return isCollapsed
30}
31
32async function summarize($: EngineInterface, said: string, log: string[], answer: string) {
33  const before = await read($, recap)
34  const r = await $.model.complete({
35    model: MODEL,
36    maxTokens: 300,
37    system: SUMMARY_SYSTEM,
38    prompt: [
39      `Previous recap: ${before ? JSON.stringify(before) : 'none'}`,
40      `The person's latest message: ${said}`,
41      `Tools used this turn: ${log.join('; ') || 'none'}`,
42      `The assistant's reply: ${answer.slice(0, 2500)}`,
43    ].join('\n\n'),
44  })
45  if (!r.isAnswered) return
46  const parsed = parseRecap(r.text)
47  if (!parsed) return
48  // A new goal restarts the clock beside it.
49  if (!before || before.goal !== parsed.goal) {
50    const at = await $.clock.now()
51    await update($, since, s => (before ? at : (s ?? at)))
52  }
53  await update($, recap, () => parsed)
54}
55
56async function longRecap($: EngineInterface, said: string, log: string[]) {
57  const messages = (await $.session.messages()).slice(-12)
58  const r = await $.model.complete({
59    model: MODEL,
60    maxTokens: 500,
61    system: LONG_SYSTEM,
62    prompt: [
63      `<transcript>\n${messages
64        .filter(m => m.text.trim() !== '')
65        .map(m => `[${m.role === 'user' ? 'person' : 'assistant'}] ${m.text.slice(0, 800)}`)
66        .join('\n')}\n</transcript>`,
67      `Latest message: ${said}`,
68      `Recent tool calls: ${log.join('; ') || 'none'}`,
69      'Write the recap of the transcript above now: the bullets only, not a reply to it.',
70    ].join('\n\n'),
71  })
72  return r.isAnswered ? r.text : 'Could not build a recap right now.'
73}
74
75export const register: Register = on => {
76  let said = ''
77  let log: string[] = []
78
79  on('session.start', async ($, e, next) => {
80    const r = await next(e)
81    // A name Claude Code already has is refused: start anyway.
82    await $.command.register({ name: 'where', description: 'Recap the session so far in a few bullets' }).catch(() => {})
83    await $.command.register({ name: 'where-collapse', description: 'Fold the where-am-i recap to one line, or open it again' }).catch(() => {})
84    if ((await $.store.get('isCollapsed')) === true) await update($, collapsed, () => true)
85    // The elapsed time beside the goal moves once a minute.
86    $.clock.every(60_000, () => {
87      void $.clock.now().then(t => update($, tick, () => t)).catch(() => {})
88    })
89    return r
90  })
91
92  on('prompt.submit', async ($, e, next) => {
93    said = e.text.slice(0, 1500)
94    log = []
95    if (!said.startsWith('/')) {
96      await update($, prompt, () => said)
97      await update($, live, () => 'reading your message')
98      if ((await read($, since)) === null) {
99        const at = await $.clock.now()
100        await update($, since, () => at)
101      }
102    }
103    return next(e)
104  })
105
106  // Observe only: note what is happening, then let the call run untouched. Only Claude's own calls count:
107  // one another mod makes in the background is raised by that plugin, and `next.origin` names it.
108  on('tool.call', async ($, e, next) => {
109    if (next.origin.plugin !== 'engine') return next(e)
110    const line = describe(e as unknown as Record<string, unknown>)
111    log = [...log, e.agentId ? `(agent) ${line}` : line].slice(-MAX_LOG)
112    if (!e.agentId) await update($, live, () => line)
113    return next(e)
114  })
115
116  on('turn.complete', async ($, e, next) => {
117    const r = await next(e)
118    if (!e.agentId) {
119      await update($, live, () => '')
120      await update($, turns, n => n + 1)
121      const hasRecap = (await read($, recap)) !== null
122      // In the background, so the turn ends at once.
123      if (!isTrivial(log.length, e.answer, hasRecap)) void summarize($, said, log, e.answer).catch(() => {})
124    }
125    return r
126  })
127
128  on('command.run', { command: 'where' }, async $ => ({ text: await longRecap($, said, log) }))
129
130  on('command.run', { command: 'where-collapse' }, async $ => {
131    const isCollapsed = await toggleCollapsed($)
132    return { text: isCollapsed ? 'Recap folded to one line.' : 'Recap expanded.' }
133  })
134
135  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
136    const rest = await next(e) // what other mods and Claude Code draw here stays, under the recap
137    if (e.props.hasSurvey || e.props.view?.agentId !== undefined) return rest
138    const [r, l, p, s, n, isCollapsed] = await Promise.all([
139      read($, recap),
140      read($, live),
141      read($, prompt),
142      read($, since),
143      read($, turns),
144      read($, collapsed),
145      read($, tick),
146    ])
147    const mine = renderBand(
148      $.ui.resolve(e),
149      { recap: r, prompt: p, live: l, isWorking: e.props.isWorking, since: s, turns: n, now: await $.clock.now() },
150      e.props.bodyColumns,
151      isCollapsed,
152      () => void toggleCollapsed($),
153      e.surface !== 'terminal',
154    )
155    if (!mine) return rest
156    if (!rest) return mine
157    const { Box } = $.ui.resolve(e)
158    return (
159      <Box flexDirection="column" rowGap={1}>
160        {mine}
161        {rest}
162      </Box>
163    )
164  })
165}
166
hooks/recap.ts 68 lines
1// Pure helpers for where-am-i: what a tool call is doing, the model's recap, when a turn is worth one.
2
3import type { WhereRecap } from '../types'
4
5/** A short label for one tool call: what a person would say Claude is doing. */
6export function describe(e: Record<string, unknown>): string {
7  const tool = String(e.tool)
8  const s = (k: string) => (typeof e[k] === 'string' ? (e[k] as string) : '')
9  const file = (p: string) => p.split('/').slice(-2).join('/')
10  if (tool === 'Bash') return `running ${s('description') || s('command').slice(0, 60)}`
11  if (tool === 'Edit' || tool === 'Write' || tool === 'NotebookEdit') return `editing ${file(s('file_path') || s('notebook_path'))}`
12  if (tool === 'Read') return `reading ${file(s('file_path'))}`
13  if (tool === 'Grep' || tool === 'Glob') return `searching for ${s('pattern').slice(0, 40)}`
14  if (tool === 'WebSearch') return `searching the web for ${s('query').slice(0, 40)}`
15  if (tool === 'WebFetch') return `reading ${s('url').replace(/^https?:\/\//, '').slice(0, 50)}`
16  if (tool === 'Agent' || tool === 'Task') return `starting an agent: ${s('description')}`
17  if (tool === 'AskUserQuestion') return 'asking you a question'
18  if (tool === 'TodoWrite') return 'updating the task list'
19  if (tool.startsWith('mcp__')) return `using ${tool.split('__').slice(1).join(' ').replace(/_/g, ' ')}`
20  return `using ${tool}`
21}
22
23/** At most `max` characters, one sentence, cut at a word: the model does not always keep to the limit. */
24export function clip(text: string, max = 70): string {
25  const first = (text.split(/(?<=[.!?])\s/)[0] ?? text).split('\n')[0]!.trim()
26  if (first.length <= max) return first.replace(/\.$/, '')
27  const cut = first.lastIndexOf(' ', max - 1)
28  return `${first.slice(0, cut > max / 2 ? cut : max - 1)}…`
29}
30
31/** The model's JSON, tolerating a code fence around it. */
32export function parseRecap(text: string): WhereRecap | null {
33  const body = text.slice(text.indexOf('{'), text.lastIndexOf('}') + 1)
34  try {
35    const o = JSON.parse(body) as Record<string, unknown>
36    const field = (k: string) => (typeof o[k] === 'string' ? clip((o[k] as string).replace(/\s*—\s*/g, ', ').trim()) : '')
37    if (!field('goal')) return null
38    return { goal: field('goal'), now: field('now'), waiting: field('waiting'), next: field('next') }
39  } catch {
40    return null
41  }
42}
43
44/** A turn with no tools and a short reply ("thanks", a quick answer) leaves the recap as it is: no model call. */
45export function isTrivial(tools: number, answer: string, hasRecap: boolean): boolean {
46  return hasRecap && tools === 0 && answer.trim().length < 280
47}
48
49/** 45 s → "just now", 12 min → "12m", 3 h 5 min → "3h 5m". */
50export function elapsed(ms: number): string {
51  const m = Math.floor(ms / 60_000)
52  if (m < 1) return 'just now'
53  if (m < 60) return `${m}m`
54  const h = Math.floor(m / 60)
55  return m % 60 === 0 ? `${h}h` : `${h}h ${m % 60}m`
56}
57
58export const SUMMARY_SYSTEM =
59  'You keep a one-glance recap of a coding session for someone who loses track easily. Plain words, no em dashes, ' +
60  'each field at most 70 characters. Reply with JSON only: {"goal","now","waiting","next"}. ' +
61  '"goal": the overall aim of the session (keep the previous goal unless it clearly changed). ' +
62  '"now": what was just done. "waiting": what the assistant needs from the person before it can go on ' +
63  '(a question to answer, a choice, something to test), or "" if nothing. "next": the next step.'
64
65export const LONG_SYSTEM =
66  'Write a recap of this coding session for someone who lost track. Plain words, no em dashes. ' +
67  'At most 6 short bullets: the goal, what is done, what is happening now, what is waiting on them, the next step.'
68
hooks/view.tsx 142 lines
1// The recap above the prompt, laid out as the other mods in this marketplace: host elements and theme colours,
2// a bold header row with dim detail and the fold chevron at its end, aligned dim labels, status dots in their
3// colour before default text, no card or background.
4
5import type { Elements, RenderElement } from 'claude-code'
6
7import type { WhereRecap } from '../types'
8import { clip, elapsed } from './recap'
9
10type Els = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'>
11type DeskSvg = Elements['desktop']['Svg']
12
13// Lucide chevron-up (fold) / chevron-down (open), drawn as plan-progress, context-cache and cache-warm draw theirs on
14// the desktop: the picture centred in its cell and a blank Button over it, so the host draws its own hover and focus
15// ring and takes the press. The terminal draws ▾ / ▸.
16const CHIP = 16
17const chevronSvg = (isCollapsed: boolean) =>
18  `<svg xmlns="http://www.w3.org/2000/svg" width="${CHIP}" height="${CHIP}" viewBox="0 0 24 24"><style>.c{stroke:#C2C0B6}` +
19  `@media (prefers-color-scheme:light){.c{stroke:#3D3D3A}}</style>` +
20  `<path class="c" fill="none" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="${isCollapsed ? 'm6 9 6 6 6-6' : 'm18 15-6-6-6 6'}"/></svg>`
21
22function chevronFor(E: Els, isDesktop: boolean, isCollapsed: boolean, toggle: () => void): RenderElement {
23  const { Box, Button } = E
24  if (!isDesktop) return <Button key="collapse" plain dimColor label={isCollapsed ? '▸' : '▾'} onPress={toggle} />
25  const Svg = (E as unknown as { Svg: DeskSvg }).Svg
26  return (
27    <Box key="collapse-cell" width={3} height={1} flexShrink={0} justifyContent="center" alignItems="center">
28      <Svg source={chevronSvg(isCollapsed)} alt={isCollapsed ? 'expand the recap' : 'collapse the recap'} width={CHIP} height={CHIP} />
29      <Box position="absolute" top={0} left={0} right={0} bottom={0} justifyContent="center" alignItems="center">
30        <Button key="collapse" plain label={'  '} onPress={toggle} />
31      </Box>
32    </Box>
33  )
34}
35
36export type Model = {
37  recap: WhereRecap | null
38  /** The goal until the first recap: the person's latest message. */
39  prompt: string
40  live: string
41  isWorking: boolean
42  since: number | null
43  turns: number
44  now: number
45}
46
47const LABEL_W = 7
48
49export function renderBand(
50  E: Els,
51  m: Model,
52  columns: number,
53  isCollapsed: boolean,
54  toggle: () => void,
55  isDesktop = false,
56): RenderElement | null {
57  const { Box, Text, Button } = E
58  const r = m.recap
59  const goal = r?.goal ?? clip(m.prompt)
60  if (!goal) return null
61  const isProvisional = !r
62  const doing = m.isWorking ? m.live || 'working' : (r?.now ?? '')
63  const meta = [m.since !== null ? elapsed(m.now - m.since) : '', m.turns > 0 ? `${m.turns} turn${m.turns === 1 ? '' : 's'}` : '']
64    .filter(Boolean)
65    .join(' · ')
66  const chevron = chevronFor(E, isDesktop, isCollapsed, toggle)
67  const status = <Text color={m.isWorking ? 'claude' : 'success'}>{'● '}</Text>
68
69  if (isCollapsed) {
70    return (
71      <Box key="where-am-i" flexDirection="row" columnGap={1}>
72        <Box flexGrow={1} flexShrink={1} minWidth={0}>
73          <Text wrap="truncate-end">
74            <Text color="suggestion">{'◆ '}</Text>
75            <Text bold dimColor={isProvisional}>{goal}</Text>
76            {doing ? <Text dimColor>{' · '}</Text> : null}
77            {doing ? status : null}
78            {doing ? <Text dimColor={!m.isWorking}>{clip(doing, 60)}</Text> : null}
79            {r?.waiting ? <Text dimColor>{' · '}</Text> : null}
80            {r?.waiting ? <Text color="warning">{'● '}</Text> : null}
81            {r?.waiting ? <Text>{clip(r.waiting, 50)}</Text> : null}
82          </Text>
83        </Box>
84        {chevron}
85      </Box>
86    )
87  }
88
89  const row = (key: string, label: RenderElement, body: RenderElement, trailing?: RenderElement | null) => (
90    <Box key={key} flexDirection="row" columnGap={1}>
91      <Box width={LABEL_W} flexShrink={0}>
92        {label}
93      </Box>
94      <Box flexGrow={1} flexShrink={1} minWidth={0}>
95        {body}
96      </Box>
97      {trailing ?? null}
98    </Box>
99  )
100  const showMeta = meta !== '' && columns >= 60
101
102  return (
103    <Box key="where-am-i" flexDirection="column">
104      {row(
105        'goal',
106        <Text>
107          <Text color="suggestion">{'◆ '}</Text>
108          <Text bold>Goal</Text>
109        </Text>,
110        <Text bold={!isProvisional} dimColor={isProvisional} wrap="truncate-end">
111          {goal}
112        </Text>,
113        <Box flexDirection="row" columnGap={1} flexShrink={0}>
114          {showMeta ? <Text dimColor>{meta}</Text> : null}
115          {chevron}
116        </Box>,
117      )}
118      {doing
119        ? row(
120            'now',
121            <Text dimColor>{'  Now'}</Text>,
122            <Text wrap="truncate-end">
123              {status}
124              <Text>{doing}</Text>
125            </Text>,
126          )
127        : null}
128      {r?.next && !m.isWorking ? row('next', <Text dimColor>{'  Next'}</Text>, <Text wrap="truncate-end">{r.next}</Text>) : null}
129      {r?.waiting
130        ? row(
131            'waiting',
132            <Text dimColor>{'  You'}</Text>,
133            <Text wrap="truncate-end">
134              <Text color="warning">{'● '}</Text>
135              <Text>{r.waiting}</Text>
136            </Text>,
137          )
138        : null}
139    </Box>
140  )
141}
142
types/index.d.ts 29 lines
1// Contract for where-am-i: the values it keeps in $.state.
2
3/** The recap a small model writes after each turn; every field one short line. */
4export type WhereRecap = {
5  goal: string
6  now: string
7  /** What Claude waits on the person for; "" when nothing. */
8  waiting: string
9  next: string
10}
11
12declare module 'claude-code' {
13  interface PluginState {
14    'where-am-i': {
15      recap: WhereRecap | null
16      /** What Claude is doing this moment ("editing hooks/view.tsx"); "" between turns. */
17      live: string
18      /** The person's latest message, first line: the goal until the first recap is written. */
19      prompt: string
20      /** When the current goal was first set, epoch ms; null before any. */
21      since: number | null
22      turns: number
23      isCollapsed: boolean
24      /** The clock, written each minute so the elapsed time redraws. */
25      tick: number
26    }
27  }
28}
29