check-linters-before-commit
Before any commit, run linters, vet, tests, and build verification; do not commit until checks pass
- License 许可
- MIT
- 所属仓库
- dimetron/pi-go
- 最近更新
- 2026-11-15
- Stars
- ★ 224
- Forks
- 34
01 前言 Front Matter
- name
- check-linters-before-commit
- tools
- bash, read, grep, find
- description
- Before any commit, run linters, vet, tests, and build verification; do not commit until checks pass
02 资源文件 23
- 参考文档chapters/ch01-introduction.md6.0 KB
- 参考文档chapters/ch02-installation.md3.8 KB
- 参考文档chapters/ch03-algorithm-lineup.md5.7 KB
- 参考文档chapters/ch04-running-experiments.md6.0 KB
- 参考文档chapters/ch05-experiment-outputs.md4.5 KB
- 参考文档chapters/ch06-plotting-results.md3.8 KB
- 参考文档chapters/ch07-key-concepts-in-rl.md7.8 KB
- 参考文档chapters/ch08-kinds-of-rl-algorithms.md8.0 KB
- 参考文档chapters/ch09-intro-to-policy-optimization.md8.5 KB
- 参考文档chapters/ch10-spinning-up-as-a-researcher.md10.1 KB
- 参考文档chapters/ch11-key-papers-in-deep-rl.md4.5 KB
- 参考文档chapters/ch12-exercises.md5.4 KB
- 参考文档chapters/ch13-benchmarks.md4.9 KB
- 参考文档chapters/ch14-vpg.md4.9 KB
- 参考文档chapters/ch15-trpo.md5.9 KB
- 参考文档chapters/ch16-ppo.md6.8 KB
- 参考文档chapters/ch17-ddpg.md7.4 KB
- 参考文档chapters/ch18-td3.md5.9 KB
- 参考文档chapters/ch19-sac.md7.7 KB
- 参考文档chapters/ch20-logger-and-utilities.md4.7 KB
- 参考文档cheatsheet.md4.9 KB
- 参考文档glossary.md5.3 KB
- 参考文档patterns.md7.7 KB
03 SKILL.md 正文
Check Linters Before Commit
You are an expert at ensuring code quality by running linters and static analysis before committing changes.
When to Use
Use this skill whenever the user asks to commit, prepare a commit, or check whether code is ready to commit. Run the checks before committing anything, and do not proceed with a commit until the required checks pass.
Workflow
1. Check What Changed
First, identify what files have changed:
git diff --name-only
git diff --cached --name-only
2. Run Linters
Run the full linting suite (uses .golangci.yml v2 config):
golangci-lint run ./...
This covers go vet, staticcheck, errcheck, errorlint, misspell, revive, and more. Falls back to go vet ./... only if golangci-lint is not installed.
3. Run Tests
Verify tests pass:
go test ./...
Since Go 1.27, go test also runs the stdversion vet check by default, which fails on
use of stdlib symbols newer than the go directive in go.mod. If a test fails that
way, bump go.mod in the same change — do not //nolint around it. See the go-127
skill.
4. Build Verification
Ensure the code builds:
go build ./cmd/pi
Success Criteria
All of the following must pass before reporting readiness or creating a commit:
- [ ]
golangci-lint run ./...exits with code 0 (no issues) - [ ]
go test ./...exits with code 0 (all tests pass) - [ ]
go build ./cmd/piexits with code 0 (builds successfully)
Output Format
Report the status of each check:
## Pre-Commit Checks
| Check | Status | Notes |
|-------|--------|-------|
| Lint (golangci-lint) | ✅ PASS / ❌ FAIL | |
| Tests | ✅ PASS / ❌ FAIL | |
| Build | ✅ PASS / ❌ FAIL | |
**Result:** Ready to commit / Fix issues before committing
If Checks Fail
For each failing check:
- Note the specific file:line where the issue occurs
- Provide the linter rule/message
- Suggest a fix or create a TODO for manual fixing
Example:
## Issues Found
### Lint Failures
1. **internal/tools/reader.go:42** — `whitespace` rule: unnecessary trailing whitespace
- Fix: Remove trailing whitespace
2. **internal/agent/runner.go:78** — `errorlint` rule: non-wrapping error creation
- Fix: Wrap error with `fmt.Errorf("context: %w", err)`
Rules
- Always run these checks before making or suggesting a commit
- Always run
golangci-lint run ./...first (most comprehensive, uses.golangci.yml) - Fall back to
go vet ./...only if golangci-lint is not installed - Do not skip or ignore linter warnings
- Do not claim code is ready to commit if any required check fails or is not run
- If there are legitimate reasons to ignore (e.g., intentional type assertions), suggest adding
//nolint:directives with justification - Check both staged (
git diff --cached) and unstaged (git diff) changes
04 同仓库更多 Skills
verify-session-flow
Formally verify the interactive session flow before or after changing it. Use when editing internal/tui/tui.go's handleKey, handleInterruptKey, handleInputSubmit, ctrlCCount or quitting, internal/tui/agent_loop.go's enqueuePrompt, submit, steerPrompt, cancelAgent or handleAgentDone, or the deferred-init splash — or when a user reports that Ctrl+C quit on the first press, that Esc did not stop a turn or a goal loop, that a queued prompt was lost when they canceled, or that the TUI hung on a spinner nothing could clear.
verify-run-pipeline
Formally verify the /run phase machine before or after changing it. Use when editing internal/tui/run.go's phase transitions (handleRunAgentDone, runGates result handling, verifyRunComplete, retryRun, reportGateHang, merge), internal/sop/verdict.go's Passed, or the checklist refresh — or when a run merged work it should not have, retried a hung gate, lost a cycle at the retry budget, or merged on a stale PASS.
verify-history-rewrite
Formally verify the session-history rewrite path before or after changing it. Use when editing internal/session/autocompact.go, internal/session/compaction*.go, internal/session/store.go's Compact/ClearEvents/rewriteEvents, internal/agent/agent.go's Run/RunStreaming/runPreTurn, or internal/tui/commands.go's clearConversation/clearSessionContext and the context gauge — or when a turn is canceled mid-flight, a tool call and its result get separated, a session's history disappears while the agent is still working, or the model is sent a tool result whose call was compacted away.
verify-goal-loop
Formally verify the /goal automatic loop before or after changing it. Use when editing internal/tui/goal.go, internal/tui/agent_loop.go's handleAgentDone/cancelAgent/steerPrompt, or internal/tools/goal.go's GoalController — or when a goal loop will not stop, stops one cycle early, closes a goal that is not met, or restarts a goal you finished.
verify-agent-lifecycle
Formally verify the subagent lifecycle before or after changing it. Use when editing internal/subagent/orchestrator.go's Spawn, trackAgent, forwardAgentEvents, terminalStatus, Cancel, ShutdownWithTimeout or evictCompletedAgentsLocked, or internal/subagent/pool.go — or when a canceled agent is reported as failed, an agent vanishes from the list with no verdict, the orchestrator panics on a pool release, or an agent can be canceled twice.
test-new-skill
暂无简介