Skip to main content

Commands

Warden provides several commands for different workflows:

warden

Main command - analyze code for issues

warden init

Initialize Warden in your repository

warden --fix

Apply suggested fixes automatically

warden logs

Manage analysis logs and history

warden add

Add skills to your configuration

warden sync

Update remote skill definitions

warden setup-app

Configure GitHub App integration

Common Patterns

Analyze uncommitted changes

The most common workflow - analyze files you’ve modified:
npx warden
This analyzes:
  • Unstaged changes (modified files not added to git)
  • Staged changes (files added but not committed)

Analyze specific files

Target specific files or directories:
# Single file
npx warden src/api/users.ts

# Directory
npx warden src/api/

# Multiple targets
npx warden src/api/ src/utils/auth.ts

# Glob patterns
npx warden 'src/**/*.ts'

Analyze git diffs

Compare branches or commits:
# Compare with main branch
npx warden main..HEAD

# Compare two commits
npx warden abc1234..def5678

# Compare with a branch
npx warden origin/main..feature-branch

Apply fixes automatically

Review and apply suggested fixes:
# Interactive mode - review each fix
npx warden --fix

# Auto-apply all fixes
npx warden --fix --yes

# Combine with targets
npx warden --fix src/api/

Control output verbosity

Adjust how much Warden prints:
# Quiet mode - only errors
npx warden --quiet

# Normal mode (default)
npx warden

# Verbose mode - show progress
npx warden --verbose

# Debug mode - show everything
npx warden --debug

Output formats

Export findings in different formats:
# JSON output
npx warden --json

# JSONL (one finding per line)
npx warden --output findings.jsonl

# Both terminal and file
npx warden --output findings.jsonl --verbose

Global Options

These options work with all commands:

—help, -h

Show help for any command:
warden --help
warden init --help
warden logs --help

—version, -v

Show the installed version:
warden --version

—config

Use a custom config file:
warden --config ./configs/strict.toml
Default: warden.toml in the repo root.

—no-color

Disable colored output:
warden --no-color
Useful for CI environments or when piping output.

Exit Codes

Warden uses these exit codes:
CodeMeaning
0Success - no failures above threshold
1Failure - findings exceed failOn threshold
130User aborted (Ctrl+C)
Use exit codes in scripts:
if npx warden; then
  echo "✓ Passed"
else
  echo "✗ Failed"
  exit 1
fi

Environment Variables

ANTHROPIC_API_KEY

Anthropic API key for authentication:
export ANTHROPIC_API_KEY=sk-ant-...
npx warden

WARDEN_ANTHROPIC_API_KEY

Warden-specific API key (takes precedence):
export WARDEN_ANTHROPIC_API_KEY=sk-ant-...
npx warden

GITHUB_TOKEN

GitHub token for API access:
export GITHUB_TOKEN=ghp_...
npx warden
Used when analyzing pull requests or fetching remote skills.

NO_COLOR

Disable colored output:
export NO_COLOR=1
npx warden

WARDEN_LOG_LEVEL

Set the log level:
export WARDEN_LOG_LEVEL=debug
npx warden
Values: quiet, normal, verbose, debug

Configuration File

The CLI reads configuration from warden.toml in your repository root. You can specify a different path with --config:
npx warden --config ./configs/strict.toml
See Configuration Reference for details.

Shell Completion

Warden doesn’t currently provide built-in shell completion, but you can create aliases for common workflows:
.bashrc
alias wf="npx warden --fix"
alias wv="npx warden --verbose"
alias wq="npx warden --quiet"

CI/CD Integration

GitHub Actions

Use the official action:
- uses: getsentry/warden@v1
  with:
    anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

GitLab CI

Run as a regular CLI command:
warden:
  script:
    - npx warden
  only:
    - merge_requests

Jenkins

Run in a shell step:
sh 'npx warden'

CircleCI

Add to your config:
- run:
    name: Run Warden
    command: npx warden

Best Practices

Add Warden to your pre-commit hook to catch issues early:
.husky/pre-commit
#!/bin/sh
npx warden || exit 1
Local development can be lenient, CI can be strict:
# Local - show all findings
npx warden

# CI - fail on high severity
npx warden --config warden.strict.toml
Save logs for later review:
npx warden --output ./logs/$(date +%Y%m%d-%H%M%S).jsonl
Then review with warden logs show.
Don’t analyze everything - focus on changed files:
# Analyze only API changes
npx warden src/api/

# Analyze related test files
npx warden src/api/ test/api/

Next Steps

Main command

Learn all options for the main warden command

Initialize

Set up Warden in your repository

Auto-fix

Apply suggested fixes automatically

Configuration

Configure Warden’s behavior

Build docs developers (and LLMs) love