Stop your AI from writing code that doesn't match your codebase.
Drift learns the patterns in your code and gives AI agents the context they need to write consistent code. No more "follow the patterns in this file" prompts that get ignored. No more 10k token steering documents that go stale.
You've got patterns in your codebase. Error handling, API responses, component structure, auth checks - stuff that took months to establish. Then you ask an AI to add a feature and it writes something completely different. Not wrong, just... not yours.
You can paste examples. You can write massive prompt documents. But the AI doesn't really know your patterns - it's just guessing based on whatever context fits in the window.
- Scans your codebase with 101 detectors across 15 categories
- Learns your patterns - not just syntax, but semantic meaning (how you handle errors, structure APIs, etc.)
- Exposes patterns to AI via MCP so agents can query what they need
- Detects FE/BE contract mismatches before they become runtime bugs
- Flags violations when code drifts from established patterns
# Install the CLI
npm install -g driftdetect
# Initialize in your project
cd your-project
drift init
# Scan for patterns
drift scan
# See what it found
drift statusThat's it. You now have a .drift/ folder with all your learned patterns.
This is where it gets good. Install the MCP server:
npm install -g driftdetect-mcpAdd to your MCP config (Kiro, Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"drift": {
"command": "drift-mcp",
"args": []
}
}
}Now your AI can query patterns instead of guessing:
| Tool | What it does |
|---|---|
drift_status |
Pattern health overview |
drift_patterns |
Query by category with confidence scores |
drift_files |
Patterns in specific files |
drift_where |
Find where patterns are used |
drift_contracts |
FE/BE API mismatches |
drift_examples |
Real code examples from your codebase |
drift_pack |
Pre-built pattern bundles for common tasks |
drift_export |
AI-optimized pattern export |
drift_feedback |
Rate examples to improve suggestions |
Drift detects patterns across 15 categories:
| Category | What it learns |
|---|---|
structural |
File naming, imports, module boundaries, barrel exports |
components |
Props patterns, hooks usage, composition, render patterns |
styling |
CSS methodology, spacing scales, color tokens, responsive patterns |
api |
Route structure, response envelopes, HTTP methods, versioning |
auth |
Token handling, RBAC patterns, session management |
errors |
Exception hierarchy, error codes, try/catch patterns |
data-access |
Repository patterns, DTOs, query builders |
testing |
Test structure, mocking patterns, fixtures |
logging |
Log levels, structured logging, correlation IDs |
security |
Input validation, sanitization, secrets handling |
config |
Environment variables, feature flags |
types |
Interface vs type usage, generics, utility types |
performance |
Memoization, lazy loading, debounce/throttle |
accessibility |
ARIA patterns, keyboard navigation, focus management |
documentation |
JSDoc style, README patterns, code comments |
Drift finds mismatches between your frontend API calls and backend endpoints:
GET /api/v1/billing/subscription
Backend returns: { plan_name: string | null, status: string | null }
Frontend expects: { plan_name: string, status: string }
⚠️ Nullability mismatch - frontend doesn't handle null
No more "works on my machine" because the backend added an optional field.
See docs/cli-reference.md for full command documentation.
- npm: driftdetect - CLI
- npm: driftdetect-mcp - MCP Server
- npm: driftdetect-core - Core engine
- npm: driftdetect-detectors - Pattern detectors
MIT