← Back to Docs

CLI Reference

vigil runs from the command line. All subcommands, options, and examples are documented below.

General usage

vigil [OPTIONS] COMMAND [ARGS]

Global options

OptionDescription
--versionShow the vigil version
--helpShow general help

vigil scan

Main command. Scans code looking for security issues specific to AI-generated code.

Syntax

vigil scan [PATHS...] [OPTIONS]

If no paths are specified, scans the current directory (.).

Options

OptionShort formTypeDefaultDescription
--config-cPATHAuto-detectPath to the .vigil.yaml file
--format-fhuman|json|junit|sarifhumanOutput format
--output-oPATHstdoutFile to write the report to
--fail-oncritical|high|medium|lowhighMinimum severity to fail (exit 1)
--category-CmultipleallOnly run specific categories
--rule-rmultipleallOnly run specific rules
--exclude-rule-RmultiplenoneExclude specific rules
--language-lpython|javascriptallOnly scan specific languages
--offlineflagfalseDo not make HTTP requests to registries
--changed-onlyflagfalseOnly scan files changed since the last commit
--verbose-vflagfalseDetailed output with debug logs
--quiet-qflagfalseOnly show findings, no summary

Examples

# Scan basico
vigil scan src/

# Scan de multiples directorios
vigil scan src/ lib/ app/

# Solo dependencias y secrets
vigil scan src/ -C dependency -C secrets

# Solo una regla especifica
vigil scan src/ -r DEP-001

# Excluir reglas que no aplican a tu proyecto
vigil scan src/ -R AUTH-003 -R TEST-004

# Solo Python
vigil scan src/ -l python

# Generar reporte SARIF para GitHub Code Scanning
vigil scan src/ -f sarif -o vigil.sarif

# Generar reporte JSON
vigil scan src/ -f json -o report.json

# Generar reporte JUnit para CI dashboards
vigil scan src/ -f junit -o report.xml

# Fallar solo con findings critical
vigil scan src/ --fail-on critical

# Fallar desde medium en adelante
vigil scan src/ --fail-on medium

# Sin HTTP requests (solo checks estaticos)
vigil scan src/ --offline

# Solo archivos cambiados (ideal para pre-commit)
vigil scan --changed-only

# Con archivo de config personalizado
vigil scan src/ -c mi-vigil.yaml

# Output detallado para debugging
vigil scan src/ -v

# Guardar reporte en archivo Y mostrar en terminal (solo formato human)
vigil scan src/ -o report.txt

Output behavior

  • human format: If --output is specified, the report is written to the file AND displayed in the terminal.
  • json, junit, sarif formats: If --output is specified, the report is only written to the file. Otherwise, it goes to stdout.
  • --verbose: Debug logs go to stderr. Findings go to stdout. They are never mixed.

vigil deps

Specialized subcommand for analyzing dependencies. Runs only the rules in the dependency category.

Syntax

vigil deps [PATH] [OPTIONS]

Options

OptionShort formTypeDefaultDescription
--verify / --no-verifyflag--verifyVerify package existence in the registry
--format-fhuman|jsonhumanOutput format
--offlineflagfalseDo not make HTTP requests
--verbose-vflagfalseDetailed output

Examples

# Verificar dependencias del proyecto actual
vigil deps

# Verificar un proyecto especifico
vigil deps /ruta/al/proyecto

# Solo checks estaticos, sin verificar registries
vigil deps --no-verify

# Output JSON
vigil deps -f json

What files it analyzes

vigil automatically detects the following dependency files:

FileEcosystem
requirements.txtPyPI (Python)
requirements-dev.txtPyPI (Python)
requirements-test.txtPyPI (Python)
pyproject.tomlPyPI (Python)
setup.pyPyPI (Python)
setup.cfgPyPI (Python)
package.jsonnpm (JavaScript)

vigil tests

Specialized subcommand for analyzing test quality. Runs only the rules in the test-quality category.

Syntax

vigil tests [TEST_PATHS...] [OPTIONS]

If no paths are specified, analyzes the tests/ directory.

Options

OptionShort formTypeDefaultDescription
--format-fhuman|jsonhumanOutput format
--min-assertionsint1Minimum assertions per test
--verbose-vflagfalseDetailed output

Examples

# Analizar directorio de tests por defecto
vigil tests

# Analizar directorio especifico
vigil tests tests/ spec/

# Requerir al menos 2 assertions por test
vigil tests --min-assertions 2

# Output JSON
vigil tests -f json

vigil init

Generates a .vigil.yaml configuration file with sensible defaults.

Syntax

vigil init [PATH] [OPTIONS]

Options

OptionTypeDefaultDescription
--strategystrict|standard|relaxedstandardConfiguration preset
--forceflagfalseOverwrite existing file

Strategies

Strategyfail_onmin_age_daysmax_token_lifetime_hoursRecommended use
strictmedium601Environments with high compliance requirements
standardhigh3024Most projects
relaxedcritical772Prototypes or early-stage projects

Examples

# Generar config con defaults
vigil init

# Generar config estricta
vigil init --strategy strict

# Generar config en otro directorio
vigil init /ruta/al/proyecto

# Sobrescribir config existente
vigil init --force

vigil rules

Lists all available rules with their descriptions, severities, and references to security standards.

Syntax

vigil rules

Example output

  DEPENDENCY
  ----------------------------------------
  DEP-001    CRITICAL  Hallucinated dependency
                       Package declared as dependency does not exist in the public registry.
                       [OWASP: LLM03, CWE-829]
  DEP-002    HIGH      Suspiciously new dependency
                       Package exists but was published less than 30 days ago.
                       [OWASP: LLM03]
  ...

  AUTH
  ----------------------------------------
  AUTH-001   HIGH      Unprotected sensitive endpoint
                       Endpoint handling sensitive data without authentication middleware.
                       [OWASP: LLM06, CWE-306]
  ...

Exit codes

All scan subcommands (scan, deps, tests) use the same exit codes:

CodeConstantMeaning
0SUCCESSNo findings above the configured threshold
1FINDINGSFindings found above the threshold
2ERRORRuntime error

Usage in scripts

# Usar en un script de CI
vigil scan src/ --fail-on high
if [ $? -eq 1 ]; then
    echo "vigil encontro problemas de seguridad"
    exit 1
fi

# Usar con operadores logicos
vigil scan src/ && echo "Limpio" || echo "Hay findings"

Alternative invocation

vigil can also be run as a Python module:

python -m vigil scan src/
python -m vigil --help

This is useful when vigil is not in the PATH or when working with multiple virtual environments.