[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BFM7GX5668FMVGDV0P7H9X":3,"skill-same:01M7BFM7GX5668FMVGDV0P7H9X":47},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BFM7GX5668FMVGDV0P7H9X","golang-testing",null,"Go testing patterns including table-driven tests, subtests, benchmarks, fuzzing, and test coverage. Follows TDD methodology with idiomatic Go practices.","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-TW\u002Fskills\u002Fgolang-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: golang-testing\ndescription: Go testing patterns including table-driven tests, subtests, benchmarks, fuzzing, and test coverage. Follows TDD methodology with idiomatic Go practices.\n---\n\n# Go 測試模式\n\n用於撰寫可靠、可維護測試的完整 Go 測試模式，遵循 TDD 方法論。\n\n## 何時啟用\n\n- 撰寫新的 Go 函式或方法\n- 為現有程式碼增加測試覆蓋率\n- 為效能關鍵程式碼建立基準測試\n- 實作輸入驗證的模糊測試\n- 在 Go 專案中遵循 TDD 工作流程\n\n## Go 的 TDD 工作流程\n\n### RED-GREEN-REFACTOR 循環\n\n```\nRED     → 先寫失敗的測試\nGREEN   → 撰寫最少程式碼使測試通過\nREFACTOR → 在保持測試綠色的同時改善程式碼\nREPEAT  → 繼續下一個需求\n```\n\n### Go 中的逐步 TDD\n\n```go\n\u002F\u002F 步驟 1：定義介面\u002F簽章\n\u002F\u002F calculator.go\npackage calculator\n\nfunc Add(a, b int) int {\n    panic(\"not implemented\") \u002F\u002F 佔位符\n}\n\n\u002F\u002F 步驟 2：撰寫失敗測試（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 步驟 3：執行測試 - 驗證失敗\n\u002F\u002F $ go test\n\u002F\u002F --- FAIL: TestAdd (0.00s)\n\u002F\u002F panic: not implemented\n\n\u002F\u002F 步驟 4：實作最少程式碼（GREEN）\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\u002F\u002F 步驟 5：執行測試 - 驗證通過\n\u002F\u002F $ go test\n\u002F\u002F PASS\n\n\u002F\u002F 步驟 6：如需要則重構，驗證測試仍然通過\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 零值 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 所有子測試共享的設置\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 捕獲範圍變數\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F 並行執行子測試\n            result := Process(tt.input)\n            \u002F\u002F 斷言...\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 標記為輔助函式\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 測試結束時清理\n    t.Cleanup(func() {\n        db.Close()\n    })\n\n    \u002F\u002F 執行 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 建立臨時目錄 - 自動清理\n    tmpDir := t.TempDir()\n\n    \u002F\u002F 建立測試檔案\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 執行測試\n    result, err := ProcessFile(testFile)\n    if err != nil {\n        t.Fatalf(\"ProcessFile failed: %v\", err)\n    }\n\n    \u002F\u002F 斷言...\n    _ = result\n}\n```\n\n## Golden 檔案\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 更新 golden 檔案：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## 使用介面 Mock\n\n### 基於介面的 Mock\n\n```go\n\u002F\u002F 定義依賴的介面\ntype UserRepository interface {\n    GetUser(id string) (*User, error)\n    SaveUser(user *User) error\n}\n\n\u002F\u002F 生產實作\ntype PostgresUserRepository struct {\n    db *sql.DB\n}\n\nfunc (r *PostgresUserRepository) GetUser(id string) (*User, error) {\n    \u002F\u002F 實際資料庫查詢\n}\n\n\u002F\u002F 測試用 Mock 實作\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 使用 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 不計算設置時間\n\n    for i := 0; i \u003C b.N; i++ {\n        Process(data)\n    }\n}\n\n\u002F\u002F 執行：go test -bench=BenchmarkProcess -benchmem\n\u002F\u002F 輸出：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 複製以避免排序已排序的資料\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 新增種子語料庫\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 隨機輸入預期會有無效 JSON\n            return\n        }\n\n        \u002F\u002F 如果解析成功，重新編碼應該可行\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 執行：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 屬性：Compare(a, a) 應該總是等於 0\n        if a == b && result != 0 {\n            t.Errorf(\"Compare(%q, %q) = %d; want 0\", a, b, result)\n        }\n\n        \u002F\u002F 屬性：Compare(a, b) 和 Compare(b, a) 應該有相反符號\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# 基本覆蓋率\ngo test -cover .\u002F...\n\n# 產生覆蓋率 profile\ngo test -coverprofile=coverage.out .\u002F...\n\n# 在瀏覽器查看覆蓋率\ngo tool cover -html=coverage.out\n\n# 按函式查看覆蓋率\ngo tool cover -func=coverage.out\n\n# 含競態偵測的覆蓋率\ngo test -race -coverprofile=coverage.out .\u002F...\n```\n\n### 覆蓋率目標\n\n| 程式碼類型 | 目標 |\n|-----------|------|\n| 關鍵業務邏輯 | 100% |\n| 公開 API | 90%+ |\n| 一般程式碼 | 80%+ |\n| 產生的程式碼 | 排除 |\n\n## HTTP Handler 測試\n\n```go\nfunc TestHealthHandler(t *testing.T) {\n    \u002F\u002F 建立請求\n    req := httptest.NewRequest(http.MethodGet, \"\u002Fhealth\", nil)\n    w := httptest.NewRecorder()\n\n    \u002F\u002F 呼叫 handler\n    HealthHandler(w, req)\n\n    \u002F\u002F 檢查回應\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# 執行所有測試\ngo test .\u002F...\n\n# 執行詳細輸出的測試\ngo test -v .\u002F...\n\n# 執行特定測試\ngo test -run TestAdd .\u002F...\n\n# 執行匹配模式的測試\ngo test -run \"TestUser\u002FCreate\" .\u002F...\n\n# 執行帶競態偵測器的測試\ngo test -race .\u002F...\n\n# 執行帶覆蓋率的測試\ngo test -cover -coverprofile=coverage.out .\u002F...\n\n# 只執行短測試\ngo test -short .\u002F...\n\n# 執行帶逾時的測試\ngo test -timeout 30s .\u002F...\n\n# 執行基準測試\ngo test -bench=. -benchmem .\u002F...\n\n# 執行模糊測試\ngo test -fuzz=FuzzParse -fuzztime=30s .\u002F...\n\n# 計算測試執行次數（用於偵測不穩定測試）\ngo test -count=10 .\u002F...\n```\n\n## 最佳實務\n\n**應該做的：**\n- 先寫測試（TDD）\n- 使用表格驅動測試以獲得完整覆蓋\n- 測試行為，而非實作\n- 在輔助函式中使用 `t.Helper()`\n- 對獨立測試使用 `t.Parallel()`\n- 用 `t.Cleanup()` 清理資源\n- 使用描述情境的有意義測試名稱\n\n**不應該做的：**\n- 不要直接測試私有函式（透過公開 API 測試）\n- 不要在測試中使用 `time.Sleep()`（使用 channels 或條件）\n- 不要忽略不穩定測試（修復或移除它們）\n- 不要 mock 所有東西（可能時偏好整合測試）\n- 不要跳過錯誤路徑測試\n\n## CI\u002FCD 整合\n\n```yaml\n# GitHub Actions 範例\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用於撰寫可靠、可維護測試的完整 Go 測試模式，遵循 TDD 方法論。\n\n## 何時啟用\n\n- 撰寫新的 Go 函式或方法\n- 為現有程式碼增加測試覆蓋率\n- 為效能關鍵程式碼建立基準測試\n- 實作輸入驗證的模糊測試\n- 在 Go 專案中遵循 TDD 工作流程\n\n## Go 的 TDD 工作流程\n\n### RED-GREEN-REFACTOR 循環\n\n```\nRED     → 先寫失敗的測試\nGREEN   → 撰寫最少程式碼使測試通過\nREFACTOR → 在保持測試綠色的同時改善程式碼\nREPEAT  → 繼續下一個需求\n```\n\n### Go 中的逐步 TDD\n\n```go\n\u002F\u002F 步驟 1：定義介面\u002F簽章\n\u002F\u002F calculator.go\npackage calculator\n\nfunc Add(a, b int) int {\n    panic(\"not implemented\") \u002F\u002F 佔位符\n}\n\n\u002F\u002F 步驟 2：撰寫失敗測試（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 步驟 3：執行測試 - 驗證失敗\n\u002F\u002F $ go test\n\u002F\u002F --- FAIL: TestAdd (0.00s)\n\u002F\u002F panic: not implemented\n\n\u002F\u002F 步驟 4：實作最少程式碼（GREEN）\nfunc Add(a, b int) int {\n    return a + b\n}\n\n\u002F\u002F 步驟 5：執行測試 - 驗證通過\n\u002F\u002F $ go test\n\u002F\u002F PASS\n\n\u002F\u002F 步驟 6：如需要則重構，驗證測試仍然通過\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 零值 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 所有子測試共享的設置\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 捕獲範圍變數\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F 並行執行子測試\n            result := Process(tt.input)\n            \u002F\u002F 斷言...\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 標記為輔助函式\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 測試結束時清理\n    t.Cleanup(func() {\n        db.Close()\n    })\n\n    \u002F\u002F 執行 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 建立臨時目錄 - 自動清理\n    tmpDir := t.TempDir()\n\n    \u002F\u002F 建立測試檔案\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 執行測試\n    result, err := ProcessFile(testFile)\n    if err != nil {\n        t.Fatalf(\"ProcessFile failed: %v\", err)\n    }\n\n    \u002F\u002F 斷言...\n    _ = result\n}\n```\n\n## Golden 檔案\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 更新 golden 檔案：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## 使用介面 Mock\n\n### 基於介面的 Mock\n\n```go\n\u002F\u002F 定義依賴的介面\ntype UserRepository interface {\n    GetUser(id string) (*User, error)\n    SaveUser(user *User) error\n}\n\n\u002F\u002F 生產實作\ntype PostgresUserRepository struct {\n    db *sql.DB\n}\n\nfunc (r *PostgresUserRepository) GetUser(id string) (*User, error) {\n    \u002F\u002F 實際資料庫查詢\n}\n\n\u002F\u002F 測試用 Mock 實作\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 使用 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 不計算設置時間\n\n    for i := 0; i \u003C b.N; i++ {\n        Process(data)\n    }\n}\n\n\u002F\u002F 執行：go test -bench=BenchmarkProcess -benchmem\n\u002F\u002F 輸出：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 複製以避免排序已排序的資料\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 新增種子語料庫\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 隨機輸入預期會有無效 JSON\n            return\n        }\n\n        \u002F\u002F 如果解析成功，重新編碼應該可行\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 執行：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 屬性：Compare(a, a) 應該總是等於 0\n        if a == b && result != 0 {\n            t.Errorf(\"Compare(%q, %q) = %d; want 0\", a, b, result)\n        }\n\n        \u002F\u002F 屬性：Compare(a, b) 和 Compare(b, a) 應該有相反符號\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# 基本覆蓋率\ngo test -cover .\u002F...\n\n# 產生覆蓋率 profile\ngo test -coverprofile=coverage.out .\u002F...\n\n# 在瀏覽器查看覆蓋率\ngo tool cover -html=coverage.out\n\n# 按函式查看覆蓋率\ngo tool cover -func=coverage.out\n\n# 含競態偵測的覆蓋率\ngo test -race -coverprofile=coverage.out .\u002F...\n```\n\n### 覆蓋率目標\n\n| 程式碼類型 | 目標 |\n|-----------|------|\n| 關鍵業務邏輯 | 100% |\n| 公開 API | 90%+ |\n| 一般程式碼 | 80%+ |\n| 產生的程式碼 | 排除 |\n\n## HTTP Handler 測試\n\n```go\nfunc TestHealthHandler(t *testing.T) {\n    \u002F\u002F 建立請求\n    req := httptest.NewRequest(http.MethodGet, \"\u002Fhealth\", nil)\n    w := httptest.NewRecorder()\n\n    \u002F\u002F 呼叫 handler\n    HealthHandler(w, req)\n\n    \u002F\u002F 檢查回應\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# 執行所有測試\ngo test .\u002F...\n\n# 執行詳細輸出的測試\ngo test -v .\u002F...\n\n# 執行特定測試\ngo test -run TestAdd .\u002F...\n\n# 執行匹配模式的測試\ngo test -run \"TestUser\u002FCreate\" .\u002F...\n\n# 執行帶競態偵測器的測試\ngo test -race .\u002F...\n\n# 執行帶覆蓋率的測試\ngo test -cover -coverprofile=coverage.out .\u002F...\n\n# 只執行短測試\ngo test -short .\u002F...\n\n# 執行帶逾時的測試\ngo test -timeout 30s .\u002F...\n\n# 執行基準測試\ngo test -bench=. -benchmem .\u002F...\n\n# 執行模糊測試\ngo test -fuzz=FuzzParse -fuzztime=30s .\u002F...\n\n# 計算測試執行次數（用於偵測不穩定測試）\ngo test -count=10 .\u002F...\n```\n\n## 最佳實務\n\n**應該做的：**\n- 先寫測試（TDD）\n- 使用表格驅動測試以獲得完整覆蓋\n- 測試行為，而非實作\n- 在輔助函式中使用 `t.Helper()`\n- 對獨立測試使用 `t.Parallel()`\n- 用 `t.Cleanup()` 清理資源\n- 使用描述情境的有意義測試名稱\n\n**不應該做的：**\n- 不要直接測試私有函式（透過公開 API 測試）\n- 不要在測試中使用 `time.Sleep()`（使用 channels 或條件）\n- 不要忽略不穩定測試（修復或移除它們）\n- 不要 mock 所有東西（可能時偏好整合測試）\n- 不要跳過錯誤路徑測試\n\n## CI\u002FCD 整合\n\n```yaml\n# GitHub Actions 範例\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,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-Everything-claude-code\u002Fdocs\u002Fzh-TW\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":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill golang-testing",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill golang-testing",{"tool":42,"command":43},"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-TW\u002Fskills\u002Fgolang-testing\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"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":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"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":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"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":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"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":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"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":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"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",[],[]]