-
Notifications
You must be signed in to change notification settings - Fork 63
Trends Analysis
Drift tracks pattern changes over time, showing regressions, improvements, and overall codebase health trends.
Trends analysis helps you:
- Detect pattern regressions before they become problems
- Track improvements in code quality
- Monitor category-specific trends
- Make data-driven decisions about technical debt
# View trends (default: 7 days)
drift trends
# 30-day trends
drift trends --period 30d
# 90-day trends with details
drift trends --period 90d --verbosedrift trends [options]| Option | Description | Default |
|---|---|---|
-p, --period <period> |
Time period: 7d, 30d, or 90d | 7d |
--verbose |
Show detailed output including improvements | false |
📊 Pattern Trends
Overall: 📈 IMPROVING
Period: 2024-01-08 → 2024-01-15
──────────────────────────────────────────────────
Regressions: 3
Improvements: 12
Stable: 832
──────────────────────────────────────────────────
📉 Regressions (3):
Critical:
• Error Handling Coverage (errors)
Coverage dropped from 85% to 72% (-15%)
• API Response Validation (api)
3 new endpoints without validation (+300%)
Warning:
• Test Coverage (testing)
Coverage decreased slightly (-5%)
Category Trends:
↑ api: improving
↑ auth: improving
↓ errors: declining
→ security: stable
→ testing: stable
Use --verbose to see 12 improvements
View full details in the dashboard:
drift dashboard
drift_trends({
period?: "7d" | "30d" | "90d", // Time period (default: 7d)
category?: string, // Filter by category
limit?: number, // Max trends to return (default: 20)
severity?: "all" | "critical" | "warning" // Filter by severity (default: all)
})Returns:
{
"overallTrend": "improving",
"startDate": "2024-01-08",
"endDate": "2024-01-15",
"regressions": [
{
"patternName": "Error Handling Coverage",
"category": "errors",
"severity": "critical",
"changePercent": -15,
"details": "Coverage dropped from 85% to 72%"
}
],
"improvements": [
{
"patternName": "API Documentation",
"category": "documentation",
"severity": "info",
"changePercent": 25,
"details": "Documentation coverage increased"
}
],
"stable": 832,
"categoryTrends": {
"api": { "trend": "improving", "change": 12 },
"errors": { "trend": "declining", "change": -8 }
}
}| Status | Meaning |
|---|---|
| 📈 IMPROVING | More improvements than regressions |
| 📉 DECLINING | More regressions than improvements |
| ➡️ STABLE | Roughly equal or no significant changes |
| Level | Description |
|---|---|
| Critical | Significant regression requiring immediate attention |
| Warning | Notable change that should be addressed |
| Info | Minor change for awareness |
Changes are calculated by comparing:
- Pattern counts (more/fewer instances)
- Coverage percentages
- Outlier counts
- Confidence scores
Every scan creates a snapshot in .drift/history/snapshots/:
.drift/history/snapshots/
├── 2024-01-08T10-00-00.json
├── 2024-01-09T10-00-00.json
├── 2024-01-10T10-00-00.json
└── ...
Trends compare the current state to historical snapshots:
Current State (today)
│
▼
┌─────────────────┐
│ Compare with │
│ 7/30/90 days │
│ ago │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Calculate │
│ - Regressions │
│ - Improvements │
│ - Stable │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Categorize │
│ by severity │
└─────────────────┘
A regression is detected when:
- Pattern count decreases significantly
- Coverage percentage drops
- Outlier count increases
- Confidence score decreases
Review code quality changes during a sprint:
drift trends --period 14d --verboseCheck for regressions before release:
drift trends --period 7d
# Ensure no critical regressionsMonitor long-term trends:
drift trends --period 90d --verboseTrack specific areas:
# Via MCP
drift_trends({ category: "security", period: "30d" })Each category gets its own trend:
| Category | What's Tracked |
|---|---|
api |
Endpoint patterns, validation, documentation |
auth |
Authentication patterns, security |
errors |
Error handling coverage, boundaries |
security |
Security patterns, vulnerabilities |
testing |
Test coverage, test patterns |
logging |
Logging consistency, observability |
data-access |
Database patterns, queries |
performance |
Performance patterns |
Run scans regularly to build history:
# Daily scan (cron or CI)
0 9 * * * cd /project && drift scanFocus on high-impact categories:
# Check security and errors weekly
drift trends --period 7d | grep -E "(security|errors)"After major refactors, establish new baselines:
drift scan
drift status --detailed
# Document current state as baselineDon't let regressions accumulate:
# Check for critical regressions
drift trends --period 7d
# If critical regressions found, address immediatelyAdd trend checks to your CI pipeline:
# .github/workflows/trends.yml
name: Weekly Trends Check
on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 9am
jobs:
trends:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Drift
run: npm install -g driftdetect
- name: Check Trends
run: |
drift trends --period 7d > trends.txt
if grep -q "DECLINING" trends.txt; then
echo "⚠️ Code quality declining"
cat trends.txt
exit 1
fi
- name: Post to Slack
if: failure()
run: |
curl -X POST $SLACK_WEBHOOK -d @trends.txtView trends visually in the dashboard:
drift dashboardThe dashboard shows:
- Trend graphs over time
- Category breakdowns
- Regression highlights
- Improvement celebrations
Not enough history data to show trends.
Run more scans over time to see pattern trends.
Solution: Run regular scans to build history:
drift scan
# Wait and scan again later
drift scan
# Now trends will have dataIf you see regressions after refactoring:
- Check if patterns were intentionally changed
- Review the specific files affected
- Consider if the "regression" is actually an improvement
If a category doesn't appear in trends:
- No patterns in that category
- No changes in that category during the period
- Dashboard — Visual trend monitoring
- Quality Gates — Enforce trend requirements
- CI Integration — Automate trend checks
- 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