Driftguard is a dependency-light, local-first scanner for integrity and drift detection in repos and skills. It flags risky patterns, hashes files, and compares against a trusted baseline so you can answer "what changed since trust?"
- Local-first recursive scans with ignore support
- Risky pattern detection (shell execution, network calls, sensitive paths, prompt injection, obfuscation)
- SHA-256 file hashes for integrity checks
- Baseline compare to detect drift over time
- JSON and Markdown reports
- Optional concise summary when scanning a directory of skills
- Prompt/documentation awareness to reduce false positives
node ./src/cli.js scan <path>Requirements:
- Node.js >= 20
Example: repo integrity scan
node ./src/cli.js scan ./fixtures/sample-repoExample: trust + compare workflow
node ./src/cli.js scan ./skills --save-baseline ./reports/skills-baseline.json
node ./src/cli.js compare ./skills --baseline ./reports/skills-baseline.jsonExample: concise skills summary
node ./src/cli.js scan ./skills --skills-summary- Scan the target with
scanto get a verdict and report artifacts. - If risk is low and you trust the state, save a baseline.
- On subsequent runs, use
compareto detect drift and focus on new findings since trust. - Act on
VERDICT_JSONin terminal output or theverdictblock inreport.json.
Example: agent-friendly loop
node ./src/cli.js scan ./repo --save-baseline ./reports/baseline.json
node ./src/cli.js compare ./repo --baseline ./reports/baseline.jsonCreate a .driftguard.json in the root (or pass --config <file>):
{
"ignorePaths": ["dist/", "node_modules/", "fixtures/ignored.txt"],
"ignoreRules": ["net.fetch", "shell.exec_generic", "shell.*"]
}Supported keys:
ignorePaths: Paths relative to the scan root. Simple globbing is supported with*and**.- Patterns without a
/match any path segment (node_modules/matches nestednode_modulesdirectories). - Trailing
/limits the match to directories (and their contents).
- Patterns without a
ignoreRules: Rule IDs or prefixes with*wildcards.
- Terminal summary with overall risk, severity counts, and combo risks
VERDICT_JSONline for machine parsing (status, level, exit code, next steps)- Compare mode highlights what changed since the trusted baseline
- Compare only auto-trusts unchanged files when the baseline version and ignore config match the current scan
- Baseline trust checks use a canonical root identity, not the current working directory
- Reports/baselines written under the scan root are auto-ignored to avoid contaminating future scans
- Symlinks are recorded (not followed) and included in drift reporting
reports/report.jsonreports/report.md
0: low risk and no drift detected (compare mode)1: drift detected or medium risk2: high or critical risk
node ./scripts/run-fixtures.js- This is a pragmatic scanner. It favors fast heuristics over deep static analysis.
- Integrity hashes cover all files (including binaries); content scanning is limited to text and skips obvious binaries or oversized files.
- Symlinks are never followed; their paths and targets are tracked for integrity/drift.
- Prompt files (
SKILL.md,SOUL.md,MEMORY.md) are scanned for prompt-injection patterns only. - Documentation files (
.md,.txt, etc.) only surface prompt-injection patterns and are marked unscored to avoid treating docs as executable code. - Code scanning ignores string literals to reduce false positives from embedded examples/help text. Template literal interpolations are still scanned, and
package.jsonscripts are scanned verbatim to catch risky install hooks. - Add more rules in
src/rules.jsto extend coverage.
fixtures/sample-repocontains a tiny repo to test against.fixtures/sample-skillcontains a minimal skill example.