Drift Detection
What is rules drift?
Section titled “What is rules drift?”Rules drift occurs when AI rule files become misaligned with the codebase they describe. Types of drift:
- Path drift — a referenced file path no longer exists
- Glob drift — a glob pattern matches zero files
- Command drift — a referenced command no longer works
- Coverage gap — a codebase pattern has no rule covering it
- Date drift — a rule’s validation date exceeds its cadence threshold
Why it matters
Section titled “Why it matters”Drifted rules don’t just fail to help — they actively mislead. A path drift causes agents to look for files that don’t exist. A stale command causes failed tool invocations.
Running drift detection
Section titled “Running drift detection”# standalone drift checkbunx @lambdacurry/anvil drift ./my-repo
# exclude generated or vendored directories from scanningbunx @lambdacurry/anvil drift ./my-repo --skip-dirs node_modules,dist,generated
# write the report to a specific filebunx @lambdacurry/anvil drift ./my-repo --output ./drift-report.md
# drift is also included in the full auditbunx @lambdacurry/anvil audit --target ./my-repoUse --skip-dirs to exclude directories that contain generated code, vendored copies, or template files — these often produce false-positive path and glob drift. Pass directory names (not paths), comma-separated.
Current capabilities
Section titled “Current capabilities”Implemented today:
- Path existence — referenced file paths are checked for existence
- Glob patterns — glob references (e.g.,
src/**/*.ts) are resolved against the file tree; patterns matching zero files are reported as drift - Validation dates — rules with
Last validatedheaders are checked against their cadence - Broken symlinks — symlinked rule files pointing at missing targets are flagged
- Command drift — referenced commands are checked against package scripts and available binaries
Planned:
- Coverage analysis — detecting codebase patterns with no matching rule
Interpreting drift output
Section titled “Interpreting drift output”Each drift issue includes:
- File and line — where in the rule file the drifted reference lives
- Type — path, glob, date, broken-symlink, or command
- Severity — low, medium, or high based on impact
- Suggestion — what to fix or remove
Fixing drift
Section titled “Fixing drift”- Missing paths — update the path reference or confirm the file was intentionally removed
- Glob drift — update the glob pattern to match existing files, or remove the stale reference
- Date drift — re-validate the rule and update the
Last validatedheader - Broken symlinks — restore the target or remove the link if it is no longer needed
- Command drift — update the referenced command, script, or binary so it is available to the target repo
Coverage analysis and its remediation guidance remain planned for a future phase.