Other

/context-check

Audit and fix per-project AI context hygiene. Compares loaded skills, MCPs, hooks, and agents against the project's context profile in ~/.golems/config.yaml. Reports wasted tokens and generates .claude/settings.local.json + CLAUDE.md containerization. Use when setting up a new project, debugging context bloat, or running maintenance sweeps.

$ golems-cli skills install context-check
Good
4 evals

Updated 2 weeks ago

Audit what's loaded vs what SHOULD be loaded for this project.

Usage

/context-check          # Audit mode — report waste
/context-check --fix    # Fix mode — generate configs

How It Works

  1. Read the registry~/.golems/config.yamlcontextProfiles section
  2. Detect current project — match cwd against registry paths
  3. Compare loaded skills/MCPs/hooks/agents against the profile
  4. Report waste (token count, attention dilution estimate)
  5. Fix (if --fix) — generate .claude/settings.local.json + CLAUDE.md section

Step-by-Step

Step 1: Read Registry

cat ~/.golems/config.yaml

Find the contextProfiles section. Look up the current project by matching pwd against registered project paths (either from contextProfiles keys or from ~/.config/ralphtools/registry.jsonprojectspath).

If project NOT found: Say so. Offer to run repo discovery (scan package.json, detect stack, suggest a profile). Do NOT guess.

Step 2: Get Current Loaded Context

Skills loaded: List all files in ~/.claude/commands/ — each directory is a loaded skill.

ls ~/.claude/commands/

MCPs loaded: Check which MCP servers are configured:

# Project MCPs
cat .mcp.json 2>/dev/null
# Parent dir MCPs (Claude Code walks up)
cat ../../../.mcp.json 2>/dev/null  # adjust depth for ~/Gits/.mcp.json
# Global MCPs
python3 -c "import json; d=json.load(open('$HOME/.claude/settings.json')); print(json.dumps(d.get('mcpServers',{}), indent=2))" 2>/dev/null

Hooks loaded: Check global settings for hooks:

python3 -c "import json; d=json.load(open('$HOME/.claude/settings.json')); print(json.dumps(d.get('hooks',{}), indent=2))" 2>/dev/null

Per-project overrides: Check if .claude/settings.local.json exists:

cat .claude/settings.local.json 2>/dev/null || echo "NO OVERRIDE — using global defaults"

Step 3: Compare Against Profile

For the matched profile, compare:

CategoryProfile FieldLoaded FromComparison
Skillsskills.allow~/.claude/commands/ dirsList extras not in allow list
MCPsmcps.block.mcp.json + parent + globalList blocked MCPs still active
Hookshooks: falseGlobal settings.jsonCheck if hooks are disabled
Agentsagents.allowSystem prompt (can't audit directly)List for CLAUDE.md

Step 4: Report

=== CONTEXT CHECK: mehayom ===
Identity: mehayomClaude
 
SKILLS (10 allowed, 42 loaded):
  ✅ Allowed: context7, commit, github, pr-loop, coderabbit, never-fabricate
  ❌ Extra (32): coach, cmux-agents, figma-swarm, orchestrator-status, ...
  ⚠️  Wasted: ~5.2k tokens (~2.6% of 200k context)
 
MCPs (2 allowed, 7 loaded):
  ✅ Active: linear, context7
  ❌ Should block: brainlayer, voicelayer, supabase
  ℹ️  Can't block (global): exa, notebooklm
 
HOOKS:
  ❌ BrainLayer hooks ACTIVE (profile says: disabled)
  ⚠️  Estimated overhead: ~500 tokens per prompt
 
AGENTS:
  ✅ Allowed: general-purpose, Explore
  ❌ In system prompt but irrelevant: coach, orchestrator, jobs, services, ...
 
OVERRIDE FILE: .claude/settings.local.json
  [EXISTS / MISSING / STALE]
 
TOTAL WASTE ESTIMATE: ~6.1k tokens (3% of context) + hook overhead

Step 5: Fix (--fix mode only)

If the user passed --fix or you're in fix mode:

1. Generate .claude/settings.local.json:

{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "disabledMcpjsonServers": ["brainlayer", "voicelayer", "supabase"],
  "hooks": {
    "SessionStart": [{ "hooks": [] }],
    "UserPromptSubmit": [{ "hooks": [] }]
  }
}

Populate disabledMcpjsonServers from mcps.block in the profile. If hooks: false, override SessionStart and UserPromptSubmit with empty hooks arrays.

2. Generate CLAUDE.md containerization section:

Add to the project's CLAUDE.md (create if needed, append if exists):