From agent-stalker
This skill should be used when the user runs "/stalker-tokens" or asks about token usage — "count tokens", "how many tokens did this session use", "show token usage", "token usage by agent", "tokens by model", "which session burned the most tokens", or "estimate the tokens in this file/text". Reports the real token usage agent-stalker captured, and counts/estimates tokens for arbitrary text or files for the Claude model family.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-stalker:stalker-tokens [--session <id>] [--since <Nm|Nh|Nd>] [--by session|agent|model] | count <file>[--session <id>] [--since <Nm|Nh|Nd>] [--by session|agent|model] | count <file>This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Two modes. Pick based on the request.
Two modes. Pick based on the request.
For questions about how many tokens tracked sessions/agents used, run the query engine's tokens subcommand and present its output verbatim:
bun "${CLAUDE_PLUGIN_ROOT}/lib/query.ts" tokens $ARGUMENTS
Options:
--session <id> — restrict to one session--since <Nm|Nh|Nd> — a recent window (e.g. --since 24h)--by session|agent|model — group the breakdown (default session)It prints a grand total (input / output / cache-read / cache-write) and a breakdown. These are real counts: agent-stalker parses the Claude Code transcript JSONL into a usage table when a session ends. If it reports no usage, the relevant sessions may not be ingested yet — run bun run ingest-usage from the plugin root (${CLAUDE_PLUGIN_ROOT}) to backfill from any transcripts still on disk, then re-run.
For "how many tokens is this text / file", use the bundled counter:
# a file
bun "${CLAUDE_PLUGIN_ROOT}/skills/stalker-tokens/scripts/count-tokens.ts" <path>
# inline text via stdin (POSIX shell)
printf '%s' "the text to count" | bun "${CLAUDE_PLUGIN_ROOT}/skills/stalker-tokens/scripts/count-tokens.ts"
The file-path form is cross-platform. On Windows PowerShell, printf is not native — pipe with PowerShell instead ('the text' | bun "$env:CLAUDE_PLUGIN_ROOT/skills/stalker-tokens/scripts/count-tokens.ts") or write the text to a temp file and pass its path.
How it counts (see scripts/count-tokens.ts):
ANTHROPIC_API_KEY is set — it calls Anthropic's count_tokens API (free; not billed). Override the model with AGENT_STALKER_TOKEN_MODEL (default claude-sonnet-4-6).~N. State plainly that it is an estimate, since Claude's tokenizer is proprietary and has no accurate local equivalent; suggest setting ANTHROPIC_API_KEY for an exact count.tokens subcommand (captured data) or count-tokens.ts (text), and report exactly what they return, including the exact-vs-estimate label.Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub ehartye/agent-stalker --plugin agent-stalker