CLI Installation & Setup
Run GitCaptain AST parsers directly in your local terminal before committing or pushing code.
Run GitCaptain AST parsers directly in your local terminal before committing or pushing code.
Installation Options
npm / npx (Universal)
# Global installation
npm install -g gitcaptain
# Or run instantly without installation
npx gitcaptain reviewHomebrew (macOS & Linux)
brew tap gitcaptain/tap
brew install gitcaptainStandalone Binary (curl)
curl -fsSL https://gitcaptain.com/install.sh | shTerminal Authentication
Link your local terminal to your GitCaptain account:
gitcaptain loginThis opens your default browser, confirms your GitHub session, and saves a cryptographically signed personal token in ~/.gitcaptain/credentials.
Offline BYOK Mode
You can also run GitCaptain completely decoupled from our cloud service by supplying your provider API key as an environment variable:
export GEMINI_API_KEY="AIzaSyYourSecretKey"
gitcaptain review --localIn this mode, all AST parsing and API calls happen directly from your local terminal.
Git Hooks & Husky Integration
Block high-risk bugs, circular imports, and broken typings before code ever leaves a developer machine.
Block high-risk bugs, circular imports, and broken typings before code ever leaves a developer machine.
Husky Pre-Push Setup
Integrate GitCaptain with Husky to guard remote branches against regressions:
# 1. Install husky if not already configured
npm install -D husky
npx husky init
# 2. Add GitCaptain review to the pre-push hook
echo "npx gitcaptain review --fail-on-risk=high" > .husky/pre-push
chmod +x .husky/pre-pushNative .git/hooks Setup
If your repository does not use Husky, configure a native Git hook:
cat << 'EOF' > .git/hooks/pre-push
#!/usr/bin/env bash
echo "🛡️ GitCaptain: Analyzing staged changes before push..."
npx gitcaptain review --diff-only --fail-on-risk=high
if [ $? -ne 0 ]; then
echo "❌ GitCaptain found high-risk defects. Push aborted."
exit 1
fi
EOF
chmod +x .git/hooks/pre-pushPre-Push Enforcement Behavior
git push, the hook runs GitCaptain against the outgoing commits.Bypassing Hooks in Emergencies
In situations where a critical hotfix must be pushed immediately:
git push --no-verifyCLI Commands & Flags Reference
Complete manual for all GitCaptain terminal flags, output formats, and CI/CD parameters.
Complete manual for all GitCaptain terminal flags, output formats, and CI/CD parameters.
Core Commands
| Command | Description |
|---|---|
| `gitcaptain login` | Authenticate terminal with your GitCaptain account. |
| `gitcaptain review` | Run AI code review on current branch diff. |
| `gitcaptain check` | Run quick syntax-tree verification without inference calls. |
| `gitcaptain config` | Inspect active `.gitcaptain.yml` resolution. |
| `gitcaptain version` | Print current CLI version and AST engine build. |
Review Command Flags
gitcaptain review [flags]--diff-only: Inspect only uncommitted git changes instead of full branch.--staged: Inspect only files staged with git add.--fail-on-risk=: Set exit code to 1 if risk meets threshold (low, medium, high, critical).--provider=: Override configured provider (google, groq, openrouter).--json: Output findings as machine-readable JSON for integration into custom scripts.CI/CD Pipeline Parameters
Run GitCaptain in GitHub Actions or GitLab CI runners:
# .github/workflows/gitcaptain.yml
name: GitCaptain CLI Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run GitCaptain Review
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
npx gitcaptain review --fail-on-risk=critical --json > findings.json