Go Lint Fix
Run golangci-lint and fix all reported issues, using auto-fix first then AI for the rest.
Discovery
This skill always calls golangci-lint directly (required for --fix). Discovery finds any project-specific flags, config, or plugins to carry into those calls.
- CLAUDE.md / AGENTS.md: Check for linting instructions. Note any flags, config paths, or constraints documented there.
- Makefile targets: Check for
lintorverify-linttargets (grep -E "^(lint|verify-lint):" Makefile). Inspect the target body to extract flags such as--config,--timeout,--build-tags, or module plugin references. - Fallback: Use
golangci-lint run ./...with no extra flags.
Collect all discovered flags into a $FLAGS variable used throughout the Fix Process.
If golangci-lint Is Not Found
Report that golangci-lint is not available and direct the user to the installation docs. Do not auto-install.
Fix Process
- Baseline: Run
golangci-lint run $FLAGS ./...and record the issue count. - Auto-fix: Run
golangci-lint run --fix $FLAGS ./...to resolve all automatically fixable issues. - Re-check: Run
golangci-lint run $FLAGS ./...again to see remaining issues. - AI fixes: For each remaining issue, fix it directly in the source file.
- Verify: Re-run
golangci-lint run $FLAGS ./...after each batch of AI fixes. - Loop: Repeat steps 4–5 until the output is clean or no further progress is made.
Guidelines
- Prefer real fixes over
//nolintdirectives. Use//nolintonly as a last resort with a comment explaining why. - Generated files: Do not modify files with a
// Code generatedheader. Add//nolintat the call site or exclude the file in.golangci.ymlinstead. - Constants: Before adding a new constant to fix a magic-number lint error, check whether an equivalent constant already exists in the package or its imports.