Skip to main content
Commands

vg scan

The primary CLI command. Scan for upgrade drift with multiple output formats and quality gates.

Overview

vg scan is the core command of the Vibgrate CLI. It recursively analyzes your repository, calculates the DriftScore, and outputs actionable findings.

Quick Start: Run npx @vibgrate/cli scan in any project directory for an instant drift assessment.


Usage

vg scan [path] [options]

Options Reference

Output Options

FlagDefaultDescription
--format <type>textOutput format: text, json, sarif, md
--out <file>stdoutWrite output to a file

Quality Gate Options

FlagDefaultDescription
--fail-on <level>Exit code 2 if findings at level: error, warn, info
--baseline <file>Compare against a previous baseline
--drift-budget <score>Fail if drift score exceeds this value (0-100)
--drift-worsening <percent>Fail if drift increased by this % vs baseline

Scope Options

FlagDefaultDescription
--exclude <glob>, -e <glob>Exclude paths from the scan as glob patterns. Repeatable, and accepts comma/semicolon-separated values. Merged (and de-duplicated) with the config file's exclude list.

Performance Options

FlagDefaultDescription
--concurrency <n>8Maximum concurrent registry API calls
--changed-onlyOnly scan files changed since baseline
--project-scan-timeout <seconds>180Per-project scan timeout in seconds
--ui-purposeEnable optional UI purpose evidence extraction (slower)
--offlineDisable network calls (requires package manifest)
--package-manifest <file>Offline package version data

Vibgrate Cloud Upload Options

FlagDefaultDescription
--pushUpload scan artifact to dashboard
--dsn <dsn>VIBGRATE_DSN envDSN token for authentication
--region <region>Data residency override: us, eu
--repository-name <name>dir / package nameOverride the repository name recorded for this scan
--strictFail pipeline if upload fails

Privacy & Security Options

FlagDefaultDescription
--max-privacyHardened privacy mode, minimal data collection
--no-local-artifactsDon't write .vibgrate/*.json files

Output Formats

Text (Default)

vg scan

Example Output:

╭─────────────────────────────────────────────╮
│  VIBGRATE DRIFT REPORT                      │
├─────────────────────────────────────────────┤
│  DriftScore: 67/100                         │
│  Projects: 4 (Node.js: 3, .NET: 1)          │
│  Findings: 12 (3 errors, 7 warnings, 2 info)│
╰─────────────────────────────────────────────╯

🔴 ERROR: Node.js 16.x is EOL
   → Upgrade to Node.js 20.x or 22.x

🟡 WARNING: 45% of dependencies are 2+ majors behind
   → Review dependency-risk findings

🔵 INFO: TypeScript 4.9 → 5.x available
   → Consider upgrade for improved type inference

JSON

vg scan --format json --out scan.json

Example Output:

{
  "meta": {
    "version": "1.0.0",
    "timestamp": "2025-01-15T10:30:00Z",
    "duration": 4520
  },
  "driftScore": 67,
  "projects": [
    {
      "path": "./",
      "ecosystem": "nodejs",
      "drift": 45,
      "runtimeVersion": "16.20.0"
    }
  ],
  "findings": [
    {
      "severity": "error",
      "scanner": "platform-matrix",
      "message": "Node.js 16.x is EOL",
      "recommendation": "Upgrade to Node.js 20.x or 22.x"
    }
  ]
}

SARIF (GitHub/Azure DevOps)

vg scan --format sarif --out vibgrate.sarif

Tip: SARIF integrates with GitHub Code Scanning and Azure DevOps for native PR annotations.

Markdown

vg scan --format md --out report.md

Use Case: Generate markdown for PR comments, wikis, or release documentation.


Quality Gates

Fail on Severity Level

# Fail on any error-level finding
vg scan --fail-on error

# Fail on warnings or worse
vg scan --fail-on warn

# Fail on any finding
vg scan --fail-on info
LevelExit CodeUse Case
error2Block on critical issues only
warn2Stricter governance
info2Zero-tolerance policy

Drift Fitness Functions

Fitness functions enforce drift budgets over time:

vg scan \
  --baseline .vibgrate/baseline.json \
  --drift-budget 40 \
  --drift-worsening 5 \
  --fail-on error
GateTriggerPurpose
--drift-budget 40Score > 40Absolute drift ceiling
--drift-worsening 5Increase > 5% vs baselinePrevent regression
--fail-on errorAny error findingCatch critical issues

Warning: Fitness functions require a baseline. Create one with vg baseline first.


Special Modes

Offline Mode

For air-gapped environments or CI runners without internet:

vg scan --offline --package-manifest ./packages.zip

Privacy Mode

For maximum data minimization:

vg scan --max-privacy --no-local-artifacts

CI Pipeline Mode

Recommended CI configuration with all quality gates:

vg scan \
  --baseline .vibgrate/baseline.json \
  --drift-budget 40 \
  --drift-worsening 5 \
  --fail-on error \
  --format sarif \
  --out vibgrate.sarif \
  --push \
  --strict

Excluding Paths

Use --exclude (alias -e) to skip paths from a scan as glob patterns. This is the command-line equivalent of the exclude array in vibgrate.config.*, useful for ad-hoc, one-off scans without editing config.

The flag follows common CLI conventions for "multiple values":

StyleExample
Repeatable--exclude "legacy/**" --exclude "vendor/**"
Comma/semicolon-separated--exclude "legacy/**,vendor/**;dist/**"
Mixed-e "legacy/**" -e "vendor/**,dist/**"
# Exclude a couple of directories for this run only
vg scan --exclude "legacy/**" --exclude "vendor/**"

# Same thing, comma/semicolon-separated in a single flag
vg scan -e "legacy/**,vendor/**;dist/**"

Additive, not a replacement: CLI excludes are merged (and de-duplicated) with the config file's exclude list rather than replacing it, so your committed defaults always apply. Patterns use glob syntax matched against the workspace root.


Exit Codes

CodeMeaningAction
0Success, no threshold violationsPipeline continues
1CLI error (invalid args, scan failure)Debug command
2Drift threshold exceededBlock merge, address findings

Related Commands

Example use cases

Expand any use case to watch a live replay of the real @vibgrate/cli running against one of our test repositories. Nothing executes in your browser — these are recordings of actual runs, with the scan time shown as of now.

vg

Related Documentation

Related Help Articles