cost-attribution
Track per-client and per-feature LLM and cloud spend with cryptographic audit trail.
Skill by MILTONADINA
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/miltonadina-cost-attribution
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, devops, ml, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/cost-attribution
What's inside
- Skill name
cost-attribution- Description
- Track per-client and per-feature LLM and cloud spend with cryptographic audit trail. Use whenever billable operations occur - LLM API calls, infrastructure provisioning, batch jobs. Required for any project with multiple clients or cost-sensitive operations. Integrates with Stratum's append-only billing_records table.
- License
- MIT
- Instructions
- 120 lines in SKILL.md · view on GitHub
Files (3)
- SKILL.md
- SKILL.md.bundle
- SKILL.md.sig
SKILL.md (first lines)
# Cost Attribution
> Per-tenant cost attribution from day one. Cryptographically signed audit
> trail.
**Tradeoff:** Every billable op needs a ledger entry. Worth it: client
invoicing is automatic, surprise bills are caught early, and cost-by-feature
guides optimization.
---
## How it works
DevOPs ships two pieces of this: the Stratum `billing_records` ledger and the
budget caps below. The exporter, the report command and the anomaly job on
this page are the design to build in each project; none of them exists in
DevOPs yet.
1. OTel baggage carries `tenant.id` and `user.id` on every span.
2. LLM calls auto-add `cost_usd` via OpenInference instrumentation.
3. The cost-attribution exporter aggregates costs by `tenant.id` per hour.
4. Aggregates are written to:
- File: `.workflow/state/cost-ledger.jsonl` (per-project)
- Stratum: `billing_records` table (HMAC-signed, append-only) if configured
5. A report command (not yet built; see Reports below) summarizes the ledger.
---
## Ledger entry shape
```json
{
"ts": 1716372013,
"tenant_id": "client-abc",
"user_id": "user-123",
"session_id": "s-7f3a",
"operation": "llm.call",
"provider": "anthropic",
"model": "claude-sonnet-4-6",
"input_tokens": 1234,
"output_tokens": 567,
"cost_usd": 0.0122,
"hmac": "sha256:..." // Stratum signs server-side
}
```
---
## Reports
Example monthly report for one client (illustrative figures; the `devops`
CLI has no `cost-report` command yet):
```
Client: client-abc
Period: 2026-05-01 to 2026-05-31
Total spend: $124.37
By provider:
Anthropic: $118.42
OpenAI: $5.95
By model:
claude-opus-4-7: $42.18 (12% of calls)
claude-sonnet-4-6: $63.71 (44% of calls)
claude-haiku-4-5: $12.53 (44% of calls)
By feature:
/api/auth: $34.21
/api/payments: $18.42
/api/search: $71.74
Cost per session: avg $0.34, p95 $1.21
Cost per request: avg $0.0023, p95 $0.012
```
---
## Hard caps integration
`hooks/universal/pre-tool/budget-brake.sh` enforces the caps in
`.workflow/state/budget.yml` against its own ledger,
`.workflow/state/budget-ledger.jsonl` (not the cost ledger above):
- Per-session cap (default $5)
- Per-hour cap (default $20)
- Per-day cap (default $100)
When a cap is hit, the hook exits 2 and the tool call is blocked; the agent
cannot override it. It runs only once the harness registers it as a
PreToolUse hook (for Claude Code, in `.claude/settings.json`).
`analyzer/install.ts` copies the script without registering it, so check the
settings before relying on the cap.
---
## Anomaly detection
A daily anomaly job (not yet built) should flag:
- Day-over-day spend > 3x weekly average
- Per-client spend exceeding contract terms
- Calls with token counts > 90th percentile (potential prompt bloat)
It should write anomalies to `governance/telemetry/cost-anomalies.jsonl`.
---
## Anti-patterns
**Tagging by session only**: lose per-feature breakdown. Always include
endpoint or skill name in span attributes.
**No HMAC**: ledger entries can be tampered. Always sign server-side.
**No retention policy**: ledger grows unbounded. Roll up to monthly aggregates
after 90 days; archive raw to cold storage.
---
**This skill is working when:** client invoices reconcile to ledger entries
exactly, and cost-anomaly alerts fire before manual review notices the spike.From MILTONADINA/DevOPs, MIT.
More from MILTONADINA/DevOPs
- 0.565score
ears-spec-writing
MILTONADINA
Write requirement specifications in EARS (Easy Approach to Requirements Syntax) notation.
SkillAFreshness: AClaude Code +9 - 0.565score
proof-of-work
MILTONADINA
Produce structured proof artifacts for every completed claim.
SkillAFreshness: AClaude Code +9 - 0.565score
plan-decomposition
MILTONADINA
Break an approved spec into atomic, ordered, verifiable tasks before any code is written.
SkillAFreshness: AClaude Code +9 - 0.565score
multi-tool-failover
MILTONADINA
Manage session continuity when switching between Claude Code, Codex CLI, Cursor, Antigravity, Kiro, or local LLMs (OpenCode, Aider).
SkillAFreshness: AClaude Code +9 - 0.565score
goal-loop
MILTONADINA
Execute the spec-tests-implement-verify cycle for one atomic task at a time.
SkillAFreshness: AClaude Code +9 - 0.565score
baton-handoff
MILTONADINA
Write a complete handoff document at session end so the next agent (Claude Code, Codex, Cursor, Antigravity, Kiro, or local LLM) resumes exactly where this…
SkillAFreshness: AClaude Code +9 - 0.565score
observability-instrument
MILTONADINA
Add OpenTelemetry spans with user_id and tenant_id in baggage to any new code path that handles requests, runs agents, or performs billable operations.
SkillAFreshness: AClaude Code +9 - 0.565score
openapi-first
MILTONADINA
Generate API code, types, validators, mock servers, and client SDKs from a single OpenAPI 3.1 specification.
SkillAFreshness: AClaude Code +9 - 0.561score
session-summary
MILTONADINA
Generate the end-of-session human-reviewable report.
SkillAFreshness: AClaude Code +9 - 0.561score
coppa-audit
MILTONADINA
Audit code, data flows, and UI for COPPA (Children's Online Privacy Protection Act) compliance.
SkillAFreshness: AClaude Code +9 - 0.560score
supabase-rpc-functions
MILTONADINA
Supabase RPC function security patterns -- SECURITY DEFINER with `SET search_path` discipline, `REVOKE EXECUTE FROM public` for least-privilege exposure…
SkillAFreshness: AClaude Code +9 - 0.560score
rust-error-handling
MILTONADINA
Rust error-handling patterns and anti-patterns -- `unwrap()` in request hot paths, `panic!` instead of returning a `Result`, leaking error internals via…
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 12
- Last commit (this folder)
- Oct 12, 2026 (17 days ago)
- Last release
- Sep 23, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/MILTONADINA/DevOPs
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from MILTONADINA
- 0.565score
goal-loop
MILTONADINA
Execute the spec-tests-implement-verify cycle for one atomic task at a time.
SkillAFreshness: AClaude Code +9 - 0.565score
baton-handoff
MILTONADINA
Write a complete handoff document at session end so the next agent (Claude Code, Codex, Cursor, Antigravity, Kiro, or local LLM) resumes exactly where this…
SkillAFreshness: AClaude Code +9 - 0.565score
openapi-first
MILTONADINA
Generate API code, types, validators, mock servers, and client SDKs from a single OpenAPI 3.1 specification.
SkillAFreshness: AClaude Code +9 - 0.565score
ears-spec-writing
MILTONADINA
Write requirement specifications in EARS (Easy Approach to Requirements Syntax) notation.
SkillAFreshness: AClaude Code +9 - 0.565score
observability-instrument
MILTONADINA
Add OpenTelemetry spans with user_id and tenant_id in baggage to any new code path that handles requests, runs agents, or performs billable operations.
SkillAFreshness: AClaude Code +9 - 0.565score
multi-tool-failover
MILTONADINA
Manage session continuity when switching between Claude Code, Codex CLI, Cursor, Antigravity, Kiro, or local LLMs (OpenCode, Aider).
SkillAFreshness: AClaude Code +9
Cite this page
cost-attribution skill. Agent Mart. https://agentmart.dev/skills/miltonadina-cost-attribution (last updated 2026-10-24)