Skip to content
Back to skills

Context Audit

BSecurity

Read-only audit of .claude/ overhead. NOT for mk:context-engineering.

  • 17 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added May 29, 2026
ai-agentsrustgoshellbash

Works with

  • mcp

Security analysis

B88/100
  • criticalPipes output to a shell interpreter

Pro scans all 5 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add ngocsangyem/MeowKit --skill context-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Audit?

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

Security grade badge for Context Audit
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/ngocsangyem-context-audit/badge)](https://www.skillsdirectory.com/skills/ngocsangyem-context-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: mk:context-audit
preamble-tier: 1
version: 1.0.0
description: "Read-only audit of .claude/ overhead. NOT for mk:context-engineering."
allowed-tools:
  - Bash
  - Read
  - Grep
  - Glob
keywords:
  - context
  - window
  - tokens
  - audit
  - overhead
  - claude-md
  - skills
  - agents
  - mcp
  - structural
when_to_use: "Bloated session."
user-invocable: true
phase: on-demand
trust_level: kit-authored
injection_risk: medium
source: local
owner: docs
criticality: medium
status: active
runtime: claude-code
---

# /mk:context-audit — Context Window Structural Audit

Read-only audit of `.claude/` structural overhead. Surfaces what is loaded into
every host-runtime session and how much of the context window it consumes,
then recommends the highest-leverage trims.

Complementary lens: `mewkit validate --substrate` shows the same artifact set
grouped by the responsibility each serves (covered / partial / missing), so a trim
can be checked against responsibility coverage before removing an artifact. The
per-phase read budget that bounds what an audit-driven session should load lives in
`.claude/skills/agent-detector/references/context-budget-rules.md`.

## When to Use

Three concrete triggers:

1. **Pre-add capacity check** — before adding a new agent, skill, or rule file,
   confirm the project is below the 25% structural-overhead threshold.
2. **Post-degradation diagnostic** — when sessions feel slow, off-topic, or
   over-compacted, audit to see if structural overhead has grown past 10%.
3. **Periodic health audit** — on model upgrades, confirm the always-on bundle
   still pays its keep (the dead-weight audit in
   `.claude/skills/cook/references/harness-rules.md` Rule 7, where that tooling is present).

## Context vs Cost (Boundary)

| Concern | Mechanism | Unit |
| --- | --- | --- |
| Monetary cost | `mewkit budget` and `.claude/skills/autobuild/scripts/budget-tracker.sh` | USD |
| Window utilization (this skill) | `/mk:context-audit` and `scripts/inventory-context.sh` | tokens / % |

This skill measures only what is statically loaded into every session: the always-on bundle (project instructions, agents, skills, rules, any project commands, MCP config). Conversation history, tool output and active edits live elsewhere.

## Workflow

Run the pipeline from the project root (or pass the root as the first argument):

```bash
SCAN_ROOT="${1:-$PWD}"
bash ${CLAUDE_SKILL_DIR}/scripts/inventory-context.sh "$SCAN_ROOT" \
  | bash ${CLAUDE_SKILL_DIR}/scripts/estimate-tokens.sh \
  | bash ${CLAUDE_SKILL_DIR}/scripts/format-audit-report.sh
```

The scripts print a markdown report (summary, top consumers, recommendations, banner) and write no files. The banner and its thresholds come from the script; `references/token-cost-model.md` owns the numbers and their reasoning. The window size defaults to 200,000 tokens and `MEOWKIT_CONTEXT_WINDOW` overrides it. If a script exits non-zero, show its stderr and stop.

Print the script output as it is: header, summary table, top consumers (top 10), recommendations sorted by token impact, and how to act (cost: `mewkit budget`; an agent file costs tokens only when that agent is spawned).

## Integration Points

- **Reuses, does not duplicate:** the chars/4 heuristic of the budget-tracker
  hook. Shell scripts inline the same heuristic with a citation comment.
- **Reads, does not write:** `.meowkit/telemetry/cost-log.json`,
  `.claude/`, `.mcp.json`. No file writes anywhere.
- **Discovery:** via `keywords:` frontmatter and a cross-reference from
  `mewkit budget`. There is no separate routing rule.

## Gotchas

- Inventory counts bytes, not what a host actually loads: an agent file costs tokens only when that agent is spawned, so weigh trims by how often the file is loaded.

## Related Rules

- `.claude/skills/skill-creator/references/skill-authoring-rules.md` — discovery + Gotchas section requirements
- `.claude/rules/injection-rules.md` Rule 11 — Skill Rule of Two; this skill
  scores 2 of 3 (untrusted SCAN_ROOT input + filename inventory may surface
  sensitive paths) so paths are canonicalized via `realpath` and never executed.

Files in this skill

  • SKILL.md5.4 KB
  • references/token-cost-model.md4.2 KB
  • scripts/estimate-tokens.sh2.4 KB
  • scripts/format-audit-report.sh5.5 KB
  • scripts/inventory-context.sh5.8 KB

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.