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.
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.
To use this template, you'll need:
gitHubRepoName
and gitHubOrgName
values to match your repositoryconst commonFields = {
'gitHubRepoName': 'your-repo-name',
'gitHubOrgName': 'your-org-name'
}
.github/workflows/lint-guardian.yml
in your repository replacing the Trigger n8n Workflow
step with your webhook:name: Lint Guardian
on:
pull_request:
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: |
{
"pull_request_number": ${{ github.event.pull_request.number }},
"repository": "${{ github.repository }}",
"branch": "${{ github.event.pull_request.head.ref }}",
"base_branch": "${{ github.event.pull_request.base.ref }}"
}
preventFailureOnNoResponse: true
When creating your GitHub Personal Access Token, remember to:
As GitHub documentation notes: "Personal access tokens are like passwords, and they share the same inherent security risks."
You can enhance this workflow by:
This template provides an excellent starting point that you can customize to fit your team's exact workflow and code style requirements.