Logo di Setup Cost Tracking

Setup Cost Tracking

Community
foyzulkarim
setup-cost-tracking

Install genuine per-session cost tracking for Claude Code by wiring bundled logger scripts into the user's statusline — preserving any existing statusline and hooks. Use when the user asks to set up, install, enable, or repair cost tracking / cost logging / session cost capture. Idempotent; safe to re-run.

Panoramica

Autorefoyzulkarim
Repositoryskills
Nome della skillsetup-cost-tracking
Stelle
43
Fork
14
File inclusi
4
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 4 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da foyzulkarim su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Setup Cost Tracking in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/foyzulkarim/skills/tree/master/dev-pipeline/skills/setup-cost-tracking
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/foyzulkarim/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/dev-pipeline/skills/setup-cost-tracking .claude/skills/setup-cost-tracking
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Setup Cost Tracking in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Setup Cost Tracking non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Setup Cost Tracking non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Setup Cost Tracking

Installs genuine cost capture for every Claude Code session on this machine. Cost data (cost.total_cost_usd etc.) is computed by Claude Code itself and is available only in the statusline payload — hooks never receive it. So this skill wires a logger into the statusline path while preserving whatever statusline and hooks the user already has.

What gets installed

Bundled in this skill's scripts/ directory, copied to ~/.claude/scripts/:

ScriptRole
cost-logger.jsCapture engine. Silent, crash-proof. Writes the log files below.
statusline-wrapper.jsUsed when the user already has a statusline: logs cost, then delegates the payload to their original command and passes its output through untouched.
statusline-command.jsUsed when the user has no statusline: full display (model, context bar, cost, cache stats) that also logs.
turn-logger.jsStop hook: stamps turn boundaries so cost samples can later be grouped into turns for analytics. No cost data itself.

Log outputs (created lazily, no setup needed):

  • ~/.claude/cost-log.jsonl — one row per session, exact cumulative totals (upserted).
  • ~/.claude/projects/<mapped-dir>/<session>.cost.jsonl — cost samples at ~5s resolution during activity.
  • ~/.claude/projects/<mapped-dir>/<session>.turn-boundaries.jsonl — one row per turn end, with transcript_path for deep-dive analytics.

Installation procedure

Follow these steps exactly. Use real JSON manipulation (a node -e script or jq) for every settings edit — never string/regex edits on settings files.

Step 0 — Preflight

  1. command -v node — if Node.js is missing, stop and tell the user it's required. Record the absolute path (call it $NODE). Use $NODE in every command you write into settings, not bare node (statusline/hook commands don't always get the user's full shell PATH).
  2. Read ~/.claude/settings.json (treat as {} if absent) and ~/.claude/settings.local.json (if present). The effective statusLine is the local one if defined there, else the user one. Remember which file defines it — edits must go to that same file.

Step 1 — Copy scripts

  1. mkdir -p ~/.claude/scripts
  2. Copy the four .js files from this skill's scripts/ directory into ~/.claude/scripts/ and chmod +x them. Overwriting previous versions of these four files is fine (that's how upgrades work). Never overwrite ~/.claude/scripts/statusline-original.json if it exists.

Step 2 — Wire the statusline (the load-bearing step)

Decide by the effective statusLine:

  • Case A — already ours: its command contains statusline-wrapper.js or statusline-command.js. Nothing to change; report "already installed" and continue to Step 3.
  • Case B — none configured: set in ~/.claude/settings.json:
    json
    "statusLine": { "type": "command", "command": "$NODE /Users/<user>/.claude/scripts/statusline-command.js", "padding": 0 }
    (expand $NODE and the home directory to absolute paths).
  • Case C — user has their own statusline: preserve it.
    1. Write ~/.claude/scripts/statusline-original.json containing exactly { "command": "<their current statusLine.command>" }.
    2. In the file that defines statusLine, replace only the command value with $NODE /Users/<user>/.claude/scripts/statusline-wrapper.js. Keep type, padding, refreshInterval, and any other sibling keys untouched.

Before the first edit to any settings file, back it up: cp settings.json settings.json.bak-cost-tracking (same pattern for the local file). One backup per run is enough.

Step 3 — Add the turn-boundary hook (additive, never replaces)

If no existing hooks.Stop entry's command mentions turn-logger.js, append this entry to the hooks.Stop array (create the array/path if missing), leaving every existing hook alone:

json
{ "matcher": "", "hooks": [ { "type": "command", "command": "$NODE /Users/<user>/.claude/scripts/turn-logger.js" } ] }

This hook carries no cost data — it only stamps turn boundaries and the idle timer. If the user objects to hooks, skipping this step still leaves session cost capture fully working.

Step 4 — Verify

  1. Build a fake statusline payload with session_id "cost-setup-verify", a workspace.current_dir of /tmp/cost-setup-verify, and nonzero cost.total_cost_usd / cost.total_api_duration_ms / model.display_name values.
  2. Pipe it via stdin into the exact statusLine.command now in settings (run through sh -c).
    • Case B: expect the rendered multi-line statusline.
    • Case C: expect the original statusline's output (the wrapper delegates). If their original command errors on the synthetic payload, that's their script's quirk — check instead that the log file below was written.
  3. Confirm ~/.claude/projects/-tmp-cost-setup-verify/cost-setup-verify.cost.jsonl now exists and contains the fake cost.
  4. Clean up all verification artifacts: that projects subdirectory, the cost-setup-verify line in ~/.claude/cost-log.jsonl, and /tmp/statusline-*-cost-setup-verify state files.

Step 5 — Report

Tell the user, concretely:

  • which case applied (fresh install / wrapped their existing statusline / already installed),
  • every file created or modified (settings edits, backups, copied scripts),
  • where their cost data will accumulate (the three log paths above),
  • that changes take effect in new sessions,
  • how to uninstall: restore the .bak-cost-tracking settings backup (or, by hand: point statusLine.command back to the command saved in ~/.claude/scripts/statusline-original.json and remove the turn-logger Stop hook entry), then delete the four scripts.

Invariants

  • Never delete or rewrite the user's hooks, statusline command, or unrelated settings keys. All changes are additive or a single-value swap that is recorded for reversal.
  • Idempotent: re-running on an installed machine must change nothing and say so.
  • If any step fails midway, restore the settings backup and report what happened.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Setup Cost Tracking?

Install genuine per-session cost tracking for Claude Code by wiring bundled logger scripts into the user's statusline — preserving any existing statusline and hooks. Use when the user asks to set up, install, enable, or repair cost tracking / cost logging / session cost capture. Idempotent; safe to re-run.

Perché usare Setup Cost Tracking su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Setup Cost Tracking è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Setup Cost Tracking in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/foyzulkarim/skills/tree/master/dev-pipeline/skills/setup-cost-tracking. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Setup Cost Tracking?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Setup Cost Tracking?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Setup Cost Tracking: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Setup Cost Tracking è gratuita?

È pubblicata su GitHub da foyzulkarim. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