Doc drift detector

From borghei/Claude-Skills · View interactive version

Doc drift detector is an AI agent skill from the GitHub repository borghei/Claude-Skills. Detect documentation drift against code changes, score staleness, validate API docs via AST parsing, and audit link integrity. Use when docs fall out of sync with code, preparing releases, running CI doc gates, or auditing doc accuracy.

How to use this skill

Skill file

Documentation Drift Detector

The agent detects documentation drift by mapping code directories to their docs, comparing git modification histories, extracting Python function signatures via AST, validating every markdown link and anchor, and scoring freshness on a weighted 0-100 scale. All four CLI tools use the Python standard library only.

Core Capabilities

When to Use

Clarify First

Before running detection, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

Workflow

  1. Links first (fast, no git needed): link_checker.py <docs-dir> --broken-only. Fix broken files and anchors.
  2. API docs (Python): api_doc_validator.py <src> <docs> --recursive lists documented-but-missing and undocumented functions and classes, and signature mismatches.
  3. Drift against history: drift_analyzer.py <repo> compares doc and code change history (needs a git checkout; on very large repositories use --scope to limit it).
  4. Score freshness: doc_staleness_scorer.py <repo> --threshold 60 for a 0-100 score per document and an aggregate gate.
  5. Fix in order: broken links and wrong API signatures (readers act on them), then stale how-tos, then completeness.
  6. Verify that all four tools exit 0 at the gates you chose before merging.

Quick Start

python3 scripts/link_checker.py . --broken-only                       # this skill's own docs: clean (exit 0)
python3 scripts/api_doc_validator.py scripts references --recursive    # undocumented helpers are reported
python3 scripts/drift_analyzer.py /path/to/repo --min-severity medium --fail-on high
python3 scripts/doc_staleness_scorer.py /path/to/repo --threshold 60 --json

Tools Overview

| Tool | What it does | Key flags | Exit codes |

|------|--------------|-----------|------------|

| link_checker.py <path> | Local files, anchors (GitHub slug rules), cross-doc anchors, images, case mismatches, duplicate anchors; ignores fenced and inline code | --broken-only, --check-external, --json | 0 clean, 1 broken links or duplicate anchors, 2 bad path |

| api_doc_validator.py <src> <docs> | Python AST vs docs: missing, undocumented and mismatched functions/classes/parameters | --recursive, --include-private, --json | 0 no documented-but-missing items, 1 mismatches, 2 bad path |

| drift_analyzer.py <repo> | Structural, factual, referential, temporal and semantic drift from git history | --min-severity (what to report), --fail-on (what fails, default high), --scope, --doc-patterns, --json | 0, 1 issue at/above --fail-on, 2 not a directory or not a git checkout |

| doc_staleness_scorer.py <repo> | Weighted 0-100 freshness per doc (age, code alignment, links, completeness, accuracy) | --threshold, --readme-focus, --required-sections, --weight-*, --json | 0, 1 aggregate below threshold, 2 bad path |

All tools are Python stdlib only; drift_analyzer.py and the scorer read git history through the git command.

Anti-Patterns

Mistake: Gating CI on every low-severity drift finding.

Why it happens: Strict gates look rigorous.

Instead: Fail on high (the default) and report the rest; a gate that fails on cosmetic drift gets disabled.

Mistake: Treating "recently edited" as "accurate".

Why it happens: Age is the easiest signal to compute.

Instead: Check alignment with the code that changed (drift analyzer, API validator); a doc edited yesterday can still describe last year's API.

Mistake: Writing example links in docs as real links.

Why it happens: It is the natural way to show syntax.

Instead: Put examples in inline code or fenced blocks; the checker ignores them there and reports only real links.

Reference Documentation

Load the reference that matches the task — keep this file lean and pull detail on demand:

Files

Scope & Limitations

Covers:

Does NOT cover:

Related skills: engineering/code-reviewer (attach the drift report to PR review), engineering/senior-devops (CI gates).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.