Detect doc drift

From Intense-Visions/harness-engineering · View interactive version

Detect doc drift is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Detect documentation that has drifted from code. Find stale docs before they mislead developers and AI agents.

How to use this skill

Skill file

Detect Doc Drift

Detect documentation that has drifted from code. Find stale docs before they mislead developers and AI agents.

When to Use

Process

Phase 1: Scan — Run Drift Detection

  1. Run harness check-docs to identify all documentation issues. Capture the full output.
  1. Run harness cleanup --type drift for a deeper analysis that cross-references code changes against documentation references.
  1. Check for stale constraints. Run detect_stale_constraints alongside drift detection to find architectural constraints that no longer match the codebase.
  1. Optionally, run git diff against a baseline (last release, last sprint, etc.) to identify which code files changed. This helps prioritize — docs for recently changed files are most likely to be drifted.

Graph-Enhanced Context (when available)

When a knowledge graph exists at .harness/graph/, use graph queries for faster, more accurate drift detection:

When a graph is available, drift is simply stale edges: doc-to-code edges where the code side has been modified more recently than the doc side. This replaces regex pattern matching and catches semantic drift that text search misses. Fall back to file-based commands if no graph is available.

Pipeline Context (when orchestrated)

When invoked by harness-docs-pipeline, check for a pipeline field in .harness/handoff.json:

No changes to the skill's interface or output format — the pipeline field is purely additive.

Phase 2: Identify — Classify Drift Types

Categorize each finding into one of these drift types:

Renamed but not updated:

A function, class, variable, or file was renamed in code, but documentation still references the old name. This is the most common type of drift.

New code with no docs:

A new module, function, or API was added but no documentation entry exists. This is not "drift" in the strict sense but a gap that grows into drift over time.

Deleted code still referenced:

A file, function, or feature was removed, but documentation still describes it as if it exists. This actively misleads readers.

Changed behavior not reflected:

A function's signature, return type, error handling, or side effects changed, but the documentation describes the old behavior.

Moved code with stale paths:

A file or module was moved to a different directory, but documentation references the old path.

Phase 3: Prioritize — Rank by Impact

Not all drift is equally harmful. Prioritize fixes:

Critical (fix immediately):

High (fix before next release):

Medium (fix in next sprint):

Low (fix when convenient):

Phase 4: Report — Generate Actionable Output

For each drift finding, provide:

  1. File and line number of the drifted documentation
  2. The specific stale content (quote the exact text that is wrong)
  3. What changed in code (the commit, file, and nature of the change)
  4. Suggested fix (the replacement text or action needed)
  5. Priority tier (Critical / High / Medium / Low)

Group findings by documentation file so that fixes can be applied file-by-file.

Harness Integration

Success Criteria

Rationalizations to Reject

| Rationalization | Why It Is Wrong |

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

| "The docs are close enough -- a renamed function is obvious from context" | Renamed references in AGENTS.md cause AI agents to hallucinate about non-existent code. Precision matters. |

| "We only changed internal code, so the docs do not need checking" | Internal API docs with wrong signatures waste developer debugging time. Changed-behavior-not-reflected drift is High priority. |

| "There are too many findings to deal with right now, so skip the scan" | The escalation protocol exists for this case: focus on Critical and High items, create a tracking issue for the rest. |

| "We can rely on code review to catch stale docs" | Code reviewers focus on code correctness, not documentation cross-references. harness check-docs catches what humans routinely miss. |

Examples

Example: Renamed function detected

Drift finding:

DRIFT: Renamed reference detected
  Doc: AGENTS.md:47
  Stale text: "Use `calculateShipping()` to compute shipping costs"
  Code change: calculateShipping renamed to computeShippingCost (commit a1b2c3d)
  File: src/services/shipping.ts:24
  Priority: High
  Suggested fix: Replace `calculateShipping()` with `computeShippingCost()`

Example: Deleted file still documented

Drift finding:

DRIFT: Reference to deleted file
  Doc: docs/architecture.md:112
  Stale text: "The legacy parser (src/utils/legacy-parser.ts) handles XML input"
  Code change: File deleted in commit d4e5f6g, functionality merged into unified-parser.ts
  Priority: Critical
  Suggested fix: Update section to reference unified-parser.ts, remove legacy parser description

Example: New module with no documentation

Drift finding:

GAP: Undocumented module
  File: src/services/notification-service.ts
  Created: commit h7i8j9k (3 weeks ago)
  Public exports: NotificationService, NotificationType, sendNotification
  Imported by: 4 modules
  Documentation references: 0
  Priority: High
  Suggested fix: Add AGENTS.md section describing purpose, constraints, and public API

Escalation

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.