agnostic-skills

Install thread-cost

Install adds hooks that show per-turn cost estimates, raise $5 alerts, and ask the model to write a handoff before you clear a thread. What it does and the rule it enforces: SKILL.md.

Requirements

Install

The installer reports first and changes nothing until --write.

  1. Put the thread-cost folder where it will stay. The hooks call its scripts by absolute path.

    • Claude Code: ~/.claude/skills/thread-cost (all projects), or <repo>/.claude/skills/thread-cost.
    • Antigravity, opencode, Codex: their skills folder, or any fixed folder.
  2. Report what is missing:

    python3 <skill>/scripts/thread_hooks_install.py
  3. Add the missing hooks:

    python3 <skill>/scripts/thread_hooks_install.py --write
  4. Restart a running session. Hooks are read at session start.

Check it works

python3 <skill>/scripts/thread_cost_alert.py status

Uninstall

python3 <skill>/scripts/thread_hooks_install.py --uninstall --write

Then delete the folder. Optional cleanup: hook state under thread_hooks_state_dir (default ${XDG_STATE_HOME:-~/.local/state}/thread-hooks, or %LOCALAPPDATA%\thread-hooks on Windows), and the config file (if you made one) under ~/.config/thread-cost/.

What the installer changes
  • Merges five hooks into Claude Code's settings.json.

  • Adds one hook named thread-cost to Antigravity's config/hooks.json when ~/.gemini exists.

  • Keeps your other hooks, and backs up each file first.

  • --no-idle leaves out the idle wake.

  • --harness limits it to one harness.

  • In Claude Code, the next reply should end with a _Last turn ~$... line. The first turn shows First turn ~$... on screen at Stop instead.

Harnesses without hooks (opencode, Codex, Cursor, a bare terminal)

Paste this into the project's AGENTS.md (or the harness's always-loaded rules):

## Thread cost
At an iteration boundary (a PR opens or merges, before a long wait, after about 40K of new
context), run `python3 <skill>/scripts/thread_cost_alert.py status`. When it prints CAPTURE NOW,
do what it says: write the handoff, make no outward writes, then tell the user to start a new
conversation from the handoff. Delegate screenshot- and log-heavy work to a subagent that returns
a verdict.
Configuration

Optional; with no config the defaults apply.

  • Put KEY=value lines in ~/.config/thread-cost/config.env (%APPDATA%\thread-cost\config.env on Windows, or the file $THREAD_COST_CONFIG names).

  • Or set the environment variables the script --help lists.

  • All keys are in SKILL.md, Config.

Most setups change only:

KeyExampleMeaning
thread_capture_step_file~/path/to/capture-step.txtOne paragraph telling the model how this setup records a handoff (which folder, what to update, whether to commit). Without it, the built-in step asks for a handoff doc where the project keeps its notes.
thread_ctx_growth_k80 (or 0)Use if the 40K growth capture fires too often.
What is in the folder
PathWhat it is
SKILL.mdThe rule, what fires, harness support, config keys
scripts/thread_cost_alert.pyCost line, alerts, capture block; status / check / replay
scripts/thread_idle_capture.pyIdle wake before the prompt cache lapses (Claude Code)
scripts/thread_handoff.pyRecords the handoff; resumes from it after /clear or /compact
scripts/thread_hook_antigravity.pyAntigravity hook adapter
scripts/thread_usage.pyReads Claude Code, opencode, Codex and Antigravity sessions: time, tokens, cost
scripts/model_prices.jsonPrice table (USD per million tokens, with an as_of date)
scripts/thread_hooks_common.pyShared config and state helpers
scripts/thread_hooks_install.pyWires, checks and removes the hooks
Update

Replace the folder in place; the hooks keep working. Run the installer again if the folder moved.