ai-setup: Command for Claude Code

.claude/commands/my-ai-stats.md

my-ai-stats is a command for Claude Code from cbmono/ai-setup. It costs 21 tokens per session (1,140 once invoked), scanned A, original, MIT.

A command that reads Claude Code's local records and displays how much work was delegated to sub-agents for a chosen month. With no month given, it uses the current month.

In plain words
What is it for?
Use it to view delegation statistics for a month written as YYYY-MM.
Why use it?
It makes delegation activity visible without replacing the underlying results with a summary. This helps you inspect how often your work was handed to other agents.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions subagents; mentions Claude Code.

This is cbmono/ai-setup's own configuration. It tells Claude Code how to work on ai-setup itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything ai-setup configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cbmono/ai-setup. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cbmono/ai-setup/main/.claude/commands/my-ai-stats.md
Clone the repo
git clone --depth 1 https://github.com/cbmono/ai-setup

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for my-ai-stats

README.md
[![agentmods](https://agentmods.dev/badge/commands/cbmono/ai-setup/my-ai-stats/github.svg)](https://agentmods.dev/commands/cbmono/ai-setup/my-ai-stats)
Your own site
<a href="https://agentmods.dev/commands/cbmono/ai-setup/my-ai-stats"><img src="https://agentmods.dev/badge/commands/cbmono/ai-setup/my-ai-stats/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for my-ai-stats

Your own site · 80×15
<a href="https://agentmods.dev/commands/cbmono/ai-setup/my-ai-stats"><img src="https://agentmods.dev/badge/commands/cbmono/ai-setup/my-ai-stats.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,140 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00021 $0.01140
Opus 5.5 $0.00008 $0.00456
Sonnet 5.5 $0.00004 $0.00228
Haiku 4.5 $0.00002 $0.00114

Measured 10d ago against content hash 6e95d08176d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

my-ai-stats scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/my-ai-stats.md · 99 lines

How it starts

The opening of the file, as written. The whole thing — 99 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Show the user their own delegation stats for a month.

Argument (optional): a month as YYYY-MM. If $ARGUMENTS is empty, use the current month.

Run exactly this, substituting the month, then show the user the output verbatim. Do not summarise it away — the table is the answer. Add at most two sentences of comment.

python3 - <<'PY' $ARGUMENTS
import pathlib, re, sys, datetime, calendar

arg = (sys.argv[1] if len(sys.argv) > 1 else "").strip()
today = datetime.date.today()
if arg:
    y, m = (int(x) for x in arg.split("-")[:2])
else:
    y, m = today.year, today.month
lo = datetime.datetime(y, m, 1).timestamp()
hi = datetime.datetime(y + (m == 12), (m % 12) + 1, 1).timestamp()

root = pathlib.Path.home() / ".claude" / "projects"
SIDE = b'"isSidechain":true'
BG = b'"sessionKind":"bg"'
ENTRY = re.compile(rb'"entrypoint":"([^"]+)"')

side = bg = sdk = live = 0
for f in root.rglob("*.jsonl"):
    try:
        if not (lo <= f.stat().st_mtime < hi):
            continue
    except OSError:
        continue
    is_side = is_bg = False
    entry = None
    with f.open("rb") as fh:
        prev = b""
        while chunk := fh.read(1 << 22):
            buf = prev + chunk
            if SIDE in buf:
                is_side = True
                break
            is_bg = is_bg or BG in buf
            if entry is None and (mt := ENTRY.search(buf)):
                entry = mt.group(1)
            prev = buf[-32:]
    if is_side:
        side += 1
    elif is_bg:
        bg += 1
    elif entry and entry.startswith(b"sdk-"):
        sdk += 1
    else:
        live += 1

runs = side + bg + sdk + live
delegated = side + bg + sdk
print(f"\n  Your Claude Code delegation — {calendar.month_name[m]} {y}   (this machine)")
print(f"  {'-'*58}")
print(f"  {'in-process sub-agents (Agent/Task tool)':<45}{side:>6}")
print(f"  {'background sessions (claude --bg)':<45}{bg:>6}")
print(f"  {'headless / SDK sessions (-p, Agent SDK)':<45}{sdk:>6}")
print(f"  {'interactive sessions — you steering':<45}{live:>6}")
print(f"  {'-'*58}")
share = f"{100*delegated/runs:.1f}%" if runs else "--"
print(f"  {'DELEGATED SHARE':<45}{share:>6}")
print(f"\n  {runs} runs scanned. Nothing leaves this machine.\n")
PY

Notes to pass on if the user asks:

  • DELEGATED SHARE is the whole point. It is the share of your Claude Code runs that did work on your behalf — sub-agents, background sessions, headless/SDK runs — rather than you steering a thread yourself. Higher is better. If it is near zero, you are working at rung ③/④, not ⑤.
  • Read from ~/.claude/projects on this machine only. Nothing is uploaded; no other person's data is visible or involved. If you use more than one machine, run it on each.
  • Files are bucketed by last-modified time, so a session spanning a month boundary lands in the month it was last touched. Fine for a monthly trend; not exact.
  • How runs are classified. Each transcript lands in exactly one bucket, checked in this order: "isSidechain":true → in-process sub-agent; "sessionKind":"bg" → background session; first entrypoint starting with sdk- (sdk-py, sdk-cli, … — headless claude -p and Agent SDK runs, e.g. loopd dispatches) → headless; anything else (cli, desktop, unknown) → interactive. The first three count as delegated. An SDK app you drive by hand would be miscounted as delegated; rare in practice.
  • No Task-dispatch counting. Anything derived from counting Task dispatches in the parent transcript is unreliable — the dispatch is frequently recorded in the child's transcript instead, which undercounts the parent badly. The per-transcript markers above are what the local data records cleanly.
  • This exists because the org dashboard's delegated figure does not count in-process sub-agent runs: one heavy user's machine showed 788 sub-agent runs in August while the whole organisation's reported figure for the same window was 287. This command measures the behaviour the dashboard cannot see.

Read the full file on GitHub · 99 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago Changed · +22 lines · +6 tokens per session 6e95d08176d5
  2. 1mo ago First seen · 77 lines · 15 tokens per session scan A 442b0ef46dd8

Subscribe to this mod's changes

my-ai-stats is a command published in the GitHub repository cbmono/ai-setup (2 stars, last pushed 10d ago), licensed MIT. It adds 21 tokens to every session and 1,140 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-20.