An automated code quality agent that fetches your code, detects bugs using an LLM, and fixes them — but only when you say so.
This n8n workflow acts as a human-in-the-loop DevOps bot. It autonomously audits a GitHub repository for bugs, inefficiencies, and redundancy, then reports its findings — it never commits blindly.
Instead of pushing AI-generated fixes straight to your repo, it sends a detailed report to Discord. You review the findings, and only if you approve (via a secure webhook link) does the agent push the fix to your repository.
- 📂 Auto-Fetch — recursively scans a GitHub repository for source files (
.js,.ts,.py,.cpp, and more) - 🧠 Intelligent Analysis — uses an LLM to identify logic errors, inefficient algorithms (e.g. avoidable O(n²) patterns), and redundant code
- 🛡️ Human-in-the-Loop — zero code is committed without an explicit approval click
- 🔔 Real-Time Reporting — delivers formatted Markdown bug reports directly to Discord
- ⚡ Automated Fixes — applies the AI-suggested fix immediately upon approval
The workflow runs as a linear 4-phase pipeline:
- Ingestion — fetches the repo's file tree from GitHub and filters for source code files
- Analysis — the LLM reads each file and returns a structured report plus a suggested fix
- Authorization — the workflow pauses and sends a report + approval link to Discord
- Execution — once approved, the workflow resumes and commits the fix via the GitHub API
- n8n instance — self-hosted or Cloud (v1.0+)
- GitHub account — a fine-grained Personal Access Token scoped to the specific repo you're auditing, with Contents: Read & Write permission only (avoid broader scopes)
- LLM API access — an OpenAI API key (GPT-4o or similar), or swap in a local model via Ollama/llama.cpp for a fully free, private setup
- Discord server — with permission to create a webhook
- Import the workflow
In n8n: Workflows → Import from File, and select
workflow.jsonfrom this folder. - Configure credentials
- GitHub API — create a credential using your fine-grained Personal Access Token
- LLM provider — create a credential using your OpenAI API key, or point the LLM node at your local Ollama/llama.cpp server instead
- Set up node values
- Manual Trigger — set your default Owner, Repo, and Branch
- Send to Discord — paste your Discord Webhook URL
- Filter Code Files (optional) — add extra file extensions if needed
- Trigger the agent — open the workflow in n8n and run it (Manual Trigger, or your own scheduled/event trigger)
- Wait for analysis — the agent processes files in batches
- Check Discord — you'll receive a report per flagged file, e.g. "🐞 Bug Report for
src/app.js" - Approve or ignore
- To fix: click the Approve & Commit link in the message
- To skip: ignore the message — no changes are made
| Placeholder | Where | What to put |
|---|---|---|
| GitHub credential | Credentials panel | Your fine-grained PAT, scoped to one repo |
| LLM credential | Credentials panel | Your OpenAI key, or your local server's base URL |
| Discord Webhook URL | "Send to Discord" node | Your server's webhook URL |
| Owner / Repo / Branch | Manual Trigger node | The repo you want this agent auditing |
- Pull Request integration — open a PR on a
fix/ai-branchinstead of committing directly tomain - RAG / context-awareness — use a vector store so the agent understands cross-file dependencies
- Local LLM support — swap OpenAI for Ollama/llama.cpp for a fully private, zero-cost setup
- Compiler loop — run a build/test command to verify the fix before requesting approval
- Scope the GitHub token to exactly one repository — never a classic token with full
repoaccess across your account - Never grant this workflow permission to push directly to
main— pair it with branch protection on the target repo - Treat the Discord approval link as sensitive — anyone with that link can trigger the commit
Part of the n8n_workflows collection. See the root README for the full workflow index, and CONTRIBUTING.md for how to submit changes.