/utils:cost-reportfrom utils
Generates cost and token-spending reports for AIWG sessions or OpenRouter fleet spend. Reads accumulated usage data and presents breakdowns by operation, model, and time period.
Ships in utils. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You generate a cost and token-spending report for the current or most recent workflow session. You read accumulated token usage data from .aiwg/ralph/cost-tracking.json and present a breakdown by operation, model, and time period.
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
| Pattern | Example | Action |
|---|---|---|
| Session cost | "cost report" | aiwg cost-report |
| Current loop cost | "how much has this session cost so far" | aiwg cost-report --session current |
| Named session | "cost for the greenfield run" | aiwg cost-report --session greenfield |
| Model breakdown | "show costs by model" | aiwg cost-report --by-model |
| Budget check | "are we over budget" | aiwg cost-report --budget <N> |
| Fleet spend | "show fleet spend" | aiwg cost-report --fleet |
When triggered:
For --fleet, run the native CLI handler. It reads ~/.config/aiwg/fleet.yaml, resolves each key_ref only from ~/.config/aiwg/keys/ or AIWG_OPENROUTER_KEY_*, and reports bot | machine | spend MTD | cap | % used | top-3 expensive sessions.
Fleet manifests contain references only. Never read a credential from a project manifest, print a credential, or copy one into an artifact. AIWG observes and correlates spend; OpenRouter enforces all limits and caps. Session/model correlation is optional and uses locally recorded bot=, session=, and generation_id= tags in .aiwg/activity.log.
aiwg cost-report --fleet
aiwg cost-report --fleet --json
aiwg cost-report --key <key_ref> --monthly-cap 10
For setup and security details, see @$AIWG_ROOT/docs/guides/openrouter-fleet-costs.md.
Determine scope:
--session current: running session (live data)--session <name>: named session from historyRead cost tracking data:
.aiwg/ralph/cost-tracking.json.aiwg/ralph/sessions/*/metrics.jsonCompute the report:
Run the command:
# Default report (most recent session)
aiwg cost-report
# Current running session
aiwg cost-report --session current
# JSON output (for scripting)
aiwg cost-report --json
# Filter to specific model
aiwg cost-report --model claude-sonnet-5
# Budget threshold check
aiwg cost-report --budget 5.00
Cost Report — Session: sdlc-review-20260401-143022
Duration: 4m 12s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Token Usage
Input tokens: 42,310
Output tokens: 18,940
Total tokens: 61,250
Estimated Cost
claude-sonnet-4-5: $0.18 (61,250 tokens)
Total: $0.18
Efficiency vs Benchmark
Tokens/line: 112 (MetaGPT baseline: 124) [green]
vs baseline: -9.7% (better than benchmark)
Steps
architecture-designer → 18,200 tokens $0.07
security-architect → 14,600 tokens $0.06
test-architect → 13,100 tokens $0.05
technical-writer → 15,350 tokens $0.06 (incl. synthesis)
Budget: $5.00
Used: $0.18 (3.6% of budget)
Status: Within budget
| Source | Contents |
|---|---|
.aiwg/ralph/cost-tracking.json | Aggregated session costs |
.aiwg/ralph/sessions/*/metrics.json | Per-session detailed metrics |
src/metrics/token-counter.ts | Token estimation logic (4 chars/token) |
User: "How much did that cost?"
Extraction: Cost report for most recent session
Action:
aiwg cost-report
Response: Session report with token totals, estimated cost, and efficiency rating against the MetaGPT baseline.
User: "Are we over the $2 budget for this run?"
Extraction: Budget comparison for current session
Action:
aiwg cost-report --session current --budget 2.00
Response:
Budget: $2.00
Used: $0.43 (21.5% of budget)
Status: Within budget
Projected total (at current rate): $0.71
User: "Show me costs broken down by model"
Action:
aiwg cost-report --by-model
Response:
Cost by Model
claude-sonnet-4-5: $0.12 (38,400 tokens)
claude-haiku-3-5: $0.02 (6,200 tokens)
Total: $0.14 (44,600 tokens)
If the session is ambiguous:
Use aiwg cost-report --by-tier [--session <id>] [--activity-log <file>] [--json]
for measured routing observations. It groups requested tier, resolved tier and
selected model, and reports input/output tokens, UTF-8 returned-summary bytes,
result use and observed USD. Unknown values are null, never zero or estimates.
A partial subtotal is labeled separately from a total. Fleet flags cannot be
combined with this mode. Details: $AIWG_ROOT/docs/models/orchestration-worker-selection.md.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jmagly/aiwg --plugin utils133 skills in this plugin
/activity-logQuery and manage the unified .aiwg/activity.log chronological record of AIWG-managed workflow operations/add-agentScaffold a new agent definition file inside an existing addon or framework/add-behaviorScaffold a new behavior definition with BEHAVIOR.md and optional scripts inside an existing addon or framework/add-commandScaffold a new command definition inside an existing addon or framework/add-skillScaffold a new SKILL.md inside an existing addon or framework/add-templateScaffold a new document template inside an existing addon or frameworkOther plugins' skills for the same job