lint-and-fix
Scannednpx machina-cli add skill yu-iskw/coding-agent-fabric/lint-and-fix --openclawFiles (1)
SKILL.md
2.6 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
- Identify: Run
pnpm lint(which executestrunk check -yandeslint .) to list current violations. For a comprehensive check across the entire project, usepnpm lint:all(executestrunk check --allandeslint .). You can also runpnpm lint:eslintfor focused ESLint checks. - Analyze: Examine the output from Trunk or ESLint, focusing on the file path, line number, and error message. Refer to ../common-references/troubleshooting.md for environment or runtime issues.
- Fix:
- For formatting issues, run
pnpm format(which executestrunk fmt). To format all files in the project, usepnpm format:all. - For linting violations, apply the minimum necessary change to the source code to resolve the error. You can use
pnpm format:eslintto automatically fix many ESLint violations. - For security-specific checks, you can run
pnpm run lint:security.
- For formatting issues, run
- Verify: Re-run
pnpm lint(orpnpm lint:allorpnpm lint:eslintdepending on what you used initially).- If passed: Move to the next issue or finish if all are resolved.
- If failed: Analyze the new failure and repeat the loop.
Termination Criteria
- No more errors reported by
pnpm lint,pnpm lint:all, orpnpm lint:eslint. - Reached max iteration limit (default: 5).
Examples
Scenario: Fixing a formatting violation
pnpm lintreports formatting issues insrc/index.ts.- Agent runs
pnpm format. pnpm lintnow passes.
Scenario: Performing a full project cleanup
- Agent runs
pnpm lint:allto check every file. - Several formatting issues are found.
- Agent runs
pnpm format:allto fix them all at once. pnpm lint:allnow passes.
Scenario: Fixing ESLint violations
pnpm lint:eslintreports several linting errors.- Agent runs
pnpm format:eslint. pnpm lint:eslintnow passes or shows fewer errors that require manual fixing.
Resources
- Project Scripts: Definitions for all lint and format scripts.
- Trunk CLI Reference: Common commands for linting and formatting.
- Trunk Documentation: Official documentation for the Trunk CLI.
Source
git clone https://github.com/yu-iskw/coding-agent-fabric/blob/main/.claude/skills/lint-and-fix/SKILL.mdView on GitHub Overview
Lint-and-fix automates identifying and repairing linting and formatting violations using Trunk. Itβs used when code quality checks fail, before submitting PRs, or to repair broken linting states.
How This Skill Works
The loop identifies violations with pnpm lint (and pnpm lint:all for a full project check), analyzes the output to locate file and message details, and fixes issues with formatting (pnpm format or format:all) or minimal code changes for lint errors. It then re-verifies with the appropriate lint command (lint, lint:all, or lint:eslint).
When to Use It
- Code quality checks fail locally or in CI.
- Before submitting a pull request to ensure clean checks.
- Repair a broken linting state after a failing run.
- Run a full project cleanup with pnpm lint:all.
- Address ESLint issues using pnpm format:eslint to auto-fix.
Quick Start
- Step 1: Run pnpm lint to identify violations.
- Step 2: Fix issues using the appropriate commands (pnpm format for formatting, pnpm format:eslint for ESLint, or fix specific errors).
- Step 3: Re-run pnpm lint (or pnpm lint:all / pnpm lint:eslint) to verify and proceed.
Best Practices
- Start by running pnpm lint to surface violations.
- Use pnpm format for formatting issues; use pnpm format:all for project-wide fixes.
- Resolve lint issues with minimal necessary code changes; use pnpm format:eslint to auto-fix many ESLint violations.
- Re-run lint commands (pnpm lint, pnpm lint:all, or pnpm lint:eslint) after fixes.
- Consult the troubleshooting docs in the repository if environment or runtime issues arise.
Example Use Cases
- Formatting issues reported in src/index.ts are fixed with pnpm format.
- ESLint errors found by pnpm lint:eslint are auto-fixed with pnpm format:eslint.
- A stale repo is cleaned up by running pnpm lint:all and then pnpm lint to verify.
- Security-related checks are run with pnpm run lint:security and resolved.
- Broken linting states are repaired by iterating through identify -> fix -> verify cycles.
Frequently Asked Questions
Add this skill to your agents