--- skill_type: analysis tools: Read, Write, Edit, Glob, Grep, Bash triggers: - "/doc-drift" - "문서 정합성" - "docs 체크" name: doc-drift context: fork user-invocable: true description: | Use this skill when the user wants to audit the memory and documents Claude Code loads into context — CLAUDE.md (user global + project + nested), MEMORY.md, @imports, .claude/skills, .claude/agents, .claude/commands, installed plugins — and detect four kinds of issues: outdated claims, mutually contradictory statements, risky-or-ambiguous wording, and session-only context leaked into skills/agents/commands docs. Produces a prioritized improvement list at `.drift-reports/`. Zero config. Trigger phrases: "doc drift", "memory drift", "memory audit", "context drift", "docs audit", "문서 점검", "문서 감사", "메모리 감사", "메모리 점검", "outdated 문서", "문서 충돌". NOT for: exhaustive content audit of an entire area (→ full-audit) · harness maturity scoring (→ check-harness, optional, not included in this repo) · single-file verification (→ verification, optional, not included in this repo). doc-drift only covers drift (contradiction/staleness/risky wording/session leakage) in already-loaded context. depends_on: skills: [] agents: [] files: - CLAUDE.md - memory/MEMORY.md - "scripts/slop_detector.py" - "scripts/claude_md_lint.py" - "scripts/stale_numbers.py" - "scripts/line_refs.py" concurrency_profile: read_only: false concurrency_safe: false destructive: low not_for: - "Memory reorganization -> memory-dream (optional, not included in this repo; reorganize by hand from the report)" - "Skill audit -> forge --audit (optional, not included in this repo; use skill-trigger-auditor for routing checks)" see_also: - skill: memory-dream relation: "optional, not included in this repo. doc-drift=document consistency, memory-dream=memory reorganization" --- # doc-drift — Claude memory audit ## Purpose Scan the memory and documents Claude loads for this project, and surface what's stale, what contradicts something else, what's risky or ambiguous, and what leaks session-only context into skills/agents/commands docs — sorted by priority. **Memory verification**: the CLAUDE.md / MEMORY.md / rules files this skill reads are past-point-in-time snapshots. Verify current state with Glob/Read before acting — never assume "it's in memory, so it must still be true". ## Dominant Variable **False-positive rate** — if a finding turns out to be wrong, the person stops trusting the report and the tool itself gets abandoned. One false positive outweighs one missed real issue. ## Trigger - `/doc-drift` - "doc drift", "memory audit", "docs audit" (more phrases in the frontmatter) ## Discard If - The project has neither CLAUDE.md nor MEMORY.md (nothing to audit) — hard discard, no override (there is nothing to read). - **Default**: skip an immediate re-audit within 24h of the last one (drift needs time to accumulate — an immediate re-audit mostly reproduces the same result). **Override**: this is a recommendation, not a block — if the user just changed something and wants to confirm the fix landed (regression check), or invokes `/doc-drift --force-after-change`, run anyway and note `Re-audit before 24h elapsed: forced` in the report header. - **Default**: skip projects with fewer than 10 files (a repo that small has little to drift, so the audit costs more than it finds). **Override**: a small repo that is high-risk (handles secrets, is a shared/published skill, or the user explicitly asks for it despite the size) is worth auditing regardless — run it and note `Small-repo override applied (N files)` in the report header. --- ## Key Assumptions This skill runs on the following assumptions: 1. **Filesystem access is available** — Read/Glob/Grep must work. If broken: fail-fast (report the missing tool). 2. **The CLAUDE.md `@import` token convention is honored** — `@path` syntax resolves per the standard spec. If broken: graceful degrade (warn + flag any import it couldn't resolve). 3. **`.drift-reports/` is writable** — create it if missing. If broken: fall back to the system temp folder or stdout. --- ## Workflow ### Step 0.0 — Check the Discard If gates (deterministic, before Step 0) Measure the two default gates in Discard If instead of guessing. 24h gate: if `.drift-reports/latest.md` exists, compare its modification time with now. Size gate: count files with `git ls-files | wc -l` (outside a git repo, `find . -type f | wc -l`). If either gate trips, check the override conditions in Discard If; with no override, tell the user the skip reason and stop. ### Step 0 — Deterministic pre-filter Before the LLM read, run three deterministic scripts over the same starting-point files Step 1 targets (CLAUDE.md, MEMORY.md, skills/agents/commands) — a scripted pass that doesn't need Step 1's full `@import` expansion to run first. Sorting "what can be counted mechanically" from "what needs a judgment call" keeps the model's read in Step 2 focused and cheap. `${CLAUDE_SKILL_DIR}` is this skill's folder; Claude Code fills it in. In other agents, replace it with the path where you installed the skill. Use `python` instead of `python3` where only that exists (common on Windows). Run each script once per file (``, project-relative or absolute): ```bash PYBIN=$(command -v python3 || command -v python) "$PYBIN" "${CLAUDE_SKILL_DIR}/scripts/slop_detector.py" "" --json "$PYBIN" "${CLAUDE_SKILL_DIR}/scripts/claude_md_lint.py" "" --json # CLAUDE.md-style files only "$PYBIN" "${CLAUDE_SKILL_DIR}/scripts/stale_numbers.py" "" [...] # CLAUDE.md / MEMORY.md-style files "$PYBIN" "${CLAUDE_SKILL_DIR}/scripts/line_refs.py" "" --root [--root ~/.claude] # file:Lnn and "N lines" refs in memory/handoff notes ``` All four exit 0 when clean, 1 when they found something, and 2 when a file is unreadable. Exit 1 is a result, not a failure. 1. **`slop_detector.py`** — Ambiguous-wording / AI-tell density scan: a fixed additive-weight pattern list (hedging phrases, hype vocabulary, empty intensifiers, antithesis constructions, stray em-dashes) scored per file, returning `verdict: HIGH/MEDIUM/LOW` and the hit list. Files at HIGH become pre-flagged Risky/Ambiguous candidates. 2. **`claude_md_lint.py`** — CLAUDE.md-as-machine-prompt linter: CLAUDE.md is a machine prompt, not documentation prose. Rewards concrete anchors (code fences, file paths, shell commands, imperative-mood lines) and penalizes vague directives ("use your judgment", "as appropriate", "depending on the situation") and length over a 150-line budget, returning `verdict: WEAK/OK/STRONG`. A WEAK verdict is itself a Risky/Ambiguous signal — a paragraph with no actionable instruction a model could act on. 3. **`stale_numbers.py`** — Hard-coded counts that go stale silently: a line that states a count of something that changes (tests, rows, skills, agents, files, lines, ...) with neither a measurement date nor a counting command in backticks. Idea from rlaope/oh-my-hermes ("write the command that counts, not the count"), re-implemented. Suggest the fix as "replace the number with the command that counts it; if that is not possible, stamp the measurement date" — for example `40 skills` becomes `` `ls skills | wc -l` (40 on 2026-10-24) ``. 4. **`line_refs.py`** — File and line references in memory or handoff notes (`file L120-140`, `file:42`, `file (1811L`, `file … 1705 lines`) checked against the real files: MISSING, AMBIGUOUS, BEYOND_EOF, COUNT_DRIFT, ANCHOR_MOVED. A line range inside the file is judged only when a backticked anchor sits in the same phrase (for example `` `for name, mod in [` ``); without one it is reported as UNANCHORED, because the script cannot tell whether an unanchored line number is stale. Suggest the fix as "put a grep anchor next to the line number". If Python is missing or a script fails to start, skip Step 0 and proceed straight to Step 1 — it's an optional accelerant, not a hard dependency (see Error Recovery). Write `Step 0: not run ()` in the report header, so the skip is visible. If one script fails (cannot start, or exit 2 on an unreadable file), write `Step 0 skipped: