Skip to content

Codebase pattern detection for AI agents. Scans your code, learns conventions, feeds context to Claude/Cursor or any IDE MCP. Also works fully offline with CLI

License

Notifications You must be signed in to change notification settings

dadbodgeoff/drift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

85 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ” Drift

The most comprehensive MCP server for codebase intelligence

Drift scans your codebase, learns YOUR patterns, and gives AI agents deep understanding of your conventions. 35+ CLI commands. 45+ MCP tools. 8 languages. Your AI finally writes code that fits.

npm version npm downloads License


The Problem

AI writes code that works but doesn't fit. It ignores your conventions, misses your patterns, and creates inconsistency. You spend more time fixing AI output than you saved.

Drift fixes this.


How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              YOUR CODEBASE                                   β”‚
β”‚  src/api/users.ts    src/auth/login.ts    src/db/queries.ts                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           1. DRIFT SCAN                                      β”‚
β”‚                                                                              β”‚
β”‚   $ drift init && drift scan                                                β”‚
β”‚                                                                              β”‚
β”‚   Drift analyzes your code with Tree-sitter parsing:                        β”‚
β”‚   β€’ Discovers patterns (how YOU write controllers, services, etc.)          β”‚
β”‚   β€’ Builds call graph (who calls what, data flow)                           β”‚
β”‚   β€’ Maps security boundaries (what touches sensitive data)                  β”‚
β”‚   β€’ Tracks test coverage (which code is tested)                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          2. PATTERN LEARNING                                 β”‚
β”‚                                                                              β”‚
β”‚   Drift discovers YOUR conventions:                                          β”‚
β”‚                                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚   β”‚ API Pattern     β”‚  β”‚ Error Pattern   β”‚  β”‚ Auth Pattern    β”‚            β”‚
β”‚   β”‚ @Controller     β”‚  β”‚ try/catch with  β”‚  β”‚ @RequireAuth()  β”‚            β”‚
β”‚   β”‚ /api/v1 prefix  β”‚  β”‚ AppError class  β”‚  β”‚ middleware      β”‚            β”‚
β”‚   β”‚ 47 locations    β”‚  β”‚ 23 locations    β”‚  β”‚ 12 locations    β”‚            β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
β”‚                                                                              β”‚
β”‚   You approve what matters: $ drift approve api-controller-pattern          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         3. AI GETS CONTEXT                                   β”‚
β”‚                                                                              β”‚
β”‚   When AI asks "Add a user preferences endpoint":                           β”‚
β”‚                                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚  drift_context({ intent: "add_feature", focus: "user preferences" })β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                    β”‚                                         β”‚
β”‚                                    β–Ό                                         β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚  Returns:                                                            β”‚   β”‚
β”‚   β”‚  β€’ Your API pattern: @Controller, /api/v1, response format          β”‚   β”‚
β”‚   β”‚  β€’ Similar endpoints: getUserProfile, updateUserSettings            β”‚   β”‚
β”‚   β”‚  β€’ Required middleware: @RequireAuth(), @ValidateBody()             β”‚   β”‚
β”‚   β”‚  β€’ Error handling: Use AppError, wrap in try/catch                  β”‚   β”‚
β”‚   β”‚  β€’ Files to modify: src/api/users.controller.ts                     β”‚   β”‚
β”‚   β”‚  β€’ Security note: User data requires audit logging                  β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        4. AI WRITES FITTING CODE                             β”‚
β”‚                                                                              β”‚
β”‚   // AI generates code that matches YOUR patterns:                          β”‚
β”‚                                                                              β”‚
β”‚   @Controller('/api/v1/users')           // βœ“ Your prefix                   β”‚
β”‚   @RequireAuth()                          // βœ“ Your auth pattern            β”‚
β”‚   export class UserPreferencesController {                                  β”‚
β”‚     @Post('/preferences')                                                   β”‚
β”‚     @ValidateBody(PreferencesSchema)      // βœ“ Your validation              β”‚
β”‚     async updatePreferences(req, res) {                                     β”‚
β”‚       try {                                                                 β”‚
β”‚         // ... implementation                                               β”‚
β”‚       } catch (error) {                                                     β”‚
β”‚         throw new AppError(error);        // βœ“ Your error pattern          β”‚
β”‚       }                                                                     β”‚
β”‚     }                                                                       β”‚
β”‚   }                                                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

# Install globally
npm install -g driftdetect

# In your project
cd your-project
drift init
drift scan

# See what Drift learned
drift status

That's it. Drift now understands your codebase.


Connect to Your AI

Add to your MCP config:

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "drift": {
      "command": "npx",
      "args": ["-y", "driftdetect-mcp"]
    }
  }
}

