mk-context-audit
Read-only audit of the project's agent-tree structural overhead vs the context window. NOT for cost tracking (budget skill); NOT for read/compact decisions (mk:context-engineering).
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 16
- Forks
- 3
01 前言 Front Matter
- name
- mk-context-audit
- description
- Read-only audit of the project's agent-tree structural overhead vs the context window. NOT for cost tracking (budget skill); NOT for read/compact decisions (mk:context-engineering).
02 资源文件 6
- 参考文档references/.gitkeep—
- 参考文档references/token-cost-model.md3.8 KB
- 脚本scripts/.gitkeep—
- 脚本scripts/estimate-tokens.sh2.4 KB
- 脚本scripts/format-audit-report.sh5.4 KB
- 脚本scripts/inventory-context.sh5.3 KB
03 SKILL.md 正文
the context-audit skill — Context Window Structural Audit
Read-only audit of the project's agent-tree (.cursor/ + .cursor/skills/) 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: the toolkit source repository (not part of this install) keeps a
generated substrate view that groups the same artifact set by the responsibility each
serves (covered / partial / missing), and mewkit validate --substrate there reports
whether that view is in sync and every responsibility is covered, 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
the context-budget rules.
When to Use
Three concrete triggers:
- Pre-add capacity check — before adding a new agent, skill, or rule file, confirm the project is below the 25% structural-overhead threshold.
- Post-degradation diagnostic — when sessions feel slow, off-topic, or over-compacted, audit to see if structural overhead has grown past 10%.
- Periodic health audit — quarterly or on model upgrades, confirm the always-on bundle still pays its keep (paired with the dead-weight audit in the harness rules Rule 7).
Context vs Cost (Boundary)
| Concern | Mechanism | Unit |
|---|---|---|
| Monetary cost | the budget skill + ../autobuild/scripts/budget-tracker.sh |
USD |
| Window utilization (this skill) | the context-audit skill + scripts/inventory-context.sh |
tokens / % |
The three concerns are deliberately separate. This skill measures only what is statically loaded into every session — the always-on bundle. Conversation history, tool output, and active edits live elsewhere.
Workflow
The slash command runs the pipeline:
SCAN_ROOT="${1:-$PWD}"
bash .cursor/skills/context-audit/scripts/inventory-context.sh "$SCAN_ROOT" \
| bash .cursor/skills/context-audit/scripts/estimate-tokens.sh \
| bash .cursor/skills/context-audit/scripts/format-audit-report.sh
Output is markdown, printed to terminal. The skill does NOT write any files.
Steps:
- Inventory —
inventory-context.shwalks the agent tree and emits raw byte/line counts per category (AGENTS.md chain, agents, skills, rules, MCP) as JSON. - Estimate —
estimate-tokens.shenriches the inventory withestimated_tokens(chars/4 heuristic) and computestotalsincludingstructural_overhead_pctagainst a 200K window. - Format —
format-audit-report.shemits a 5-section markdown report: header, summary table, top consumers, recommendations, footer. - Banner — the formatter selects a banner based on
structural_overhead_pct:< 10%→ Healthy10–25%→ Watch≥ 25%→ Action recommended
Output Format
# Context Audit — <scan_root>
*Scanned at <timestamp> · model window 200K tokens · banner: <Healthy|Watch|Action>*
## Summary
| Category | Components | Bytes | Tokens | % of Window |
| ... | ... | ... | ... | ... |
## Top Consumers
1. <component> ~<tokens> (<path>)
... (top 10)
## Recommendations
1. <priority finding> — saves ~<tokens>
... (sorted by token impact, descending)
## How to Act
- Cost: see `the budget skill`
- Runtime trim: see `mk:lazy-agent-loader`
The 10% / 25% thresholds are the canonical source of truth for token-overhead
banners — see references/token-cost-model.md. They are NOT linked to
MEOWKIT_BUDGET_* env vars (those are USD amounts, not token percentages).
Integration Points
- Self-contained heuristic:
scripts/estimate-tokens.shdefines the chars/4 estimate inline; it needs no hook or build step. - Reads, does not write:
.meowkit/telemetry/cost-log.json, the project's agent-tree,.mcp.json. No file writes anywhere. - No env vars introduced. Window size is hard-coded 200K; override deferred until a real 1M-context use case appears.
- Discovery: via
keywords:frontmatter and a cross-reference fromthe budget skill. There is no separate routing rule.
Gotchas
(none yet — grow from observed failures)
Related Rules
- Skill authoring conventions — discovery + Gotchas section requirements
AGENTS.md(Data & injection boundary) 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 viarealpathand never executed.
04 同仓库更多 Skills
mk-worktree
Manages git worktrees for parallel agent isolation: creates parallel/{name}-{timestamp} branches, merges with conflict detection. NOT for user feature branches (use git worktree directly).
mk-workflow-orchestrator
Auto-invoked 7-phase workflow for complex-feature intent; fasttrack mode for pre-approved specs. NOT for explicit single tasks (mk:cook), green-field builds (mk:autobuild), or simple fixes (mk:fix).
mk-web-to-markdown
Fetch a URL and return clean markdown, for arbitrary external pages (blog, RFC, GitHub issue, vendor doc) not covered by mk:docs-finder. Static-only by default; opt-in JS rendering available.
mk-vulnerability-scanner
Vulnerability analysis: OWASP Top 10, current threat landscape, supply chain security, attack surface mapping, risk prioritization. Use for security audits. NOT for STRIDE/CSO infra audits (mk:cso).
mk-vue
Vue 3 authoring/review: components, composables, reactivity, Pinia, Pinia Colada, file routing, forms. Composition API + script setup. Auto-activates on .vue files. Deep review: mk:vue-best-practices.
mk-vue-testing-best-practices
Vue 3 testing best-practices review: Vitest + Vue Test Utils for components, composables, Pinia, Router, async/Suspense, forms, a11y, plus Playwright E2E strategy. Advisory only.