drift / docs

Documentation

Everything you need to install, configure, and use drift.

On this page

01 Installation

Homebrew (recommended)

$ brew install greatnessinabox/tap/drift

Shell script

$ curl -fsSL https://raw.githubusercontent.com/greatnessinabox/drift/main/install.sh | sh

Go install

$ go install github.com/greatnessinabox/drift/cmd/drift@latest

Build from source

$ git clone https://github.com/greatnessinabox/drift.git
$ cd drift
$ go build ./cmd/drift/

Verify it works

$ drift --version
drift v1.0.0

02 Quick Start

# Run the live dashboard in any supported project
$ cd your-project
$ drift

# Generate a report
$ drift report

# Check health (for CI)
$ drift check --fail-under 70

# Interactive fix with GitHub Copilot CLI
$ drift fix

drift auto-detects the language by checking for manifest files (go.mod, package.json, Cargo.toml, pyproject.toml, pom.xml). Supports Go, TypeScript/JavaScript, Python, Rust, and Java.

03 Configuration

Create a .drift.yaml in your project root. All fields are optional — drift works with zero config.

# Language (empty = auto-detect)
language: ""

# Directories to exclude
exclude:
  - vendor
  - node_modules
  - .git
  - __pycache__
  - target

# Metric weights (must sum to 1.0)
weights:
  complexity: 0.30
  deps: 0.20
  boundaries: 0.20
  dead_code: 0.15
  coverage: 0.15

# Architecture boundary rules
boundaries:
  - deny: "pkg/api -> internal/db"
  - deny: "cmd -> internal/tui"

# AI diagnostics (optional)
ai:
  provider: anthropic  # or "openai"
  model: ""            # uses sensible defaults

# Thresholds
thresholds:
  max_complexity: 15
  max_stale_days: 90
  min_score: 70

04 CLI Reference

drift

Launch the interactive TUI dashboard. Auto-detects language and starts real-time monitoring with file watching.

drift init

Initialize a .drift.yaml config file in the current directory with sensible defaults.

drift report

Generate a one-shot health report to stdout. Useful for quick checks.

drift check --fail-under <score>

Exit with code 1 if health score is below the threshold. Designed for CI pipelines.

drift fix

Interactive mode — finds issues, asks GitHub Copilot for fixes, and lets you apply them one by one.

drift snapshot

Output full health data as JSON. Useful for scripting and advanced CI workflows.

05 Health Metrics

The overall health score is a weighted average of five dimensions. Weights are configurable in .drift.yaml.

30%

Cyclomatic Complexity

Full AST analysis for Go, heuristic pattern matching for TS, Python, Rust, Java. Finds your most complex functions.

20%

Dependency Freshness

Checks every dependency against its registry — Go proxy, npm, PyPI, crates.io, Maven Central.

20%

Architecture Boundaries

Define import deny rules (e.g., "api cannot import db") and detect violations.

15%

Dead Code

Finds exported functions/types with zero callers across the entire codebase.

15%

Test Coverage

Reads coverage data from language-specific tools and factors it into the score.

06 AI Diagnostics

Press d in the dashboard to trigger an AI diagnosis. The AI analyzes your worst-scoring metrics and provides specific, actionable recommendations with code snippets.

Supported providers

Anthropic Claude

Sonnet, Opus, Haiku

ANTHROPIC_API_KEY

OpenAI GPT-4o

GPT-4o, o1

OPENAI_API_KEY
# .drift.yaml
ai:
  provider: anthropic  # or "openai"
  model: ""            # uses sensible defaults

07 GitHub Copilot Integration

Interactive fixing

$ drift fix

  Analyzing codebase... (Score: 78/100)

  Found 3 issue(s) to fix:
  1. [HIGH] model.Update() in app.go:126 (complexity: 25)

  Asking GitHub Copilot for suggestions...
  Apply this suggestion? [y/N/s(kip rest)]

Custom agent

$ copilot --agent drift-dev "analyze internal/tui/app.go"
$ copilot --agent drift-dev "suggest refactoring for Update()"
$ copilot --agent drift-dev "help me add C# analyzer support"

Requires brew install copilot-cli. drift also works with any AI coding assistant — see the multi-agent guide.

08 CI/CD

Basic GitHub Action

# .github/workflows/drift.yml
name: Code Health
on: [pull_request]

jobs:
  drift:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - run: go install github.com/greatnessinabox/drift/cmd/drift@latest
      - run: drift check --fail-under 70

Advanced: JSON snapshot

$ SCORE=$(drift snapshot | jq '.score.total')
$ LANG=$(drift snapshot | jq -r '.language')
$ echo "Language: $LANG, Score: $SCORE"

09 Keyboard Shortcuts

Key Action
tab Navigate between panels
shift+tab Navigate backwards
d Run AI diagnosis
r Force full re-analysis
q / ctrl+c Quit
esc Close diagnosis overlay

10 Compatibility

Operating Systems

  • macOS (arm64, amd64)
  • Linux (arm64, amd64)
  • Windows (amd64, arm64)

Shells

  • bash / zsh
  • fish / nushell
  • PowerShell / cmd

Languages

  • Go 1.21+
  • TypeScript / JavaScript
  • Python, Rust, Java

drift is a single static binary with zero runtime dependencies. No Node.js, no Python runtime, no Docker. Just download and run.

11 FAQ & Troubleshooting

drift says "no supported project found"
drift looks for manifest files (go.mod, package.json, Cargo.toml, pyproject.toml, pom.xml) in the current directory. Make sure you're running drift from the project root, or set the language explicitly in .drift.yaml.
AI diagnosis says "no API key configured"
Set ANTHROPIC_API_KEY or OPENAI_API_KEY as an environment variable, or configure the provider in .drift.yaml under the ai section.
The health score seems too low
Scores are based on five weighted metrics. Run drift report to see which dimension is dragging your score down. You can adjust weights in .drift.yaml to match your team's priorities.
Can I use drift in a monorepo?
Yes — run drift from any subdirectory that has its own manifest file. Each sub-project is analyzed independently.
Does drift send any data externally?
Only if you enable AI diagnostics (which calls the LLM API you configure). Otherwise, drift is fully offline. No telemetry, no analytics, no phone-home.
How do I update drift?
Same way you installed it: brew upgrade drift, re-run the shell script, or go install ...@latest. Check the releases page for changelogs.