Learn-skills.dev acommons
git clone https://github.com/NeverSight/learn-skills.dev
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/Phlegonlabs/agentic-commons/acommons" ~/.claude/skills/neversight-learn-skills-dev-acommons && rm -rf "$T"
data/skills-md/Phlegonlabs/agentic-commons/acommons/SKILL.mdacommons — AI Usage Analytics Skill
You are an AI agent with access to local AI tool usage data. When the user invokes
/acommons, parse $ARGUMENTS and route to the matching subcommand below.
Default subcommand:
stats (when no argument given)
Environment
DATA_DIR = ~/.agentic-commons CLAUDE_STATS = ~/.claude/stats-cache.json CLAUDE_LEDGER = ~/.agentic-commons/claude-ledger.json CODEX_SESSIONS = ~/.codex/sessions/ CODEX_LEDGER = ~/.agentic-commons/codex-ledger.json OPENCODE_DB = ~/.local/share/opencode/opencode.db GEMINI_SESSIONS = ~/.gemini/tmp/*/chats/session-*.json EXTERNAL_USAGE = ~/.agentic-commons/external-usage/
On Windows:
~/.opencode → ~/AppData/Roaming/opencode
Subcommand: stats
(default)
statsShow today's AI tool usage in a table.
Steps:
- Read
→ extract today from~/.claude/stats-cache.json
(messages, sessions, toolCalls) anddailyActivity
(tokensByModel sum)dailyModelTokens - Check
→ if it has today's entry, sum all models'~/.agentic-commons/claude-ledger.json
for a more accurate token counttotalIO - Check
→ count~/.codex/sessions/
files as sessions. For token total: prefer.jsonl
if exists, otherwise count files~/.agentic-commons/codex-ledger.json - Check
→ if exists, report "detected" (reading SQLite requires the collect script)~/.local/share/opencode/opencode.db - Check
→ count~/.gemini/tmp/
filessession-*.json - Check
→ count~/.agentic-commons/external-usage/
files.jsonl
Output format:
AI Tool Usage — Today (YYYY-MM-DD) Tool Sessions Messages IO Tokens Tool Calls ──────────── ──────── ──────── ────────── ────────── Claude Code 3 42 130.0K 120 Codex CLI 5 -- 89.2K -- OpenCode 2 -- 45.1K -- Gemini CLI 1 -- 12.3K -- ──────────── ──────── ──────── ────────── ────────── Total 11 42 276.6K 120
Format numbers:
1,234 for small, 12.3K for thousands, 1.5M for millions.
Subcommand: daily
dailyShow 14-day daily breakdown.
Steps:
- Read
→~/.claude/stats-cache.json
array (each has date, messageCount, sessionCount)dailyActivity - Read
→~/.claude/stats-cache.json
array (each has date, tokensByModel)dailyModelTokens - Also read Claude ledger for more accurate daily totals if available
- For other tools: read their respective data sources and group by date
Output format:
Daily Usage — Last 14 Days Date Claude Codex OpenCode Gemini Total ────────── ──────── ─────── ──────── ─────── ──────── 2025-01-15 130.0K 89.2K 45.1K 12.3K 276.6K 2025-01-14 95.0K 72.1K 38.0K 8.1K 213.2K ...
Subcommand: models
modelsShow per-model token usage aggregated across all time.
Steps:
- Read
→~/.claude/stats-cache.json
object (keyed by model name, each has inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens)modelUsage - Read Claude ledger →
→ aggregate all dates per modeldailyByModel - Read Codex ledger → aggregate per [provider, model]
- Read other sources as available
Output format:
Token Usage by Model Source Model Input Output Cached Total IO ─────────── ───────────────────────────── ──────── ──────── ───────── ──────── Claude claude-sonnet-4-20250514 80.0K 50.0K 230.0K 130.0K Claude claude-haiku-4-5-20251001 20.0K 10.0K 50.0K 30.0K Codex gpt-4o 60.0K 29.2K 15.0K 89.2K OpenCode claude-sonnet-4-20250514 30.0K 15.1K 40.0K 45.1K Gemini gemini-2.5-pro 8.0K 4.3K 6.0K 12.3K
Subcommand: total
totalShow all-time aggregated summary.
Steps:
- Aggregate all data sources
- Sum by source (claude, codex, opencode, gemini, external)
Output:
All-Time Usage Summary Source Days Sessions IO Tokens Cached Tokens ─────────── ───── ───────── ─────────── ───────────── Claude 45 150 4.5M 12.3M Codex 30 89 2.1M 0.3M OpenCode 20 45 0.9M 0.4M Gemini 10 25 0.3M 0.1M External 5 -- 0.1M 0 ─────────── ───── ───────── ─────────── ───────────── Total 45 309 7.9M 13.1M
Subcommand: sync
syncRun the full collect + upload pipeline.
Action: Execute the collect script:
node ~/.agentic-commons/collect.mjs
If
~/.agentic-commons/collect.mjs does not exist, tell the user to run /acommons setup first.
Show the script output to the user.
Subcommand: setup
setupFirst-time setup: install hook, scheduler, and copy scripts.
Action: Execute the setup script:
bash <skill_dir>/scripts/setup.sh
Where
<skill_dir> is the directory containing this SKILL.md file.
If on Windows and bash is not available, run the steps manually:
- Create
directory~/.agentic-commons/ - Copy
→<skill_dir>/scripts/hook.mjs~/.agentic-commons/hook.mjs - Copy
→<skill_dir>/scripts/collect.mjs~/.agentic-commons/collect.mjs - Install Claude Code Stop Hook by modifying
:~/.claude/settings.json
(Merge with existing hooks, don't overwrite){ "hooks": { "Stop": [ { "hooks": [{ "type": "command", "command": "node ~/.agentic-commons/hook.mjs" }] } ] } } - Install hourly scheduler:
- Windows:
schtasks /create /tn "AgenticCommons" /tr "wscript.exe <vbs_path>" /sc hourly /f - macOS: Create LaunchAgent plist at
~/Library/LaunchAgents/com.agentic-commons.plist - Linux: Add crontab entry
0 * * * * node ~/.agentic-commons/collect.mjs
- Windows:
After setup, suggest the user run
/acommons link to connect their account.
Subcommand: link
linkDevice OAuth authentication flow.
Steps:
- Read or create device secret from
(64-char hex)~/.agentic-commons/device-secret.key - Build device identity (hostname, platform, arch, cpu/memory info)
- POST to
:https://api.agenticcommons.xyz/v1/auth/device/start{ "device_label": "<hostname>", "device_secret": "<hex>", "device_profile": {...} } - Show the user: verification URL and user code
- Open browser to
verification_uri_complete - Poll
withPOST /v1/auth/device/poll
every N seconds{ "device_code": "..." } - On
: save"authorized"
toaccess_token~/.agentic-commons/api-token.secret - Update
with~/.agentic-commons/config.json
andlinkedAtdeviceLabel
Note: On Windows, the token is encrypted with PowerShell SecureString before saving.
Subcommand: doctor
doctorHealth check and diagnostics.
Check each item and report status:
directory exists and permissions are 700~/.agentic-commons/
exists, show~/.agentic-commons/config.json
datelastSetup
exists (linked status)~/.agentic-commons/api-token.secret
has acommons Stop hook configured~/.claude/settings.json- Scheduler installed (check schtasks/launchd/crontab)
readable (Claude Code detected)~/.claude/stats-cache.json
exists (Codex CLI detected)~/.codex/sessions/
exists (OpenCode detected)~/.local/share/opencode/opencode.db
exists (Gemini CLI detected)~/.gemini/tmp/
— last upload info~/.agentic-commons/upload-tracker.json
Output format:
acommons Doctor ✓ Data directory exists (~/.agentic-commons/) ✓ Config found (last setup: 2025-01-10) ✓ Device linked (api-token.secret present) ✓ Claude Code Stop hook installed ✓ Scheduler: schtasks (Windows) ✓ Claude Code detected (stats-cache.json readable) ✗ Codex CLI not found ✓ OpenCode detected (opencode.db readable) ✗ Gemini CLI not found ✓ Last upload: 2025-01-15 (42 payloads)
Subcommand: probe
probeDetect all installed AI coding tools (not just data sources).
Scan for these tools:
| Tool | Config Dir | Binary | Provider |
|---|---|---|---|
| Claude Code | ~/.claude | claude | anthropic |
| Codex CLI | ~/.codex | codex | openai |
| Gemini CLI | ~/.gemini | gemini | |
| Kimi CLI | ~/.kimi | kimi | moonshot |
| OpenCode | ~/.opencode | opencode | various |
| Cursor | ~/.cursor | cursor | various |
| Windsurf | ~/.codeium | windsurf | codeium |
| Aider | ~/.aider | aider | various |
| Goose | ~/.config/goose | goose | various |
| Amp | ~/.config/amp | amp | sourcegraph |
| Droid | ~/.factory | droid | factory |
| Kiro | ~/.kiro | kiro-cli | aws |
| Copilot CLI | ~/.copilot | copilot | github |
| Cody | ~/.config/sourcegraph | cody | sourcegraph |
For each: check if config directory exists AND/OR if binary is on PATH (use
which/where).
Output:
AI Tool Probe Tool Binary Config Provider ───────────── ────── ────── ────────── Claude Code yes yes anthropic Codex CLI yes yes openai OpenCode yes yes various Gemini CLI yes yes google Cursor yes no various 5 detected, 9 not found
Subcommand: report
reportGenerate an HTML usage report.
Steps:
- Collect all available data (same as
+stats
+daily
)models - Generate a self-contained HTML file at
~/.agentic-commons/report.html - Include: daily chart, model breakdown table, source summary
- Open in browser
Notes for AI Agents
- All data is LOCAL. No API calls needed for
,stats
,daily
,models
,total
,probe
.doctor - Only
,sync
, andlink
perform network/system operations.setup - Token formatting: use
for thousands,K
for millions (e.g.,M
,130.0K
).1.5M - The
field equalstotal_io
— it does NOT include cached tokens.input_uncached + output - When reading JSON files, always handle missing/malformed files gracefully.
- Refer to
for detailed data format documentation.references/data-sources.md