Skip to main content
driftguard logo

driftguard

Your AI coding agent will build anything you ask. driftguard asks whether you should.

Audits your Claude Code · Codex · Antigravity · Cursor history, interviews you, hosts an interactive report on localhost, and writes drift guards into your agent's rules, so the next session catches you before a bug fix turns into a new app.

CI PyPI Python Zero deps 100% local License: MIT

Live demo → · Website · Install · How it works · Token crisis mode

driftguard report: focus map (where your attention breaks, by prompt position and hour)

Why

Vibe coding makes starting things free. The cost shows up later: seven half-built side projects, a usage limit hit every week, and prompts that slid from "fix these 3 bugs" to "uhhh make it 3D or whatever".

Typical patterns driftguard surfaces from your own history:

  • a burst month where most sessions went into projects you never use
  • focus breaking right after the first answer: the second prompt is a new topic, a long absence, or frustration
  • vague delegation ("do whatever you want") right before the sessions you rage at

Analytics tools show you numbers. driftguard turns them into rules your agent follows every session.

What you get

Drift guard A managed block in your global agent rules: who you are, a project registry (active / stalled / parked / dead), and protocols your agent follows: stop and poll when you drift, a new-project gate ("who uses it? does a tool already exist? which active project pauses?"), and a frustration protocol.
Purpose blocks Every project's CLAUDE.md / AGENTS.md / GEMINI.md / .cursor/rules gets its purpose, done-condition and the drift traps you actually fell into, with dates.
Interview Your agent polls you (goals, plan, tone, "is this verdict fair?"). Your answers override the AI.
Interactive report Motivation timeline, prompt-quality coaching with rewrites of your worst prompts, a brain-disconnect map, token spend, project kill/keep board, drift graph, 3D views. One HTML file, opens offline.
Token crisis mode Detects heavy usage and switches to frugal mode; driftguard handoff writes a ≤40-line HANDOFF.md so you can restart cheap.
Pulse driftguard pulse (opt-in SessionStart hook) checks new sessions for zero tokens and speaks up only when something needs attention.

3D brain terrain: prompts per hour × weekday, red = focus breaks
3D "brain terrain": prompts per hour × weekday; red = where you disconnect. Drag to rotate in the live demo.

Install

pipx install driftguard-cli        # or: uv tool install driftguard-cli   ·   pip install --user driftguard-cli

One-liners that also install the agent integrations they find:

curl -fsSL https://raw.githubusercontent.com/stelies/driftguard/main/scripts/install.sh | sh       # macOS / Linux / WSL
irm https://raw.githubusercontent.com/stelies/driftguard/main/scripts/install.ps1 | iex           # Windows

Windows is native: no WSL, no Node, no admin rights. PowerShell or cmd, with Python 3.9+ (winget install Python.Python.3.13). It reads Claude Code from %USERPROFILE%\.claude, and the driftguard pulse hook works there unchanged.

Claude Code: plugin or skill
/plugin marketplace add stelies/driftguard
/plugin install driftguard@driftguard

Then run /driftguard. Manual: copy integrations/claude/skills/driftguard/ to ~/.claude/skills/. Optional zero-token pulse, in ~/.claude/settings.json (see hooks-example.json):

