check-claude-md-tokens

check-claude-md-tokens is a command for Claude Code from sgaunet/claude-plugins. It costs 25 tokens per session (1,193 once invoked), scanned A, original, MIT.

A command that estimates how many tokens CLAUDE.md files use, based on their character count, against a recommended 2,500-token limit.

In plain words
What is it for?
It finds project and global CLAUDE.md files, reports whether each is under, near, or over the limit, and suggests ways to shorten files that exceed it.
Why use it?
It helps detect when project instructions are too long and may leave less room for useful conversation or task context.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; positional $N argument.

Part of the software-engineering plugin — 4 skills, 12 commands, 7 agents shipped together

Good fit It finds project and global CLAUDE.md files, reports whether each is under, near, or over the limit, and suggests ways to shorten files that exceed it.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/sgaunet/claude-plugins/check-claude-md-tokens
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sgaunet/claude-plugins

Made for: Claude Code.

Or install software-engineering, the plugin that ships this one along with the rest of its 4 skills, 12 commands, 7 agents.

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 check-claude-md-tokens

README.md
[![agentmods](https://agentmods.dev/badge/commands/sgaunet/claude-plugins/check-claude-md-tokens/github.svg)](https://agentmods.dev/commands/sgaunet/claude-plugins/check-claude-md-tokens)
Your own site
<a href="https://agentmods.dev/commands/sgaunet/claude-plugins/check-claude-md-tokens"><img src="https://agentmods.dev/badge/commands/sgaunet/claude-plugins/check-claude-md-tokens/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 check-claude-md-tokens

Your own site · 80×15
<a href="https://agentmods.dev/commands/sgaunet/claude-plugins/check-claude-md-tokens"><img src="https://agentmods.dev/badge/commands/sgaunet/claude-plugins/check-claude-md-tokens.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 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,193 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.00025 $0.01193
Opus 5 $0.00013 $0.00596
Sonnet 5 $0.00005 $0.00239
Haiku 4.5 $0.00003 $0.00119

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

Security

Grade A, and why

check-claude-md-tokens 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.

plugins/software-engineering/commands/check-claude-md-tokens.md · 141 lines

How it starts

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

CLAUDE.md Token Counter Command

Monitor the token count of CLAUDE.md files to ensure they stay within the recommended 2500 token limit. This command analyzes the current token usage and provides reduction recommendations when the limit is exceeded.

Process

  1. Locate CLAUDE.md Files: Find all CLAUDE.md files in the repository:

    • Project-level: ./CLAUDE.md
    • Global user config: ~/.claude/CLAUDE.md
  2. Calculate Token Count: Use character-based estimation (~4 characters per token):

    wc -c CLAUDE.md | awk '{print int($1/4)}'
    
  3. Evaluate Against Limit: Check if token count exceeds 2500 tokens

  4. Report Status: Display current token usage with clear status indicator:

    • ✅ Under limit (< 2500 tokens)
    • ⚠️ Near limit (2000-2500 tokens)
    • ❌ Over limit (> 2500 tokens)
  5. Offer Reduction: If over limit, analyze content and propose specific reductions

Token Count Formula

Estimation: tokens ≈ characters ÷ 4

This rough estimate works well for English text. The actual token count may vary slightly based on:

  • Word length and complexity
  • Technical terminology
  • Code snippets
  • Formatting characters

Reduction Strategies

When CLAUDE.md exceeds the token limit, apply these optimization techniques:

1. Remove Redundancy

  • Eliminate duplicate instructions
  • Consolidate similar rules
  • Remove verbose explanations

2. Use Concise Language

  • Replace verbose phrases with concise alternatives
  • Remove filler words and redundant modifiers
  • Use bullet points instead of paragraphs

3. Externalize Content

  • Move detailed examples to separate documentation
  • Reference external guides instead of duplicating content
  • Create auxiliary files for extensive specifications

4. Prioritize Critical Instructions

  • Keep only essential directives
  • Remove nice-to-have preferences
  • Focus on behavior-changing instructions

5. Optimize Formatting

  • Use abbreviations for repeated terms
  • Reduce whitespace and empty lines
  • Compress nested lists

Read the full file on GitHub · 141 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 First seen · 141 lines · 25 tokens per session scan A cb9e23c1c684

Subscribe to this mod's changes

check-claude-md-tokens is a command published in the GitHub repository sgaunet/claude-plugins (16 stars, last pushed 8d ago), licensed MIT. It adds 25 tokens to every session and 1,193 once invoked, about $0.0001 per session on Opus 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-08-30.