Skip to main content
The veto doctor command checks your Veto setup and reports any issues.

Syntax

veto doctor [options]

Description

Runs comprehensive diagnostics on:
  • Runtime: Node.js version and environment
  • Project Structure: Veto directory and configuration
  • Policy Files: Rules loading and validation
  • Authentication: Cloud credentials (if configured)
  • Connectivity: Network access to Veto Cloud (if configured)

Options

Directory

--directory <path>
Project directory to check (default: current directory). Example:
veto doctor --directory ./packages/backend

JSON Output

--json
Output result as JSON instead of human-readable text. Example:
veto doctor --json

Examples

Basic Health Check

veto doctor
Output:
Veto Doctor
===========

✓ Runtime
  Node.js: v20.11.0
  Platform: darwin arm64
  CLI Version: 1.16.2

✓ Project Structure
  Veto directory: /path/to/project/veto
  Config file: veto.config.yaml
  Rules directory: /path/to/project/veto/rules

✓ Policy Rules
  Files loaded: 3
  Total rules: 12
  Global rules: 2
  Tool-specific rules: 10
  Source files:
    - veto/rules/defaults.yaml (4 rules)
    - veto/rules/financial.yaml (5 rules)
    - veto/rules/communication.yaml (3 rules)

✓ Validation Mode
  Mode: local
  No cloud configuration needed

✓ All checks passed!

With Cloud Configuration

veto doctor
Output:
Veto Doctor
===========

✓ Runtime
  Node.js: v20.11.0
  Platform: linux x64
  CLI Version: 1.16.2

✓ Project Structure
  Veto directory: /path/to/project/veto
  Config file: veto.config.yaml
  Rules directory: /path/to/project/veto/rules

✓ Policy Rules
  Files loaded: 2
  Total rules: 8
  Global rules: 1
  Tool-specific rules: 7

✓ Cloud Authentication
  API Key: Set (via VETO_API_KEY)
  API URL: https://api.veto.so

✓ Cloud Connectivity
  Endpoint: https://api.veto.so/health
  Status: OK (200)
  Response time: 45ms

✓ All checks passed!

With Issues

veto doctor
Output:
Veto Doctor
===========

✓ Runtime
  Node.js: v18.0.0
  Platform: darwin arm64
  CLI Version: 1.16.2
  ⚠️  Warning: Node.js v18 is below recommended v20

✗ Project Structure
  ✗ Veto directory not found: /path/to/project/veto
  Recommendation: Run 'veto init' to initialize Veto

✗ Policy Rules
  ✗ No rules directory found
  Recommendation: Run 'veto init' to create default rules

⚠️  Cloud Authentication
  ⚠️  No VETO_API_KEY set
  ⚠️  No cloud session found
  Recommendation: Run 'veto cloud login' or set VETO_API_KEY

✗ Diagnostics completed with issues
  Errors: 2
  Warnings: 2

JSON Output

veto doctor --json
Output:
{
  "ok": true,
  "data": {
    "runtime": {
      "nodeVersion": "v20.11.0",
      "platform": "darwin",
      "arch": "arm64",
      "cliVersion": "1.16.2"
    },
    "project": {
      "vetoDir": "/path/to/project/veto",
      "vetoDirExists": true,
      "configFile": "veto.config.yaml",
      "configExists": true,
      "rulesDirectory": "/path/to/project/veto/rules",
      "rulesDirExists": true
    },
    "rules": {
      "filesLoaded": 3,
      "totalRules": 12,
      "globalRules": 2,
      "toolSpecificRules": 10,
      "sourceFiles": [
        "veto/rules/defaults.yaml",
        "veto/rules/financial.yaml",
        "veto/rules/communication.yaml"
      ]
    },
    "auth": {
      "mode": "local",
      "cloudConfigured": false
    },
    "health": {
      "allChecksPassed": true,
      "errors": [],
      "warnings": []
    }
  }
}

Diagnostic Checks

Runtime Check

