
Amp Autofix Example
https://github.com/snarktank/amp-autofix-example- Category
- Developer Tools
- Rank
- No. 1931Tools index
Previous survey · No. 1920 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- snarktank
- GitHub
- 8 stars
- Date
About
Reference setup using Amp AI to automatically detect and fix production errors via GitHub Actions.
What it does
Production logs flow into a signed webhook, which selects likely failures and sends compact error details to a repository workflow. Amp receives that context, edits the application on a new branch, verifies the build, and opens a pull request for human approval. Optional email alerts announce created pull requests.
Why it's ranked here
This is a useful, unusually complete reference for connecting error intake to a reviewable code change. It includes filtering, deduplication, a kill switch, build checks, branching, pull request creation, and notifications. The verdict is mixed because setup documentation misses one required repository setting, while several operational failures can pass without clear reporting.
What's good
The safety boundaries are concrete. Requests require a timing-safe signature check, the webhook excludes its own errors, and each batch produces at most three workflow dispatches. Amp works on a separate branch, the workflow checks the build, and nothing merges automatically. That keeps generated changes visible and subject to normal human review.
Tradeoffs
The setup spans Vercel, GitHub Actions, Amp, multiple secrets, and optionally Resend. Instructions omit the repository setting required by the webhook. Error detection relies partly on broad message words, so false positives are plausible. Dispatch responses are not checked for failure. The test route is intentionally public, and Amp receives unrestricted command permission inside the workflow runner.
How to use it well
Use it as a starting point for a Next.js application already hosted on Vercel and maintained through GitHub pull requests. Add stronger dispatch error handling, restrict the public test route after validation, tune error matching, and keep mandatory review. It does not replace monitoring, incident triage, regression tests, or production rollback procedures.
Technical notes+
app/api/webhooks/log-drain/route.ts verifies x-vercel-signature with HMAC-SHA1 and timingSafeEqual, filters error and fatal logs plus 5xx responses and message patterns, deduplicates by the first 100 message characters, caps dispatches at three, and calls GitHub repository dispatch without checking response.ok. It requires GITHUB_REPO, although README.md does not list that variable during setup. .github/workflows/auto-fix.yml installs @sourcegraph/amp, invokes amp --dangerously-allow-all -x, runs npm run build:ci, pushes a generated branch, creates a PR with gh, and optionally posts to Resend. Its step conditions include contains(github.event.client_payload.error_message, ''), which is always true, though later shell checks prevent a PR when no branch was pushed. app/api/test-autofix/route.ts exposes a GET route that deliberately throws.
Observed
- License
- MIT License
- Primary language
- TypeScript for the Next.js API routes
- Install surface
- Copy a GitHub Actions workflow and Next.js API routes, then install Amp CLI through npm in CI
- Interfaces
- Signed Vercel Log Drain webhook, GitHub repository dispatch, Amp CLI, GitHub pull requests, and optional Resend email API
- Platform support
- Next.js on Vercel with GitHub Actions running Node.js 20 on Ubuntu
- Safety structure
- Includes a kill switch, webhook self-loop exclusion, three-dispatch batch limit, build verification, and mandatory human pull request review
Read from README.md, app/api/test-autofix/route.ts, app/api/webhooks/log-drain/route.ts, LICENSE, .github/workflows/auto-fix.yml.
What it can do
Detect production errors automatically
Production application runtime data → Error detection alerts and analysis
Generate code fixes for detected errors
Error logs and application code context → Code patches and fixes
Apply fixes via GitHub Actions workflow
Generated code fixes and repository access → Automated pull requests with fixes
Monitor application health continuously
Application performance metrics and logs → Health status reports and alerts
Integrate with GitHub repository workflow
GitHub repository configuration and credentials → Automated CI/CD pipeline setup
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.