Skip to content

dadbodgeoff/driftscan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Drift

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.

The Problem

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.

What Drift Does

  1. Scans your codebase with 101 detectors across 15 categories
  2. Learns your patterns - not just syntax, but semantic meaning (how you handle errors, structure APIs, etc.)
  3. Exposes patterns to AI via MCP so agents can query what they need
  4. Detects FE/BE contract mismatches before they become runtime bugs
  5. Flags violations when code drifts from established patterns

Quick Start

# 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 status

That's it. You now have a .drift/ folder with all your learned patterns.

For AI Agents (MCP)

This is where it gets good. Install the MCP server:

npm install -g driftdetect-mcp

Add 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

Pattern Categories

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

Contract Detection

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.

CLI Reference

See docs/cli-reference.md for full command documentation.

Links

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published