{ "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "driftguard pulse" } ] } ] } }
Codex CLI

Copy integrations/codex/skills/driftguard/ to ~/.codex/skills/ and add AGENTS.snippet.md to ~/.codex/AGENTS.md. Ask Codex: "run driftguard". Guards go to AGENTS.md.

Antigravity

Copy driftguard.md to ~/.gemini/antigravity/global_workflows/ and run /driftguard in the agent panel. Guards go to ~/.gemini/GEMINI.md (Antigravity's global rules) and each project's GEMINI.md. Still on the old Gemini CLI? Use driftguard.toml in ~/.gemini/commands/.

History: driftguard reads the plain-text chat logs under ~/.gemini/. Antigravity's IDE conversations are stored as binary .pb files and are not parsed yet, so the report may show fewer Antigravity sessions than you actually had.

Cursor

Copy driftguard.mdc to .cursor/rules/ and ask the agent to run driftguard. Guards go to .cursor/rules/driftguard.mdc; Cursor has no global rules file, so paste the global block into Settings → Rules.

Use

driftguard scan                 # read every agent's history (incremental, ~0.5 s warm)
driftguard report --serve       # metrics-only report on localhost, no LLM needed
/driftguard                     # in your agent: scoring + interview + verdicts + guards
Command What it does LLM tokens
scan [--json] Parse histories → ~/.driftguard/scan.json, choose the mode 0
digest Prompt-only chunks for the scoring pass (often 100× smaller than transcripts) 0
ingest findings.json --answers answers.json Merge agent verdicts + your answers (answers win) 0
report [--serve] [--lan] Single-file interactive report; serves on the first free port ≥ 5191 0
guard [--apply] Diff (default) or write the guard blocks, with .bak backups 0
handoff ≤40-line HANDOFF.md from your latest session 0
pulse Silent unless: new project, reopened parked project, token spike, 20+ new sessions 0
budget Token burn per 5-hour block + advice 0

How it works

flowchart LR
  subgraph local["Your machine (nothing leaves it)"]
    H[("~/.claude · ~/.codex<br/>~/.gemini · Cursor DB")] -->|scan, 0 tokens| S[scan.json + metrics]
    S -->|digest, 0 tokens| D[prompt-only chunks]
    D -->|your agent scores| F[findings.json]
    S --> M{mode}
    M -->|new user| X[scaled-up diagnostics]
    M -->|heavy usage| Y[frugal mode]
    F --> I[[interview polls]]
    I -->|answers override| F
    F --> R[report.html on localhost]
    F --> G[guard blocks → CLAUDE.md / AGENTS.md / GEMINI.md / .cursor/rules]
    G -.->|every session| A((your agent stops<br/>and asks before drifting))
  end

Two layers. A deterministic, dependency-free Python CLI does all reading and math. Your agent does only the judgment (scoring prompt digests, interviewing you, wording the guards). Raw transcripts never enter the model's context.

It adapts to you:

  • New user (fewer than ~15 sessions, under 3 weeks, or no rules/skills/hooks yet): every metric is explained, Setup health comes first, starter rewrites use your own prompts, and you get fewer verdicts.
  • Heavy usage (limit talk in prompts, spend concentrated in a few sessions, recent 5h blocks above your p90): Haiku/Sonnet subagents, at most 2 at once, smaller digests, an optional scoring pass, and token-saver rules added to your guard.

The disconnect heuristics

Signal Rule
away ≥ 40 min since your previous prompt in the same session
topic switch ≥ 8 content words, < 4% word overlap with your last 3 prompts, not a slash command
frustration rage words + caps, ??, or dense shouting (pasted logs excluded)

They're heuristics, and the report says so. The interview exists because only you know whether a project was a waste.

Token crisis mode

If you're about to hit your limit:

driftguard budget          # where the tokens went, per 5-hour block
driftguard handoff         # ≤40-line HANDOFF.md: goal, files touched, open todos, last asks, next step

Then start a fresh session: "read HANDOFF.md and continue". Your guard also gains rules such as cheap subagents ≤2, digests instead of transcripts, never re-reading files, and compacting at boundaries.

Privacy

  • Everything runs locally. The CLI makes no network calls.
  • The scoring pass runs inside your own agent session, under your plan, like any other prompt.
  • Transcript text is treated as data: the skill tells your agent never to follow instructions found inside old messages.
  • guard is a dry run until you pass --apply, and every changed file gets a .bak.
  • The live demo uses a synthetic dataset.

driftguard vs. the rest (use them together)

driftguard /insights (built-in) ccusage sniffly
Token & cost accounting ✓ (5h blocks, per project) – ✓✓ ✓
Friction / usage report ✓ ✓✓ – ✓
Cross-project drift & side-project verdicts ✓ – – –
Interview that overrides the AI ✓ – – –
Writes persistent guards into agent rules ✓ suggestions – –
New-project gate + project registry ✓ – – –
Codex · Antigravity · Cursor ✓ – partial –
Zero dependencies, offline single-file report ✓ ✓ – –

If you only want token numbers, use ccusage. If you want the agent to stop you from starting project #8, use driftguard.

FAQ

Does it cost tokens? The CLI costs zero. The optional scoring pass reads compact prompt-only digests, typically hundreds of times smaller than the raw transcripts (a few hundred sessions come to roughly 100k tokens, split into chunks). In frugal mode it shrinks further, or you can skip it and keep a metrics-only report.
Will it rewrite my CLAUDE.md? Only between its own markers (<!-- driftguard:global v1 --> … <!-- /driftguard:global -->), only with --apply, and with a .bak backup. Everything outside the markers is untouched.
Windows? WSL? Both. On native Windows it runs from PowerShell or cmd: paths resolve via %USERPROFILE% / %APPDATA% (and CLAUDE_CONFIG_DIR if set), output is UTF-8 even through legacy code-page pipes, and the report opens in your default browser. If driftguard is not found right after installing, reopen the terminal or use py -m driftguard. On WSL it also reads the Windows-side histories under /mnt/c/Users/*. CI runs the tests on Windows (including a PowerShell-only smoke test), macOS and Linux.
Codex / Antigravity / Cursor formats change. Will it break? Adapters are defensive (unknown events are skipped) and covered by fixture tests. Codex .jsonl.zst needs pip install driftguard-cli[zstd].

Contributing

git clone https://github.com/stelies/driftguard && cd driftguard
python -m pip install -e ".[dev]" && python -m pytest -q
cd web && npm ci && npm run build      # rebuilds driftguard/report/template.html
python scripts/make_demo_data.py --out /tmp/demo.html

Adapter fixes with a fixture are especially welcome. Report UI: SvelteKit + Tailwind with components from llama.cpp's web UI (MIT).

License

MIT © stelies

Metadata

Release files for driftguard-cli 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for driftguard-cli 0.1.1
File Size Uploaded Provenance
driftguard_cli-0.1.1.tar.gz 212.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for driftguard-cli 0.1.1
File Interpreter ABI Platform
driftguard_cli-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 420.2 kB

Release files / driftguard_cli-0.1.1.tar.gz

Download URL driftguard_cli-0.1.1.tar.gz
Size 212.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bf7a92ae0c5c9e91846dd09c8733ad305d88f29cfd5c04b46c9b12feb833603c
BLAKE2b-256 checksum
How to use checksums
c535d908d4db8e612008515e46a0f407debbe6442dc728147590d06d777e8c77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / driftguard_cli-0.1.1-py3-none-any.whl

Download URL driftguard_cli-0.1.1-py3-none-any.whl
Size 208.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e01d91697f0d637a8ed35ce94286f6fa9766a84dc7eba46b6e76e7cf9f6115bf
BLAKE2b-256 checksum
How to use checksums
b2afb9a20a4fd3f245dc8a58c29b07a915f38ba8d01948cd3db2e90ed882d6fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for driftguard-cli 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for driftguard_cli-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page