datashaman/code-skills/audit-context

Claude Code and agent skill by datashaman/code-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Audit your Claude Code setup for token waste and context bloat. Checks MCP servers, CLAUDE.md files, skills, agents, commands, plugins, hooks, and permissions. Mines session transcripts for cache hit rate, autocompact frequency, turn costs, tool errors, and unused assets. Flags broken MCP servers that load schemas but never connect. Returns a health score with specific fixes. Use when asked to "audit my context", "check my settings", "token optimization", or "why is Claude slow".

Install

npx vskill@latest install datashaman/code-skills/audit-context

SKILL.md

The same SKILL.md was published earlier as datashaman/code-skills/audit-context.

Context Audit

Bloated context costs more and produces worse output. This skill finds the waste and tells you what to cut. Static config audit + behavioral scan of real session data.

Step 1: Get /context Data

Check the conversation history for /context output. If the user already ran /context in this session, use that data. If not, ask:

"Run /context in this session terminal and let me know when you're done. I can't run slash commands myself, but once I can see the breakdown I'll audit everything it flags."

STOP HERE. Do NOT proceed until the user has run /context. The breakdown determines audit priority; without it, the audit is guessing.

Step 2: Config Audit

Run the bundled config scanner first — it inventories everything that contributes to per-turn context:

bash
python3 "$SKILL_DIR/scripts/scan_configs.py"

Substitute the skill's absolute base directory for $SKILL_DIR (it's announced at the top of this invocation). Output is a single JSON object; use the sections below to interpret each field.

MCP Servers

/context tells you the real overhead (System tools bucket). If that bucket is small (< 5k), MCP servers are lazy-loaded and cheap — don't over-penalize. If large, drill in:

  • Count user-configured servers from ~/.claude.json > mcpServers and

project-scoped projects[<cwd>] > mcpServers (the scan scripts already do this).

  • Look for redundant tool schemas: servers with 40 tools where only

3 get called — narrow via per-server allowlist rather than uninstalling.

CLI-alternative candidates. Scanner emits cli_alternative_candidates[] listing user-configured MCP servers that match a known-heavyweight registry (GitHub, GitLab, AWS, GCP, Kubernetes, Docker, Terraform, Postgres, Jira, Linear, Trello, Playwright, Puppeteer, Stripe, Sentry, filesystem/memory/fetch built-ins, and more). For each match, flag as a WARNING with the suggested CLI and the specific reason:

  • github MCP has 40+ tools and loads their schemas every turn —

gh covers issues, PRs, workflows, releases, and repo ops at zero token cost when idle. Same story for gitlab/glab, aws/aws CLI, gcp/gcloud, kubernetes/kubectl, and so on.

  • The CLI-first rule of thumb: if a reasonable CLI exists and the

MCP server has > 5 tools, the CLI is almost always cheaper unless you specifically need schema-level awareness of the responses (rare).

  • Context7 (docs server) and similar narrow-purpose servers don't

have obvious CLI replacements — they aren't in the registry.

See Step 3 "MCP log scan" for broken/stale detection.

CLAUDE.md

Scanner returns claude_md.files[] (path, line count, mtime) with @imports followed, plus claude_md.total_lines.

Test every rule against five filters:

FilterFlag when...
DefaultClaude already does this without being told ("write clean code", "handle errors")
ContradictionConflicts with another rule in same or different file
RedundancyRepeats something already covered elsewhere
BandaidAdded to fix one bad output, not improve outputs generally
VagueInterpreted differently every time ("be natural", "use good tone")

If total_lines > 200, look for progressive-disclosure wins: rules that only apply to specific tasks (API conventions, deployment steps, testing guidelines) should move to reference files with one-line pointers.

Ghost references. Scanner emits ghost_refs[]: slash-command-like references (/foo) in CLAUDE.md that don't resolve to any installed skill or command. These rot whenever you reorganize — recommend removal. Each one is also a tiny correctness hazard (Claude may try to invoke the dead name).

Rot signal. Cross-reference claude_md.files[].mtime with the behavioral scan's correction_user_turns / user_turns_sampled ratio (Step 3). A stale CLAUDE.md (> 90 days old) plus a high correction rate (> 15%) is strong evidence the rules have drifted from what the user actually wants. Recommend a review pass.

Skills

Scanner emits skills[] with {name, scope, path, body_lines, mtime} and flags.skills_oversize / flags.skills_critical.

For each oversize skill (>200 lines) or critical (>500):

  • Run the same five filters on the body.
  • Check for restated goals, hedging ("you may want to"), synonymous

instructions ("be concise" + "keep it short" + "don't be verbose").

  • If the body is mostly example code or long scripts, recommend

extracting to sibling files under a scripts/ or examples/ dir and referencing them — this skill does exactly that.

Also compare descriptions pairwise. If two skills have highly overlapping descriptions (same triggers, same verbs), the router wastes tokens disambiguating. Flag the overlap and recommend merging or narrowing triggers.

Cache stability. Skill descriptions are in every turn's prompt cache. If a skill's mtime falls inside the behavioral window AND cache_hit_rate dropped, flag it as cache churn — editing skills mid-sessions silently tanks hit rate.