Cursor (.cursor/mcp.json):

{
  "mcpServers": {
    "drift": {
      "command": "npx",
      "args": ["-y", "driftdetect-mcp"]
    }
  }
}

Windsurf, Kiro, VS Code β€” same format in their respective config files.


What Questions Can Drift Answer?

Question Drift Tool What You Get
"How do I add a new endpoint?" drift_context Patterns, examples, files to modify
"What data can this function access?" drift_reachability Full data flow path
"What breaks if I change this?" drift_impact_analysis Blast radius, affected callers
"Which tests should I run?" drift_test_topology Minimum test set
"Who can access user passwords?" drift_reachability --inverse All code paths to sensitive data
"Are there dependency cycles?" drift_coupling Cycles, hotspots, metrics
"What errors aren't handled?" drift_error_handling Gaps, swallowed exceptions

Supported Languages

Language Parsing Call Graph Data Access Frameworks
TypeScript/JS βœ… Tree-sitter βœ… βœ… React, Next.js, Express, Prisma, TypeORM
Python βœ… Tree-sitter βœ… βœ… Django, FastAPI, Flask, SQLAlchemy
Java βœ… Tree-sitter βœ… βœ… Spring Boot, JPA/Hibernate
C# βœ… Tree-sitter βœ… βœ… ASP.NET Core, EF Core, WPF
PHP βœ… Tree-sitter βœ… βœ… Laravel, Eloquent
Go βœ… Tree-sitter βœ… βœ… Gin, Echo, GORM
Rust βœ… Tree-sitter βœ… βœ… Actix, Axum, Diesel
C++ βœ… Tree-sitter βœ… βœ… Qt, Boost, custom frameworks

The MCP Architecture

Drift's MCP server uses a 7-layer architecture designed for efficient AI interaction:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ORCHESTRATION    drift_context                                β”‚
β”‚  "Tell me what you want, I'll give you everything"             β”‚
β”‚  Token budget: 1000-2000                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  DISCOVERY        drift_status, drift_capabilities             β”‚
β”‚  "Quick health check"                                          β”‚
β”‚  Token budget: 200-500                                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  SURGICAL         drift_signature, drift_callers, drift_type   β”‚
β”‚  "I need exactly this one thing"                               β”‚
β”‚  Token budget: 200-500 (12 tools)                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  EXPLORATION      drift_patterns_list, drift_security_summary  β”‚
β”‚  "Let me browse and filter"                                    β”‚
β”‚  Token budget: 500-1000                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  DETAIL           drift_pattern_get, drift_impact_analysis     β”‚
β”‚  "Deep dive into this specific thing"                          β”‚
β”‚  Token budget: 500-1500                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ANALYSIS         drift_coupling, drift_test_topology          β”‚
β”‚  "Run complex analysis"                                        β”‚
β”‚  Token budget: 1000-2000                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  GENERATION       drift_validate_change, drift_suggest_changes β”‚
β”‚  "Help me write code"                                          β”‚
β”‚  Token budget: 500-1500                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why this matters: Most MCP servers dump 50 flat tools. AI wastes tokens figuring out which to call. Drift's orchestration layer understands intent and returns curated context in one call.


Key Features

🧠 Pattern Learning

drift scan                    # Discover patterns
drift status                  # See what was found
drift approve <pattern-id>    # Approve conventions

πŸ“Š Call Graph Analysis

drift callgraph reach src/api/users.ts:42    # What data can line 42 access?
drift callgraph inverse users.password_hash  # Who can access passwords?

πŸ”’ Security Boundaries

drift boundaries              # See sensitive data access
drift security-summary        # Security posture overview

πŸ§ͺ Test Topology

drift test-topology build                     # Build test mappings
drift test-topology affected src/auth/login.ts  # Minimum tests to run

πŸ”— Module Coupling

drift coupling build          # Build dependency graph
drift coupling cycles         # Find dependency cycles
drift coupling hotspots       # High-coupling modules

⚠️ Error Handling

drift error-handling build    # Analyze error handling
drift error-handling gaps     # Find unhandled errors

CI Integration

# Fail on violations
drift check --ci --fail-on warning

# GitHub Actions format
drift check --format github

# GitLab CI format
drift check --format gitlab

Documentation


License

Open Core model:

  • Core packages: Apache 2.0 (fully open source)
  • Enterprise features: BSL 1.1 (converts to Apache 2.0 after 4 years)

Individual developers and small teams use Drift completely free.

See licenses/LICENSING.md for details.


Stop fixing AI output. Start shipping.

About

Codebase pattern detection for AI agents. Scans your code, learns conventions, feeds context to Claude/Cursor or any IDE MCP. Also works fully offline with CLI

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages