一键导入
md-scanner
Scans markdown documentation against actual behavioral data to find what's missing. Recommends additions to CLAUDE.md, rules, memory, and skills.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scans markdown documentation against actual behavioral data to find what's missing. Recommends additions to CLAUDE.md, rules, memory, and skills.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | md-scanner |
| description | Scans markdown documentation against actual behavioral data to find what's missing. Recommends additions to CLAUDE.md, rules, memory, and skills. |
| version | 1.0.0 |
| author | nhangen |
Analyzes session history to find patterns where missing documentation caused wasted tokens — repeated file reads, command trial-and-error, recurring user corrections, context bloat, and more. Recommends specific additions to the right documentation surface.
/md-scanner Full walkthrough
/md-scanner review Deferred items only
/md-scanner report Non-interactive summary
This skill reads from four existing systems. Run the load commands below, skip any that fail (optional dependencies).
Read all files matching ~/.claude/context-gaps/pending-*.jsonl. Each file is one session's structured extract containing file read counts, bash commands, tool sequences, user messages, file edit sets, and token usage.
Also read ~/.claude/context-gaps/applied.jsonl, ~/.claude/context-gaps/dismissed.jsonl, and ~/.claude/context-gaps/deferred.jsonl if they exist. Each line is a JSON record with a fingerprint field. Build an exclusion set from applied + dismissed records. Build a deferred set from deferred records.
Run via Bash (skip if token-scope not installed):
export PATH="$HOME/.bun/bin:/opt/homebrew/bin:$PATH"
token-scope --context --json 2>/dev/null || echo '{"error": "token-scope not available"}'
This returns context bloat data per session (bloatRatio, input token growth). Group results by cwd to identify which projects have high bloat.
Run via Bash (skip if RTK not installed):
rtk discover 2>/dev/null || echo "RTK not available"
Use the claude-mem MCP search tool to find:
feedback (recurring corrections)concepts that may not be documentedQuery: search("feedback OR correction OR repeated", limit=50, type="feedback")
Then: search("", limit=100, orderBy="created_at_epoch DESC") to get recent concept tags.
Read these files (skip any that don't exist):
project_path in pending extracts)~/.claude/CLAUDE.md (global)~/.claude/rules/ directory~/.claude/projects/*/memory/MEMORY.md (memory index files)Group all pending files by project_path. For each project, merge across sessions:
{filepath: [session_ids]} — count how many sessions read each fileApply these detectors in order. For each, check the exclusion set — skip if fingerprint matches an applied or dismissed record.
1. Repeated file reads — Files read in 3+ sessions (cold start: < 10 sessions) or 5+ sessions (mature). Evidence: session count, estimated tokens (sum turn_tokens from turns containing that file's Read calls).
2. Command trial-and-error — Bash commands where the same binary (first word of command) has is_error: true in 2+ sessions. Cross-reference with RTK discover output if available. Evidence: session count, the failing and succeeding command variants.
3. Repeated user statements — Read the user message corpus (max 50 messages, most recent sessions first). Cluster semantically similar statements — you are the clustering engine. Look for messages where the user is telling Claude the same thing across sessions. If corpus exceeds 50 messages, flag: "Large message corpus — showing top 50 most recent. Some patterns may be missed." Evidence: the repeated statement, session count.
4. Context bloat — From token-scope data, find projects where 3+ sessions have bloatRatio > 2.0 AND the project's CLAUDE.md is either missing or under 50 lines. Evidence: average bloatRatio, session count, CLAUDE.md line count.
5. Undocumented concepts — From claude-mem observations, find concept tags appearing in 5+ observations that don't match any keyword in the project's CLAUDE.md (case-insensitive substring match). Evidence: concept name, observation count, sample observation titles.
5b. CLAUDE.md drift via graph_file_history — Stronger signal than #5 for the project CLAUDE.md case. For each project's CLAUDE.md path (e.g. /Users/nhangen/Local Sites/appoptinmonstertest/app/public/CLAUDE.md), call:
mcp__plugin_claude-mem-graph_claude-mem-graph__graph_file_history({
file_path: "<absolute path to CLAUDE.md>"
})
graph_file_history does exact-match lookup on the file path — pass the literal path the user has edited, not a guessed or relative one. Returns observations grouped by project that have touches edges to that file.
For each touching observation, extract its concepts field. Check membership in current CLAUDE.md text (case-insensitive substring). Surface concepts present in 2+ touching observations but absent from CLAUDE.md as claudemd-touch-drift — these are concepts the user thought worth recording at the time of editing the doc, but whose names didn't make it into the final text. Stronger signal than #5 because the underlying observation actually modified the doc.
Evidence: concept name, touching-observation count, observation IDs and titles, CLAUDE.md line count at time of touch (if available).
If claude-mem-graph is unavailable (MCP error or version < v0.2.3): skip this pattern silently and fall through to pattern #5 only. No warning needed.
6. File pair co-occurrence — File pairs appearing in the same edit set in 3+ sessions. Evidence: the two files, session count.
7. Cross-project confusion — Out-of-project paths appearing in 2+ sessions from the same project. Evidence: the wrong path, the project it was accessed from, session count.
8. Skill candidates — From sessions with high total token cost (top 25%), compress tool sequences via run-length encoding (e.g., Read×4, Grep×2, Edit, Bash×3). Present the compressed sequences for human review. Do not attempt automated similarity detection — just show the patterns. Evidence: the compressed sequence, session cost.
For each detected pattern, determine the target:
~/.claude/CLAUDE.md (global)~/.claude/rules/<name>.md (follow creating-rules process: YAML frontmatter with description and globs, matching section in ~/.claude/CLAUDE.md)allowlist-gap) → project .claude/settings.local.json under permissions.allow[]. If the file doesn't exist, create it (gitignored convention). Don't write to the committed .claude/settings.json unless the project explicitly uses that path for personal allowlists. Note: this detector currently covers Bash only; MCP tool allowlisting is tracked as a follow-up.claudemd-unused-section) → project CLAUDE.md — propose archival or rewrite. The section may have been written speculatively; behavioral data shows it's never exercised. User may reject if the section documents a future workflow not yet adopted.claudemd-undocumented-repeat) → memory file — the doc exists but the routing/content isn't surfacing in-context. Cache the relevant values directly (e.g., resolved paths, taxonomies) rather than the file path/reference. Different fix from repeated-file-read (which assumes no doc exists).rule-drift, cron-only) → whichever rule directory the user picks. Walkthrough offers Cursor → Claude or Claude → Cursor for each drifted rule; for cursor-only / claude-only cases, default action is to copy across (with frontmatter conversion: .mdc ↔ .md, alwaysApply ↔ globs). Only fires in cron mode — drift is rare and slow-changing, not worth running per-Stop.Sort by frequency (sessions affected), use estimated token cost as tiebreaker. Show trend as visual indicator:
If mode is report: print a markdown table of all findings grouped by pattern type (pattern, evidence summary, frequency, cost estimate, trend, target surface). No edits. Done.
If mode is review: filter to deferred items only, then proceed with walkthrough below.
If mode is default (full walkthrough):
Prompt: "Found N recommendations. Walk through now, or save for later?"
deferred.jsonl with action "deferred" and exitFor each recommendation, highest score first, present:
--- Recommendation N of M ---
Pattern: <pattern type in plain English>
Evidence: <primary evidence statement>
Cost: ~<token estimate> across <N> sessions
Trend: <↑/↓/→> <context>
Target: <file path>, under "<section name>"
Proposed addition:
<the actual text to add, indented>
Approve, skip, edit, defer, or quit (defers remaining)?
Handle responses:
~/.claude/context-gaps/applied.jsonl.~/.claude/context-gaps/dismissed.jsonl. Will not resurface.~/.claude/context-gaps/deferred.jsonl. Resurfaces on /md-scanner review.For rules: follow the creating-rules process in ~/.cursor/rules/creating-rules.mdc — create the .md file with frontmatter, add matching section to ~/.claude/CLAUDE.md.
After walkthrough completes:
For each pending-<session_id>.jsonl file: check if all recommendations that used data from that session have been resolved (applied, dismissed, or deferred). If yes, delete the pending file.
When reading dismissed.jsonl and deferred.jsonl, skip records where timestamp is more than 90 days old. These patterns may have become relevant again.
A recommendation's fingerprint is {pattern_type, target_file, primary_key}:
primary_key = the file pathprimary_key = the command binary nameprimary_key = SHA-256 of lowercased, whitespace-collapsed cluster representative text, truncated to 16 hex charsprimary_key = the concept nameprimary_key = both paths joined with |, sorted alphabeticallyprimary_key = the wrong pathprimary_key = "skill-candidate" (always show, never auto-dismiss)