-
Notifications
You must be signed in to change notification settings - Fork 59
Getting Started
Get Drift running and understanding your codebase in under 5 minutes.
# Install globally
npm install -g driftdetect
# Run the guided setup wizard
cd your-project
drift setup
# See what Drift discovered
drift statusThat's it. Drift now understands your codebase patterns, conventions, and architecture.
The setup wizard walks you through:
- β Initializing Drift
- β Scanning for patterns
- β Auto-approving high-confidence patterns
- β Building call graph (optional)
- β Setting up test topology (optional)
- β Initializing Cortex memory (optional)
Quick setup (skip prompts):
drift setup -y| Requirement | Version | Check Command |
|---|---|---|
| Node.js | 18.0.0+ | node --version |
| npm | 9.0.0+ | npm --version |
| pnpm (optional) | 8.0.0+ | pnpm --version |
# Verify your environment
node --version # Should show v18.x.x or higher
npm --version # Should show 9.x.x or higher# CLI tool (provides the 'drift' command)
npm install -g driftdetect
# MCP server (for AI agent integration)
npm install -g driftdetect-mcp
# Verify installation
drift --version# Add as dev dependencies
npm install --save-dev driftdetect driftdetect-mcp
# Run via npx
npx drift --versiongit clone https://github.com/dadbodgeoff/drift.git
cd drift
pnpm install
pnpm build
# Run locally
node packages/cli/dist/bin/drift.js --versioncd your-project
drift setupThe setup wizard guides you through all features and lets you choose what to enable.
cd your-project
drift init
drift scan
drift approve --auto # Auto-approve high-confidence patternsThis creates the .drift/ directory structure:
.drift/
βββ config.json # Project configuration
βββ manifest.json # Analysis manifest
βββ patterns/
β βββ discovered/ # Auto-discovered patterns
β βββ approved/ # Patterns you've approved
β βββ ignored/ # Patterns you've ignored
βββ lake/ # Analysis data lake
βββ indexes/ # Fast lookup indexes
βββ cache/ # Analysis cache
βββ history/ # Historical snapshots
βββ memory/ # Cortex memory database (if initialized)
βββ cortex.db
# Drift: Commit approved patterns, ignore transient data
.drift/lake/
.drift/cache/
.drift/history/
.drift/call-graph/
.drift/patterns/discovered/
.drift/patterns/ignored/
.drift/patterns/variants/
.drift/indexes/
.drift/memory/
# Keep these in version control:
# .drift/config.json
# .drift/patterns/approved/
# .drift/constraints/approved/drift scanWhat happens during a scan:
- Language Detection β Identifies TypeScript, Python, Java, C#, PHP, Go, Rust, C++
- Framework Detection β Recognizes Express, NestJS, Spring Boot, Laravel, FastAPI, etc.
- Tree-sitter Parsing β Builds AST for all source files
- Pattern Detection β Runs 400+ detectors across 15 categories
- Call Graph Building β Maps function calls and data flow
- Security Analysis β Identifies sensitive data access patterns
-
Storage β Persists results to
.drift/directory
Example output:
π Drift - Enterprise Pattern Scanner
β Discovered 1,245 files
β Loaded 156 detectors [4 worker threads]
β Analyzed 1,245 files in 23.45s
Patterns detected by category:
api: 147 occurrences
auth: 89 occurrences
errors: 234 occurrences
data-access: 156 occurrences
security: 78 occurrences
testing: 112 occurrences
β Saved 312 new patterns
β Call graph: 2,847 functions, 8,234 call sites
drift statusdrift status --detailed# TypeScript/JavaScript projects
drift ts status
drift ts routes # List HTTP routes
drift ts components # List React components
# Python projects
drift py status
drift py routes # List Flask/FastAPI/Django routes
# Java projects
drift java status
drift java routes # List Spring/JAX-RS routes
# Other languages
drift go status # Go projects
drift rust status # Rust projects
drift php status # PHP/Laravel projectsApproved patterns become the "golden standard" for your project.
# Approve a specific pattern by ID
drift approve api-rest-controller-abc123
# Approve all patterns in a category
drift approve --category api
# Auto-approve high-confidence patterns (>95%)
drift approve --auto# Install MCP server globally
npm install -g driftdetect-mcpAdd to your AI tool's MCP configuration:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp"
}
}
}| AI Tool | Config File Location |
|---|---|
| Claude Desktop (Mac) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Desktop (Windows) | %APPDATA%\Claude\claude_desktop_config.json |
| Cursor |
.cursor/mcp.json (project root) |
| Windsurf | Settings β MCP Servers |
| Kiro |
.kiro/settings/mcp.json (project root) |
| VS Code |
.vscode/mcp.json (project root) |
Replace static AGENTS.md files with living memory using the interactive setup wizard:
# Run the setup wizard (recommended)
drift memory setupThe wizard walks you through 7 optional sections:
- Core Identity β Project name, tech stack, preferences
- Tribal Knowledge β Gotchas, warnings, institutional knowledge
- Workflows β Deploy, code review, release processes
- Agent Spawns β Reusable agent configurations
- Entities β Projects, teams, services
- Skills β Knowledge domains and proficiency
- Environments β Production, staging, dev configs
All sections are optional β skip any with 'n'.
Or initialize manually:
# Initialize Cortex memory
drift memory init
# Add institutional knowledge
drift memory add tribal "Always use bcrypt for passwords" --importance critical
drift memory add tribal "Services should not call controllers" --topic Architecture
# Check memory status
drift memory statusβ Memory Setup Wizard | Cortex V2 Overview | Memory CLI Reference
For deeper analysis capabilities, build additional data structures:
# Build call graph (required for impact analysis)
drift callgraph build
# Build test topology (required for coverage analysis)
drift test-topology build
# Build coupling graph (required for dependency analysis)
drift coupling build# Morning: Check project status
drift status
# Get context for your task
drift memory why "authentication" --intent add_feature
# Before committing: Check staged files
drift check --staged
# Before PR: Run quality gates
drift gate# Understand impact of changes
drift callgraph reach src/api/users.ts
# Find affected tests
drift test-topology affected src/api/users.ts
# Run strict quality gates
drift gate --policy strict# Understand the codebase
drift status --detailed
# See tribal knowledge
drift memory list --type tribal --importance high
# See active warnings
drift memory warnings
# Get context for a feature area
drift memory why "authentication"Edit .drift/config.json to customize behavior:
{
"version": "2.0.0",
"project": {
"id": "uuid-here",
"name": "my-project"
},
"ignore": [
"node_modules/**",
"dist/**",
"build/**",
"**/*.test.ts"
],
"learning": {
"autoApproveThreshold": 0.95,
"minOccurrences": 3
},
"features": {
"callGraph": true,
"boundaries": true,
"contracts": true,
"testTopology": true
}
}# Diagnose issues automatically
drift troubleshoot
# Get personalized recommendations
drift next-steps# Use incremental scanning
drift scan --incremental
# Increase timeout
drift scan --timeout 300000# Check if files are being ignored
drift troubleshoot
# Force full rescan
drift scan --forceβ Full Troubleshooting Guide
# Upgrade to latest version
npm install -g driftdetect@latest driftdetect-mcp@latest
# Verify versions
drift --version
driftdetect-mcp --version| Goal | Command | Documentation |
|---|---|---|
| Set up AI memory | drift memory setup |
Memory Setup Wizard |
| Connect AI agents | npm install -g driftdetect-mcp |
MCP Setup |
| Analyze call graph | drift callgraph build |
Call Graph Analysis |
| Set up CI/CD | drift gate --ci |
Quality Gates |
| Explore patterns | drift where --category api |
Pattern Categories |
- Home β Project overview
- Configuration β Full configuration reference
- CLI Reference β All 60+ CLI commands
- MCP Tools Reference β All 50+ MCP tools
- Cortex V2 Overview β Memory system architecture
- Architecture β How Drift works under the hood
- 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