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
make lint(which executestrunk check -a) to list current violations. - Analyze: Examine the output from Trunk, focusing on the file path, line number, and error message.
- Fix:
- For formatting issues, run
make format(which executestrunk fmt -a). - For linting violations, apply the minimum necessary change to the source code to resolve the error.
- For formatting issues, run
- Verify: Re-run
make lint.- 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
make lint. - Reached max iteration limit (default: 5).
Examples
Scenario: Fixing a formatting violation
make lintreports formatting issues insrc/your_package/main.py.- Agent runs
make format. make lintnow passes.
Resources
- Python Development Commands: Common commands for linting and formatting.
- Trunk Documentation: Official documentation for the Trunk CLI.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.