What you need
- PHP 8.2 or newer.
- Composer.
- A git repository with local changes.
- A CodeGuards API key from Integrations.
- Your organization slug and repository connection id from CodeGuards.
Install the CodeGuards CLI once, connect a repository with your workspace API key, and run security plus architecture review directly from the terminal. No local server is required: the CLI talks to CodeGuards Cloud by default.
Install once on your machine so the codeguards command is available in every repository. The installer checks PHP/Composer, installs the package, updates your shell PATH, and verifies the command.
curl -fsSL https://codeguards.io/dist/codeguards-install.sh | sh
Expected result: the CLI prints the command list and ends with CodeGuards CLI is ready. Open a new terminal tab after installation so your shell reloads the updated profile.
Prefer manual install? Run the Composer commands and add its global bin directory to PATH:
composer global config repositories.codeguards composer https://codeguards.io/dist/composer
composer global require codeguards/ci-runner
CG_BIN="$(composer global config bin-dir --absolute | awk 'END{print}')"
export PATH="$CG_BIN:$PATH"
grep -qxF "export PATH=\"$CG_BIN:\$PATH\"" ~/.zshrc || echo "export PATH=\"$CG_BIN:\$PATH\"" >> ~/.zshrc
codeguards
Open the repository you want to review and initialize CodeGuards.
cd /path/to/your/repository
codeguards init
The CLI asks for three values:
The normal flow does not ask for an API URL. Production is the default: https://codeguards.io/ci/reviews.
codeguards doctor
Expected result:
[ok] config loaded
[ok] credentials loaded
[ok] git repository detected
Review staged, unstaged, and untracked files:
codeguards review --mode=all
Generate and open an HTML report with changed files, snippets, findings, and recommendations:
codeguards review --mode=all --products=review,security --report-html --open
If your plan does not include security, CodeGuards will only return the products available to your workspace.
codeguards show --finding=1
codeguards open --finding=1
codeguards chat --finding=1 --message="why does this matter?"
codeguards fix --finding=1 --dry-run
codeguards suppress --finding=1 --reason="accepted risk for this test"
codeguards hallucination --finding=1 --reason="not true in this code path"
.codeguards/config.json repository settings
~/.config/codeguards/credentials.json API key, chmod 0600
.codeguards/session.json last review session
.codeguards/report.html latest HTML report
Generated session and report files are ignored by the CLI's local .codeguards/.gitignore. Do not commit credentials.
PATH, or install inside the repository and use ./vendor/bin/codeguards.codeguards init or set CODEGUARDS_API_KEY.git status --short, then run codeguards review --mode=all.codeguards install-hook