Skip to content

CLI reference ​

Install the beta with npm install -g codeguard-local@beta; the executable is codeguard. In a local checkout, use node dist/cli/index.js after building.

Install and verify the beta ​

sh
npm install -g codeguard-local@beta
codeguard --help
codeguard --version

Commands ​

CommandPurpose
codeguard --helpShow commands and options.
codeguard --versionPrint the installed version.
codeguard initCreate codeguard.config.json in the current directory; never overwrites.
codeguard check [path]Analyze a project directory; path defaults to ..
codeguard check [path] --jsonWrite the existing machine-readable AnalysisResult schema to stdout.
codeguard watch [path]Analyze, then re-analyze on source changes. See Watch mode.
codeguard watch [path] --debounce <ms>Set the change-settling delay (default 300, maximum 60000).
codeguard mcp --root <path>Start the stdio MCP server; --root is required.

Common project-local commands:

sh
codeguard init
codeguard check .
codeguard check . --json
codeguard watch .
codeguard mcp --root .

Output and exit codes ​

Typical terminal output:

text
CodeGuard analysis: sample-app
Project type: node
Language: typescript
Frameworks: none detected
Files scanned: 12

Analyzers
- typescript: completed
- javascript: skipped (No JavaScript or JSX files were found.)
- security: disabled
- architecture: disabled

Diagnostics
No diagnostics.

Summary: 0 error(s), 0 warning(s).

The CLI exits with 0 for no errors, 1 for completed analysis with errors, and 2 for configuration or execution failures. --json keeps stdout valid JSON on successful analysis and execution failures.

JSON output ​

Use --json to write the machine-readable analysis result to standard output:

sh
codeguard check . --json

The output includes the project summary, analyzer statuses, and diagnostics with their existing identifiers, severities, and file locations. Keep standard output available for the JSON document when piping it to another tool.

MCP stdout is reserved for protocol messages; startup diagnostics go to stderr. The MCP root determines the boundary for that server process.