Cost Report logo

Cost Report

Community
jmagly
cost-report

Generate a cost report for an AIWG session or observe per-bot OpenRouter fleet spend

Overview

Publisherjmagly
Repositoryaiwg
Skill namecost-report
Stars
225
Forks
34
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by jmagly on GitHub. Read the source before you install it.

Installation

Install the Cost Report AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/aiwg-utils/skills/cost-report
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jmagly/aiwg.git /tmp/aiwg
mkdir -p .claude/skills
cp -r /tmp/aiwg/agentic/code/addons/aiwg-utils/skills/cost-report .claude/skills/cost-report
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cost Report in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cost Report on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cost Report is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

cost-report

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.

Triggers

Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):

  • "how much did that cost" → report for most recent session
  • "what did this iteration cost" → report scoped to current agent loop
  • "token breakdown" → report with per-model detail
  • "did we stay in budget" → report with budget threshold comparison

Trigger Patterns Reference

PatternExampleAction
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

Behavior

When triggered:

Fleet mode

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.

bash
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.

Session mode

  1. Determine scope:

    • Default: most recent completed session
    • --session current: running session (live data)
    • --session <name>: named session from history
  2. Read cost tracking data:

    • Primary source: .aiwg/ralph/cost-tracking.json
    • Fallback: aggregate from .aiwg/ralph/sessions/*/metrics.json
  3. Compute the report:

    • Total tokens (input + output)
    • Estimated cost using model pricing table
    • Breakdown by workflow step and model
    • Comparison to MetaGPT baseline (124 tokens/line, REF-013)
  4. Run the command:

    bash
    # 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

Report Format

Standard Output

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 Check Output

Budget: $5.00
Used:   $0.18  (3.6% of budget)
Status: Within budget

Data Sources

SourceContents
.aiwg/ralph/cost-tracking.jsonAggregated session costs
.aiwg/ralph/sessions/*/metrics.jsonPer-session detailed metrics
src/metrics/token-counter.tsToken estimation logic (4 chars/token)

Examples

Example 1: Quick session report

User: "How much did that cost?"

Extraction: Cost report for most recent session

Action:

bash
aiwg cost-report

Response: Session report with token totals, estimated cost, and efficiency rating against the MetaGPT baseline.

Example 2: Budget check mid-session

User: "Are we over the $2 budget for this run?"

Extraction: Budget comparison for current session

Action:

bash
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

Example 3: Model breakdown

User: "Show me costs broken down by model"

Action:

bash
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)

Clarification Prompts

If the session is ambiguous:

  • "Should I report on the current session or the most recent completed session?"

References

  • @$AIWG_ROOT/src/cli/handlers/subcommands.ts — Cost report handler
  • @$AIWG_ROOT/src/metrics/token-counter.ts — Token counting and MetaGPT baseline (REF-013)
  • @$AIWG_ROOT/docs/cli-reference.md — CLI reference
  • @$AIWG_ROOT/docs/guides/openrouter-fleet-costs.md — OpenRouter fleet configuration and security contract

Frequently asked questions

What does the Cost Report AI skill do?

Generate a cost report for an AIWG session or observe per-bot OpenRouter fleet spend

Why use Cost Report on TypingMind?

Because you install it once and use it with any model. Cost Report is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cost Report in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/aiwg-utils/skills/cost-report. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Cost Report?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cost Report?

As many as you like. As long as a model supports skills, you can use Cost Report with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cost Report AI skill free?

Yes. It is published on GitHub by jmagly under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