Cost History logo

Cost History

Community
jmagly
cost-history

Show cost trends across multiple workflow sessions, surfacing expensive operations, spending patterns, and outliers

Overview

Publisherjmagly
Repositoryaiwg
Skill namecost-history
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 History 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-history
  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-history .claude/skills/cost-history
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cost History 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 History 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 History 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-history

You show cost trends across multiple workflow sessions. You read historical cost records from .aiwg/ralph/sessions/ and surface patterns — which operations are expensive, how spending has changed over time, and which sessions were outliers.

For questions about what happened in historical conversations, use session-explore. When explaining a cost outlier, correlate the cost record with catalog tool/session evidence only through a reliable identity mapping. Catalog tool-call/result counts and timeline duration are not token usage or billed spend; report an unavailable correlation rather than joining by a similar title.

Triggers

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

  • "what have I spent overall" → full history summary
  • "are costs going up or down" → trend analysis
  • "most expensive sessions" → sorted history by cost
  • "cost this week" / "cost this month" → time-windowed history

Trigger Patterns Reference

PatternExampleAction
Full history"show cost history"aiwg cost-history
Recent sessions"last 5 sessions"aiwg cost-history --last 5
Time window"costs this week"aiwg cost-history --since 7d
Trend summary"are my costs trending up"aiwg cost-history --trend
Sorted by cost"most expensive sessions"aiwg cost-history --sort cost

Behavior

When triggered:

  1. Determine scope:

    • Default: all recorded sessions, newest first
    • --last N: most recent N sessions
    • --since <duration>: sessions within the time window (e.g., 7d, 30d, 2026-03-01)
  2. Read session records:

    • .aiwg/ralph/sessions/*/metrics.json — per-session cost records
    • .aiwg/ralph/cost-tracking.json — aggregated history index
  3. Compute trend data:

    • Session-over-session delta
    • Rolling 7-session average
    • Outlier detection (sessions > 2x average)
  4. Run the command:

    bash
    # All sessions, newest first
    aiwg cost-history
    
    # Most recent 10 sessions
    aiwg cost-history --last 10
    
    # Sessions in the past 30 days
    aiwg cost-history --since 30d
    
    # Trend analysis
    aiwg cost-history --trend
    
    # Sorted by cost descending
    aiwg cost-history --sort cost
    
    # JSON output
    aiwg cost-history --json

Report Format

Standard History Output

Cost History (12 sessions)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Date        Session                     Tokens    Cost    Status
──────────  ──────────────────────────  ────────  ──────  ──────
2026-04-01  sdlc-review-143022          61,250    $0.18   green
2026-03-31  greenfield-092211           94,800    $0.28   green
2026-03-30  security-review-174503     118,400    $0.36   yellow
2026-03-28  api-development-110022      52,100    $0.15   green
2026-03-26  full-stack-iteration-3     201,700    $0.61   red *outlier
...

Totals (12 sessions)
  Total tokens: 842,100
  Total cost:   $2.54
  Avg/session:  $0.21

7-session rolling average: $0.23
Trend: stable (±8% over last 7 sessions)

Trend Output (--trend)

Cost Trend — Last 7 Sessions
  Session 6 (oldest):  $0.28
  Session 5:           $0.22
  Session 4:           $0.36
  Session 3:           $0.15
  Session 2:           $0.61  ← outlier (full-stack-iteration-3)
  Session 1:           $0.18
  Current avg:         $0.23

Direction: stable
Outliers:  1 (full-stack-iteration-3 — 2.6x average)

Efficiency Thresholds

Sessions are color-coded by tokens/line ratio against the MetaGPT 124 tokens/line benchmark (REF-013):

StatusTokens/LineMeaning
green≤ 124At or below MetaGPT benchmark
yellow125–150Above benchmark, acceptable
red> 150Significantly above benchmark — review recommended

Examples

Example 1: Quick history overview

User: "Show cost history"

Action:

bash
aiwg cost-history

Response: Full session history table with totals, rolling average, and trend direction.

Example 2: Recent session costs

User: "What did the last 3 sessions cost?"

Extraction: --last 3

Action:

bash
aiwg cost-history --last 3

Response:

Cost History (last 3 sessions)

Date        Session                  Tokens   Cost
──────────  ───────────────────────  ───────  ────
2026-04-01  sdlc-review-143022       61,250   $0.18
2026-03-31  greenfield-092211        94,800   $0.28
2026-03-30  security-review-174503  118,400   $0.36

Total: $0.82 over 3 sessions  (avg: $0.27)

Example 3: Identifying expensive outliers

User: "Which sessions were most expensive?"

Action:

bash
aiwg cost-history --sort cost

Response: History table sorted by cost descending, with outlier flag on sessions more than 2x the rolling average.

Clarification Prompts

If a time window is ambiguous:

  • "Should I show all-time history or a specific window? (e.g., last 7 days, last 30 days)"

References

  • @$AIWG_ROOT/src/cli/handlers/subcommands.ts — Cost history handler
  • @$AIWG_ROOT/src/metrics/token-counter.ts — Token counting and MetaGPT baseline (REF-013)
  • @$AIWG_ROOT/docs/cli-reference.md — CLI reference

Frequently asked questions

What does the Cost History AI skill do?

Show cost trends across multiple workflow sessions, surfacing expensive operations, spending patterns, and outliers

Why use Cost History on TypingMind?

Because you install it once and use it with any model. Cost History 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 History 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-history. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Cost History?

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 History?

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

Is the Cost History 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 👇