Get the FREE Ultimate OpenClaw Setup Guide →

lint-and-fix

npx machina-cli add skill yu-iskw/coding-agent-skills/lint-and-fix --openclaw
Files (1)
SKILL.md
1.0 KB

Lint-and-Fix

Purpose

An autonomous loop to format the codebase, run linters, and fix any remaining violations until the project passes format and lint checks.

Loop Logic

  1. Format: Run make format (trunk fmt).
  2. Identify: Run make lint to list current failures.
  3. Analyze: Read the linter output and the affected code.
  4. Fix: Apply the minimum necessary change to resolve each issue.
  5. Verify: Re-run make format and make lint.
    • If both pass: Done.
    • If failures remain: Repeat from step 2 (or move to the next issue).

Termination Criteria

  • No failures from make lint after fixes.
  • Optional: Cap iterations (e.g. 5) to avoid unbounded loops.

Reference

Format and lint commands are defined in the project Makefile: make format runs trunk fmt -a; make lint runs trunk check -a -y.

Source

git clone https://github.com/yu-iskw/coding-agent-skills/blob/main/.cursor/skills/lint-and-fix/SKILL.mdView on GitHub

Overview

Lint-and-Fix automates formatting and linting by running make format (trunk fmt) and make lint (trunk check). It then applies the minimal changes to resolve violations and repeats the process until both checks pass. This helps keep the codebase consistently formatted and lint-clean.

How This Skill Works

The tool runs trunk fmt via make format to format the code, then runs trunk check via make lint to identify failures. It analyzes the reported issues, applies the smallest necessary fixes, and re-runs format and lint to verify progress, looping until success or a defined cap.

When to Use It

  • You’re starting a codebase to ensure formatting and lint compliance.
  • You’ve added new code and want to fix any resulting lint or style violations.
  • You’re preparing for a code review and want to minimize lint noise beforehand.
  • CI lint checks fail locally and you need to reproduce and fix issues quickly.
  • You’re refactoring or mass-changing code and want to re-run format and lint iteratively.

Quick Start

  1. Step 1: Run make format to auto-format code (trunk fmt -a).
  2. Step 2: Run make lint to identify failures (trunk check -a -y).
  3. Step 3: Apply minimal fixes and re-run format and lint; repeat until both pass or cap iterations.

Best Practices

  • Always run make format first to normalize diffs before linting.
  • Review lint output carefully and target the minimal set of changes.
  • Fix only what is necessary to satisfy a rule to keep commits clean.
  • After fixes, re-run make format and make lint to confirm progress.
  • Set a reasonable iteration cap (e.g., 5) to avoid unbounded looping.

Example Use Cases

  • A trunk-based project with a CI-like lint surface regularly uses lint-and-fix before releases.
  • After adding a new module, developers run lint-and-fix to catch style issues early.
  • When a lint failure appears after a refactor, the loop auto-resolves formatting and minor violations.
  • Teams align on formatting by running lint-and-fix locally before pushing changes.
  • Before a code-freeze, developers execute lint-and-fix to ensure a clean state.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers