Claude Code
The steps below will setup Claude Code with GitHub Actions.
1. Configure Secrets
In your GitHub repository settings, add the following secrets:
KAIMO_API_KEY: Your API key for authentication.
You can obtain an API key by going to Kaimo’s web app and clicking API Keys at the top of the homepage.
Claude Code Authentication
Step 1: Install the GitHub App
Install the Claude GitHub app to your repository: https://github.com/apps/claude
Step 2: Choose Authentication Method
You must authenticate for Claude Code in one of two ways:
Option 1: Claude Pro/Max
-
Add
CLAUDE_CODE_OAUTH_TOKENas a repository secret. -
Obtain the OAuth token by running
claude setup-tokenlocally on your computer. -
In the pipeline (shown above), replace this line:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Option 2: API Key Authentication
- Add
ANTHROPIC_API_KEYas a repository secret. - Keep the pipeline configuration as shown above.
2. Create A Workflow File
Copy/paste the content below into a file named .github/workflows/claude.yml in your repository. We’ll customize the file to match your specific setup in the next step.
name: Claude PR Assistant
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
claude-code-action:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: |
npm ci --prefix backend
npm ci --prefix frontend
- name: Start backend
run: |
CI=false npm run dev --prefix backend &
npx wait-on http://localhost:3001
echo "Backend server is ready!"
- name: Start frontend
run: |
CI=false npm run dev --prefix frontend &
npx wait-on http://localhost:3000
echo "Frontend server is ready!"
- name: Create a test user
run: |
npm --prefix backend run add-user -- '${{ secrets.TEST_USER_USERNAME }}' '${{ secrets.TEST_USER_PASSWORD }}'
- name: Run Claude PR Action
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
mcp_config: |
{
"mcpServers": {
"kaimo": {
"command": "npx",
"args": [
"-y",
"--registry=https://packages.kaimo.ai",
"@kaimo-ai/mcp-server"
],
"env": {
"API_KEY": "${{ secrets.KAIMO_API_KEY }}",
"TEST_USER_USERNAME": "${{ secrets.TEST_USER_USERNAME }}",
"TEST_USER_PASSWORD": "${{ secrets.TEST_USER_PASSWORD }}",
"TARGET_URL": "http://localhost:3000"
}
}
}
}
timeout_minutes: "60"
allowed_tools: |
mcp__kaimo__execute_test_flow Next, you’ll need to modify this workflow file to match your specific needs by following the guide here.