Marketplace

context-audit

Audit current context composition and identify optimization opportunities. Use when context window is overloaded, agents are underperforming, or applying the R&D framework to optimize token usage.

allowed_tools: Read, Grep, Glob

$ 安裝

git clone https://github.com/melodic-software/claude-code-plugins /tmp/claude-code-plugins && cp -r /tmp/claude-code-plugins/plugins/tac/skills/context-audit ~/.claude/skills/claude-code-plugins

// tip: Run this command in your terminal to install the skill


name: context-audit description: Audit current context composition and identify optimization opportunities. Use when context window is overloaded, agents are underperforming, or applying the R&D framework to optimize token usage. allowed-tools: Read, Grep, Glob

Context Audit Skill

Audit a codebase's context engineering health and identify optimization opportunities.

Purpose

A focused agent is a performant agent. This skill helps you understand what's consuming your context window and where to apply the R&D framework.

When to Use

  • Starting work on a new codebase
  • Agent performance feels sluggish
  • Context warnings appearing
  • Before optimizing context strategy
  • Periodic context health checks

Audit Process

1. Memory File Analysis

Scan for CLAUDE.md and related memory files:

Check:
- Root CLAUDE.md size (target: <2KB)
- Number of imports
- Per-directory CLAUDE.md files
- Total memory file tokens

Score memory health:

SizeScoreAssessment
<1KBExcellentMinimal and focused
1-2KBGoodWithin target range
2-5KBNeeds ReviewGrowing, audit content
>5KBAction RequiredBloated, needs R&D

2. MCP Server Analysis

Check MCP configurations:

Check:
- .mcp.json existence
- Number of MCP servers configured
- Per-server token estimate (2-5% each)
- Active vs unused servers

Score MCP health:

ServersScoreAssessment
0ExcellentNo MCP bloat
1-2GoodTargeted usage
3-5ReviewMay be over-provisioned
>5Action RequiredLikely consuming 15%+

3. Commands Analysis

Review .claude/commands/:

Check:
- Number of commands
- Command complexity (simple vs complex)
- Priming commands present?
- Task-type coverage

Score command health:

CommandsScoreAssessment
Has primingExcellentDynamic context loading
No primingNeeds AttentionRelying on static memory

4. Hooks Analysis

Check for context-consuming hooks:

Check:
- Number of hooks
- Hook event types
- Potential context injection

5. Overall Context Score

Calculate overall context engineering score:

ComponentWeightMax Points
Memory Files30%30
MCP Configuration25%25
Command Infrastructure25%25
Context Patterns20%20

Output Format

{
  "score": 75,
  "grade": "B",
  "components": {
    "memory": {
      "score": 20,
      "max": 30,
      "files_found": ["CLAUDE.md"],
      "total_tokens": 1500,
      "issues": ["No priming commands detected"]
    },
    "mcp": {
      "score": 25,
      "max": 25,
      "servers_found": 0,
      "estimated_consumption": "0%"
    },
    "commands": {
      "score": 15,
      "max": 25,
      "count": 5,
      "has_priming": false,
      "issues": ["Missing /prime command"]
    },
    "patterns": {
      "score": 15,
      "max": 20,
      "issues": ["No output styles defined"]
    }
  },
  "recommendations": [
    "Create /prime command for dynamic context loading",
    "Reduce CLAUDE.md size by delegating to priming",
    "Consider output styles for token efficiency"
  ]
}

Grading Scale

ScoreGradeStatus
90-100AElite context engineering
80-89BGood practices, minor optimizations
70-79CFunctional, needs attention
60-69DSignificant issues
<60FContext bloat, major rework needed

Recommendations Framework

Based on findings, recommend:

For Memory Bloat (Reduce)

  • Identify content that can move to priming commands
  • Flag outdated or contradictory guidance
  • Suggest minimal CLAUDE.md structure

For Missing Infrastructure (Delegate)

  • Recommend priming command creation
  • Suggest output styles for verbosity control
  • Propose agent expert patterns

Cross-References

  • @rd-framework.md - Reduce and Delegate strategies
  • @context-layers.md - Understanding context composition
  • @context-rot-vs-pollution.md - Diagnosing context problems
  • @context-priming-patterns.md - Dynamic context loading

Version History

  • v1.0.0 (2025-12-26): Initial release

Last Updated

Date: 2025-12-26 Model: claude-opus-4-5-20251101