lint-fix
npx machina-cli add skill yu-iskw/meta-agent-skills/lint-fix --openclawLint & 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
- Auto-Format: Run
trunk fmt(ortrunk fmt -a) to apply automatic formatting fixes. - Discovery: Run
trunk check -y(ortrunk check -a -yfor all files) to list current linting issues. - 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, ShellcheckSC2086).
- Fix: Apply the minimum necessary change to resolve the manual fix required.
- Verify: Re-run
trunk check -yon 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
| Task | Command |
|---|---|
| Check changed files | trunk check -y |
| Check all files | trunk check -a -y |
| Format changed files | trunk fmt |
| Format all files | trunk fmt -a |
| Check specific file | trunk check -y <path> |
| Format specific file | trunk fmt <path> |
Examples
Scenario: Fixing Python Lint Errors
trunk check -yreportsruff: D103(missing docstring) inscripts/utils.py(after auto-fixing unused imports).- Agent adds the missing docstring in
scripts/utils.py. trunk check -y scripts/utils.pypasses.
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
- Step 1: Run trunk fmt (or trunk fmt -a) to auto-format files
- Step 2: Run trunk check -y (or trunk check -a -y) to list current issues
- 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