go-precommit
Run full pre-commit workflow for Go code. Use when preparing to commit Go changes, before creating pull requests, or ensuring code quality.
When & Why to Use This Skill
The Go Pre-Commit Workflow skill is a comprehensive automation tool designed to ensure high-quality Golang code standards. It executes a rigorous, multi-step validation pipeline—including automated linting with auto-fixes, race detection, and code coverage analysis—to catch bugs and style inconsistencies before code is committed or merged. By enforcing a 'stop-on-failure' policy, it guarantees that only production-ready code progresses through the development lifecycle.
Use Cases
- Pre-Pull Request Validation: Run the full suite of tests and linters locally to ensure code meets quality requirements before submitting a PR for review.
- Automated Code Formatting: Use the integrated golangci-lint auto-fix feature to maintain a consistent codebase and resolve style issues without manual effort.
- Concurrency Debugging: Identify intermittent data races in Go applications by leveraging the built-in race detection during the testing phase.
- Code Coverage Monitoring: Generate and verify coverage profiles (cover.out) to ensure new features are adequately tested and meet project benchmarks.
| name | go-precommit |
|---|---|
| description | Run full pre-commit workflow for Go code. Use when preparing to commit Go changes, before creating pull requests, or ensuring code quality. |
| allowed-tools | ["shell"] |
| short-description | Run Go pre-commit checks |
Go Pre-Commit Workflow
Read these references:
~/.config/agent/domain/coding/go/tooling.md- Go command details~/.config/agent/domain/coding/quality.md- Quality requirements (all steps blocking)
Instructions
Execute the full pre-commit workflow in order. All steps are blocking - stop on first failure.
Step 1: Format and Lint (with auto-fix)
golangci-lint run --new-false --fix ./...
Wait for completion. If errors occur, investigate and fix before proceeding.
Step 2: Run Tests (with race detection and coverage)
go test -race -count 1 -coverprofile=cover.out ./...
All tests must pass. If failures occur:
- Read test output carefully
- Identify root cause
- Fix issues
- Re-run from Step 1
Step 3: Final Lint Check (verify no unfixed issues)
golangci-lint run --new-false ./...
Ensures all lint issues are resolved. Any errors indicate problems introduced during fixes.
Failure Handling
Per AGENT.md Problem-Solving Framework:
- Understand: Read error output carefully
- Plan: Identify root cause and fix strategy
- Execute: Apply fix methodically
- Verify: Re-run workflow from beginning
- Reflect: Consider what caused the issue
Success Criteria
All three steps must pass with zero errors before code is ready for commit.