跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

go-logic-review

Review Go code for business logic correctness, boundary conditions, off-by-one errors, state management, data flow integrity, and return value contracts. Trigger on any Go code change that modifies behavior, conditional logic, state transitions, or data processing. Use for logic-correctness focused review.

johnqtcg · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add johnqtcg/awesome-skills --skill go-logic-review

技能说明


name: go-logic-review description: Review Go code for business logic correctness, boundary conditions, off-by-one errors, state management, data flow integrity, and return value contracts. Trigger on any Go code change that modifies behavior, conditional logic, state transitions, or data processing. Use for logic-correctness focused review. allowed-tools: Read, Grep, Glob, Bash(go build*), Bash(go vet*)

Go Logic Review

Purpose

Audit Go code for business logic correctness. Core question: "Does the code do what it's supposed to do?"

Key distinction from other 6 vertical skills: they use pattern matching (see SQL → check injection, see goroutine → check race). This skill uses semantic understanding — understand the code's intent, then compare with its implementation.

This skill relies primarily on AI's general reasoning ability, not heavy reference files. The checklist provides the review framework; AI provides the reasoning.

This skill does NOT cover: security patterns, concurrency patterns, performance patterns, code style, test quality, or error handling patterns — those belong to sibling skills.

When To Use

  • Any code change that modifies behavior
  • Code contains conditional branches (if/else, switch)
  • Code contains data transformation or processing
  • Code contains state management or state transitions
  • Default dispatch: always run (any code change can introduce logic errors)

When NOT To Use

  • Pure refactoring with no behavior change
  • Config-only changes
  • Security vulnerability patterns → go-security-review
  • Concurrency patterns → go-concurrency-review
  • Code style → go-quality-review

Mandatory Gates

1) Context Understanding Gate (unique to this skill)

Before evaluating correctness, understand the INTENT:

  • Read function name, comments, docstring
  • Read caller context — who calls this function, what do they expect?
  • Read related tests — they document expected behavior
  • Read commit message / PR description if available

If intent is ambiguous after these steps, flag as "unclear intent — needs clarification" rather than guessing. Do not report uncertain intent as a confirmed defect.

2) Anti-Example Suppression Gate

MUST cite evidence of intent mismatch. Category match alone insufficient.

Embedded anti-examples:

  • "Function name doesn't match behavior" — when you cannot verify the expected behavior from available context (don't guess business rules you don't know).
  • "Off-by-one in pagination" — when the code follows the framework's pagination convention (0-based vs 1-based varies by framework). Verify convention before flagging.
  • "Missing state transition validation" — when the state machine is intentionally permissive by design (e.g., admin override paths).
  • "Unused function parameter" — this is a quality/style issue (go-quality-review), not a logic issue. Only flag here if the unused parameter indicates a logic bug (function ignores input it should use).
  • "Return value could be nil" — when callers already handle nil (check all callers before flagging).

3) Generated Code Exclusion Gate

Exclude: *.pb.go, *_gen.go, mock_*.go.

Workflow

  1. Define scope — files/diff under review. Apply Generated Code Exclusion Gate.
  2. Understand intent — read function signatures, comments, callers, tests (Context Understanding Gate). This step is a prerequisite — do not skip.
  3. Trace data flow — map inputs through transformations to outputs. For each function: what goes in? What comes out? Does the transformation match the intent?
  4. Evaluate ALL 10 checklist items — for each: "does the implementation match the intent?"
  5. Classify findings — confirmed (clear evidence of mismatch) vs needs-clarification (ambiguous intent) → format output.

Logic Checklist (10 Items)

All 10 items are semantic-only — no grep patterns are applicable. Logic review relies on AI reasoning to understand code intent vs implementation. This skill does not use the Grep-Gated Execution Protocol.

#ItemWhat to Check
1Happy path correctnessFunction's actual behavior matches its name, comments, caller expectations? Example: GetTopN() but no LIMIT applied
2Boundary conditionsnil input, empty collection, single element, zero value, MaxInt/MinInt. Example: average(items) divides by len(items) without zero check
3Off-by-oneLoop < vs <=, slice [start:end] (end exclusive), pagination offset/limit. Example: items[0:count] when count can equal len(items)+1
4Conditional logic> vs >=, && vs `
5State consistencyState transitions complete? Illegal paths possible? Modified state persisted? Example: order "pending" → "completed" skipping "processing"
6Data flow integrityInput fully consumed? Intermediate results correctly passed? Example: filter returns filtered list but caller uses original unfiltered list
7Resource lifecycleFiles/connections/transactions closed on ALL paths? Note: overlaps with go-error-review — here focus on logic (missing close as logic gap), there on error handling pattern
8Return value contractReturn values meet caller's implicit assumptions? Example: caller assumes non-nil slice, function returns nil on empty
9Idempotency and reentrancyOperations marked retriable actually idempotent? Example: "retry-safe" endpoint creates duplicate records
10Timing assumptionsCode assumes "A before B" — always guaranteed? Example: cache populated before first read, but init is async

Severity Rubric

High — Logic error producing incorrect results, data corruption, or silent failure in production.

Medium — Logic concern under specific edge cases or conditions.

Evidence Rules

  • For each finding: explain w
阅读完整来源 ↗