Getting Started
Run critiq check from any repository, install the rules catalog when prompted, pin packages for CI, and scope scans to a diff.
#Prerequisites
- Node.js 20 or newer.
- npm 10 or newer (yarn, pnpm, and bun work when you pin packages locally).
- A repository with source files you want to scan.
#Quick start
Run this from your repository root. You do not need to install anything first in an interactive terminal: when the default @critiq/rules catalog is missing, Critiq detects whether the CLI is installed locally or globally, checks your repo and global Node modules, then prompts you to install the catalog in the repository or globally. Critiq picks npm, yarn, pnpm, or bun from your lockfile, prints the exact install command, and continues the scan after a successful install.
The target argument defaults to ., so npx @critiq/cli check and npx @critiq/cli check . target the current working tree.
#Pin for CI and teams
Add both packages as dev dependencies when you want reproducible versions in package.json, shared scripts, or CI. This is the recommended path for pull request checks and non-interactive runners (where Critiq prints install instructions instead of prompting).
#One-shot without installing
Use this when you want a single command that downloads both @critiq/cli and @critiq/rules into a temporary npx cache, for example in a snippet or a non-interactive environment that should not modify your repository.
#Scan behavior
- If
.critiq/config.yamlexists, the scan uses it. If it does not exist, Critiq falls back to the default OSS catalog andrecommendedpreset. - Built-in ignores skip dependency output and generated folders before your own
ignorePathsare applied. - Test files are excluded by default so the first run focuses on production paths. Enable
includeTests: truewhen you want rules to inspect test code as well. - Findings should be treated as deterministic rule results. The rule ID, category, severity, and evidence are stable enough to use in scripts and CI checks.
#Diff-scoped scan
Use diff mode when a pull request or local branch only needs findings for changed files and changed ranges. Both --base and --head are required.
#Output formats
--format prettyis the default for terminal output.--format jsonis available for scripts, checks, and CI parsing.--format sarifproduces a SARIF document for security-platform ingestion.checkonly.--format htmlproduces a human-readable report for review handoff.checkonly.
#Audit secrets
critiq audit secrets is a dedicated secret-pattern scan that exits non-zero on findings. critiq check already runs the same scanner in an advisory pass (it does not affect the check exit code), so use the audit when you want secrets to fail the run.
See the Audit Secrets guide for configuration tuning, JSON envelope, and sample pre-commit / pre-push hooks. The Scan code guide covers the catalog scan workflow and how it relates to audits.
#Exit codes
| Code | Meaning |
|---|---|
0 | Success. |
1 | Findings, user/input errors, invalid configuration, or validation diagnostics. |
2 | Internal/runtime errors. |
#Package scripts
For local repeatability, add Critiq to the same script surface your team already uses for tests and linting after you pin the packages.
#Common failures
Unknown optionusually means the command does not support that flag yet. Check the CLI reference for the exact command surface.The check command no longer accepts a rules globmeans rule selection should move into.critiq/config.yaml.- If Critiq reports that the rules catalog package is missing in CI or with
--format json, pin@critiq/cliand@critiq/rulesinpackage.jsonor use the one-shotnpx -p @critiq/cli -p @critiq/rulesform. - If a scan exits with
1, inspect whether the cause is a finding, invalid input, or a config diagnostic before treating it as a runtime failure.
#Language support
Tests are excluded by default unless includeTests: true is set in .critiq/config.yaml. TypeScript and JavaScript have the deepest support today. Go, Java, PHP, Python, Ruby, and Rust have narrower phase-one adapter coverage.