Skip to main content

Installation Methods

Warden can be run via npx without installation, or installed globally for convenience. No installation required - run Warden directly:
npx warden

Install globally

Install Warden globally for faster execution:
npm install -g @sentry/warden
warden --version

Install as dev dependency

Add Warden to your project’s dev dependencies:
npm install --save-dev @sentry/warden
Then add a script to package.json:
package.json
{
  "scripts": {
    "warden": "warden",
    "warden:fix": "warden --fix"
  }
}

Authentication

Warden requires authentication with Anthropic’s API to use Claude. You have two options: If you have the Claude Code CLI installed and are logged in, Warden automatically uses your subscription. Install Claude Code CLI:
curl -fsSL https://claude.ai/install.sh | bash
Log in:
claude auth login
Verify authentication:
npx warden
If authentication succeeds, Warden runs without requiring an API key.
Claude Code CLI provides a better local development experience with automatic credential refresh and no API key management.

Option 2: API Key

Get an API key from the Anthropic Console and set it via environment variable. Set the environment variable:
export ANTHROPIC_API_KEY=sk-ant-...
npx warden
Or use the Warden-specific variable:
export WARDEN_ANTHROPIC_API_KEY=sk-ant-...
npx warden
Never commit API keys to version control. Use environment variables or secret management tools.

Precedence

Warden checks for credentials in this order:
  1. WARDEN_ANTHROPIC_API_KEY environment variable
  2. ANTHROPIC_API_KEY environment variable
  3. CLAUDE_CODE_OAUTH_TOKEN environment variable
  4. Claude Code CLI session (if logged in)

GitHub Action Setup

To use Warden in GitHub Actions, add your API key as a repository secret.
1

Get an API key

Go to the Anthropic Console and create an API key.
2

Add secret to GitHub

  1. Go to your repository Settings → Secrets and variables → Actions
  2. Click New repository secret
  3. Name: ANTHROPIC_API_KEY
  4. Value: Your API key (starts with sk-ant-)
  5. Click Add secret
3

Configure the workflow

Create or update .github/workflows/warden.yml:
.github/workflows/warden.yml
name: Warden
on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  warden:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: getsentry/warden@v1
        with:
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
4

Test the setup

Open a pull request to trigger the workflow. Warden will:
  • Analyze the PR diff
  • Post findings as review comments
  • Create a summary comment
Run npx warden init to automatically create the workflow file.

GitHub App Setup (advanced)

For better GitHub integration and finer-grained permissions, set up a GitHub App instead of using GITHUB_TOKEN.
1

Run the setup command

npx warden setup-app
This launches an interactive wizard that:
  1. Opens your browser to create a GitHub App
  2. Configures the app with required permissions
  3. Exchanges credentials for an installation token
  4. Stores the token locally
2

Benefits over GITHUB_TOKEN

GitHub Apps provide:
  • Better rate limits (5,000 requests/hour vs 1,000)
  • Finer-grained permissions
  • Visible attribution (comments show as your app)
  • Token refresh without re-authentication
3

Use in workflows

The stored credentials work automatically in both CLI and CI environments.
See the setup-app command reference for details.

System Requirements

  • Node.js: 20.0.0 or later
  • Operating systems: Linux, macOS, Windows (WSL recommended)
  • Git: Required for diff analysis
Verify your Node.js version:
node --version
If you need to upgrade Node.js, use nvm:
nvm install 20
nvm use 20

Verification

Verify your installation and authentication:
# Check version
npx warden --version

# Run a simple analysis
npx warden --help

# Test authentication
npx warden
If authentication fails, you’ll see:
❌ Authentication failed: Invalid API key or Claude Code CLI not logged in
See the authentication guide for troubleshooting.

Next Steps

Quickstart

Run your first analysis in 5 minutes

Initialize configuration

Create warden.toml and workflows

CLI reference

Learn all CLI commands

Authentication troubleshooting

Resolve authentication issues

Build docs developers (and LLMs) love