AGENT SKILL

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

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/pi exits 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:

  1. Note the specific file:line where the issue occurs
  2. Provide the linter rule/message
  3. 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

dimetron
dimetron/pi-go

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.

★ 224
dimetron
dimetron/pi-go

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.

★ 224
dimetron
dimetron/pi-go

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.

★ 224
dimetron
dimetron/pi-go

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.

★ 224
dimetron
dimetron/pi-go

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.

★ 224
dimetron
dimetron/pi-go

test-new-skill

暂无简介

★ 224