Automated code reviews using Amp with two deployment options: GitHub Actions or Webhook Service.
- Reviews code for bugs, security issues, logic errors and more
- Runs automatically on PR open; can manually trigger re-reviews
- Can suggest fixes for identified issues
- Aware of existing PR conversation
Requirements: Amp account with API key required for code reviews.
Option | Setup | Maintenance |
---|---|---|
GitHub Actions | Copy workflow file | None |
Webhook Service | GitHub App + hosting | Server management |
The simplest way to add code reviews to any repository:
-
Copy the workflow file to your repo:
mkdir -p .github/workflows # Copy review.yml from this repo to .github/workflows/
-
Configure repository settings:
- Go to your repo → Settings → Secrets and variables → Actions
- Add Variable:
AMP_SERVER_URL
=https://ampcode.com
- Add Secret:
AMP_API_KEY
= your Amp API key
-
Create a pull request - reviews will run automatically!
GitHub App + external service with full API access, queue management, and custom integrations.
To build and publish the Docker image:
# Build for GitHub Actions (linux/amd64)
podman build --platform linux/amd64 -t ghcr.io/your-username/cra-github:latest .
# Push to GitHub Container Registry
podman push ghcr.io/your-username/cra-github:latest
Update the workflow file to use your image: docker://ghcr.io/your-username/cra-github:latest
Example for the current review.yml
:
podman build -t ghcr.io/sayansisodiya/cra-github:latest . && podman push ghcr.io/sayansisodiya/cra-github:latest
-
Clone and Install
cd cra-github pnpm install
-
Build (required for toolbox)
pnpm run build
-
Environment Setup
cp .env.example .env
-
Start Development Server
pnpm run dev
-
Create GitHub App
- Go to GitHub Settings > Developer settings > GitHub Apps > New GitHub App
- Set webhook URL to placeholder (e.g.,
https://example.com/webhook
) - Download private key, note App ID and webhook secret
-
Configure Environment
cp .env.example .env # Fill in GitHub App credentials from step 1 # For Docker, use GITHUB_APP_PRIVATE_KEY (base64) instead of file path: # cat private-key.pem | base64 -w 0
-
Start Container
docker compose up --build # or with Podman: podman-compose up --build
-
Update Webhook URL
- For local dev: start ngrok (
ngrok http 5053
) - Update GitHub App webhook URL to
https://your-url/github/webhook
- For local dev: start ngrok (
-
Install the App
- Visit
http://localhost:5053/github/install
- Select repositories to enable code reviews
- Visit
- Create a GitHub App in your GitHub settings (
Settings > Developer settings > GitHub Apps
) - Set the following permissions:
- Repository: Pull requests (Read & Write)
- Repository: Checks (Write)
- Repository: Contents (Read)
- Repository: Metadata (Read)
- Repository: Webhooks (Write)
- Configure webhook settings:
- Webhook URL:
https://your-domain.com/github/webhook
(use your APP_BASE_URL) - Subscribe to: Pull request events and Installation events
- Webhook URL:
- Generate and download a private key from the app settings page
Copy .env.example
to .env
and configure the required values.
The GitHub App requires a private key for authentication. You have two options:
- Download the
.pem
file from your GitHub App settings - Place it in your project root as
private-key.pem
- Set
GITHUB_APP_PRIVATE_KEY_PATH=./private-key.pem
- Add
*.pem
to your.gitignore
to avoid committing the key
- Convert your private key to base64:
cat private-key.pem | base64 -w 0
- Set the result as
GITHUB_APP_PRIVATE_KEY
in your environment - The application will automatically decode and format the key
Note: Docker setup requires the base64 encoded key in .env
- private key files are not accessible in containers.
Contains GitHub settings, queue configuration, server settings, Amp integration, and the AI review prompt. Environment variables are interpolated using ${VARIABLE_NAME}
syntax.
To customize review behavior, modify the prompt_template
section.
GET /
- Service informationGET /health
- Health checkGET /queue/status
- Queue status informationGET /jobs/:jobId
- Job status informationPOST /github/webhook
- GitHub webhook endpointGET /github/install
- Start GitHub App installationGET /github/callback
- GitHub App installation callback
For development, you'll need to expose your local server to the internet for GitHub webhooks to work:
-
Install ngrok:
npm install -g ngrok
or download from ngrok.com -
Start your local server:
pnpm run dev
-
Expose with ngrok (in a separate terminal):
ngrok http 5053
-
Update your environment:
- Copy the ngrok URL (e.g.,
https://abc123.ngrok.io
) - Update
APP_BASE_URL
in your.env
file - Update your GitHub App webhook URL to
{your-ngrok-url}/github/webhook
- Copy the ngrok URL (e.g.,
pnpm run build
pnpm run type-check
pnpm run lint
The app uses Amp's toolbox feature to provide GitHub operations as simple executable tools. Tools are located in toolbox/
and copied to dist/toolbox/
during build.
Available tools:
leave_inline_comment
- Leave line-specific code feedbackleave_general_comment
- Leave overall PR feedbackget_pr_comments
- Retrieve existing PR comments
- Hono.js: Fast web framework for the server
- GitHub API: Integration with GitHub's REST API
- GitHub Apps: Secure app installation and JWT authentication
- Job Queue: Background processing for code reviews
- Amp: AI-powered code analysis engine
- Toolbox: Simple executable tools for AI agent integration
MIT License