SLOPSHOPPER

statusline-desktop

Runs your configured statusLine command and draws its line above the prompt in the Claude desktop app

bandguardprocesstimer
★ 1v0.1.1MITupdated 2026-10-11enhki/claude-mods/mods/statusline-desktop
A shopper browsing a rack in a slop shop
README

claude-mods

Small Claude Code mods: plugins of function hooks that change what Claude Code shows or does, in the terminal and in the desktop app's Code tab.

Install

In a terminal Claude Code session:

/plugin install <mod> --marketplace enhki/claude-mods

Answer y to add the marketplace, then pick the user scope so the mod loads in every session, desktop ones included.

Mods

ModWhat it does
statusline-desktopDraws your terminal status line above the prompt in the desktop app
forgejo-issuesBrowse, search and manage the current repo's Forgejo or Gitea issues in a pane
work-sessionKicks off and wraps up working sessions with your own start and end commands, and titles each session
walkthroughA checklist pane for testing by hand: mark each step, add notes, send the results back in one message

statusline-desktop

The desktop app doesn't run your statusLine command. This mod does: it picks the command the way Claude Code does (project .claude/settings.local.json, then .claude/settings.json, then ~/.claude/settings.json), pipes it the same JSON the terminal would (model, cwd, cost, context window, rate limits), and draws the first line it prints in the band above the prompt.

  • ANSI colours keep the terminal's palette when ghostty's config (and the files it pulls in with config-file) sets one; otherwise they map to the app's own theme colours.
  • Refreshes on session start, after each tool call and turn, and every 30 s.
  • Stays out of the terminal, which already draws the real status line.
  • Only the input side of the context window is known to mods, so a token count your script sums from current_usage reads slightly lower than in the terminal (output tokens come through as 0).

forgejo-issues

/issues opens a pane on the issues of the repo the session runs in. The forge and repo come from git remote get-url origin (ssh or https), so it works for any Forgejo or Gitea host, Codeberg included.

  • Browse: every issue as a card, grouped by milestone; Open, Closed, All; label chips with counts (scoped labels like kind/bug sit under their scope, exclusive scopes pick one); a milestone picker.
  • Search: fzf-style fuzzy matching with highlights, plus label:bug, -label:wontfix, label:kind/, milestone:"Some name", is:closed. Enter opens the top match.
  • Read: the body on a raised panel, comments as cards, #N mentions as chips that open in the pane.
  • Write: comment, close and reopen (behind a Confirm), edit labels, set the milestone, file a new issue. Text goes in a full-width Markdown editor with a toolbar and a preview.
  • Other repos: when a project's issues live in more than one repo, list the others in .claude/forgejo-issues.json in the folder you start Claude in, as {"repos": ["owner/repo"]} on the same forge. The pane then shows a button per repo (a picker past five), and /issues <repo> jumps to one by name or prefix. The last repo picked is remembered for that project.

Token. The mod needs an API token with issue read/write and repository read. Put it in ~/.config/claude-mods/secrets/forgejo.env (folder 700, file 600), keyed by host so a token only ever goes to its own forge:

FORGEJO_TOKEN_CODEBERG_ORG=...
FORGEJO_TOKEN_GIT_EXAMPLE_COM=...

Without one, it falls back to fgj's config for that host. The mod also stops Claude's own file and shell tools from reading that secrets folder.