Verifies:
  • Node.js version (must be >= 20)
  • Platform and architecture
  • CLI version
Possible Issues:
  • ⚠️ Node.js version below 20
  • ✗ Node.js not found

Project Structure Check

Verifies:
  • veto/ directory exists
  • veto.config.yaml exists
  • Rules directory exists and is accessible
Possible Issues:
  • ✗ Veto not initialized
  • ✗ Config file missing
  • ✗ Rules directory not found

Policy Rules Check

Verifies:
  • Rules load successfully
  • No YAML syntax errors
  • No schema validation errors
  • At least one rule is defined
Possible Issues:
  • ✗ No rules files found
  • ✗ YAML syntax error in rules
  • ✗ Invalid rule schema
  • ⚠️ No rules defined

Authentication Check

Verifies:
  • Cloud API key or device session
  • Authentication credentials are valid
Possible Issues:
  • ⚠️ No credentials found (OK for local mode)
  • ✗ Invalid or expired credentials

Connectivity Check

Verifies:
  • Can reach Veto Cloud API
  • API responds to health check
  • Reasonable response time (under 1 second)
Possible Issues:
  • ✗ Cannot connect to API
  • ✗ API health check failed
  • ⚠️ Slow response time (over 1 second)

Exit Codes

  • 0 - All checks passed
  • 1 - One or more checks failed

Use Cases

Verify Installation

# After installing CLI
npm install -g veto-cli
veto doctor

Troubleshoot Issues

# If commands are failing
veto doctor

# Review errors and warnings
# Follow recommendations

CI/CD Health Gate

# .github/workflows/veto.yml
name: Veto Health Check

on: [push]

jobs:
  health:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 20
      - run: npm install -g veto-cli
      - run: veto doctor --json
      - run: veto doctor  # Will fail if issues found

Pre-Deployment Check

#!/bin/bash
set -e

echo "Running pre-deployment checks..."

# Verify Veto setup
veto doctor

# Verify policy coverage
veto scan --fail-uncovered

# Deploy
echo "All checks passed. Deploying..."

Debug Environment

# Capture full environment details
veto doctor --json > veto-doctor-$(date +%Y%m%d).json

# Share with team or support
cat veto-doctor-*.json

Troubleshooting

Node.js Version Warning

⚠️  Warning: Node.js v18 is below recommended v20
Solution:
# Install Node.js 20 with nvm
nvm install 20
nvm use 20
nvm alias default 20

# Verify
node --version

Veto Not Initialized

✗ Veto directory not found
Solution:
veto init
veto doctor

No Rules Found

✗ No rules files found
Solution:
# Generate a policy
veto policy generate --tool xyz --prompt "..."

# Or create manually
mkdir -p veto/rules
vim veto/rules/defaults.yaml

# Verify
veto doctor

Cloud Connection Failed

✗ Cannot connect to API
Solution:
# Check network
ping api.veto.so
curl https://api.veto.so/health

# Check proxy settings
echo $HTTP_PROXY
echo $HTTPS_PROXY

# Re-authenticate
veto cloud login

# Verify
veto doctor

Invalid Credentials

✗ Invalid or expired credentials
Solution:
# Re-authenticate
veto cloud logout
veto cloud login

# Or refresh API key
export VETO_API_KEY=new-key-here

# Verify
veto doctor

Best Practices

1. Run After Setup

# After any configuration change
veto init
veto doctor

veto policy apply --file rules.yaml
veto doctor

2. Run Before Deployment

# Always check health before deploying
veto doctor && veto policy apply --file rules.yaml --target cloud

3. Include in CI

# Add to CI pipeline
veto doctor
veto scan --fail-uncovered

4. Capture Diagnostics

# Save diagnostics for support
veto doctor --json > diagnostics.json

5. Regular Health Checks

# Add to cron or scheduled tasks
0 9 * * * cd /path/to/project && veto doctor

Next Steps

Build docs developers (and LLMs) love