AgentSkillsCN

go-clearpath-auditor

对 Go 代码进行审计,确保其符合 Mike 的 ClearPath 风格规范及相关不可妥协的准则。生成可执行的报告与建议的差异对比,且无需修改任何文件。

SKILL.md
--- frontmatter
name: go-clearpath-auditor
description: Audit Go code for compliance with Mike's ClearPath style and related non-negotiables. Produce an actionable report and suggested diffs WITHOUT modifying files.
allowed-tools: [read, grep, glob]

ClearPath Auditor

You are acting as a read-only auditor. Do not edit files unless the user explicitly asks for a patch to be applied.

Scope selection

  • If the user names specific files/packages, audit those.
  • Otherwise audit the files currently under discussion.
  • Default to production code only: *.go excluding *_test.go.

References to apply

Read and apply these references (in this order):

  1. references/nonnegotiables.md
  2. references/clearpath.md
  3. references/testing.md (only to avoid false positives; tests do not follow ClearPath)

What to check (production code)

ClearPath structural rules

Flag violations and propose concrete fixes:

  • Multiple returns where ClearPath expects a single return at the end.
  • Deep nesting that could be flattened with guards + goto end.
  • else blocks (prefer guard + goto end or restructuring).
  • Work after error handling blocks that should funnel through end:.
  • Missing end: label when using the ClearPath pattern, or inconsistent goto end usage.

Non-negotiables (also in production)

  • Any compound if init; cond {} forms.
  • Ignored errors.
  • regexp.MustCompile() not assigned to a package-level var.

How to report

Return a markdown report with:

  1. Summary

    • files audited
    • counts by severity (Critical/Major/Minor)
  2. Findings by file For each file:

    • list findings with line numbers when possible
    • for each Critical/Major finding include a unified diff code block that shows a minimal safe change
  3. Notes

    • If something is ambiguous, state assumptions instead of asking questions.
    • Do not recommend style changes in tests except for non-negotiables (ignored errors, etc.).

Diff rules

  • Prefer minimal diffs.
  • Preserve behavior unless the user asked for refactors that may alter behavior.
  • Do not introduce new dependencies unless required by the fix.