Settings (the plugin's options):

SettingDefaultWhat it does
apiUrlemptyThe API base when it isn't https://<remote host>/api/v1
requireCommentOnCloseonClosing needs a comment, posted before the close
requireMilestoneoffNew issues need a milestone
requireLabelFromemptyNew issues need one of these comma-separated labels
editorCommandemptyAdds Open in editor: e.g. ghostty --gtk-single-instance=false --class=popup.editor -e nvim {file}

Desktop notes. The desktop app currently drops Button and Markdown-link presses from plugin panes, so every control here is a small Client that posts a message instead; and it passes no paste into a Client, so for long or pasted text use Open in editor. The editor command must wait until you close the file; one that returns at once (a launcher that forks) leaves a Use editor text button to pull the file back by hand. Ghostty needs --gtk-single-instance=false for this, or it may hand the window to a running instance and return at once.

work-session

For projects where you start and end each working session with your own slash commands (a "continue working session" and an "end working session", say /cws and /ews), this mod offers them at the right moments and gives each session a title you can tell apart in the session list.

  • Kickoff: when a session starts fresh (launch or /clear, not a resume) in a project that has the start command, a band above the prompt offers it: press 1 to run it, 2 to skip, or just type something else. Set Kickoff to auto to run it straight away, or off.
  • Title: Claude gets a set_session_title tool and a line of context asking it to title the session once its focus is clear: <Project> S<n> · <focus> when the project numbers its sessions, else <Project> · <focus>. The title shows from your next message on. A /rename of your own wins: the mod stops setting it.
  • Wrap: once the context window passes Offer the wrap at (75% by default) or a rate limit passes 90%, the band offers the end command, with Later to dismiss it for the session.

Projects without the start command see nothing. In the desktop app the band draws above the desktop status line rather than in place of it.

Settings (the plugin's options):

SettingDefaultWhat it does
startCommandcwsThe command that kicks a session off, without the slash
endCommandewsThe command that wraps one up
kickoffbandband offers it, auto runs it at start, off never
wrapAtPercent75Context fullness that brings up the wrap offer; 0 turns it off

walkthrough

When Claude asks you to check something by hand (run a demo, resize a window, try a key), it publishes the steps to a Walkthrough pane instead of a list in chat, and you send the results back from there.

  • Steps: each one says what to run, where (directory, terminal, window size) and what you should see. Claude's publish_walkthrough tool refuses a step that doesn't say what to expect. Publishing again replaces the list.
  • The pane opens when Claude publishes, or with /walkthrough. The step you're on is drawn open: its command with Copy, what to expect, Pass / Fail / Skip and a note. Marking it opens the next one; done steps fold to one line you can click to reopen. Pressing a mark again takes it back.
  • Notes on the desktop wrap and grow as you type (Enter starts a new line); the desktop passes no paste to a pane, so type them. The terminal keeps a one-line field.
  • Keys (terminal, once the pane has the keyboard): p pass, f fail, s skip, c copy, r send.
  • Send results submits one message: a tally, then each step as PASS, FAIL, SKIP or NOT DONE with your note beside it.

Screenshots don't go through the pane: paste them in the prompt as usual. No settings.

Writing a mod

A mod is a plugin of function hooks: a plugin.json, a hooks/hooks.json naming one TypeScript module, and that module's register(on, options). In a Claude Code session, the bundled plugin-authoring skill holds the full API (types, examples, the test kit); load it before writing one.

Where it lives

KindWhereLoads
General, shareablehere, mods/<name>/ + an entry in .claude-plugin/marketplace.jsoneverywhere, once installed at user scope
Tied to one project, or naming private hoststhat project's .claude/skills/<name>/in that project's sessions only, watched for edits
Just for you, everywhere, private~/.claude/skills/<name>/every session, watched for edits

Anything that names a private host, a person or a machine stays out of this public repo: make it a project mod, or read the value from a setting.

Workflow

  1. Sketch in the session's dev folder. The plugin-authoring skill gives a mods folder that hot-reloads when each turn ends: the quickest loop.
  2. Move it here as mods/<name>/, list it in the marketplace file, and install it from this clone (below). From then on, edits are live after /reload-plugins.
  3. Test it on the surface you'll use. The terminal and the desktop app draw the same tree differently (see the notes below); try both when it matters.
  4. Before each commit: claude plugin validate mods/<name>, claude plugin test mods/<name>, and a type-check. Bump version in the mod's plugin.json when behaviour changes, so GitHub installs update.

Conventions shared by these mods

  • Pure logic in its own files, with tests; the hooks module stays thin. claude plugin test runs *.test.ts(x) against the engine itself; a test stands in for engine calls with on('<event>', () => ({ value: … })).
  • Settings are the manifest's userConfig (shown in the plugin's options); nothing personal is hard-coded.
  • Secrets go in ~/.config/claude-mods/secrets/<service>.env (folder 700, file 600), keyed by host where a token belongs to a host. A mod that reads one also keeps Claude's own tools out of that folder (see forgejo-issues/hooks/guard.ts).
  • Saved state ($.state) outlives reloads and upgrades: read and update it through helpers that fill in defaults, or a field a new version adds arrives undefined.

Desktop app notes (Claude Code 2.1.29x)

  • Button and Markdown-link presses from a plugin pane don't arrive (the app logs ui_press not handled in ~/.config/Claude/logs/claude.ai-web.log). Input, Select and Client messages do. Make each pressable control its own small Client that posts a message (forgejo-issues/hooks/pill.tsx).
  • Set a Client's pointer and key listeners once, on its first draw. Each set is a message to the page, and many Clients re-setting them on every redraw get unmounted for flooding it.
  • Don't map pointer rows by arithmetic. Borders are thin lines, not rows, and text is proportional (about 1.2 characters per cell). One Client per clickable item makes hit-testing unnecessary.
  • No paste into a Client, and the native Input is one line at a fixed width. For long text, hand off to an external editor (forgejo-issues's Open in editor).
  • A "Nothing to show yet" pane means the drawing threw; a transcript line <mod>: <event> hook skipped: threw … names the handler that did.

Developing

Clone, then add the clone itself as your marketplace so edits are live after /reload-plugins with no reinstall:

claude plugin marketplace add ~/repos/claude-mods
claude plugin install <mod>@claude-mods --scope user

Check a mod before committing:

claude plugin validate mods/<mod>
claude plugin test mods/<mod>
Source 3 files
hooks/register.tsx 138 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface as $, Register } from 'claude-code'
3
4import type { Segment } from '../types'
5import { buildInput, ghosttyIncludes, parseAnsi, parsePalette, pickCommand } from './line'
6
7const line = atom({ plugin: 'statusline-desktop', key: 'line' } as const, null as Segment[] | null)
8
9// The terminal refreshes its status line on its own; the clock and git parts
10// only need this tick between turns.
11const TICK_MS = 30_000
12
13let isRunning = false
14let isPending = false
15let home: string | null = null
16let configHome: string | null = null
17
18async function readOrNull($: $, path: string): Promise<string | null> {
19  try {
20    return await $.fs.read(path)
21  } catch {
22    return null
23  }
24}
25
26async function env($: $, name: string): Promise<string> {
27  const { stdout } = await $.process.run(['printenv', name])
28  return stdout.trim()
29}
30
31async function homeDir($: $): Promise<string> {
32  if (home === null) home = await env($, 'HOME')
33  return home
34}
35
36// The terminal's own ANSI palette, so the line keeps the colours it has there:
37// ghostty's config and the files it pulls in with `config-file`, in load order.
38async function terminalPalette($: $, h: string): Promise<string[]> {
39  if (configHome === null) configHome = (await env($, 'XDG_CONFIG_HOME')) || `${h}/.config`
40  const dir = `${configHome}/ghostty`
41  const main = (await readOrNull($, `${dir}/config`)) ?? ''
42  const texts = [main]
43  for (const path of ghosttyIncludes(main, dir)) texts.push((await readOrNull($, path)) ?? '')
44  return parsePalette(...texts)
45}
46
47async function runOnce($: $): Promise<void> {
48  const [sessionId, cwd, root, model, version, usage, h] = await Promise.all([
49    $.session.id(),
50    $.session.cwd(),
51    $.session.root(),
52    $.session.model(),
53    $.session.version(),
54    $.session.usage(),
55    homeDir($),
56  ])
57  const command = pickCommand(
58    await Promise.all([
59      readOrNull($, `${root}/.claude/settings.local.json`),
60      readOrNull($, `${root}/.claude/settings.json`),
61      readOrNull($, `${h}/.claude/settings.json`),
62    ]),
63  )
64  if (command === null) {
65    await update($, line, () => null)
66    return
67  }
68  const stdin = JSON.stringify(buildInput({ sessionId, cwd, root, model, version: version.version, usage }))
69  const { exitCode, stdout } = await $.process.run(['bash', '-c', command], { cwd, stdin, timeoutMs: 10_000 })
70  if (exitCode !== 0 && stdout.trim() === '') return
71  const palette = await terminalPalette($, h)
72  const firstLine = stdout.split('\n').find(l => l.trim() !== '') ?? ''
73  await update($, line, () => parseAnsi(firstLine, palette))
74}
75
76// One run at a time; a request while one runs queues exactly one more.
77async function refresh($: $): Promise<void> {
78  if (isRunning) {
79    isPending = true
80    return
81  }
82  isRunning = true
83  try {
84    do {
85      isPending = false
86      await runOnce($)
87    } while (isPending)
88  } catch (err) {
89    $.ui.log(`statusline-desktop: ${err instanceof Error ? err.message : String(err)}`)
90  } finally {
91    isRunning = false
92  }
93}
94
95export const register: Register = on => {
96  on('session.start', async ($, e, next) => {
97    const result = await next(e)
98    void refresh($)
99    $.clock.every(TICK_MS, () => void refresh($))
100    return result
101  })
102
103  on('turn.complete', async ($, e, next) => {
104    const result = await next(e)
105    void refresh($)
106    return result
107  })
108
109  on('tool.call', async ($, e, next) => {
110    const result = await next(e)
111    void refresh($)
112    return result
113  })
114
115  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
116    // The terminal already draws the real status line under the prompt.
117    if (e.surface === 'terminal' || e.props.hasSurvey) return next(e)
118    const segments = await read($, line)
119    if (!segments || segments.length === 0) return next(e)
120    const { Box, Text } = $.ui.resolve(e)
121    // The band is shared: what the plugins beneath draw (a kickoff offer) stacks
122    // above the line, which stays next to the prompt as in the terminal.
123    const beneath = await next(e)
124    return (
125      <Box flexDirection="column">
126        {beneath}
127        <Box flexDirection="row">
128          {segments.map((s, i) => (
129            <Text key={String(i)} color={s.color} bold={s.bold} dimColor={s.dim} wrap="truncate-end">
130              {s.text}
131            </Text>
132          ))}
133        </Box>
134      </Box>
135    )
136  })
137}
138
hooks/line.ts 144 lines
1import type { SessionUsage } from 'claude-code'
2
3import type { Segment } from '../types'
4
5// ANSI 0-15 as the app's own theme keys, so with no terminal palette to copy
6// the line still follows whatever theme the desktop app is in.
7export const fallbackPalette: string[] = [
8  'inactive', 'error', 'success', 'warning', 'permission', 'merged', 'suggestion', 'text',
9  'inactive', 'error', 'success', 'warning', 'permission', 'merged', 'suggestion', 'text',
10]
11
12/** Lays `palette = N=#rrggbb` lines from ghostty config texts, in load order, over the fallback. */
13export function parsePalette(...texts: string[]): string[] {
14  const palette = [...fallbackPalette]
15  for (const text of texts) {
16    for (const m of text.matchAll(/^\s*palette\s*=\s*(\d+)\s*=\s*(#[0-9a-fA-F]{6})/gm)) {
17      const slot = Number(m[1])
18      const hex = m[2]
19      if (hex && slot < 16) palette[slot] = hex
20    }
21  }
22  return palette
23}
24
25/** The files a ghostty config pulls in with `config-file =`, resolved against its folder. */
26export function ghosttyIncludes(text: string, dir: string): string[] {
27  const out: string[] = []
28  for (const m of text.matchAll(/^\s*config-file\s*=\s*"?\??([^"\n]+?)"?\s*$/gm)) {
29    const path = m[1]
30    if (!path) continue
31    out.push(path.startsWith('/') ? path : `${dir}/${path}`)
32  }
33  return out
34}
35
36type Style = Omit<Segment, 'text'>
37
38function applySgr(params: number[], style: Style, palette: string[]): Style {
39  let next = { ...style }
40  for (let i = 0; i < params.length; i++) {
41    const p = params[i] ?? 0
42    if (p === 0) next = {}
43    else if (p === 1) next.bold = true
44    else if (p === 2) next.dim = true
45    else if (p === 22) { delete next.bold; delete next.dim }
46    else if (p === 39) delete next.color
47    else if (p >= 30 && p <= 37) next.color = palette[p - 30]
48    else if (p >= 90 && p <= 97) next.color = palette[p - 90 + 8]
49    else if (p === 38 && params[i + 1] === 5) {
50      const n = params[i + 2]
51      if (n !== undefined && n < 16) next.color = palette[n]
52      i += 2
53    } else if (p === 38 && params[i + 1] === 2) {
54      const [r, g, b] = params.slice(i + 2, i + 5).map(v => (v ?? 0).toString(16).padStart(2, '0'))
55      next.color = `#${r}${g}${b}`
56      i += 4
57    }
58  }
59  return next
60}
61
62/** Splits a status line's ANSI output into styled runs; codes other than SGR are dropped. */
63export function parseAnsi(raw: string, palette: string[] = fallbackPalette): Segment[] {
64  const out: Segment[] = []
65  let style: Style = {}
66  const re = /\x1b\[([0-9;]*)([A-Za-z])/g
67  let last = 0
68  const push = (text: string) => {
69    if (text) out.push({ text, ...style })
70  }
71  for (const m of raw.matchAll(re)) {
72    push(raw.slice(last, m.index))
73    last = (m.index ?? 0) + m[0].length
74    if (m[2] === 'm') {
75      const params = !m[1] ? [0] : m[1].split(';').map(Number)
76      style = applySgr(params, style, palette)
77    }
78  }
79  push(raw.slice(last))
80  // The terminal shows one line; so does the band.
81  return out.map(s => ({ ...s, text: s.text.replace(/\r?\n/g, ' ') }))
82}
83
84export type InputFacts = {
85  sessionId: string
86  cwd: string
87  root: string
88  model: string
89  version: string
90  usage: SessionUsage
91}
92
93/** The JSON Claude Code pipes to a statusLine command, built from `$.session`. */
94export function buildInput(f: InputFacts): Record<string, unknown> {
95  const { context, cost, rateLimits } = f.usage
96  const limits: Record<string, { used_percentage: number; resets_at?: number }> = {}
97  for (const r of rateLimits) {
98    limits[r.kind] = {
99      used_percentage: r.percentUsed,
100      ...(r.resetsAt ? { resets_at: Math.floor(Date.parse(r.resetsAt) / 1000) } : {}),
101    }
102  }
103  return {
104    hook_event_name: 'Status',
105    session_id: f.sessionId,
106    cwd: f.cwd,
107    model: { id: f.model, display_name: f.model },
108    workspace: { current_dir: f.cwd, project_dir: f.root },
109    version: f.version,
110    ...(cost ? { cost: { total_cost_usd: cost.usd } } : {}),
111    context_window: {
112      context_window_size: context.window,
113      ...(context.tokens !== undefined
114        ? {
115            total_input_tokens: context.tokens,
116            // Only the input side is known here; output tokens read as 0.
117            current_usage: {
118              input_tokens: context.tokens,
119              output_tokens: 0,
120              cache_read_input_tokens: 0,
121              cache_creation_input_tokens: 0,
122            },
123          }
124        : {}),
125      ...(context.percent !== undefined ? { used_percentage: context.percent } : {}),
126    },
127    ...(rateLimits.length ? { rate_limits: limits } : {}),
128  }
129}
130
131/** The statusLine command from the first settings text that names one, most specific first. */
132export function pickCommand(settingsTexts: (string | null)[]): string | null {
133  for (const text of settingsTexts) {
134    if (!text) continue
135    try {
136      const line = JSON.parse(text)?.statusLine
137      if (line?.type === 'command' && typeof line.command === 'string') return line.command
138    } catch {
139      // A settings file mid-edit is not fatal; the next one may name it.
140    }
141  }
142  return null
143}
144
types/index.d.ts 14 lines
1/** One run of the status line's text, styled as its ANSI codes said. */
2export type Segment = {
3  text: string
4  color?: string
5  bold?: boolean
6  dim?: boolean
7}
8
9declare module 'claude-code' {
10  interface PluginState {
11    'statusline-desktop': { line: Segment[] | null }
12  }
13}
14