Get the FREE Ultimate OpenClaw Setup Guide →

lint-and-fix

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

Lint and Fix Loop: Trunk

Purpose

An autonomous loop for the agent to identify, fix, and verify linting and formatting violations using Trunk.

Loop Logic

  1. Format: Run pnpm format (which executes trunk fmt) to automatically fix trivial formatting issues.
  2. Identify: Run pnpm lint (which executes trunk check) to list any remaining violations.
  3. Analyze: Examine the output from Trunk, focusing on the file path, line number, and error message. Refer to ../common-references/troubleshooting.md for environment or runtime issues.
  4. Fix: Apply the minimum necessary change to the source code to resolve the reported linting violations.
  5. Verify: Re-run the loop (starting from Format) until all issues are resolved.
    • If pnpm lint passes: Finish.
    • If it fails: Analyze the new failure and repeat the loop.

Termination Criteria

  • No more errors reported by pnpm lint.
  • Reached max iteration limit (default: 5).

Examples

Scenario: Fixing violations in a modified file

  1. Agent runs pnpm format to ensure consistent style.
  2. Agent runs pnpm lint and finds a linting violation in src/index.ts.
  3. Agent analyzes the error and applies a manual fix.
  4. Agent runs pnpm format again (part of the loop).
  5. Agent runs pnpm lint and it now passes.

Resources

Source

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

Overview

This skill orchestrates an autonomous lint-and-fix cycle using Trunk. It formats code with pnpm format, runs pnpm lint to surface violations, and applies minimal edits to repair issues, repeating until lint passes or a max iteration limit is reached, ensuring PR-ready code quality.

How This Skill Works

It runs pnpm format to auto-fix formatting, then runs pnpm lint to list remaining violations. The agent analyzes the lint output for file paths, line numbers, and messages, applies the smallest necessary changes to resolve issues, and restarts the loop from the formatting step to verify completion.

When to Use It

  • When code quality checks fail locally before submitting a PR
  • When a modified file triggers formatting or linting issues
  • To repair a broken linting state after an unrelated code change
  • When CI reports lint errors and you need an autonomous fix loop
  • To enforce consistent formatting and style across the repo

Quick Start

  1. Step 1: Run pnpm format (trunk fmt) to auto-fix trivial formatting issues
  2. Step 2: Run pnpm lint (trunk check) to surface remaining violations
  3. Step 3: If violations persist, apply the minimal fixes and re-run the loop from Step 1

Best Practices

  • Run the loop with minimal edits to avoid churn and preserve intent
  • Always start with trunk fmt via pnpm format before addressing lint errors
  • Re-run pnpm lint after each fix to confirm resolution
  • Limit iterations to the configured max (default 5) to prevent endless loops
  • Review lint messages to distinguish true issues from false positives

Example Use Cases

  • Fix a newly added formatting violation in src/index.ts and pass pnpm lint
  • Resolve a trailing comma and spacing issue in components/Button.tsx
  • Clean up YAML formatting in a config file flagged by trunk fmt
  • Repair a broken lint state after a dependency upgrade introduced new lint errors
  • After a collaborative change, re-run the loop to ensure no new violations appear

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers