Skip to content

setup — Claude Code

Install the polytropos statusline (current model, live session cost, context usage, rate-limit burn) into the user's Claude Code settings. Use when the user asks to set up or enable the cost statusline.

In practice

What it does

Installs a statusline into your Claude Code settings that shows, at a glance, which model you're on, roughly what the session has cost so far, how full the context window is, and — on subscription sessions — how much of your 5-hour and 7-day rate-limit windows you've burned. A separate, optional step can also install a hook that blocks a kit task from being marked done without a genuine verify pass.

When to reach for it

  • You want the model, cost, and context usage visible without asking for them.
  • You're running kits and want a marker-backed guarantee that done means verified.
  • After noticing the statusline is missing, wrong, or showing another tool's format.
  • Not something this skill bundles together — the hook is a separate opt-in, offered only after the statusline step, never installed alongside it by default.

Worked example

echo '{"model":{"id":"...","display_name":"..."},"cost":{"total_cost_usd":0},
"context_window":{"used_percentage":0},
"rate_limits":{"five_hour":{"used_percentage":0},"seven_day":{"used_percentage":0}}}' \
  | python3 <abs-path>/statusline.py

Confirms the script runs before touching settings. The written command is always a literal absolute path, never ${CLAUDE_PLUGIN_ROOT} — that variable doesn't exist once the statusline runs outside plugin context. Nothing is written until you confirm the exact block shown; an existing statusLine key is flagged and replaced only with your go-ahead.

Failure modes & fallbacks

  • The statusline doesn't appear. It only shows after a restart or new session — say so up front rather than let the user assume the write failed.
  • The hook seems inactive. Hook configuration also loads at session start; claude --debug is how registration is confirmed.
  • A done flip via the Write tool isn't blocked. The hook fires only on Edit — Claude Code's Write payload carries no old content to compare, so this is a silent no-op, not a bypass to fix. Read references/kit-verify-hook.md before explaining what the marker does and doesn't prove.

Cost & safety

This is the one skill in the roster that writes user-level settings, so every step gets explicit confirmation before it writes — shown as an exact block first, applied only after you agree, and merged so other keys in the file survive untouched. The rendered cost figure is a client-side estimate, never a bill; rate-limit fields render only on subscription sessions.

  • update — checks and refreshes what's installed across every harness, not just this statusline.
  • cost-report — the fuller spend analysis behind the number this statusline shows live.
  • Deep dive: how it works — where the statusline's numbers come from.

The skill card — what the model reads

This is the SKILL.md body the model reads, transformed for this page: the source's own leading title, if it had one, is removed; every remaining heading is demoted one level to nest under this section; and relative links are rewritten to site or GitHub URLs. ${CLAUDE_PLUGIN_ROOT} and {{POLYTROPOS_ROOT}} are install-time path variables, left intact exactly as the model sees them. The unmodified original is skills/setup/SKILL.md.

Wire bin/statusline.py (in this plugin) into the user's ~/.claude/settings.json as the statusLine command. This edits user-level settings, so get explicit confirmation before writing.

Steps

  1. Resolve <abs-path> — the absolute path to this plugin's bin directory — from ${CLAUDE_PLUGIN_ROOT}/bin, the env var Claude Code sets for plugin-executed content; if it is unset, fall back to resolving ../../bin relative to this SKILL.md to an absolute path. Verify the script exists and runs:
    echo '{"model":{"id":"claude-fable-5","display_name":"Fable 5"},"cost":{"total_cost_usd":1.23},"context_window":{"used_percentage":42},"rate_limits":{"five_hour":{"used_percentage":12},"seven_day":{"used_percentage":34}}}' | python3 <abs-path>/statusline.py
    
    Expected output shape: model | cost | ctx | 5h 12% · 7d 34% — this exercises the rate-limit rendering the skill's description promises.
  2. Read ~/.claude/settings.json. If a statusLine key already exists, show the user their current value and warn that proceeding replaces it.
  3. Show the exact block to be added and ask for confirmation. The command written into ~/.claude/settings.json must be a literal absolute path — never ${CLAUDE_PLUGIN_ROOT} — because this statusline command runs outside plugin context, where that variable is not set:
    "statusLine": {
      "type": "command",
      "command": "python3 <abs-path>/statusline.py"
    }
    
  4. Only after the user confirms: apply the edit, preserving all other keys in the file.
  5. Tell the user the statusline appears after a restart (or new session), and what the fields mean: model (color-coded — red = Fable tier, yellow = Opus tier), estimated session cost, context %, and 5h/7d rate-limit % (subscription sessions only; the cost figure is a client-side estimate, not a bill).

Optional: kit verify-pass enforcement hook (separate opt-in — never bundled with the statusline step)

bin/kit_verify_hook.py hook is a PostToolUse command hook that blocks a .claude/kits/<slug>/TASKS.md task's - status: line from being edited to done unless a verify-pass marker already exists for that task (PLAN D3/D10 of the graph-convergence kit — the marker is written only by bin/kit_verify_hook.py record, itself called only from the actual verify path). It never dispatches a real claude/copilot/codex CLI, never writes outside the kit-local, gitignored .claude/kits/<slug>/verify-pass/ directory, and this skill NEVER installs it without an explicit, separate confirmation from the statusline step above.

  1. Resolve <abs-path> the same way as the statusline step (${CLAUDE_PLUGIN_ROOT}/bin, falling back to ../../bin relative to this SKILL.md, resolved to an absolute path). Verify the script loads:
    python3 <abs-path>/kit_verify_hook.py --help
    
  2. Read ~/.claude/settings.json. If a hooks.PostToolUse array already exists, show the user its current matcher groups and explain that this step ADDS a new matcher group to that array rather than replacing anything.
  3. Show the exact block to be added and ask for confirmation. As with the statusline command, the command written into ~/.claude/settings.json must be a literal absolute path — never ${CLAUDE_PLUGIN_ROOT} — because it runs outside plugin context:
    {
      "hooks": {
        "PostToolUse": [
          {
            "matcher": "Edit",
            "hooks": [
              {
                "type": "command",
                "command": "python3 <abs-path>/kit_verify_hook.py hook"
              }
            ]
          }
        ]
      }
    }
    
    Merge this matcher group into any existing hooks object; preserve every other event, matcher, and top-level key already present in the file.
  4. Only after the user confirms: apply the edit.
  5. Tell the user precisely what this does and does not cover: it fires only on the Edit tool — the tool this repo's own skills and drivers actually use to flip a single - status: line — and is a silent no-op on every other file, tool, or edit, because Claude Code's PostToolUse payload for a Write rewrite carries only the new file content, never the old; a done flip performed via Write instead of Edit is therefore NOT enforced by this hook. Hook configuration loads at session start, so tell the user this change needs a restart (or new session) before it takes effect, and that claude --debug confirms the hook registered. Read references/kit-verify-hook.md before telling the user what a marker proves — what precheck freshness and the verify-command match add, and the three things it still cannot prove.