Agents

Scanner emits agents[] (user and project scope) and flags.agents_oversize. Agents are system prompts for subagents spawned via the Agent tool. Each spawn pays the agent's prompt budget.

Audit:

  • Body size (same >200 / >500 thresholds as skills).
  • Usage via Step 3's agent_subagent_types — agents never called

are dead weight. With zero window usage, flag for removal unless the user confirms they're for future use.

  • Description overlap with skills or other agents.
Slash Commands

Scanner emits commands[] and flags.commands_oversize. Commands are less chatty than skills (only load when invoked) but dead commands still clutter /help output and can be confused with ghost refs. Cross-check against ghost_refs — if a CLAUDE.md mentions /foo and no command named foo exists, that's the correct resolution.

Plugins

Scanner emits plugins_enabled[] from the merged settings. Each enabled plugin may contribute skills, agents, hooks, and MCP servers. For each plugin with zero observed use (no matching entries in skill_top, agent_subagent_types, hooks firing, or MCP tool calls) over the window, recommend disabling it.

Hooks

Scanner emits hooks (per-scope count of configured hooks). Hooks run on every matching event — even a no-op fork costs latency and tokens if it prints anything. Flag:

  • Hooks guarded solely by an || true or env-var check — they fork

a shell every event for nothing. Remove unless you actively need them (this skill flagged one such batch earlier).

  • Hook counts > 10 in any scope — audit whether each is earning its

cost.

  • disableAllHooks: true — note it in the report so the user knows

hooks aren't running at all.

Settings

Scanner reads every persisted settings source and emits misc (merged in precedence order, lowest → highest):

  1. ~/.claude/settings.json (user)
  2. ~/.claude/settings.local.json (user local — not in official

precedence docs but read in practice)

  1. <cwd>/.claude/settings.json (project)
  2. <cwd>/.claude/settings.local.json (project local)
  3. Managed / enterprise — loaded from the first existing path:
  • macOS: /Library/Application Support/ClaudeCode/managed-settings.json
  • Linux/WSL: /etc/claude-code/managed-settings.json
  • Windows: C:\Program Files\ClaudeCode\managed-settings.json

Managed settings take highest precedence and cannot be overridden by the user; settings.managed_path reports which file was used (null if none). Source: <https://code.claude.com/docs/en/settings.md>.

Relevant fields in misc:

SettingFlag ifRecommended
autoCompactWindowMissing and sessions hit autocompact (see Step 3)~75% of the model's context window in tokens (e.g. 150000 for 200k models, 750000 for 1M). Schema range: 100000–1000000.
env.BASH_MAX_OUTPUT_LENGTHAt default (30–50k)"150000" (string)
disableSkillShellExecutionTrue (if user depends on skill scripts)Note in report
advisorModelMissing or set to a weaker model than default"opus" or leave default
skillListingBudgetFraction / skillListingMaxDescCharsRaised above defaultsStandard defaults unless user is intentionally spending context on skill descriptions

Before recommending autoCompactWindow, confirm from Step 3 that sessions_hit_autocompact > 0. Same for BASH_MAX_OUTPUT_LENGTH — if no tool_result outliers above the default, there's no waste to fix.

Permissions staleness. Cross-reference permissions.allow with Step 3's bash_commands_sample and tool_top. A Bash(git *) rule that never matched an observed command in the window is a candidate for removal. These cost nothing but clutter audits.

File Permissions

Scanner emits bloat_dirs_present[]. If non-empty and permissions.deny lacks matching entries, recommend adding them:

If this exists...Should deny reads under...
package.jsonnode_modules, dist, build, .next, coverage
Cargo.tomltarget
go.modvendor
pyproject.toml / requirements.txt__pycache__, .venv, *.egg-info
.mcp.json files

Scanner emits mcp_json_files[]. Project-scoped MCP configs live here. Walk each up from cwd to $HOME. If a .mcp.json exists that the user didn't author, it's team-shared — audit the same way as ~/.claude.json > mcpServers.

Step 3: Behavioral Scan (JSONL)

Static config says what's loaded. JSONL says what's used. This is where the real wins are.

Transcripts live under ~/.claude/projects/<slug>/*.jsonl where <slug> is the project path with / → -. The bundled scan script resolves this automatically from cwd; if the script reports {"error": "no session history"}, skip Step 3.

Window: default to last 30 days of session files (by mtime). Let the user override.

Critical: JSONL files can be tens of MB each and contain sensitive history. NEVER Read them into context. Use the bundled script, which streams them and emits JSON aggregates only.

Aggregation script

Run from the project root (the script derives the JSONL path from cwd):

bash
python3 "$SKILL_DIR/scripts/scan_jsonl.py" 30

Where $SKILL_DIR is the skill's base directory announced at the top of this invocation (substitute the absolute path literally). The argument is the window in days; default 30.

Derive findings from the aggregate

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/datashaman/code-skills/audit-context/badge)](https://verified-skill.com/skills/datashaman/code-skills/audit-context)

Something wrong with this skill or its page? Tell us.