/cc-skills-analysis:claude-audit [focus-area]from cc-skills-analysis
Audit and optimize Claude Code configuration (CLAUDE.md, .claude/rules/, skills, hooks, agents, MCP, plugins, MEMORY.md) for over-engineering, token waste, and rule-shape — whether each rule lives in the right mechanism. Consolidates claudit + config-audit. Self-contained; no external subagent fleet.
Ships in cc-skills-analysis. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
One local-owned audit skill. Replaces /claudit (quickstop, third-party) and /config-audit (this plugin). Adds a dimension neither had: Rule-Shape — auditing whether each rule lives in the mechanism that matches its trigger.
/claude-audit owns/claude-audit owns the runtime environment layer:
settings.json / settings.local.json wiring and dispatch surface.claude/rules/ content shape (rule-shape audit: does this rule live in the right mechanism?)It does not own:
/skill-audit/review/red-team/improve/debriefWhen the user's question touches both layers (e.g., "is this hook design
correct?"), /claude-audit answers the wiring question; /skill-audit
answers the content question; route accordingly or run both with explicit
scope.
A rule's trigger determines where it must live. The .claude/rules/ loader supports file paths/extensions only — there is no activity trigger. Mis-matched trigger → either bloats every session (wrongly always-loaded) or silently never loads.
| Trigger | Mechanism | Loads |
|---|---|---|
File path (hooks/*.py, plugins/**) | .claude/rules/ + paths: glob | On matching-file read |
| Subtree (one package/module) | Subdirectory CLAUDE.md | On subtree read (additive, walks up) |
| Activity (debug, refactor, remove, test) | Skill | On invocation |
| Reusable procedure/expertise | Skill | On invocation |
| Truly universal (identity, language, safety) | Root / global CLAUDE.md | Always |
Full framework, defect catalog, and @import/paths: caveats: references/claude-md-architecture.md. Apply it as a scoring dimension in Phase 3.
Execute the phases in order. Argument is an optional focus area (see Phase 1.5). Do not summarize this file — execute it.
git rev-parse --show-toplevel 2>/dev/null (empty if not a repo).echo $HOME.Discover via parallel Glob (cap 50 files total, keep 50 most-recent):
| Project (if comprehensive) | Pattern |
|---|---|
| Instructions | {PROJECT_ROOT}/**/CLAUDE.md (exclude node_modules/.git/vendor/dist/build) |
| Local instructions | {PROJECT_ROOT}/CLAUDE.local.md |
| Rules | {PROJECT_ROOT}/.claude/rules/**/*.md |
| Settings | {PROJECT_ROOT}/.claude/settings.json, .claude/settings.local.json |
| Skills | {PROJECT_ROOT}/.claude/skills/*/SKILL.md |
| Agents | {PROJECT_ROOT}/.claude/agents/*.md |
| Memory (index) | {PROJECT_ROOT}/.claude/MEMORY.md |
| Memory (topic files) | {PROJECT_ROOT}/.claude/memory/**/*.md |
| MCP | {PROJECT_ROOT}/.mcp.json |
| Plugin hooks | {PROJECT_ROOT}/.claude/plugins/*/hooks/hooks.json |
| Global (always) | Path |
|---|---|
| Settings | ~/.claude/settings.json |
| Instructions | ~/.claude/CLAUDE.md (also ~/CLAUDE.md legacy) |
| Rules | ~/.claude/rules/**/*.md |
| Memory (index) | ~/.claude/MEMORY.md (or ~/.claude/projects/<proj>/memory/MEMORY.md — project-scoped) |
| Memory (topic files) | same dir as the index, memory/**/*.md |
| MCP | ~/.claude/.mcp.json |
| Plugins | ~/.claude/plugins/installed_plugins.json |
| Managed policy | /Library/Application Support/ClaudeCode/CLAUDE.md (macOS) or /etc/claude-code/CLAUDE.md (Linux/WSL) |
Get line counts in one batched wc -l. Quote spaced paths. Present the map:
=== CONFIGURATION MAP ===
Scope: Comprehensive | Project: {PROJECT_ROOT}
Instructions (N files, ~M tokens):
CLAUDE.md 45 lines
src/api/CLAUDE.md 30 lines
.claude/rules/testing.md 15 lines [no paths: → always-loaded]
...
GLOBAL: ~/.claude/
...
=== END MAP ===
Token estimate: (total_lines * 40) / 4. Flag every .claude/rules/*.md that lacks a paths: field — those load unconditionally.
Store GIT_USER = git config user.name 2>/dev/null.
If $ARGUMENTS empty → full audit. Else match (fuzzy) to a focus area + categories:
| Input | Focus | Categories |
|---|---|---|
| skills, agents, skill quality | Skills & Agents | CLAUDE.md Quality, Over-Engineering |
| CLAUDE.md, instructions, rules, rule-shape | Instruction Files | CLAUDE.md Quality, Over-Engineering, Context Efficiency |
| MCP, servers | MCP Configuration | MCP Configuration, Context Efficiency |
| hooks, hook sprawl | Hooks | Over-Engineering, Security Posture |
plugins, plugin health, <plugin-name> | Plugins | Plugin Health |
| security, permissions, secrets | Security | Security Posture |
| over-engineering, verbosity | Over-Engineering | Over-Engineering |
| memory, MEMORY.md, recall | Memory | Memory, Context Efficiency |
| context, tokens | Context Efficiency | Context Efficiency |
| (other) | Free-form | all (best effort) |
Focus is additive depth, not routing — always run the full audit; just go deeper on focus-area findings and present them first.
Research is IO-bound → run it as a cheap/fast delegation; analysis is CPU-bound → run it on the quality model in-process. Fetch current Anthropic guidance for the target types present (CLAUDE.md memory hierarchy, .claude/rules/ paths: semantics, skills progressive disclosure). Cache findings; refresh only if stale or Claude Code version changed. If research fetch fails, continue with the Rule-Shape reference (always bundled) and note the gap.
Apply references/scoring-rubric.md to the mapped files. For each file: read it, score against the rubric, quote evidence as file:line. The Rule-Shape checks (Phase 0 flagged the candidates) resolve here:
references/claude-md-architecture.md:
.claude/rules/ + paths:paths: → loads unconditionally (or never via legacy key)CLAUDE.mdPremise: MEMORY.md is an always-loaded index (200-line / ~24KB ceiling); the value lives in per-topic files it points to. The index line is a retrieval key, not prose. A stale, bloated, or redundant index wastes tokens every session and degrades recall. Memory is personal/long-term — destructive actions default to archive (memory/archive/<name>.md), never delete.
Resolve the index from Phase 0. Topic files = the directory the index's relative links point into (usually memory/ alongside MEMORY.md). If no MEMORY.md mapped, skip this phase (note "Memory: not configured").
For each line matching - [Title](<rel-path>) — <hook>, extract {title, rel_path, hook, line_no, index_line_length}. Lines not matching (section headers, free prose, the table-of-contents block) are tracked separately as non-index prose — they consume the 200-line budget without being retrieval keys.
Liveness — does the referenced topic file exist and is it resolvable? glob the resolved path. Missing file → broken retrieval key. If the path resolves but the named symbol/file/skill inside the body no longer exists in the repo (grep for the file path, symbol, or skill name the entry cites), the entry points at dead state.
Derivability — can the entry's claim be re-derived from a cheaper, authoritative source already loaded or trivially inspectable? Entry that restates a CLAUDE.md rule, a git log/git blame fact, an existing doc, or a code comment is redundant → drop. Cross-check: grep the entry's title keywords against CLAUDE.md and references/ docs. Verbatim overlap = derivable.
Redundancy — cluster entries whose bodies name the same failure / same correction / same artifact. Two entries describing variants of one root cause (e.g., two "premature root cause" lessons from different sessions) → merge into one topic file, leave one index line. Cluster key = normalized root-cause/correction noun phrase, not the surface date.
Index discipline — is the line a retrieval key or prose? A line over ~150 chars, or containing multiple sentences, is prose masquerading as an index entry → shorten to Title — one-line hook. Also flag: entries whose topic-file body is under ~5 lines (the index line carries more than the file → fold into a sibling topic file and drop the entry).
keep | shorten | merge | archive. archive = move the topic file to memory/archive/ and remove its index line (reversible — git mv back restores). merge = append body into the survivor, archive the loser, rewrite the loser's index line to point at the survivor. No entry is deleted without per-item user approval.
archive/merge candidate before finalizing)These optimize long-term outcomes — the audit is not just "is this file live," it's "does this memory still earn its slot in the model's future attention."
Record answers in the audit notes; an entry survives the archive recommendation only if at least one prompt produces a concrete future-mistake that is not already structurally blocked.
Behavioral (metadata.type: feedback) entries: the "structurally blocked?" test is wrong for these — they are prompt-advisory discipline by definition, so the answer is always "no," which would wrongly archive every behavioral rule. For feedback entries, substitute the recurrence-based liveness test and consult references/behavioral-memory-lifecycle.md for the memory→hook graduation ladder (recurring + specific → deterministic trigger → measurable FP → advisory-then-blocking). Do not auto-archive behavioral entries; flag them for user decision.
A ranked keep / shorten / merge / archive table with evidence (MEMORY.md:line, resolved path, cluster members) and token-delta per candidate (always-loaded tokens freed = (index_line_chars + topic_body_chars)/4). Feed archive/merge/shorten candidates into Phase 4 (apply). Score feeds Phase 3 Memory category.
If the index exceeds ~100 entries, emit an intent→entry quick-nav table grouped by activity (debug / hook-edit / plugin-work / git / etc.), | I want to... | entry-title |. Max 8–10 rows, grouped by category if more. This mirrors the /lmc+/mlc smart-TOC pattern: a model under attention pressure retrieves by intent faster than by keyword scan. Skip for small indices — it's overhead.
shorten/merge in Phase 4)After rewriting an index line or merging a topic, re-read the new line in isolation and confirm it still predicts the surviving body — a shortened key that no longer discriminates its own topic is information loss, not compaction (the /mlc "verify equivalence: ensure no information lost" rule). If the line fails this, rewrite until it predicts the body. Token savings without equivalence is a regression.
env block)Premise: An env var earns its slot only if it carries information the consuming code does not already have. Count alone is not debt — debt is a var that exists with no consumer, or whose settings.json value merely restates the code's own default. The unit of work is "remove the var AND simplify the consuming code," not just "remove the var."
env block from settings.json (Phase 0).P:/.claude/**/*.py + P:/packages/.claude-marketplace/plugins/**/*.py + plugin hooks.json/settings.json shell commands + ~/.claude.json MCP config. Skip _archive/backup dirs.For each defined env var, find every consumer (grep -rn '"VAR"\|\$VAR'), then classify:
| Verdict | Test | Action |
|---|---|---|
| remove-var (dead) | Zero real consumers outside settings_health_check.py's own SYSTEM_VARS allowlist and outside this audit | Delete the env entry; no code change |
| remove-var-and-simplify (redundant override) | Exactly one consumer reads it via os.environ.get("VAR", <default>) (or _env_bool("VAR", default=...)) and the settings.json value equals that <default> | Delete the env entry and delete the env-read indirection at the consumer site — hardcode the default inline. The var was carrying no information. |
| keep-killswitch | Name matches *_BYPASS, *_DEBUG, *_VERBOSE, *_DISABLE*, *_ENABLED, *_MODE — deliberate operator override even if currently equal to default | Keep; document intent in a one-line comment if absent |
| keep | Has consumers and the value changes behavior vs. the code default | Keep |
remove-*)A var can be read by mechanisms grep '"VAR"' misses. Before any remove-* verdict, confirm none of these apply:
settings.json hook entry: $VAR or ${VAR} (not quoted).~/.claude.json or project .mcp.json: "env": {"VAR": "$VAR"} or command referencing it.OTHER_VAR="$VAR" in a profile script or settings.json value.__lib/ module the scan pattern missed — re-grep the specific plugin dir).If any apply, downgrade to keep and note the consumer site.
Per-var table with evidence and the recommended action:
=== ENV VAR AUDIT ===
VAR_NAME settings code_default verdict consumer
TDD_AUTOSCAFFOLD 0 "0" remove-var-and-simplify PreToolUse.py:412
MULTI_AGENT_ENABLED true False keep (default-true, value changes behavior)
STRAWBERRY_VALIDATOR_VERBOSE false — keep-killswitch (no consumer; *_VERBOSE override)
DELEGATION_GATE_ENABLED false True keep (default-true; settings flips to false)
SOME_DEAD_VAR "x" — remove-var (0 consumers)
=== END ===
settings and code_default columns show both values so the reviewer can sanity-check the equality claim. Feed remove-* candidates into Phase 4 (apply). Score feeds Phase 3 Context Efficiency category.
env block.os.environ.get("VAR", X) / _env_bool("VAR", X) with the literal X. Re-grep the consumer after the edit to confirm no other read site exists. Run the consumer's tests if present.~/.claude/settings.json. Run each through the falsification gate a second time at apply time (state may have changed since Phase 2.6).Score the 7 categories (rubric), compute weighted overall, look up grade. Decision-memory handling in Phase 4.
╔══════════════════════════════════════════════════════════╗
║ CLAUDE-AUDIT HEALTH REPORT ║
║ Scope: Comprehensive | Files: N project + N global ║
║ Decision Memory: N past decisions ║
║ Overall Score: XX/100 Grade: X (Label) ║
╚══════════════════════════════════════════════════════════╝
Over-Engineering ████████████████████░░░░░ XX/100 X
CLAUDE.md Quality ◆ ████████████████████░░░░░ XX/100 X
Security Posture ████████████████████░░░░░ XX/100 X
MCP Configuration ████████████████████░░░░░ XX/100 X
Plugin Health ████████████████████░░░░░ XX/100 X
Context Efficiency ████████████████████░░░░░ XX/100 X
Memory ◆ ████████████████████░░░░░ XX/100 X
(◆ marks focus-relevant categories.) Then: Focus Deep Dive (if focused) → Critical Issues (category < 50) → Ranked Recommendations (focus first) → Features to Adopt.
Use AskUserQuestion (multiSelect) grouped by priority. Never auto-apply. For each selected fix: read → Edit/Write → report. Common fixes: CLAUDE.md trimming, rule → .claude/rules/+paths:, procedure → skill, @import repair, permission simplification, MCP/hook cleanup.
Memory fixes (Phase 2.5 candidates): default destructive action is archive (git mv memory/<name>.md memory/archive/<name>.md + drop the index line) — reversible via git mv back. merge = append body into survivor topic file, archive loser, rewrite loser's index line to alias the survivor. shorten = rewrite index line to Title — one-line hook (≤150 chars). No memory entry is hard-deleted without per-item user approval. Run each archive/merge through the Phase 2.5 self-reflection prompts before recording the decision.
Scope safety: project-scoped files (CLAUDE.md, .claude/settings.json, rules/) are PR-eligible. CLAUDE.local.md, settings.local.json, ~/.claude/, and all memory files are personal — edit directly, never PR.
Path: comprehensive → {PROJECT_ROOT}/.claude/claude-audit-decisions.json; global → ~/.cache/claude-audit/decisions.json. Schema {"schema_version":1,"decisions":[...]}. Each decision: {fingerprint, action: accepted|rejected|deferred, reason, decided_by, timestamp, context}. Fingerprint = {category_slug}:{issue_type}:{file_stem}:{hash8} (slugs in rubric).
accepted, and ask one follow-up to classify unselected items as rejected/deferred with optional reason.After fixes, re-score affected categories and show before → after.
/claude-audit emits XSTC for runtime/environment/hook/config/context-
injection patterns that recur or generalize. Hook double-fire, MCP
lifecycle issues, plugin cache drift, context-injection source overlap →
XSTC classification: applies_to_hooks_or_gates with owner
/claude-audit itself (it owns the surface). If the pattern touches the
skill/command layer too, split into two XSTCs — one per owner, since the
template requires one owner per artifact. One-off runtime issues → no
XSTC; record in the audit report.
When reviewing plugin activation, hook/runtime/config changes, cache
rebuilds, mechanism manifests, or command-surface claims, the Completion
Evidence Contract governs the acceptance bar. The contract lives at
debrief/references/completion-evidence-contract.md. Required mappings:
plugin_bumped rows require the literal === Done === line from
plugin-audit-and-fix.py --bump.cache_rebuilt rows require the literal Zero drift confirmed line.drift_checked rows require either --drift exit 0 OR the literal
Zero drift confirmed line.command_surface_changed rows require a structural triggers: diff
OR claude plugin list before/after. A static test forbidding a few
token strings is PARTIAL at best.wiki_not_written rows require grep across plugins/ for
/wiki ingest in workflow_steps: or triggers: + absence of
wiki_after_write import wiring in any active hook.guardrail_added rows require file:line of the new gate. They are NOT
proof the gate fires in the live dispatch path — that is a separate
guardrail_runtime_enforced row, requiring live smoke or direct
invocation.If a report claims a runtime artifact is "enforced" with only a doc or
text-test behind it, flag as NOT_PROVEN with protection_level: prompt_advisory or static_invariant_tested (whichever matches).
Advisory status: The CEC discipline itself is prompt-advisory; the
runtime BLOCK authority lives in /red-team's Pre-check 0 (see
red-team/commands/red-team.md). /claude-audit applies the contract as
a reviewer, not as a runtime gate.
At the end of a non-trivial /claude-audit run, emit a Thought Partner
Addendum (TPA) when the audit surfaced a runtime concern the framing did not
center — runtime activation (plugin bumped but not enabled), stale cache,
hook/plugin drift, source-vs-cache mismatch, or ground-truth freshness. Each
item carries observation, why_it_matters, evidence, recommended_action,
urgency: now | later | watch. Omit the section when nothing material was
found; never displace the audit verdict or the CEC ledger. Canonical contract
debrief/references/thought-partner-addendum.md
(canonical owner: /improve). The TPA is prompt-advisory only./claude-audit's posture is Runtime / Environment Audit Partner (see
the Partner Posture Map in debrief/references/thought-partner-addendum.md).
/claude-audit audits Claude Code runtime behavior, hooks, plugin loading,
settings, routing, cache/source drift, context injection, ground-truth
freshness, and command activation, separates source edits from loaded
runtime behavior, and catches stale config, stale cache, and environment
assumptions. Posture is prompt-advisory.
/claude-audit ensures known transcript/log/config locations can be
injected as runtime ground truth — so agents have fewer excuses to ask the
user for discoverable facts. When auditing the runtime environment, check:
~/.claude/projects/**/*.jsonl) resolvable?settings.json, plugin roots, .claude/) resolvable?If an agent asks the user for a path that's already in the runtime ground
truth, that's a discoverable_fact_offloading enabler — the fix is to
surface the known path in the context injection, not to teach the agent a
new instruction. Full rule at
debrief/references/discoverability-classification.md.
.claude/ at project → audit global, recommend project setup.file:line for every finding./claude-audit cross-suggests after a run:
/skill-audit — when findings implicate skill design (systemic, not one-off config)./improve — when a finding is a design or process improvement, not a config defect./review — when a config change touches implementation quality worth a structured review./red-team — when the config change is high-risk (gate/hook/permission edits) and deserves adversarial review before commit.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (enduser123/cc-skills-analysis) — no native marketplace selected
npx claudepluginhub p/enduser123-cc-skills-analysis14 skills in this plugin
/behaveStructured behavioral analysis for LLM performance debugging — hypothesis testing for session patterns (loops, context degradation, decision inefficiency, cognitive overload, attention drift)/debriefUnified analysis hub — mines transcripts for unfinished work + origin-anchored tasks. Modes: default (transcript → root-cause tasks), chain (multi-session retrospective: /recap→gaps→/friction→/red-team→/rns + SCORES), gaps (deterministic gap detectors + mandatory haiku gap reviewer + RNS + artifact contract), top (6-source problem scan → ranked tasks). Trigger phrases: 'debrief this transcript', 'mine the chat history', 'victim log', 'why is this broken', 'run a retro', 'top problems', 'what gaps remain'. Absorbs /retro and /top-problems; gap detection is debrief-owned./