reflect:cost
Report reflect drain spend over a time window — tokens split by cached (cache_read), uncached writes (cache_creation), and io (input+output), with a $ estimate, grouped by day / outcome / model / transcript. Reads the drainer's cost log and surfaces outlier runs and cache-reuse health (the 41.5M-token failure mode = low cache reuse + high cache writes). Use to answer "what is reflection costing me" for the last day / week.
Best use case
reflect:cost is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Report reflect drain spend over a time window — tokens split by cached (cache_read), uncached writes (cache_creation), and io (input+output), with a $ estimate, grouped by day / outcome / model / transcript. Reads the drainer's cost log and surfaces outlier runs and cache-reuse health (the 41.5M-token failure mode = low cache reuse + high cache writes). Use to answer "what is reflection costing me" for the last day / week.
Teams using reflect:cost should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cost/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How reflect:cost Compares
| Feature / Agent | reflect:cost | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Report reflect drain spend over a time window — tokens split by cached (cache_read), uncached writes (cache_creation), and io (input+output), with a $ estimate, grouped by day / outcome / model / transcript. Reads the drainer's cost log and surfaces outlier runs and cache-reuse health (the 41.5M-token failure mode = low cache reuse + high cache writes). Use to answer "what is reflection costing me" for the last day / week.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# /reflect:cost — Drain spend report
Shows what the reflect background drainer is spending: token volume split into
**cached** (cheap reuse), **uncached writes** (expensive cache_creation), and
**io** (input+output), plus a ballpark `$est`, grouped by day, outcome, model,
or transcript. This is the observability the 2026-05-31 incident lacked — one
drain run burned 41.5M tokens / ~$713 for zero net-new learnings and nothing
surfaced it until a manual backfill.
## When to Use
- "What did reflection cost me today / this week?"
- Spot an outlier run (a single transcript that blew up the spend).
- Check **cache reuse**: a healthy drain is cache_read-heavy; a low cache-reuse
% with high cache_creation is the costly failure mode.
- Confirm the drain is running on the cheap model (should be `sonnet`, not
`opus`) after a deploy.
## Window argument
Parse the window from the user's request and pass it as `--since`:
| User says | `--since` |
|-----------|-----------|
| "1 day", "today", "last 24h", (default) | `1d` |
| "this week", "last 7 days" | `7d` |
| "last hour" | `1h` |
| "last month", "30 days" | `30d` |
Default to `1d` when unspecified.
## Run it
Locate the cost reporter (prefer the running plugin, else the newest cached
version), then render. The script is `reflect_cost.py`, shipped in the reflect
plugin's `scripts/`.
```bash
WINDOW="1d" # ← substitute from the table above
# Resolve reflect_cost.py robustly across deploy layouts.
COST_PY=""
for cand in \
"${CLAUDE_PLUGIN_ROOT:-}/scripts/reflect_cost.py" \
$(ls -t "$HOME"/.claude/plugins/cache/agents-in-a-box/reflect/*/scripts/reflect_cost.py 2>/dev/null); do
if [ -n "$cand" ] && [ -f "$cand" ]; then COST_PY="$cand"; break; fi
done
if [ -z "$COST_PY" ]; then
echo "reflect_cost.py not found — install/update the reflect plugin (v4+):"
echo " claude plugin update reflect@agents-in-a-box"
exit 1
fi
# Headline: by outcome (where the spend goes), then model (cheap vs expensive),
# then the top transcripts (find the outlier).
python3 "$COST_PY" --since "$WINDOW" --by outcome
echo
python3 "$COST_PY" --since "$WINDOW" --by model
echo
python3 "$COST_PY" --since "$WINDOW" --by transcript --top 10
```
For a machine-readable view, add `--json`.
## If tokens show 0 (historical / pre-v4 events)
The drainer only began recording the full token envelope in v4. Older cost
events carry only `outcome` (no tokens/model), so the split shows `0`.
Reconstruct the real numbers from the raw session logs with the backfill — it
scans `~/.claude/projects`, finds the reflect runs, and sums their usage into a
separate `drain-cost-backfill.jsonl` (which `reflect_cost.py` reads alongside
the live log):
```bash
BACKFILL_PY="$(dirname "$COST_PY")/backfill_costs.py"
python3 "$BACKFILL_PY" --since "$WINDOW" \
--projects-dir "$HOME/.claude/projects" \
--state-dir "${REFLECT_STATE_DIR:-$HOME/.reflect}"
# then re-run the reflect_cost.py commands above
```
## Reading the output
```
outcome runs tokens cache_rd cache_wr io $est
ok 48 120M 95M 18M 7.0M 220.40
partial_max_turns 3 40M 30M 8M 2.0M 70.10
```
- **cache_rd** (cache_read) — cheap reuse, *should* dominate.
- **cache_wr** (cache_creation) — expensive writes; high here means caching is
not amortizing (re-paying to rebuild context). The incident was cache_wr-heavy.
- **io** — input + output tokens.
- **$est** — authoritative `cost_usd` from `claude -p` where recorded, else an
order-of-magnitude estimate from token buckets × ballpark list prices. Not a bill.
- **⚠ outlier** — any single run above `--outlier-tokens` (default 5M). One
flagged transcript is usually where a spend spike lives.
- The **cache-reuse %** line at the bottom is the fastest health read: low % +
high cache_wr = the 41.5M failure mode.
Then summarize for the user in one or two lines: total tokens, the cached vs
uncached split, the model, the $est, and call out any outlier transcript.
## Troubleshooting
- **"reflect_cost.py not found"** — the installed plugin predates v4. Run
`claude plugin update reflect@agents-in-a-box` and restart.
- **All rows show model `?` and 0 tokens** — pre-v4 events only; run the
backfill above.
- **No events at all** — the drain hasn't run in the window, or
`REFLECT_STATE_DIR` points elsewhere (`ls "${REFLECT_STATE_DIR:-$HOME/.reflect}"`).Related Skills
cost-aware-pipeline
Cost-aware LLM pipeline patterns for optimal model routing, narrow retry strategies, and prompt caching. Reduces API costs 40-70% through intelligent model selection, targeted retries, and cache-friendly prompt structures. Use when: (1) Building multi-model pipelines, (2) Optimizing API costs, (3) Designing retry strategies for LLM calls, (4) Implementing prompt caching, (5) Choosing between haiku/sonnet/opus for sub-tasks.
reflect
Full conversation scan for self-improvement. Detects behavioral corrections and knowledge signals, classifies them, proposes agent updates and knowledge notes with entity sidecars for GraphRAG indexing. Correct once, never again.
reflect-status
Show reflection metrics, pending reviews, sidecar coverage, and GraphRAG health. Read-only views into the reflect system state. Can also approve/reject pending low-confidence items.
reflect:recall
Retrieve relevant prior learnings from the global knowledge base. Hybrid vector + graph search over 170+ indexed learnings, reranked by confidence, recency, and tag overlap. Use when starting work, debugging a recurring problem, or before implementing a feature that may have prior art.
reflect:ingest
The global knowledge indexer. Harvests ALL memory sources across all tools (Claude, Codex, Copilot, Gemini) and all project types into the unified GraphRAG + QMD knowledge base. Archives originals, generates entity sidecars, and dual-indexes for future retrieval. This is THE command that makes the knowledge base comprehensive.
reflect:errors-ack
Triage and acknowledge entries in the reflect errors sink (~/.reflect/errors.json). Invoked from the statusline ⚠N badge when pipeline errors accumulate (drain poison, parser crashes, ingest failures, hook timeouts).
reflect:consolidate
Project-level memory consolidation. Merges orphaned worktree memory directories into a single .agents/MEMORY.md for the current project. Deduplicates, sections, and proposes cleanup of orphan dirs. Does NOT index into the global knowledge base — use reflect:ingest for that.
workflow
Guide through structured delivery workflow with plan, implement, validate phases
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
validate
Verify implementation against specifications
ui-ux-pro-max
UI/UX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, Astro, Nuxt, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, Jetpack Compose). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient.
tui-style-guide
TUI style guide for consistent terminal interface design