SLOPSHOPPER

session-cost

A tool the model calls to report the session's cost, for remote control where /cost isn't available

newguardtool
★ 20v0.1.0MITupdated 2026-10-03david-crespo/dotfiles/claude/mods/session-cost
A shopper browsing a rack in a slop shop
README

dotfiles

install.sh is a good guide to how things work because it sets up all the symlinks.

Note: .helix and deno.jsonc are not dotfiles; they are config files for this repo.

Source 1 files
hooks/register.ts 23 lines
1import type { Register } from 'claude-code'
2
3// The mobile app over remote control has no /cost, so this gives the model a
4// tool to report it when asked.
5
6const usd = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
7
8export const register: Register = on => {
9  on('session.start', async ($, e, next) => {
10    await $.tool.register({
11      name: 'cost',
12      description:
13        "What the session has cost so far in US dollars, as /cost totals it. Call it when the user asks about cost.",
14    })
15    return next(e)
16  })
17
18  on('tool.call', { tool: 'mcp__session-cost__cost' }, async $ => {
19    const { cost } = await $.session.usage()
20    return { result: cost ? usd.format(cost.usd) : 'No cost ledger in this session.' }
21  })
22}
23