Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .claude/skills/drift/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
name: drift
description: Drift spec-to-code anchor conventions. Use when editing code that is bound by drift specs, updating specs, working with drift frontmatter, or when drift check reports stale anchors.
drift:
origin: github:fiberplane/drift
files:
- src/main.zig@sig:d873ec9ee4847ab0
- src/frontmatter.zig@sig:418dbef4a977ea1d
- src/scanner.zig@sig:161bae32d2c984b8
- src/vcs.zig@sig:31d5ca6c615ea8dd
- src/main.zig@sig:80171c2f3d2c2f4c
- src/frontmatter.zig@sig:ec04c25b0a6b05b2
- src/scanner.zig@sig:580c0f12170d4d35
- src/vcs.zig@sig:1699bd9349c613a6
---

# Drift
Expand Down
7 changes: 6 additions & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
drift:
files:
- src/main.zig@sig:d873ec9ee4847ab0
- src/main.zig@sig:80171c2f3d2c2f4c
---

# CLI Reference
Expand Down Expand Up @@ -34,9 +34,14 @@ docs/project.md
STALE src/core/old-module.ts
file not found

vendor/shared-skill.md
SKIP src/main.rs (origin: github:acme/other-repo)

2 specs stale, 1 ok
```

Specs with an `origin:` field that doesn't match the current repo are skipped — their anchors reference files in a different repository.

## drift status

Show all specs and their anchors without checking staleness. This includes explicit frontmatter anchors, `<!-- drift: ... -->` comment anchors, and inline `@./path` references from the spec body.
Expand Down
12 changes: 10 additions & 2 deletions docs/DECISIONS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
drift:
files:
- src/main.zig@sig:d873ec9ee4847ab0
- src/main.zig@sig:80171c2f3d2c2f4c
- src/symbols.zig@sig:a31cb9bf8bd80d64
- src/vcs.zig@sig:31d5ca6c615ea8dd
- src/vcs.zig@sig:1699bd9349c613a6
---

# Decisions
Expand Down Expand Up @@ -92,3 +92,11 @@ Content signatures solve several problems with VCS-based provenance:
- The staleness check is a pure function of the file's content, not of VCS state. This makes drift behavior deterministic and easier to reason about.

Legacy `@<sha>` provenance is still supported — `drift lint` detects the format and routes to the VCS-based comparison path. Migration is incremental: running `drift link <spec>` on any spec rewrites its anchors to `@sig:` format.

## 10. Origin-qualified anchors

Specs can declare `origin: github:owner/repo` in their `drift:` frontmatter section. At lint time, drift resolves the current repo's identity from `git remote get-url origin`, normalizes it to `github:owner/repo`, and compares. If a spec's origin doesn't match, its anchors are skipped — they belong to a different repository.

This solves the problem of specs traveling across repository boundaries. Shared skill files, vendored documentation, and monorepo imports all contain anchors that point at files in the source repo, not the consuming repo. Without origin qualification, `drift lint` would report these as STALE (file not found) every time, creating noise. With it, foreign specs are silently skipped and only local specs are checked.

Origin is opt-in. Specs without `origin:` are always checked. The normalized format (`github:owner/repo`) is derived from the git remote URL, handling SSH, HTTPS, and SSH URL formats uniformly.
14 changes: 10 additions & 4 deletions docs/DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
drift:
files:
- src/main.zig@sig:d873ec9ee4847ab0
- src/frontmatter.zig@sig:418dbef4a977ea1d
- src/scanner.zig@sig:161bae32d2c984b8
- src/main.zig@sig:80171c2f3d2c2f4c
- src/frontmatter.zig@sig:ec04c25b0a6b05b2
- src/scanner.zig@sig:580c0f12170d4d35
- src/symbols.zig@sig:a31cb9bf8bd80d64
- src/vcs.zig@sig:31d5ca6c615ea8dd
- src/vcs.zig@sig:1699bd9349c613a6
---

# Design
Expand Down Expand Up @@ -59,6 +59,12 @@ The `@provenance` suffix is optional. Bare paths still work. Different anchors c

`drift link` produces `@sig:` provenance by default. Content signatures are VCS-independent — they encode a fingerprint of the code itself, so staleness detection works without querying git history. Legacy `@<sha>` provenance is still supported for backward compatibility.

### Origin-Qualified Anchors

A spec can declare its origin repository via `origin: github:owner/repo` in the `drift:` section. When `drift lint` runs, it resolves the current repo's identity from `git remote get-url origin` and normalizes it to the same `github:owner/repo` format. If a spec's origin doesn't match the current repo, all its anchors are reported as `SKIP` — they belong to a different repository and can't be checked locally.

This lets specs travel across repo boundaries (vendored docs, shared skill files, monorepo imports) without producing false STALE reports. Specs without an `origin:` field are always checked — origin qualification is opt-in.

### Symbol-Level Anchors

An anchor like `src/auth/provider.ts#AuthConfig` resolves to a specific AST symbol rather than the whole file. drift parses the file with tree-sitter, finds the symbol's declaration, and hashes a normalized representation of that subtree. Changes elsewhere in the file don't trigger staleness, and formatting-only changes inside the symbol are ignored.
Expand Down
Loading