Skip to content
Back to skills

Context Token Audit

ASecurity

Read and report token usage stats from Hermes gateway logs. Use when asked "how many tokens", "token breakdown", "context size", "what's using my context", or any question about token/component breakdown in the current session or across recent sessions.

  • 6 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added November 26, 2026
ai-agentsbashapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add jleechanorg/jleechan-skills --skill context-token-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Token Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Context Token Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jleechanorg-context-token-audit/badge)](https://www.skillsdirectory.com/skills/jleechanorg-context-token-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: context-token-audit
description: Read and report token usage stats from Hermes gateway logs. Use when asked "how many tokens", "token breakdown", "context size", "what's using my context", or any question about token/component breakdown in the current session or across recent sessions.
---

# Context Token Audit

Read actual token usage from Hermes gateway logs to report precise breakdown of context components.

## Log Location

```
~/.hermes_prod/logs/gateway.log
```

## Relevant Log Pattern

The gateway logs token stats with this format:
```
⏱️  Elapsed: 0.21s  Context: 4 msgs, ~14,339 tokens
```

Also contains per-message headers when sending to the LLM API:
```
DEBUG anthropic._base_client: Request options: ...'content': None, 'json_data': {'max_tokens': 131072, 'messages': [...]
```

## How to Read Tokens

### Single Session Token Count

```bash
grep -E "^   ⏱" ~/.hermes_prod/logs/gateway.log | tail -10 | grep -oE "Context: [0-9]+ msgs, ~[0-9,]+ tokens"
```

Returns most recent sessions with msg count and token estimate.

### Historical Token Distribution

```bash
grep -E "^   ⏱" ~/.hermes_prod/logs/gateway.log | awk '{print $NF}' | sed 's/[^0-9]//g' | sort -n | uniq -c | sort -rn | head -20
```

### Per-Session Range

```bash
grep -E "^   ⏱" ~/.hermes_prod/logs/gateway.log | grep -oE "[0-9]+ msgs, ~[0-9,]+ tokens" | sort -t: -k3 -rn | head -20
```

## Estimated Context Composition (for reporting)

When reporting token breakdown, use these known proportions from analysis:

| Component | Approx % | Notes |
|---|---|---|
| Tool definitions | ~45% | 35 tools with full JSON schemas |
| System prompt framework | ~18% | Fixed instruction structure |
| SOUL.md + AGENTS.md | ~25-27% | Combined policy files |
| Skills list (metadata only) | ~6% | 130+ entries, names + descriptions |
| Session context + profiles | ~4% | Slack thread, user profile, memory |
| TOOLS.md | <1% | Local setup notes |

**Note:** Skill content (`SKILL.md` files) loads on-demand via `skill_view()`, not pre-loaded. Only the skill metadata (name + description) is in the baseline context.

## Reporting Format

When asked "what's in my context" or "token breakdown":

1. Run the gateway log grep commands above
2. Report the observed token count for current session
3. Explain the composition using the estimated percentages above
4. Highlight which component dominates (usually tool definitions at ~45%)

## Caveats to State

- The `~NN,NNN tokens` figure is an **estimate** from the gateway, not the model's own count
- Actual tokenization varies by provider/model (GLM vs Claude vs GPT)
- The breakdown percentages are from analysis, not measured per-component
- Full file contents (SOUL.md, AGENTS.md) are only partially visible in the initial context load — the gateway may truncate large files

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.