Drift detects when your docs drift from your code. It extracts the real API surface — TypeScript exports, OpenAPI operations, or Clarity contract functions — and checks that docs, JSDoc, and @example blocks are accurate and complete.
bun add -D @driftdev/cli
Or globally:
bun add -g @driftdev/cli
This gives you the drift binary.
Navigate to a TypeScript package with an exported API surface (library, SDK, or CLI package) and run:
drift scan
Drift auto-detects your entry point from package.json "types", "typings", "exports", "main", "module", and "bin" fields. No configuration needed for standard package layouts.
If your package has a custom layout, pass an explicit entry:
drift scan src/drift.ts
Recommended first pass:
drift scan
drift lint
drift list --undocumented
Example output:
my-lib v1.2.0
Coverage 72% (18/25 exports documented)
Lint 3 issues
Health 68%
Issues:
parseConfig @param 'options' type mismatch: documented as 'object', actual 'ParseOptions'
createClient @returns type mismatch: documented as 'Client', actual 'Promise<Client>'
formatOutput @param 'input' not in signature (has: 'data')
Health below threshold? Use drift scan --min 80 to enforce.
JSON output (piped or --json):
{
"ok": true,
"data": {
"coverage": { "score": 72, "documented": 18, "total": 25, "undocumented": 7 },
"lint": { "issues": [...], "count": 3 },
"health": 68,
"pass": true,
"packageName": "my-lib",
"packageVersion": "1.2.0"
},
"meta": { "command": "scan", "duration": 342, "version": "1.4.0" }
}
Based on your scan results:
drift list --undocumented to see which ones.drift lint for details with file paths and line numbers.# List all exports, filter to undocumented
drift list --undocumented
# List exports with stale JSDoc
drift list --drifted
# Check just coverage
drift coverage
# Check just lint (JSDoc accuracy)
drift lint
# Validate @example blocks
drift examples
# Set a coverage floor
drift config set coverage.min 80
# Run in CI with PR comments
drift ci
All analysis commands support --all to run across workspace packages:
drift scan --all
drift coverage --all
drift lint --all
Private packages are excluded by default. Add --private to include them.
Drift stores all state in ~/.drift/ -- nothing is written to your project directory. Config can optionally live in drift.config.json or package.json "drift" key. See Configuration.
@driftdev/sdk programmatically