AGENT SKILL

code-review-pi

Review code for quality, run linters, check test coverage, fix issues, and enforce gates. Save the final report to ./specs/issues/003-code-review-pi/PROMPT.md. Use before committing changes.

License 许可
MIT
所属仓库
dimetron/pi-go
最近更新
2026-11-15
Stars
★ 224
Forks
34

01 前言 Front Matter

name
code-review-pi
description
Review code for quality, run linters, check test coverage, fix issues, and enforce gates. Save the final report to ./specs/issues/003-code-review-pi/PROMPT.md. Use before committing changes.

03 SKILL.md 正文

Code Review

Review code for quality, test coverage, and fix problems found.

The canonical output artifact for this skill is ./specs/issues/003-code-review-pi/PROMPT.md. Only report success after writing the final review summary there.

Steps

  1. Identify scope: Run git diff --name-only to find modified files. If there are changes, review only modified packages. If no uncommitted changes, review all packages (./...).

  2. Run linters: Execute linters on target packages:

    • go vet ./...
    • golangci-lint run --new-from-rev=HEAD~1 ./... (if available)
  3. Run tests and check coverage:

    • go test -race -count=1 -coverprofile=coverage.out ./...
    • go tool cover -func=coverage.out
    • Identify failing tests, functions with 0% coverage, packages below 80%
  4. Review code quality: Read target files and check for:

    • Missing tests for new/changed functions
    • Error handling (missing checks, swallowed errors)
    • Resource leaks (unclosed files, connections)
    • Concurrency issues (race conditions, missing mutexes)
  5. Fix issues in parallel using subagents: For each package needing coverage fixes, spawn a subagent to work on it concurrently:

    • Use the agent tool to spawn one subagent per package that needs test coverage improvement
    • Each subagent prompt: "Write tests for uncovered functions in package <pkg>. Read the source files, identify untested functions using the coverage data, write table-driven tests covering happy path and error cases. Run go test -race ./<pkg>/... to verify. NEVER delete existing tests."
    • While subagents write tests, fix linter warnings and code quality issues yourself
    • Wait for all subagents to complete, then verify their work compiles
  6. Verify gates: All gates must pass before reporting success:

    • GATE 1: go build ./... — zero errors
    • GATE 2: go vet ./... — zero warnings
    • GATE 3: go test -race ./... — all tests pass
    • GATE 4: go test -cover ./... — >= 80% per package
    • If any gate fails, fix and re-run until all pass
  7. Report: Write the final summary to ./specs/issues/003-code-review-pi/PROMPT.md and present:

    • Gates: PASS / FAIL for each
    • Test results: pass/fail count
    • Coverage: per-package percentages (before → after)
    • Issues fixed with file:line references

Gates

All gates are mandatory. Do not report success unless every gate passes.

Gate Command Requirement
Build go build ./... Zero errors
Vet go vet ./... Zero warnings
Test go test -race ./... All pass
Coverage go test -cover ./... >= 80% per package

Examples

  • /code-review — Full review: lint, test, coverage, parallel fix, verify gates

Guidelines

  • If uncommitted changes exist, focus on modified packages
  • If no changes, review all packages for full codebase quality check
  • NEVER delete existing tests — only add or fix tests
  • Use subagents to parallelize test writing across packages (one subagent per package)
  • While subagents handle coverage, fix linter and quality issues in parallel
  • Tests are mandatory: every new/changed exported function needs a test
  • Table-driven tests preferred for Go code
  • Test both happy path and error cases
  • Fix issues directly — don't just report them
  • Keep iterating until all gates pass

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