/sjh-skills:context-auditfrom sjh-skills
Audits project context management (CLAUDE.md, rules, knowledge) for progressive disclosure compliance: checks reachability, stale references, orphaned files, and index leakage.
Ships in sjh-skills. 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.
None: SKILL.md is the whole skill.
Audits the project's three-layer context management system (CLAUDE.md / rules / knowledge) against the progressive disclosure architecture:
CLAUDE.md (always loaded) — describes architecture, no detailed index
└─ Rules (.claude/rules/) (always loaded) — inline `> 详见` refs to knowledge
└─ Knowledge (docs/knowledge/) — on-demand deep experience
Scan the project to find all context files:
# Knowledge files
find docs/knowledge/ -name "*.md" -type f 2>/dev/null | sort
# Rule files
find .claude/rules/ -name "*.md" -type f 2>/dev/null | sort
# CLAUDE.md
ls CLAUDE.md 2>/dev/null
If docs/knowledge/ or .claude/rules/ doesn't exist, report and skip the corresponding checks.
For each knowledge file found in Phase 1:
docs/knowledge/<filename> or bare <filename>)docs/knowledge/*-index.md or files whose name ends with -index.md). An index file that is itself rule-referenced transitively covers the leaves it lists.[DEPRECATED] marker (info only, no action needed)For each reference found in rule/AGENTS/CLAUDE files:
docs/knowledge/xxx.md, <filename>.md, foo.md) inside example/format sections are not real refs. Detect by:
xxx, foo, bar, <.*>, or详见 docs/knowledge/xxx.md 引用)Check that CLAUDE.md follows the architecture principle — it should describe the progressive disclosure system, NOT duplicate the detailed index.
docs/knowledge/ patternsException: a summary table mapping rule files to knowledge domains is acceptable (it's architecture description, not a detailed index).
Output a structured report:
==========================================
CONTEXT AUDIT REPORT
<project-name> | YYYY-MM-DD
==========================================
## Coverage Summary
Knowledge files: N total
- M directly covered (cited from a rule)
- K indirectly covered (cited from a rule-linked knowledge index)
- X orphaned
- Y deprecated
Rule files: N total
Stale references: N (placeholders excluded)
## Orphaned Knowledge Files (not indexed from any rule)
| File | Suggested Rule | Reason |
|------|---------------|--------|
| docs/knowledge/foo.md | rl-training.md | topic overlaps with RL training |
## Stale References (pointing to non-existent files)
| Rule File | Line | Reference | Status |
|-----------|------|-----------|--------|
| .claude/rules/bar.md | 42 | docs/knowledge/removed.md | file not found |
## CLAUDE.md Compliance
- Architecture description: [FOUND / MISSING]
- Direct knowledge refs: N (threshold: <=3)
- Status: [PASS / WARN — index leakage detected]
## Coverage Map
| Rule File | Knowledge Files Referenced |
|-----------|--------------------------|
| rl-training.md | reward, config, verl-integration, ... |
| cluster-ops.md | container-unify, mutagen-sync, ... |
## Deprecated Files
| File | Deprecation Notice |
|------|--------------------|
| docs/knowledge/experiments.md | migrated to experiment-registry |
==========================================
If orphaned files are found, suggest concrete edits:
> 详见 reference should be addedDo NOT auto-apply fixes. Present suggestions and let the user decide.
If audit reveals rules are too large (always-loaded context bloat), recommend the three-tier split approach (validated on agentic_umm 2026-04-25, reduced 8 rules / ~830 lines → 6 rules / 469 lines, -43%):
Tier 1 — Whole-file migration (highest ROI)
Identify rules that are pure how-to / reference manuals with no hard constraints. Move the entire file to docs/knowledge/, update the index pointer in CLAUDE.md/AGENTS.md to point at knowledge instead.
Signals: rule reads like a tutorial, no "必须 / 不要 / 硬约束" language, pure command recipes or organization conventions.
Tier 2 — In-file split (medium ROI)
For mixed rules, split into:
Create a sibling knowledge file (e.g., <rule-name>-howto.md, <rule-name>-details.md) and replace the moved sections with a one-line > 详见 docs/knowledge/<...>.md.
Tier 3 — Index extraction (low-medium ROI)
If a rule contains a long flat table indexing many knowledge files (e.g., 20+ rows like "数据/轨迹/评估"), extract that table into a dedicated docs/knowledge/<topic>-index.md. The rule keeps a single sentence pointing to the index. The index file is itself rule-referenced, so leaves remain reachable (legal two-tier pattern recognized in Phase 2).
Decision rules:
.claude/rules/ → may need direct knowledge refs in AGENTS.md; this is acceptable cross-tool-compat redundancy, not a violationPhases 1-6 are reverse audits — start from existing files, check structural compliance. Phase 7 is the forward audit — start from recent changes, check whether the knowledge they introduced actually landed in every place it should.
This phase is opt-in: trigger it when the user supplies a change summary, or when the audit follows a sizable session (feature shipped, refactor done, bug fixed). Skip silently if there's nothing to forward-audit.
Inputs
Collect "new facts" introduced by recent work. Sources, in order of preference:
git log --since="<session start>" --oneline + git diff of touched filesA "new fact" is anything that, if the next session reads stale docs, would mislead the agent. Examples: dependency swap (SQLite → PostgreSQL), new env var, renamed CLI flag, deprecated module, new invariant ("never call X directly"), new directory convention.
Mapping rules — fact type → expected locations
| Fact type | Should appear in |
|---|---|
| Tech stack swap (DB, framework, runtime) | CLAUDE.md tech section + relevant rule + setup docs/README |
| New env var / config key | runbook + CLAUDE.md (if always-needed) + .env.example |
| New hard constraint ("never X") | a rule (always-loaded), not knowledge |
| New how-to / command recipe | knowledge file + index reference from rule |
| Deprecated feature/file | [DEPRECATED] marker + rule reference removed + replacement noted |
| Renamed module/function | grep-replace across all docs + CLAUDE.md if mentioned |
| New directory or file convention | a rule + CLAUDE.md repository structure section |
Procedure
For each new fact:
Output
Append to the Phase 4 report:
## Change Impact Matrix
Source: [user-supplied | git diff | conversation]
Window: <commit range or session start>
### Fact 1: <one-line description, e.g. "DB switched from SQLite to PostgreSQL">
| Expected location | Status | Evidence |
|-------------------|--------|----------|
| CLAUDE.md "Tech Stack" | ❌ Missing | line 42 still reads "SQLite" |
| docs/knowledge/db-schema.md | ⚠️ Conflict | lines 10-30 use Postgres, line 88 still has `sqlite3` import |
| .claude/rules/data-access.md | ✅ Updated | — |
| README.md install steps | ❌ Missing | step 3 still says "create sqlite db" |
Cross-project: agentic_umm-cli depends on this repo's DB schema → flag for review
### Fact 2: ...
Constraints
docs/knowledge/ and .claude/rules/. Does not assume specific file names.[DEPRECATED] markers are expected to exist without rule references. Report them for visibility but don't flag as errors.What SKILL.md sets; muted values are Claude Code's defaults
15 skills in this plugin
/bibtex-fetchFetch BibTeX entries from arXiv / Semantic Scholar. Triggers: 'fetch bibtex', 'cite this paper', 'arXiv bibtex', '拉 bibtex', '获取引用', '引用这篇论文'. Not for citation format conversion (APA/MLA) or literature review./daily-summaryProduce daily/yesterday work summary (日报) by aggregating Claude Code sessions, Git commits, and Notion task data — git log alone cannot do this. Args: today (default), yesterday, 24h, YYYY-MM-DD. Triggers: 'daily summary', 'what did I do today', 'yesterday summary', '日报', '今天干了什么', '工作总结', '某天做了什么'. Not for weekly reports or summarizing files./experiment-registryManage ML experiment lifecycle via structured YAML registry — register, record results, compare runs, track status. Triggers: 'register experiment', 'compare experiments', 'experiment results', 'exp init', 'exp list', '注册实验', '对比实验', '查实验', '哪个实验最好', '记录结果'. Not for training monitoring, checkpoints, or launching jobs.npx claudepluginhub jiahao-shao1/sjh-skills --plugin sjh-skillsOther plugins' skills for the same job