-
Notifications
You must be signed in to change notification settings - Fork 59
FAQ
Drift is a codebase intelligence platform that learns patterns from your code and provides that knowledge to AI agents. It scans your codebase, detects patterns, builds a call graph, and exposes this information via CLI and MCP tools.
| Linters | Drift |
|---|---|
| Hardcoded rules | Learns from YOUR code |
| Style enforcement | Pattern detection |
| Single-file analysis | Full call graph |
| No AI integration | 40+ MCP tools |
Drift doesn't replace linters β it complements them by understanding your codebase at a deeper level.
8 languages with full feature parity:
- TypeScript/JavaScript
- Python
- Java
- C#
- PHP
- Go
- Rust
- C++
Drift is open source under BSL-1.1 license. Free for most uses, with some restrictions for competing products.
npm install -g driftdetectOr use without installing:
npx driftdetect initAdd to your MCP config:
{
"mcpServers": {
"drift": {
"command": "npx",
"args": ["-y", "driftdetect-mcp"]
}
}
}See MCP Setup for detailed instructions.
All data is stored in .drift/ at your project root. This includes:
- Patterns (discovered, approved, ignored)
- Call graph data
- Security boundaries
- Configuration
Short answer: Use this simple .gitignore pattern:
# Drift: ignore caches and temporary data
.drift/lake/
.drift/cache/
.drift/history/
.drift/call-graph/
.drift/patterns/discovered/
.drift/patterns/ignored/
.drift/patterns/variants/
.drift/constraints/discovered/
.drift/constraints/ignored/
.drift/contracts/discovered/
.drift/contracts/ignored/
.drift/contracts/mismatch/
# Always ignore backup files (created during updates)
.drift/**/.backups/What gets committed (good for teams):
-
.drift/config.json- Project configuration -
.drift/patterns/approved/- Your approved conventions -
.drift/boundaries/- Security boundary rules -
.drift/indexes/- Small lookup indexes -
.drift/views/- Status cache -
.drift/constraints/approved/- Architectural constraints -
.drift/contracts/verified/- Verified API contracts
What gets ignored (rebuild on scan):
- All
/lake/,/cache/,/history/,/call-graph/directories - All
/discovered/,/ignored/,/variants/,/mismatch/directories - All
/.backups/directories (internal backup files)
This approach explicitly lists what to ignore rather than using complex negation patterns.
| Codebase Size | First Scan | Incremental |
|---|---|---|
| <10K LOC | <5s | <1s |
| 10-100K LOC | 10-60s | 1-5s |
| 100K-1M LOC | 1-10min | 5-30s |
| >1M LOC | 10-30min | 30s-2min |
-
Use incremental scans (default):
drift scan --incremental
-
Exclude unnecessary files in
.driftignore:node_modules/ dist/ build/ *.generated.ts -
Scan specific directories:
drift scan src/
Good news: Drift automatically respects your .gitignore, so node_modules/, dist/, etc. are already excluded if they're in your .gitignore.
Use .driftignore only for additional exclusions specific to Drift:
# .driftignore - Additional exclusions
# (Your .gitignore patterns are already respected automatically)
# Test files (if you don't want test patterns)
*.test.ts
*.spec.ts
__tests__/
# Generated code
*.generated.ts
*.g.cs
# Large data files
*.log
*.sql
fixtures/Possible reasons:
-
File excluded β Check
.driftignore -
Language not supported β Check
drift parser - Pattern too rare β Drift needs multiple occurrences
-
Dynamic code β
eval(), reflection can't be analyzed
Patterns are recurring code structures Drift detects in your codebase:
- API endpoint patterns
- Error handling patterns
- Authentication patterns
- Data access patterns
- etc.
# See discovered patterns
drift status
# Approve a pattern
drift approve <pattern-id>
# Approve all in a category
drift approve --category apiSet learning.autoApproveThreshold in .drift/config.json:
{
"learning": {
"autoApproveThreshold": 0.9,
"minOccurrences": 3
}
}Patterns with confidence β₯ 0.9 and at least 3 occurrences will be auto-approved. Set to 1.0 to disable.
- Pattern moves from "discovered" to "approved"
- Drift uses it as a reference for your conventions
- AI agents see it as YOUR preferred approach
- Outliers (code that doesn't match) are flagged
drift ignore <pattern-id> --reason "Legacy code"Ignored patterns won't be suggested to AI agents.
Outliers are code that doesn't match approved patterns. They might be:
- Bugs or mistakes
- Legacy code
- Intentional exceptions
- New patterns not yet approved
Any tool supporting MCP:
- Claude Desktop
- Cursor
- Windsurf
- Kiro
- VS Code (with MCP extension)
- Any MCP-compatible client
- You ask: "Add a user endpoint"
- AI calls
drift_contextwith your intent - Drift returns your patterns, examples, conventions
- AI generates code matching YOUR style
Start with drift_context β it returns curated context for any task:
{
"intent": "add_feature",
"focus": "user authentication"
}See MCP Tools Reference for all 45+ tools.
- MCP not configured β Check your MCP config
-
Project not scanned β Run
drift scan - AI not calling tools β Ask explicitly: "Use Drift to..."
# What data can this code access?
drift callgraph reach src/api/users.ts:42
# Who can access this data?
drift callgraph inverse users.password_hashSee Call Graph Analysis.
# Security overview
drift boundaries overview
# Find sensitive data access
drift boundaries sensitive
# Check for violations
drift boundaries checkSee Security Analysis.
# Build test topology
drift test-topology build
# Find affected tests
drift test-topology affected src/auth/login.tsSee Test Topology.
# Build coupling analysis
drift coupling build
# Find cycles
drift coupling cyclesSee Coupling Analysis.
# GitHub Actions
- name: Install Drift
run: npm install -g driftdetect
- name: Scan
run: drift scan
- name: Check
run: drift check --ciSee CI Integration.
drift gate --policy strict --format githubThis outputs GitHub annotations for violations.
TESTS=$(drift test-topology affected --staged --format list)
npm test -- $TESTS-
Check you're scanning source files:
drift scan src/
-
Check language is supported:
drift parser
-
Check files aren't excluded:
cat .driftignore
- Check
.driftignoreexcludesnode_modules/,dist/ - Use incremental scans:
drift scan --incremental - Scan specific directories:
drift scan src/
- Restart your AI client after config changes
- Check config file path is correct
- Test manually:
npx driftdetect-mcp --help
Some tools require pre-built data:
drift test-topology build
drift coupling build
drift error-handling build- Check parser status:
drift parser --test - Check for syntax errors in your code
- Try regex fallback:
drift scan --fallback
No. All analysis happens locally. Your code never leaves your machine.
Anonymous usage data (opt-out available):
- Commands run
- Languages scanned
- Error rates
- Performance metrics
Never collected:
- Source code
- File contents
- Pattern details
- Personal information
Disable with: drift telemetry disable
- All data stored locally in
.drift/ - No cloud services required
- No external API calls for analysis
- You control what's committed to git
- Approve patterns that represent your conventions
- Report false positives when Drift gets it wrong
- Suggest patterns Drift should detect
- Contribute code to the open source project
See Contributing.
- Cortex V2 Overview
- Memory Setup Wizard
- Memory CLI
- Universal Memory Types
- Learning System
- Token Efficiency
- Causal Graphs
- Code Generation
- Predictive Retrieval
- Architecture
- Call Graph Analysis
- Impact Analysis
- Security Analysis
- Data Boundaries
- Test Topology
- Coupling Analysis
- Error Handling Analysis
- Wrappers Detection
- Environment Variables
- Constants Analysis
- Styling DNA
- Constraints
- Contracts
- Decision Mining
- Speculative Execution
- Watch Mode
- Trends Analysis
- Projects Management
- Package Context
- Monorepo Support
- Reports & Export
- Dashboard
- 10 Languages
- 21 Frameworks
- 16 ORMs
- 400+ Detectors
- 50+ MCP Tools
- 60+ CLI Commands
- 23 Memory Types