Command Syntax
The basic syntax for running pgvet is:- A single SQL file
- A directory (recursively scans for
.sqlfiles) - Multiple files or directories
- SQL from stdin (when no arguments are provided)
Flags
pgvet accepts the following command-line flags:—format
Type:stringDefault:
textValues:
text, json
Sets the output format for diagnostics.
—rules
Type:stringDefault: (all default rules)
Format: Comma-separated list of rule names Runs only the specified rules. When you use this flag, you can also enable opt-in rules that are not part of the default set.
—exclude
Type:stringDefault: (none)
Format: Comma-separated list of rule names Excludes specific rules from the analysis.
Usage Examples
Analyze a Single File
Run all default rules on a single SQL file:Analyze a Directory
pgvet recursively scans directories for.sql files:
Analyze Multiple Paths
You can specify multiple files and directories:Analyze SQL from stdin
When you don’t provide any file or directory arguments, pgvet reads SQL from standard input:Combine Flags
You can combine multiple flags:When both
--rules and --exclude are specified, pgvet first selects the rules from --rules, then removes any rules listed in --exclude.Exit Codes
pgvet uses exit codes to indicate the result of the analysis:| Exit Code | Meaning |
|---|---|
0 | No issues found — all analyzed SQL passed the selected rules |
1 | Issues found — one or more diagnostics were reported |
2 | Usage error or parse error — invalid flags, unable to read input, or malformed SQL |
Using Exit Codes in CI
You can use the exit code to fail CI builds when issues are detected:Getting Help
To see all available flags and rules:- All command-line flags
- Default rules (always enabled unless excluded)
- Opt-in rules (only enabled when specified with
--rules)