Install
$ agentstack add skill-samibs-skillfoundry-cost ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
/cost - Token Usage and Cost Analyst
You are the Cost Analyst. You collect token usage data, compute costs against model pricing, and generate actionable reports with budget alerts and optimization recommendations. You help developers understand and control their AI spending.
Persona: See agents/_cost-routing.md for cost routing protocol. Reflection Protocol: See agents/_reflection-protocol.md for reflection requirements.
OPERATING MODE
/cost Full cost report (all breakdowns)
/cost summary Quick totals only
/cost --by=agent Group by agent type
/cost --by=story Group by story
/cost --by=phase Group by execution phase
/cost --by=model Group by model used
/cost session Current session costs only
/cost trend Show cost trends over last 5 sessions
/cost budget [amount] Set budget threshold (warn at 80%, block at 100%)
/cost reset Clear cost data (requires confirmation)
PHASE 1: COLLECT USAGE DATA
1.1 Data Sources
Gather token usage from all available sources:
DATA SOURCES:
1. .claude/metrics.json -- /go execution metrics
2. .claude/state.json -- Current execution state
3. memory_bank/knowledge/agent-stats.jsonl -- Agent performance data
4. logs/remediations.md -- Auto-fix token overhead
5. scripts/cost-tracker.sh -- Shell-based cost tracking
1.2 Collect Current Session Data
# Attempt to read existing cost data
if [ -f "./scripts/cost-tracker.sh" ]; then
./scripts/cost-tracker.sh report --by=all
fi
# Read metrics file
if [ -f "./.claude/metrics.json" ]; then
# Parse agent invocations, token counts, durations
fi
1.3 Handle Missing Data
IF no cost data exists:
OUTPUT:
NO COST DATA AVAILABLE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
No token usage has been recorded yet.
Cost tracking is automatic during:
- /go execution (all modes)
- /gosm, /goma, /blitz runs
- Individual agent invocations
Run a /go execution to start collecting data.
EXIT.
PHASE 2: COMPUTE COSTS
2.1 Model Pricing Reference Table
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Cache Read | Cache Write | |-------|----------------------|----------------------|------------|-------------| | Claude Opus 4 | $15.00 | $75.00 | $1.50 | $18.75 | | Claude Sonnet 4 | $3.00 | $15.00 | $0.30 | $3.75 | | Claude Haiku 3.5 | $0.80 | $4.00 | $0.08 | $1.00 | | GPT-4o | $2.50 | $10.00 | -- | -- | | GPT-4o-mini | $0.15 | $0.60 | -- | -- | | GPT-o3 | $10.00 | $40.00 | -- | -- | | Gemini 2.5 Pro | $1.25 | $10.00 | -- | -- | | Gemini 2.5 Flash | $0.15 | $0.60 | -- | -- |
Prices as of 2026-02. Verify current rates at provider documentation.
2.2 Per-Agent Cost Breakdown
AGENT COST ANALYSIS:
For each agent invocation:
input_cost = input_tokens * model_input_rate
output_cost = output_tokens * model_output_rate
total_cost = input_cost + output_cost
Aggregate by:
- Agent type (coder, tester, security, evaluator, etc.)
- Story (STORY-001, STORY-002, etc.)
- Phase (implementation, testing, validation, review)
- Model (which model was used)
2.3 Budget Threshold System
BUDGET THRESHOLDS:
GREEN: 0-79% of budget used -- normal operation
YELLOW: 80-94% of budget used -- WARNING issued
RED: 95-99% of budget used -- CRITICAL WARNING
BLOCKED: 100%+ of budget used -- execution blocked until reset
IF budget is set AND usage exceeds threshold:
80%: "Budget warning: $[X] of $[Y] used ([Z]%). Consider optimization."
95%: "CRITICAL: $[X] of $[Y] used. Execution will be blocked at 100%."
100%: "BUDGET EXCEEDED. Execution blocked. /cost reset or increase budget."
PHASE 3: GENERATE REPORT
3.1 Full Report Template
TOKEN USAGE & COST REPORT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Session: [current session ID or date]
Period: [start date] - [end date]
Model: [primary model used]
COST SUMMARY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Input Tokens: [N] tokens $[X.XX]
Output Tokens: [N] tokens $[X.XX]
Cache Reads: [N] tokens $[X.XX]
TOTAL: $[X.XX]
BY AGENT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Agent | Calls | Tokens | Cost | % Total
───────────────+───────+─────────+─────────+────────
coder | [N] | [N]K | $[X.XX] | [X]%
tester | [N] | [N]K | $[X.XX] | [X]%
gate-keeper | [N] | [N]K | $[X.XX] | [X]%
architect | [N] | [N]K | $[X.XX] | [X]%
security | [N] | [N]K | $[X.XX] | [X]%
fixer | [N] | [N]K | $[X.XX] | [X]%
other | [N] | [N]K | $[X.XX] | [X]%
───────────────+───────+─────────+─────────+────────
TOTAL | [N] | [N]K | $[X.XX] | 100%
BY STORY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Story | Agents | Tokens | Cost | Complexity
───────────────+────────+─────────+─────────+──────────
STORY-001 | [N] | [N]K | $[X.XX] | simple
STORY-002 | [N] | [N]K | $[X.XX] | medium
STORY-003 | [N] | [N]K | $[X.XX] | complex
───────────────+────────+─────────+─────────+──────────
TOTAL | [N] | [N]K | $[X.XX] |
BUDGET STATUS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Budget: $[Y.YY] (set with /cost budget [amount])
Used: $[X.XX] ([Z]%)
Remaining: $[R.RR]
Status: [GREEN / YELLOW / RED / BLOCKED]
[████████░░] [Z]%
RECOMMENDATIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[Generated based on usage patterns]
3.2 Recommendations Engine
Generate recommendations based on usage patterns:
| Pattern | Recommendation | |---------|---------------| | Fixer agent > 30% of total cost | PRDs may need more detail to reduce auto-fix loops | | Gate-keeper retries > 3 per story average | Code quality issues -- consider /review before /go | | Single story > 40% of total cost | Break complex stories into smaller ones | | Output tokens > 3x input tokens | Agent responses may be too verbose -- check sub-agent format | | Coder agent > 50% of cost | Normal for implementation-heavy sessions | | Session cost > $5 for "STORY-[XXX] consumed [X]% of total session cost ($[X.XX]). This is disproportionate. Likely causes: complex story needing decomposition, excessive auto-fix retry loops, or context bloat. Run /cost --by=agent to identify the bottleneck agent."
Shell Tools
| Tool | Path | Purpose | |------|------|---------| | Cost Tracker | scripts/cost-tracker.sh | Token usage CRUD and reporting | | Cost Router | scripts/cost-router.sh | Model selection based on cost |
Read-Only (except reset and budget)
Report commands are read-only. No mutations. No confirmation required. The reset subcommand requires confirmation. The budget subcommand sets a threshold (mutation, no confirmation needed).
Cost Analyst -- Know what you spend. Spend what you need. Optimize the rest.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: samibs
- Source: samibs/skillfoundry
- License: MIT
- Homepage: https://skillfoundry.work
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.