agentleFS
majiayu000majiayu000/test-loop/.claude/skills/drift-check/SKILL.md

drift-check

Skill0 starsChanged 37 days agoMITView on GitHub

Flag public symbols in the project's source tree that are not documented in the project's knowledge base. Use this before committing, in CI, or whenever a public API surface changes and you want to know whether the knowledge base has gone stale.

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use handoff.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before committing a change that adds, renames, or removes a public symbol.

    line 23
  2. Distinctive:

    After a git pull if the upstream changed the public API.

    line 25
  3. Distinctive:

    Do not use this skill to scan private internals, generated code, or third-party dependencies.

    line 27
  4. Very specific:

    Tokenise: every file under knowledge_base into identifier-like tokens (alphanumerics and underscores).

    line 69

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

drift-check

Detect drift between the project's public API surface and its knowledge base (a docs/knowledge/ directory that names every public type and function).

When to use

  • Before committing a change that adds, renames, or removes a public symbol.
  • As a CI step that runs after every push.
  • After a git pull if the upstream changed the public API.

Do not use this skill to scan private internals, generated code, or third-party dependencies. Its job is to keep the human-readable knowledge base honest about the public surface.

Inputs

NameRequiredDefaultDescription
source_globyesnoneGlob for the source files to scan, e.g. Sources/CaffCore/*.swift or src/**/*.py.
knowledge_baseyesnonePath to a Markdown directory, usually docs/knowledge/. The skill extracts identifier tokens from every file under it.
baselinenononeOptional file with one identifier per line, listing symbols intentionally left undocumented. Add an entry here only after a human has confirmed it is genuinely not worth a knowledge-base entry.
scopenoallall scans every file matching source_glob. changed scans only files in git diff (staged + unstaged + untracked-but-staged).

Output

ChannelContent
stdoutOne line per undocumented symbol in the form <relative_path>:<Symbol>.
exit code0 = every public symbol in scope is either in the knowledge base or in the baseline. 1 = at least one symbol is missing. 2 = the input was malformed (e.g. the knowledge base path does not exist).
stderrSummary line, then a hint pointing at where to fix the drift.

What counts as a public symbol

The skill uses a coarse regex; the precise rules are language-specific:

LanguagePublic surface is
Swiftpublic struct, public class, public enum, public protocol, public func, public static func, public init
Pythondef and class not prefixed with _ at module top level; __all__ if present
Goidentifiers in package ... that start with an uppercase letter
Rustpub struct, pub fn, pub enum, pub trait, pub use re-exports
TypeScriptexport function, export class, export interface, export type

The skill is deliberately not a full parser. It trades false positives for a small, predictable rule set. If the regex does not match a deliberate public symbol, add it to baseline rather than fight the regex.

Algorithm (in three steps)

  1. Extract public symbol names from the source tree using the language-specific regex.
  2. Tokenise every file under knowledge_base into identifier-like tokens (alphanumerics and underscores).
  3. Diff the symbol set against (knowledge base tokens ∪ baseline). Any symbol not present is drift.

Worked example (Swift)

Suppose Sources/CaffCore/SafetyPolicy.swift adds:

public struct SafetyPolicy {
    public func someNewMethod() { ... }
}

docs/knowledge/L1_modules.md does not mention someNewMethod.

Running drift-check with source_glob=Sources/CaffCore/*.swift and knowledge_base=docs/knowledge/ produces:

scanned 24 public symbol(s) across 9 file(s)
drift: 1 public symbol(s) not in L1_modules.md or baseline:
  - Sources/CaffCore/SafetyPolicy.swift:someNewMethod

The fix is to add someNewMethod to the L1 modules document. If it is genuinely not worth a knowledge-base entry, add someNewMethod to the baseline file.

Anti-patterns

  • Running the skill on generated code. Generated code can change with every build, and its public surface is the generator's contract, not the project's. Exclude it from source_glob.
  • Adding every internal helper to the baseline. The baseline is for symbols intentionally left out of the knowledge base, not for skipping the work. Use the knowledge base.
  • Treating drift warnings as a code review substitute. The skill tells you the knowledge base is stale. It does not tell you whether the new symbol is well-designed.

Cross-references

  • failure-classify — the next step in the loop. drift-check runs before the test, failure-classify runs after.
  • init-loop — installs the script that this skill describes into a fresh project.
  • drill — verifies that this skill actually reacts to a deliberately drifted commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.