Linter agent

From oyi77/1ai-skills · View interactive version

Linter agent is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when detecting and fixing code style violations, enforcing project conventions, ensuring consistent formatting.

How to use this skill

Skill file

Overview

This agent detects and fixes code style violations and enforces the project's lint rules across the tree. Use it after any batch of edits to keep the diff convention-clean. It reports what changed and why, so the style pass stays auditable.

Linter Agent

Quick Reference — see parent for full agent ecosystem.

The Linter Agent enforces code style, convention rules, and formatting standards across the codebase at scale. It goes beyond running a tool — it interprets project-specific conventions that static linters cannot express, fixes violations in bulk, migrates rules when upgrading linters, and surfaces only the warnings that matter. Its job is to make the codebase look like one person wrote it, even when fifty people contributed.

When Not to Use

Dependencies

Commands

# Refer to the skill's usage section for specific commands
# Adapt these to your workflow

Key Responsibilities

Code Example

"""Minimal linter agent pattern — scan and fix."""

import json, subprocess, sys
from pathlib import Path

def lint(paths: list[str], config: str | None = None, auto_fix: bool = True) -> dict:
    results = {"files_scanned": 0, "errors": 0, "warnings": 0, "auto_fixed": 0}

    for p in paths:
        target = Path(p)
        if not target.exists():
            continue

        # Run the linter (simplified — real agent integrates tool output)
        cmd = ["ruff", "check", str(target)]
        if auto_fix:
            cmd.append("--fix")
        if config:
            cmd.extend(["--config", config])

        result = subprocess.run(cmd, capture_output=True, text=True)

        # Parse output (simplified — real agent parses JSON/SARIF)
        results["files_scanned"] += 1
        if result.returncode != 0:
            results["errors"] += 1

    # Apply project-specific conventions the linter cannot enforce
    for p in paths:
        for file in Path(p).rglob("*.py"):
            content = file.read_text()
            # Detect and fix common patterns (example: ensure newline at EOF)
            if content and not content.endswith("\n"):
                file.write_text(content + "\n")
                results["auto_fixed"] += 1

    return results

if __name__ == "__main__":
    result = lint(sys.argv[1:])
    print(json.dumps(result, indent=2))

Checklist

Workflow

  1. Identify the task or trigger.
  2. Prepare inputs and configure parameters.
  3. Execute the core routine.
  4. Verify the output against expected results.
  5. Iterate based on feedback or new data.

Verification

Anti-Rationalization Table

| Rationalization | Reality |

|---|---|

| "I will fix formatting in the next PR" | Postponing lint debt compounds — every new file copies the bad patterns, making the eventual cleanup harder |

| "My editor already highlights these" | Highlighted warnings you habitually ignore become permanent noise. The linter agent treats them as blockers |

| "We have too many false positives to run lint strictly" | Each false positive deserves a rule suppression with a reason, not a habit of ignoring all warnings |

When to Use

Use before every PR commit, after merge conflicts, when adopting new lint rules or migrating configs, after bulk code generation, and when on-boarding new team members to enforce standards. Do NOT use on generated code (protobuf, OpenAPI stubs) or vendored dependencies where upstream formatting is outside your control.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.