add-go-test

GitHub

指导为Go仓库编写或扩展单元测试,强调先检查现有测试风格(如Convey BDD或标准testing.T),确保风格一致,添加最小化测试文件并运行验证。

.claude/skills/add-go-test/SKILL.md authgear/authgear-server

触发场景

用户要求添加Go单元测试 用户要求更新现有Go测试

安装

npx skills add authgear/authgear-server --skill add-go-test -g -y
更多选项

非标准路径

npx skills add https://github.com/authgear/authgear-server/tree/main/.claude/skills/add-go-test -g -y

不安装直接使用

npx skills use authgear/authgear-server@add-go-test

指定 Agent (Claude Code)

npx skills add authgear/authgear-server --skill add-go-test -a claude-code -g -y

安装 repo 全部 skill

npx skills add authgear/authgear-server --all -g -y

预览 repo 内 skill

npx skills add authgear/authgear-server --list

SKILL.md

Frontmatter
{
    "name": "add-go-test",
    "description": "Write or extend Go unit tests in this repo. Use when the user asks to add or update Go tests.",
    "argument-hint": "<package or behavior>"
}

Follow this skill when adding Go tests.

Critical: Match Existing Test Style First

Always inspect existing *_test.go files in the package first. This repo uses different testing styles in different packages:

  • Convey (BDD-style): Many packages use github.com/smartystreets/goconvey. Identified by import . "github.com/smartystreets/goconvey/convey" and test structure like:

    func TestFoo(t *testing.T) {
      Convey("description", func() {
        // assertions here
        So(result, ShouldEqual, expected)
      })
    }
    
  • Standard testing.T: Some packages use plain *testing.T with manual assertions.

When in doubt, use Convey if the package has any imports of it. Convey provides better error messages and matches the repo's BDD conventions.

Workflow

  1. Inspect the package's *_test.go files first to identify the testing style being used.
  2. Match the local test style exactly. Do not mix styles in the same package.
  3. Add the smallest test file that covers the behavior.
  4. Run go test on the affected package. If the change crosses packages or touches shared code, run the narrowest broader test set that proves the change is safe.

Notes

  • Prefer table-driven tests when the package already uses them.
  • Keep fixtures local to the test file unless they are reused elsewhere.
  • If the test requires generated code or assets, rerun the generator before the final test run.
  • When using Convey, use So() assertions for consistency with the package style, not manual if statements.

版本历史

  • 2dd6d88 当前 2026-07-24 16:30

同 Skill 集合

.claude/skills/add-portal-admin-api-mutation/SKILL.md
.claude/skills/add-portal-admin-api-query/SKILL.md
.claude/skills/add-portal-screen/SKILL.md
.claude/skills/api-design/SKILL.md
.claude/skills/bootstrap-local-dev/SKILL.md
.claude/skills/dep-audit/SKILL.md
.claude/skills/generate-schemas-and-gentype/SKILL.md
.claude/skills/new-siteadmin-api/SKILL.md
.claude/skills/review-pr/SKILL.md
.claude/skills/update-deps/SKILL.md
.claude/skills/update-email-templates/SKILL.md
.claude/skills/update-feature-config/SKILL.md
.claude/skills/update-important-modules/SKILL.md
.claude/skills/update-portal-ui/SKILL.md
.claude/skills/update-vettedpositions/SKILL.md
.claude/skills/write-e2e-test/SKILL.md
.claude/skills/write-implementation-plan/SKILL.md
.claude/skills/update-go-version/SKILL.md
.claude/skills/portal-admin-api-graphql/SKILL.md

元信息

文件数
0
版本
9bd841a
Hash
70fe7249
收录时间
2026-07-24 16:30

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-15 19:07
浙ICP备14020137号-1