Automate GitHub PR linting with Google Gemini AI and auto-fix PRs
Needs changesNeeds changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.
What to replace before upgrading
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) AI Agent (v1.9) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (11)
- Webhook
n8n-nodes-base.webhook - AI Agent
@n8n/n8n-nodes-langchain.agent - Respond to Webhook
n8n-nodes-base.respondToWebhook - HTTP Request
n8n-nodes-base.httpRequest - Convert to File
n8n-nodes-base.convertToFile - Extract from File
n8n-nodes-base.extractFromFile - Edit Fields (Set)
n8n-nodes-base.set - Aggregate
n8n-nodes-base.aggregate - Http Request Tool
n8n-nodes-base.httpRequestTool - Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - Code
n8n-nodes-base.code
What it does
LintGuardian: Automated PR Linting with n8n & AI What It Does LintGuardian is an n8n workflow template that automates code quality enforcement for GitHub repositories. When a pull request is created, the workflow automatically analyzes the changed files, identifies linting issues, fixes them, and submits a new PR with corrections. This eliminates manual code style reviews, reduces back-and-forth comments, and lets your team focus on functionality rather than formatting. How It Works The workflow is triggered by a GitHub webhook when a PR is created. It fetches all changed files from the PR using the GitHub API, processes them through an AI-powered linting service (Google Gemini), and automatically generates fixes. The AI agent then creates a new branch with the corrected files and submits a "linting fixes" PR against the original branch. Developers can review and merge these fixes with a single click, keeping code consistently formatted with minimal effort. Prerequisites To use this template, you'll need: 1. n8n instance: Either self-hosted or using n8n.cloud 2. GitHub repository: Where you want to enforce linting standards 3. GitHub Personal Access Token: With permissions for repo access (repo, workflow, admin:repohook) 4. Google AI API Key: For the Gemini language model that powers the linting analysis 5. GitHub webhook: Configured to send PR creation events to your n8n instance Setup Instructions 1. Import the template into your n8n instance 2. Configure credentials: - Add your GitHub Personal Access Token under Credentials → GitHub API - Add your Google AI API key under Credentials → Google Gemini API 3. Update repository information: - Locate the "Set Common Fields" code node at the beginning of the workflow - Change the gitHubRepoName and gitHubOrgName values to match your repository javascript const commonFields = { 'gitHubRepoName': 'your-repo-name', 'gitHubOrgName': 'your-org-name' } 4. Configure the webhook: Create a file named .github/workflows/lint-guardian.yml in your repository replacing the Trigger n8n Workflow step with your webhook: yaml name: Lint Guardian on: pullrequest: types: opened, synchronize jobs: trigger-linting: runs-on: ubuntu-latest steps: - name: Trigger n8n Workflow uses: fjogeleit/http-request-action@v1 with: url: 'https://your-n8n-instance.com/webhook/1da5a6e1-9453-4a65-bbac-a1fed633f6ad' method: 'POST' contentType: 'application/json' data: | { "pullrequestnumber": ${{ github.event.pullrequest.number }}, "repository": "${{ github.repository }}", "branch": "${{ github.event.pullrequest.head.ref }}", "basebranch": "${{ github.event.pullrequest.base.ref }}" } preventFailureOnNoResponse: true 5. Customize linting rules (optional): - Modify the AI Agent's system message to specify your team's linting preferences - Adjust file handling if you have specific file types to focus on or ignore Security Considerations When creating your GitHub Personal Access Token, remember to: - Choose the minimal permissions needed (repo, workflow, admin:repohook) - Set an appropriate expiration date - Treat your token like a password and store it securely - Consider using GitHub's fine-grained personal access tokens for more limited scope As GitHub documentation notes: "Personal access tokens are like passwords, and they share the same inherent security risks." Extending the Template You can enhance this workflow by: - Adding Slack notifications when linting fixes are submitted - Creating custom linting rules specific to your team's needs - Expanding it to handle different types of code quality checks - Adding approval steps for more controlled environments This template provides an excellent starting point that you can customize to fit your team's exact workflow and code style requirements.