[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BFCTC0S5NAEX4JJ98Y1X6D":3,"skill-same:01M7BFCTC0S5NAEX4JJ98Y1X6D":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M7BFCTC0S5NAEX4JJ98Y1X6D","golang-testing",null,"Go测试模式包括表格驱动测试、子测试、基准测试、模糊测试和测试覆盖率。遵循TDD方法论，采用地道的Go实践。","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fgolang-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: golang-testing\ndescription: Go测试模式包括表格驱动测试、子测试、基准测试、模糊测试和测试覆盖率。遵循TDD方法论，采用地道的Go实践。\norigin: ECC\n---\n\n# Go 测试模式\n\n遵循 TDD 方法论，用于编写可靠、可维护测试的全面 Go 测试模式。\n\n## 何时激活\n\n* 编写新的 Go 函数或方法时\n* 为现有代码添加测试覆盖率时\n* 为性能关键代码创建基准测试时\n* 为输入验证实现模糊测试时\n* 在 Go 项目中遵循 TDD 工作流时\n\n## Go 的 TDD 工作流\n\n### 红-绿-重构循环\n\n```\nRED     → 首先编写一个失败的测试\nGREEN   → 编写最少的代码来通过测试\nREFACTOR → 改进代码，同时保持测试通过\nREPEAT  → 继续处理下一个需求\n```\n\n### Go 中的分步 TDD\n\n```go\n\u002F\u002F Step 1: Define the interface\u002Fsignature\n\u002F\u002F calculator.go\npackage calculator\n\nfunc Add(a, b int) int {\n    panic(\"not implemented\") \u002F\u002F Placeholder\n}\n\n\u002F\u002F Step 2: Write failing test (RED)\n\u002F\u002F calculator_test.go\npackage calculator\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {\n    got := Add(2, 3)\n    want := 5\n    if got != want {\n        t.Errorf(\"Add(2, 3) = %d; want %d\", got, want)\n    }\n}\n\n\u002F\u002F Step 3: Run test - verify FAIL\n\u002F\u002F $ go test\n\u002F\u002F --- FAIL: TestAdd (0.00s)\n\u002F\u002F panic: not implemented\n\n\u002F\u002F Step 4: Implement minimal code (GREEN)\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\u002F\u002F Step 5: Run test - verify PASS\n\u002F\u002F $ go test\n\u002F\u002F PASS\n\n\u002F\u002F Step 6: Refactor if needed, verify tests still pass\n```\n\n## 表驱动测试\n\nGo 测试的标准模式。以最少的代码实现全面的覆盖。\n\n```go\nfunc TestAdd(t *testing.T) {\n    tests := []struct {\n        name     string\n        a, b     int\n        expected int\n    }{\n        {\"positive numbers\", 2, 3, 5},\n        {\"negative numbers\", -1, -2, -3},\n        {\"zero values\", 0, 0, 0},\n        {\"mixed signs\", -1, 1, 0},\n        {\"large numbers\", 1000000, 2000000, 3000000},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := Add(tt.a, tt.b)\n            if got != tt.expected {\n                t.Errorf(\"Add(%d, %d) = %d; want %d\",\n                    tt.a, tt.b, got, tt.expected)\n            }\n        })\n    }\n}\n```\n\n### 包含错误情况的表驱动测试\n\n```go\nfunc TestParseConfig(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   string\n        want    *Config\n        wantErr bool\n    }{\n        {\n            name:  \"valid config\",\n            input: `{\"host\": \"localhost\", \"port\": 8080}`,\n            want:  &Config{Host: \"localhost\", Port: 8080},\n        },\n        {\n            name:    \"invalid JSON\",\n            input:   `{invalid}`,\n            wantErr: true,\n        },\n        {\n            name:    \"empty input\",\n            input:   \"\",\n            wantErr: true,\n        },\n        {\n            name:  \"minimal config\",\n            input: `{}`,\n            want:  &Config{}, \u002F\u002F Zero value config\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got, err := ParseConfig(tt.input)\n\n            if tt.wantErr {\n                if err == nil {\n                    t.Error(\"expected error, got nil\")\n                }\n                return\n            }\n\n            if err != nil {\n                t.Fatalf(\"unexpected error: %v\", err)\n            }\n\n            if !reflect.DeepEqual(got, tt.want) {\n                t.Errorf(\"got %+v; want %+v\", got, tt.want)\n            }\n        })\n    }\n}\n```\n\n## 子测试和子基准测试\n\n### 组织相关测试\n\n```go\nfunc TestUser(t *testing.T) {\n    \u002F\u002F Setup shared by all subtests\n    db := setupTestDB(t)\n\n    t.Run(\"Create\", func(t *testing.T) {\n        user := &User{Name: \"Alice\"}\n        err := db.CreateUser(user)\n        if err != nil {\n            t.Fatalf(\"CreateUser failed: %v\", err)\n        }\n        if user.ID == \"\" {\n            t.Error(\"expected user ID to be set\")\n        }\n    })\n\n    t.Run(\"Get\", func(t *testing.T) {\n        user, err := db.GetUser(\"alice-id\")\n        if err != nil {\n            t.Fatalf(\"GetUser failed: %v\", err)\n        }\n        if user.Name != \"Alice\" {\n            t.Errorf(\"got name %q; want %q\", user.Name, \"Alice\")\n        }\n    })\n\n    t.Run(\"Update\", func(t *testing.T) {\n        \u002F\u002F ...\n    })\n\n    t.Run(\"Delete\", func(t *testing.T) {\n        \u002F\u002F ...\n    })\n}\n```\n\n### 并行子测试\n\n```go\nfunc TestParallel(t *testing.T) {\n    tests := []struct {\n        name  string\n        input string\n    }{\n        {\"case1\", \"input1\"},\n        {\"case2\", \"input2\"},\n        {\"case3\", \"input3\"},\n    }\n\n    for _, tt := range tests {\n        tt := tt \u002F\u002F Capture range variable\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F Run subtests in parallel\n            result := Process(tt.input)\n            \u002F\u002F assertions...\n            _ = result\n        })\n    }\n}\n```\n\n## 测试辅助函数\n\n### 辅助函数\n\n```go\nfunc setupTestDB(t *testing.T) *sql.DB {\n    t.Helper() \u002F\u002F Marks this as a helper function\n\n    db, err := sql.Open(\"sqlite3\", \":memory:\")\n    if err != nil {\n        t.Fatalf(\"failed to open database: %v\", err)\n    }\n\n    \u002F\u002F Cleanup when test finishes\n    t.Cleanup(func() {\n        db.Close()\n    })\n\n    \u002F\u002F Run migrations\n    if _, err := db.Exec(schema); err != nil {\n        t.Fatalf(\"failed to create schema: %v\", err)\n    }\n\n    return db\n}\n\nfunc assertNoError(t *testing.T, err error) {\n    t.Helper()\n    if err != nil {\n        t.Fatalf(\"unexpected error: %v\", err)\n    }\n}\n\nfunc assertEqual[T comparable](t *testing.T, got, want T) {\n    t.Helper()\n    if got != want {\n        t.Errorf(\"got %v; want %v\", got, want)\n    }\n}\n```\n\n### 临时文件和目录\n\n```go\nfunc TestFileProcessing(t *testing.T) {\n    \u002F\u002F Create temp directory - automatically cleaned up\n    tmpDir := t.TempDir()\n\n    \u002F\u002F Create test file\n    testFile := filepath.Join(tmpDir, \"test.txt\")\n    err := os.WriteFile(testFile, []byte(\"test content\"), 0644)\n    if err != nil {\n        t.Fatalf(\"failed to create test file: %v\", err)\n    }\n\n    \u002F\u002F Run test\n    result, err := ProcessFile(testFile)\n    if err != nil {\n        t.Fatalf(\"ProcessFile failed: %v\", err)\n    }\n\n    \u002F\u002F Assert...\n    _ = result\n}\n```\n\n## 黄金文件\n\n针对存储在 `testdata\u002F` 中的预期输出文件进行测试。\n\n```go\nvar update = flag.Bool(\"update\", false, \"update golden files\")\n\nfunc TestRender(t *testing.T) {\n    tests := []struct {\n        name  string\n        input Template\n    }{\n        {\"simple\", Template{Name: \"test\"}},\n        {\"complex\", Template{Name: \"test\", Items: []string{\"a\", \"b\"}}},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := Render(tt.input)\n\n            golden := filepath.Join(\"testdata\", tt.name+\".golden\")\n\n            if *update {\n                \u002F\u002F Update golden file: go test -update\n                err := os.WriteFile(golden, got, 0644)\n                if err != nil {\n                    t.Fatalf(\"failed to update golden file: %v\", err)\n                }\n            }\n\n            want, err := os.ReadFile(golden)\n            if err != nil {\n                t.Fatalf(\"failed to read golden file: %v\", err)\n            }\n\n            if !bytes.Equal(got, want) {\n                t.Errorf(\"output mismatch:\\ngot:\\n%s\\nwant:\\n%s\", got, want)\n            }\n        })\n    }\n}\n```\n\n## 使用接口进行模拟\n\n### 基于接口的模拟\n\n```go\n\u002F\u002F Define interface for dependencies\ntype UserRepository interface {\n    GetUser(id string) (*User, error)\n    SaveUser(user *User) error\n}\n\n\u002F\u002F Production implementation\ntype PostgresUserRepository struct {\n    db *sql.DB\n}\n\nfunc (r *PostgresUserRepository) GetUser(id string) (*User, error) {\n    \u002F\u002F Real database query\n}\n\n\u002F\u002F Mock implementation for tests\ntype MockUserRepository struct {\n    GetUserFunc  func(id string) (*User, error)\n    SaveUserFunc func(user *User) error\n}\n\nfunc (m *MockUserRepository) GetUser(id string) (*User, error) {\n    return m.GetUserFunc(id)\n}\n\nfunc (m *MockUserRepository) SaveUser(user *User) error {\n    return m.SaveUserFunc(user)\n}\n\n\u002F\u002F Test using mock\nfunc TestUserService(t *testing.T) {\n    mock := &MockUserRepository{\n        GetUserFunc: func(id string) (*User, error) {\n            if id == \"123\" {\n                return &User{ID: \"123\", Name: \"Alice\"}, nil\n            }\n            return nil, ErrNotFound\n        },\n    }\n\n    service := NewUserService(mock)\n\n    user, err := service.GetUserProfile(\"123\")\n    if err != nil {\n        t.Fatalf(\"unexpected error: %v\", err)\n    }\n    if user.Name != \"Alice\" {\n        t.Errorf(\"got name %q; want %q\", user.Name, \"Alice\")\n    }\n}\n```\n\n## 基准测试\n\n### 基本基准测试\n\n```go\nfunc BenchmarkProcess(b *testing.B) {\n    data := generateTestData(1000)\n    b.ResetTimer() \u002F\u002F Don't count setup time\n\n    for i := 0; i \u003C b.N; i++ {\n        Process(data)\n    }\n}\n\n\u002F\u002F Run: go test -bench=BenchmarkProcess -benchmem\n\u002F\u002F Output: BenchmarkProcess-8   10000   105234 ns\u002Fop   4096 B\u002Fop   10 allocs\u002Fop\n```\n\n### 不同大小的基准测试\n\n```go\nfunc BenchmarkSort(b *testing.B) {\n    sizes := []int{100, 1000, 10000, 100000}\n\n    for _, size := range sizes {\n        b.Run(fmt.Sprintf(\"size=%d\", size), func(b *testing.B) {\n            data := generateRandomSlice(size)\n            b.ResetTimer()\n\n            for i := 0; i \u003C b.N; i++ {\n                \u002F\u002F Make a copy to avoid sorting already sorted data\n                tmp := make([]int, len(data))\n                copy(tmp, data)\n                sort.Ints(tmp)\n            }\n        })\n    }\n}\n```\n\n### 内存分配基准测试\n\n```go\nfunc BenchmarkStringConcat(b *testing.B) {\n    parts := []string{\"hello\", \"world\", \"foo\", \"bar\", \"baz\"}\n\n    b.Run(\"plus\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var s string\n            for _, p := range parts {\n                s += p\n            }\n            _ = s\n        }\n    })\n\n    b.Run(\"builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var sb strings.Builder\n            for _, p := range parts {\n                sb.WriteString(p)\n            }\n            _ = sb.String()\n        }\n    })\n\n    b.Run(\"join\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            _ = strings.Join(parts, \"\")\n        }\n    })\n}\n```\n\n## 模糊测试 (Go 1.18+)\n\n### 基本模糊测试\n\n```go\nfunc FuzzParseJSON(f *testing.F) {\n    \u002F\u002F Add seed corpus\n    f.Add(`{\"name\": \"test\"}`)\n    f.Add(`{\"count\": 123}`)\n    f.Add(`[]`)\n    f.Add(`\"\"`)\n\n    f.Fuzz(func(t *testing.T, input string) {\n        var result map[string]interface{}\n        err := json.Unmarshal([]byte(input), &result)\n\n        if err != nil {\n            \u002F\u002F Invalid JSON is expected for random input\n            return\n        }\n\n        \u002F\u002F If parsing succeeded, re-encoding should work\n        _, err = json.Marshal(result)\n        if err != nil {\n            t.Errorf(\"Marshal failed after successful Unmarshal: %v\", err)\n        }\n    })\n}\n\n\u002F\u002F Run: go test -fuzz=FuzzParseJSON -fuzztime=30s\n```\n\n### 多输入模糊测试\n\n```go\nfunc FuzzCompare(f *testing.F) {\n    f.Add(\"hello\", \"world\")\n    f.Add(\"\", \"\")\n    f.Add(\"abc\", \"abc\")\n\n    f.Fuzz(func(t *testing.T, a, b string) {\n        result := Compare(a, b)\n\n        \u002F\u002F Property: Compare(a, a) should always equal 0\n        if a == b && result != 0 {\n            t.Errorf(\"Compare(%q, %q) = %d; want 0\", a, b, result)\n        }\n\n        \u002F\u002F Property: Compare(a, b) and Compare(b, a) should have opposite signs\n        reverse := Compare(b, a)\n        if (result > 0 && reverse >= 0) || (result \u003C 0 && reverse \u003C= 0) {\n            if result != 0 || reverse != 0 {\n                t.Errorf(\"Compare(%q, %q) = %d, Compare(%q, %q) = %d; inconsistent\",\n                    a, b, result, b, a, reverse)\n            }\n        }\n    })\n}\n```\n\n## 测试覆盖率\n\n### 运行覆盖率\n\n```bash\n# Basic coverage\ngo test -cover .\u002F...\n\n# Generate coverage profile\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in browser\ngo tool cover -html=coverage.out\n\n# View coverage by function\ngo tool cover -func=coverage.out\n\n# Coverage with race detection\ngo test -race -coverprofile=coverage.out .\u002F...\n```\n\n### 覆盖率目标\n\n| 代码类型 | 目标 |\n|-----------|--------|\n| 关键业务逻辑 | 100% |\n| 公共 API | 90%+ |\n| 通用代码 | 80%+ |\n| 生成的代码 | 排除 |\n\n### 从覆盖率中排除生成的代码\n\n```go\n\u002F\u002Fgo:generate mockgen -source=interface.go -destination=mock_interface.go\n\n\u002F\u002F In coverage profile, exclude with build tags:\n\u002F\u002F go test -cover -tags=!generate .\u002F...\n```\n\n## HTTP 处理器测试\n\n```go\nfunc TestHealthHandler(t *testing.T) {\n    \u002F\u002F Create request\n    req := httptest.NewRequest(http.MethodGet, \"\u002Fhealth\", nil)\n    w := httptest.NewRecorder()\n\n    \u002F\u002F Call handler\n    HealthHandler(w, req)\n\n    \u002F\u002F Check response\n    resp := w.Result()\n    defer resp.Body.Close()\n\n    if resp.StatusCode != http.StatusOK {\n        t.Errorf(\"got status %d; want %d\", resp.StatusCode, http.StatusOK)\n    }\n\n    body, _ := io.ReadAll(resp.Body)\n    if string(body) != \"OK\" {\n        t.Errorf(\"got body %q; want %q\", body, \"OK\")\n    }\n}\n\nfunc TestAPIHandler(t *testing.T) {\n    tests := []struct {\n        name       string\n        method     string\n        path       string\n        body       string\n        wantStatus int\n        wantBody   string\n    }{\n        {\n            name:       \"get user\",\n            method:     http.MethodGet,\n            path:       \"\u002Fusers\u002F123\",\n            wantStatus: http.StatusOK,\n            wantBody:   `{\"id\":\"123\",\"name\":\"Alice\"}`,\n        },\n        {\n            name:       \"not found\",\n            method:     http.MethodGet,\n            path:       \"\u002Fusers\u002F999\",\n            wantStatus: http.StatusNotFound,\n        },\n        {\n            name:       \"create user\",\n            method:     http.MethodPost,\n            path:       \"\u002Fusers\",\n            body:       `{\"name\":\"Bob\"}`,\n            wantStatus: http.StatusCreated,\n        },\n    }\n\n    handler := NewAPIHandler()\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            var body io.Reader\n            if tt.body != \"\" {\n                body = strings.NewReader(tt.body)\n            }\n\n            req := httptest.NewRequest(tt.method, tt.path, body)\n            req.Header.Set(\"Content-Type\", \"application\u002Fjson\")\n            w := httptest.NewRecorder()\n\n            handler.ServeHTTP(w, req)\n\n            if w.Code != tt.wantStatus {\n                t.Errorf(\"got status %d; want %d\", w.Code, tt.wantStatus)\n            }\n\n            if tt.wantBody != \"\" && w.Body.String() != tt.wantBody {\n                t.Errorf(\"got body %q; want %q\", w.Body.String(), tt.wantBody)\n            }\n        })\n    }\n}\n```\n\n## 命令测试\n\n```bash\n# Run all tests\ngo test .\u002F...\n\n# Run tests with verbose output\ngo test -v .\u002F...\n\n# Run specific test\ngo test -run TestAdd .\u002F...\n\n# Run tests matching pattern\ngo test -run \"TestUser\u002FCreate\" .\u002F...\n\n# Run tests with race detector\ngo test -race .\u002F...\n\n# Run tests with coverage\ngo test -cover -coverprofile=coverage.out .\u002F...\n\n# Run short tests only\ngo test -short .\u002F...\n\n# Run tests with timeout\ngo test -timeout 30s .\u002F...\n\n# Run benchmarks\ngo test -bench=. -benchmem .\u002F...\n\n# Run fuzzing\ngo test -fuzz=FuzzParse -fuzztime=30s .\u002F...\n\n# Count test runs (for flaky test detection)\ngo test -count=10 .\u002F...\n```\n\n## 最佳实践\n\n**应该：**\n\n* **先**写测试 (TDD)\n* 使用表驱动测试以实现全面覆盖\n* 测试行为，而非实现\n* 在辅助函数中使用 `t.Helper()`\n* 对于独立的测试使用 `t.Parallel()`\n* 使用 `t.Cleanup()` 清理资源\n* 使用描述场景的有意义的测试名称\n\n**不应该：**\n\n* 直接测试私有函数 (通过公共 API 测试)\n* 在测试中使用 `time.Sleep()` (使用通道或条件)\n* 忽略不稳定的测试 (修复或移除它们)\n* 模拟所有东西 (在可能的情况下优先使用集成测试)\n* 跳过错误路径测试\n\n## 与 CI\u002FCD 集成\n\n```yaml\n# GitHub Actions example\ntest:\n  runs-on: ubuntu-latest\n  steps:\n    - uses: actions\u002Fcheckout@v4\n    - uses: actions\u002Fsetup-go@v5\n      with:\n        go-version: '1.22'\n\n    - name: Run tests\n      run: go test -race -coverprofile=coverage.out .\u002F...\n\n    - name: Check coverage\n      run: |\n        go tool cover -func=coverage.out | grep total | awk '{print $3}' | \\\n        awk -F'%' '{if ($1 \u003C 80) exit 1}'\n```\n\n**记住**：测试即文档。它们展示了你的代码应如何使用。清晰地编写它们并保持更新。\n","# Go 测试模式\n\n遵循 TDD 方法论，用于编写可靠、可维护测试的全面 Go 测试模式。\n\n## 何时激活\n\n* 编写新的 Go 函数或方法时\n* 为现有代码添加测试覆盖率时\n* 为性能关键代码创建基准测试时\n* 为输入验证实现模糊测试时\n* 在 Go 项目中遵循 TDD 工作流时\n\n## Go 的 TDD 工作流\n\n### 红-绿-重构循环\n\n```\nRED     → 首先编写一个失败的测试\nGREEN   → 编写最少的代码来通过测试\nREFACTOR → 改进代码，同时保持测试通过\nREPEAT  → 继续处理下一个需求\n```\n\n### Go 中的分步 TDD\n\n```go\n\u002F\u002F Step 1: Define the interface\u002Fsignature\n\u002F\u002F calculator.go\npackage calculator\n\nfunc Add(a, b int) int {\n    panic(\"not implemented\") \u002F\u002F Placeholder\n}\n\n\u002F\u002F Step 2: Write failing test (RED)\n\u002F\u002F calculator_test.go\npackage calculator\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {\n    got := Add(2, 3)\n    want := 5\n    if got != want {\n        t.Errorf(\"Add(2, 3) = %d; want %d\", got, want)\n    }\n}\n\n\u002F\u002F Step 3: Run test - verify FAIL\n\u002F\u002F $ go test\n\u002F\u002F --- FAIL: TestAdd (0.00s)\n\u002F\u002F panic: not implemented\n\n\u002F\u002F Step 4: Implement minimal code (GREEN)\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\u002F\u002F Step 5: Run test - verify PASS\n\u002F\u002F $ go test\n\u002F\u002F PASS\n\n\u002F\u002F Step 6: Refactor if needed, verify tests still pass\n```\n\n## 表驱动测试\n\nGo 测试的标准模式。以最少的代码实现全面的覆盖。\n\n```go\nfunc TestAdd(t *testing.T) {\n    tests := []struct {\n        name     string\n        a, b     int\n        expected int\n    }{\n        {\"positive numbers\", 2, 3, 5},\n        {\"negative numbers\", -1, -2, -3},\n        {\"zero values\", 0, 0, 0},\n        {\"mixed signs\", -1, 1, 0},\n        {\"large numbers\", 1000000, 2000000, 3000000},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := Add(tt.a, tt.b)\n            if got != tt.expected {\n                t.Errorf(\"Add(%d, %d) = %d; want %d\",\n                    tt.a, tt.b, got, tt.expected)\n            }\n        })\n    }\n}\n```\n\n### 包含错误情况的表驱动测试\n\n```go\nfunc TestParseConfig(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   string\n        want    *Config\n        wantErr bool\n    }{\n        {\n            name:  \"valid config\",\n            input: `{\"host\": \"localhost\", \"port\": 8080}`,\n            want:  &Config{Host: \"localhost\", Port: 8080},\n        },\n        {\n            name:    \"invalid JSON\",\n            input:   `{invalid}`,\n            wantErr: true,\n        },\n        {\n            name:    \"empty input\",\n            input:   \"\",\n            wantErr: true,\n        },\n        {\n            name:  \"minimal config\",\n            input: `{}`,\n            want:  &Config{}, \u002F\u002F Zero value config\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got, err := ParseConfig(tt.input)\n\n            if tt.wantErr {\n                if err == nil {\n                    t.Error(\"expected error, got nil\")\n                }\n                return\n            }\n\n            if err != nil {\n                t.Fatalf(\"unexpected error: %v\", err)\n            }\n\n            if !reflect.DeepEqual(got, tt.want) {\n                t.Errorf(\"got %+v; want %+v\", got, tt.want)\n            }\n        })\n    }\n}\n```\n\n## 子测试和子基准测试\n\n### 组织相关测试\n\n```go\nfunc TestUser(t *testing.T) {\n    \u002F\u002F Setup shared by all subtests\n    db := setupTestDB(t)\n\n    t.Run(\"Create\", func(t *testing.T) {\n        user := &User{Name: \"Alice\"}\n        err := db.CreateUser(user)\n        if err != nil {\n            t.Fatalf(\"CreateUser failed: %v\", err)\n        }\n        if user.ID == \"\" {\n            t.Error(\"expected user ID to be set\")\n        }\n    })\n\n    t.Run(\"Get\", func(t *testing.T) {\n        user, err := db.GetUser(\"alice-id\")\n        if err != nil {\n            t.Fatalf(\"GetUser failed: %v\", err)\n        }\n        if user.Name != \"Alice\" {\n            t.Errorf(\"got name %q; want %q\", user.Name, \"Alice\")\n        }\n    })\n\n    t.Run(\"Update\", func(t *testing.T) {\n        \u002F\u002F ...\n    })\n\n    t.Run(\"Delete\", func(t *testing.T) {\n        \u002F\u002F ...\n    })\n}\n```\n\n### 并行子测试\n\n```go\nfunc TestParallel(t *testing.T) {\n    tests := []struct {\n        name  string\n        input string\n    }{\n        {\"case1\", \"input1\"},\n        {\"case2\", \"input2\"},\n        {\"case3\", \"input3\"},\n    }\n\n    for _, tt := range tests {\n        tt := tt \u002F\u002F Capture range variable\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F Run subtests in parallel\n            result := Process(tt.input)\n            \u002F\u002F assertions...\n            _ = result\n        })\n    }\n}\n```\n\n## 测试辅助函数\n\n### 辅助函数\n\n```go\nfunc setupTestDB(t *testing.T) *sql.DB {\n    t.Helper() \u002F\u002F Marks this as a helper function\n\n    db, err := sql.Open(\"sqlite3\", \":memory:\")\n    if err != nil {\n        t.Fatalf(\"failed to open database: %v\", err)\n    }\n\n    \u002F\u002F Cleanup when test finishes\n    t.Cleanup(func() {\n        db.Close()\n    })\n\n    \u002F\u002F Run migrations\n    if _, err := db.Exec(schema); err != nil {\n        t.Fatalf(\"failed to create schema: %v\", err)\n    }\n\n    return db\n}\n\nfunc assertNoError(t *testing.T, err error) {\n    t.Helper()\n    if err != nil {\n        t.Fatalf(\"unexpected error: %v\", err)\n    }\n}\n\nfunc assertEqual[T comparable](t *testing.T, got, want T) {\n    t.Helper()\n    if got != want {\n        t.Errorf(\"got %v; want %v\", got, want)\n    }\n}\n```\n\n### 临时文件和目录\n\n```go\nfunc TestFileProcessing(t *testing.T) {\n    \u002F\u002F Create temp directory - automatically cleaned up\n    tmpDir := t.TempDir()\n\n    \u002F\u002F Create test file\n    testFile := filepath.Join(tmpDir, \"test.txt\")\n    err := os.WriteFile(testFile, []byte(\"test content\"), 0644)\n    if err != nil {\n        t.Fatalf(\"failed to create test file: %v\", err)\n    }\n\n    \u002F\u002F Run test\n    result, err := ProcessFile(testFile)\n    if err != nil {\n        t.Fatalf(\"ProcessFile failed: %v\", err)\n    }\n\n    \u002F\u002F Assert...\n    _ = result\n}\n```\n\n## 黄金文件\n\n针对存储在 `testdata\u002F` 中的预期输出文件进行测试。\n\n```go\nvar update = flag.Bool(\"update\", false, \"update golden files\")\n\nfunc TestRender(t *testing.T) {\n    tests := []struct {\n        name  string\n        input Template\n    }{\n        {\"simple\", Template{Name: \"test\"}},\n        {\"complex\", Template{Name: \"test\", Items: []string{\"a\", \"b\"}}},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := Render(tt.input)\n\n            golden := filepath.Join(\"testdata\", tt.name+\".golden\")\n\n            if *update {\n                \u002F\u002F Update golden file: go test -update\n                err := os.WriteFile(golden, got, 0644)\n                if err != nil {\n                    t.Fatalf(\"failed to update golden file: %v\", err)\n                }\n            }\n\n            want, err := os.ReadFile(golden)\n            if err != nil {\n                t.Fatalf(\"failed to read golden file: %v\", err)\n            }\n\n            if !bytes.Equal(got, want) {\n                t.Errorf(\"output mismatch:\\ngot:\\n%s\\nwant:\\n%s\", got, want)\n            }\n        })\n    }\n}\n```\n\n## 使用接口进行模拟\n\n### 基于接口的模拟\n\n```go\n\u002F\u002F Define interface for dependencies\ntype UserRepository interface {\n    GetUser(id string) (*User, error)\n    SaveUser(user *User) error\n}\n\n\u002F\u002F Production implementation\ntype PostgresUserRepository struct {\n    db *sql.DB\n}\n\nfunc (r *PostgresUserRepository) GetUser(id string) (*User, error) {\n    \u002F\u002F Real database query\n}\n\n\u002F\u002F Mock implementation for tests\ntype MockUserRepository struct {\n    GetUserFunc  func(id string) (*User, error)\n    SaveUserFunc func(user *User) error\n}\n\nfunc (m *MockUserRepository) GetUser(id string) (*User, error) {\n    return m.GetUserFunc(id)\n}\n\nfunc (m *MockUserRepository) SaveUser(user *User) error {\n    return m.SaveUserFunc(user)\n}\n\n\u002F\u002F Test using mock\nfunc TestUserService(t *testing.T) {\n    mock := &MockUserRepository{\n        GetUserFunc: func(id string) (*User, error) {\n            if id == \"123\" {\n                return &User{ID: \"123\", Name: \"Alice\"}, nil\n            }\n            return nil, ErrNotFound\n        },\n    }\n\n    service := NewUserService(mock)\n\n    user, err := service.GetUserProfile(\"123\")\n    if err != nil {\n        t.Fatalf(\"unexpected error: %v\", err)\n    }\n    if user.Name != \"Alice\" {\n        t.Errorf(\"got name %q; want %q\", user.Name, \"Alice\")\n    }\n}\n```\n\n## 基准测试\n\n### 基本基准测试\n\n```go\nfunc BenchmarkProcess(b *testing.B) {\n    data := generateTestData(1000)\n    b.ResetTimer() \u002F\u002F Don't count setup time\n\n    for i := 0; i \u003C b.N; i++ {\n        Process(data)\n    }\n}\n\n\u002F\u002F Run: go test -bench=BenchmarkProcess -benchmem\n\u002F\u002F Output: BenchmarkProcess-8   10000   105234 ns\u002Fop   4096 B\u002Fop   10 allocs\u002Fop\n```\n\n### 不同大小的基准测试\n\n```go\nfunc BenchmarkSort(b *testing.B) {\n    sizes := []int{100, 1000, 10000, 100000}\n\n    for _, size := range sizes {\n        b.Run(fmt.Sprintf(\"size=%d\", size), func(b *testing.B) {\n            data := generateRandomSlice(size)\n            b.ResetTimer()\n\n            for i := 0; i \u003C b.N; i++ {\n                \u002F\u002F Make a copy to avoid sorting already sorted data\n                tmp := make([]int, len(data))\n                copy(tmp, data)\n                sort.Ints(tmp)\n            }\n        })\n    }\n}\n```\n\n### 内存分配基准测试\n\n```go\nfunc BenchmarkStringConcat(b *testing.B) {\n    parts := []string{\"hello\", \"world\", \"foo\", \"bar\", \"baz\"}\n\n    b.Run(\"plus\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var s string\n            for _, p := range parts {\n                s += p\n            }\n            _ = s\n        }\n    })\n\n    b.Run(\"builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var sb strings.Builder\n            for _, p := range parts {\n                sb.WriteString(p)\n            }\n            _ = sb.String()\n        }\n    })\n\n    b.Run(\"join\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            _ = strings.Join(parts, \"\")\n        }\n    })\n}\n```\n\n## 模糊测试 (Go 1.18+)\n\n### 基本模糊测试\n\n```go\nfunc FuzzParseJSON(f *testing.F) {\n    \u002F\u002F Add seed corpus\n    f.Add(`{\"name\": \"test\"}`)\n    f.Add(`{\"count\": 123}`)\n    f.Add(`[]`)\n    f.Add(`\"\"`)\n\n    f.Fuzz(func(t *testing.T, input string) {\n        var result map[string]interface{}\n        err := json.Unmarshal([]byte(input), &result)\n\n        if err != nil {\n            \u002F\u002F Invalid JSON is expected for random input\n            return\n        }\n\n        \u002F\u002F If parsing succeeded, re-encoding should work\n        _, err = json.Marshal(result)\n        if err != nil {\n            t.Errorf(\"Marshal failed after successful Unmarshal: %v\", err)\n        }\n    })\n}\n\n\u002F\u002F Run: go test -fuzz=FuzzParseJSON -fuzztime=30s\n```\n\n### 多输入模糊测试\n\n```go\nfunc FuzzCompare(f *testing.F) {\n    f.Add(\"hello\", \"world\")\n    f.Add(\"\", \"\")\n    f.Add(\"abc\", \"abc\")\n\n    f.Fuzz(func(t *testing.T, a, b string) {\n        result := Compare(a, b)\n\n        \u002F\u002F Property: Compare(a, a) should always equal 0\n        if a == b && result != 0 {\n            t.Errorf(\"Compare(%q, %q) = %d; want 0\", a, b, result)\n        }\n\n        \u002F\u002F Property: Compare(a, b) and Compare(b, a) should have opposite signs\n        reverse := Compare(b, a)\n        if (result > 0 && reverse >= 0) || (result \u003C 0 && reverse \u003C= 0) {\n            if result != 0 || reverse != 0 {\n                t.Errorf(\"Compare(%q, %q) = %d, Compare(%q, %q) = %d; inconsistent\",\n                    a, b, result, b, a, reverse)\n            }\n        }\n    })\n}\n```\n\n## 测试覆盖率\n\n### 运行覆盖率\n\n```bash\n# Basic coverage\ngo test -cover .\u002F...\n\n# Generate coverage profile\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in browser\ngo tool cover -html=coverage.out\n\n# View coverage by function\ngo tool cover -func=coverage.out\n\n# Coverage with race detection\ngo test -race -coverprofile=coverage.out .\u002F...\n```\n\n### 覆盖率目标\n\n| 代码类型 | 目标 |\n|-----------|--------|\n| 关键业务逻辑 | 100% |\n| 公共 API | 90%+ |\n| 通用代码 | 80%+ |\n| 生成的代码 | 排除 |\n\n### 从覆盖率中排除生成的代码\n\n```go\n\u002F\u002Fgo:generate mockgen -source=interface.go -destination=mock_interface.go\n\n\u002F\u002F In coverage profile, exclude with build tags:\n\u002F\u002F go test -cover -tags=!generate .\u002F...\n```\n\n## HTTP 处理器测试\n\n```go\nfunc TestHealthHandler(t *testing.T) {\n    \u002F\u002F Create request\n    req := httptest.NewRequest(http.MethodGet, \"\u002Fhealth\", nil)\n    w := httptest.NewRecorder()\n\n    \u002F\u002F Call handler\n    HealthHandler(w, req)\n\n    \u002F\u002F Check response\n    resp := w.Result()\n    defer resp.Body.Close()\n\n    if resp.StatusCode != http.StatusOK {\n        t.Errorf(\"got status %d; want %d\", resp.StatusCode, http.StatusOK)\n    }\n\n    body, _ := io.ReadAll(resp.Body)\n    if string(body) != \"OK\" {\n        t.Errorf(\"got body %q; want %q\", body, \"OK\")\n    }\n}\n\nfunc TestAPIHandler(t *testing.T) {\n    tests := []struct {\n        name       string\n        method     string\n        path       string\n        body       string\n        wantStatus int\n        wantBody   string\n    }{\n        {\n            name:       \"get user\",\n            method:     http.MethodGet,\n            path:       \"\u002Fusers\u002F123\",\n            wantStatus: http.StatusOK,\n            wantBody:   `{\"id\":\"123\",\"name\":\"Alice\"}`,\n        },\n        {\n            name:       \"not found\",\n            method:     http.MethodGet,\n            path:       \"\u002Fusers\u002F999\",\n            wantStatus: http.StatusNotFound,\n        },\n        {\n            name:       \"create user\",\n            method:     http.MethodPost,\n            path:       \"\u002Fusers\",\n            body:       `{\"name\":\"Bob\"}`,\n            wantStatus: http.StatusCreated,\n        },\n    }\n\n    handler := NewAPIHandler()\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            var body io.Reader\n            if tt.body != \"\" {\n                body = strings.NewReader(tt.body)\n            }\n\n            req := httptest.NewRequest(tt.method, tt.path, body)\n            req.Header.Set(\"Content-Type\", \"application\u002Fjson\")\n            w := httptest.NewRecorder()\n\n            handler.ServeHTTP(w, req)\n\n            if w.Code != tt.wantStatus {\n                t.Errorf(\"got status %d; want %d\", w.Code, tt.wantStatus)\n            }\n\n            if tt.wantBody != \"\" && w.Body.String() != tt.wantBody {\n                t.Errorf(\"got body %q; want %q\", w.Body.String(), tt.wantBody)\n            }\n        })\n    }\n}\n```\n\n## 命令测试\n\n```bash\n# Run all tests\ngo test .\u002F...\n\n# Run tests with verbose output\ngo test -v .\u002F...\n\n# Run specific test\ngo test -run TestAdd .\u002F...\n\n# Run tests matching pattern\ngo test -run \"TestUser\u002FCreate\" .\u002F...\n\n# Run tests with race detector\ngo test -race .\u002F...\n\n# Run tests with coverage\ngo test -cover -coverprofile=coverage.out .\u002F...\n\n# Run short tests only\ngo test -short .\u002F...\n\n# Run tests with timeout\ngo test -timeout 30s .\u002F...\n\n# Run benchmarks\ngo test -bench=. -benchmem .\u002F...\n\n# Run fuzzing\ngo test -fuzz=FuzzParse -fuzztime=30s .\u002F...\n\n# Count test runs (for flaky test detection)\ngo test -count=10 .\u002F...\n```\n\n## 最佳实践\n\n**应该：**\n\n* **先**写测试 (TDD)\n* 使用表驱动测试以实现全面覆盖\n* 测试行为，而非实现\n* 在辅助函数中使用 `t.Helper()`\n* 对于独立的测试使用 `t.Parallel()`\n* 使用 `t.Cleanup()` 清理资源\n* 使用描述场景的有意义的测试名称\n\n**不应该：**\n\n* 直接测试私有函数 (通过公共 API 测试)\n* 在测试中使用 `time.Sleep()` (使用通道或条件)\n* 忽略不稳定的测试 (修复或移除它们)\n* 模拟所有东西 (在可能的情况下优先使用集成测试)\n* 跳过错误路径测试\n\n## 与 CI\u002FCD 集成\n\n```yaml\n# GitHub Actions example\ntest:\n  runs-on: ubuntu-latest\n  steps:\n    - uses: actions\u002Fcheckout@v4\n    - uses: actions\u002Fsetup-go@v5\n      with:\n        go-version: '1.22'\n\n    - name: Run tests\n      run: go test -race -coverprofile=coverage.out .\u002F...\n\n    - name: Check coverage\n      run: |\n        go tool cover -func=coverage.out | grep total | awk '{print $3}' | \\\n        awk -F'%' '{if ($1 \u003C 80) exit 1}'\n```\n\n**记住**：测试即文档。它们展示了你的代码应如何使用。清晰地编写它们并保持更新。\n",{"name":5,"origin":24,"description":7},"ECC","main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fgolang-testing",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill golang-testing",{"tool":40,"command":41},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill golang-testing",{"tool":43,"command":44},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill golang-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Fzh-CN\u002Fskills\u002Fgolang-testing\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]