Get the FREE Ultimate OpenClaw Setup Guide →

lint-fix

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

Lint & Fix with Trunk

Purpose

This skill provides an autonomous loop for identifying, fixing, and verifying linting and formatting issues using trunk. Use this when you need to ensure the codebase adheres to project standards or when fixing specific lint errors.

Loop Logic

  1. Auto-Format: Run trunk fmt (or trunk fmt -a) to apply automatic formatting fixes.
  2. Discovery: Run trunk check -y (or trunk check -a -y for all files) to list current linting issues.
  3. Analyze: For any remaining issues from Step 2:
    • Examine the error message and the failing code.
    • Identify the specific rule being violated (e.g., Ruff E501, Shellcheck SC2086).
  4. Fix: Apply the minimum necessary change to resolve the manual fix required.
  5. Verify: Re-run trunk check -y on the affected file(s).
    • If passed: Move to next issue.
    • If failed: Analyze the new failure and repeat the loop.

Termination Criteria

  • No more errors reported by trunk check -y.
  • Reached max iteration limit (default: 5).

Common Commands

TaskCommand
Check changed filestrunk check -y
Check all filestrunk check -a -y
Format changed filestrunk fmt
Format all filestrunk fmt -a
Check specific filetrunk check -y <path>
Format specific filetrunk fmt <path>

Examples

Scenario: Fixing Python Lint Errors

  1. trunk check -y reports ruff: D103 (missing docstring) in scripts/utils.py (after auto-fixing unused imports).
  2. Agent adds the missing docstring in scripts/utils.py.
  3. trunk check -y scripts/utils.py passes.

Source

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

Overview

lint-fix automates formatting and lint checks using Trunk, then applies minimal manual fixes and re-checks until issues are resolved or a max iteration limit is reached. It helps ensure the codebase adheres to project standards and reduces repetitive error handling.

How This Skill Works

The skill runs a loop: auto-format with trunk fmt, discover issues with trunk check -y, analyze remaining issues to identify the violated rule, apply the minimal manual fix, and verify by re-running trunk check -y on affected files. The loop repeats until there are no errors or the maximum iterations are reached (default 5).

When to Use It

  • Ensure the codebase adheres to project standards before merging or releasing
  • Before committing or creating a pull request to clear lint and formatting issues
  • When a linter reports issues after an auto-format pass and needs targeted fixes
  • To resolve specific lint errors with minimal manual changes
  • When maintaining consistency across multiple files by rechecking affected areas

Quick Start

  1. Step 1: Run trunk fmt (or trunk fmt -a) to auto-format files
  2. Step 2: Run trunk check -y (or trunk check -a -y) to list current issues
  3. Step 3: For remaining issues, analyze, apply minimal fixes, then re-run trunk check -y on affected files; repeat until no errors or max iterations

Best Practices

  • Always run trunk fmt before performing checks to apply automatic formatting
  • Limit manual fixes to the minimal change required to resolve the issue
  • Carefully examine the error message and the failing code to identify the exact rule violated
  • Track iterations and stop when the max limit is reached to avoid endless loops
  • Verify fixes by re-running trunk check -y on the affected files

Example Use Cases

  • Scenario: Fixing Python Lint Errors
  • Scenario: Auto-format and fix a Rust project with trunk fmt and trunk check
  • Scenario: Resolve a Ruff E501 long line after an auto-fix
  • Scenario: Address ShellCheck SC2086 warnings in a shell script
  • Scenario: Re-run the loop until trunk check -y passes for all affected files

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers