[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79ZBYACFX1SWWYE4FFM0HG7":3,"skill-same:01M79ZBYACFX1SWWYE4FFM0HG7":62},{"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":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":51},"01M79ZBYACFX1SWWYE4FFM0HG7","go-test-table-driven",null,"Deep dive on table-driven tests in Go: when to use them, when to avoid them, struct design, subtest naming, advanced patterns like test matrices and shared setup, and refactoring bloated tables into clean ones. Use when writing table-driven tests, refactoring test tables, reviewing table test structure, or deciding whether table-driven is the right approach. Trigger examples: \"table-driven test\", \"table test\", \"test cases struct\", \"test matrix\", \"parametrize tests\", \"data-driven test\", \"refactor test table\". Not for: general test strategy, mocks, golden files, fuzzing (go-test-quality), benchmarks (go-performance-review).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(testing)\u002Fgo-test-table-driven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-test-table-driven\ndescription: >\n  Deep dive on table-driven tests in Go: when to use them, when to avoid\n  them, struct design, subtest naming, advanced patterns like test matrices\n  and shared setup, and refactoring bloated tables into clean ones. Use when\n  writing table-driven tests, refactoring test tables, reviewing table test\n  structure, or deciding whether table-driven is the right approach. Trigger\n  examples: \"table-driven test\", \"table test\", \"test cases struct\", \"test\n  matrix\", \"parametrize tests\", \"data-driven test\", \"refactor test table\".\n  Not for: general test strategy, mocks, golden files, fuzzing\n  (go-test-quality), benchmarks (go-performance-review).\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)\nmetadata:\n  author: eduardo-sl\n  version: \"1.2.1\"\n---\n\n# Go Table-Driven Tests\n\nTable-driven tests are a powerful Go idiom — when used correctly. Most\ncodebases either underuse them (10 copy-paste tests) or overuse them\n(complex branching logic in a 200-line struct). This skill covers the\nsweet spot.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fpatterns.md` — full worked examples: canonical tables,\n  `wantErr`\u002F`wantErrIs`, parallel tables, map-based tables, error-only\n  tables, struct alignment for readability.\n- `references\u002Frefactoring.md` — recognizing bloated tables and rewriting\n  them as explicit subtests, with before\u002Fafter examples.\n\nRead a reference file only when the summary below is not enough for the\ntask at hand.\n\n## 1. When Table-Driven Tests Shine\n\nUse a table only when ALL of these are true:\n\n- **Same function** under test across all cases\n- **Same assertion pattern** — input in, output out, compare\n- **Cases differ only in data**, not in setup or verification logic\n- **3+ cases** — fewer than 3, explicit tests are clearer\n\nCanonical use case: pure functions, parsers, validators, formatters.\n\n```go\nfunc TestParseSize(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   string\n        want    int64\n        wantErr bool\n    }{\n        {name: \"plain bytes\", input: \"1024\", want: 1024},\n        {name: \"kilobytes suffix\", input: \"4KB\", want: 4096},\n        {name: \"empty string\", input: \"\", wantErr: true},\n        {name: \"negative size\", input: \"-1\", wantErr: true},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got, err := ParseSize(tt.input)\n            if tt.wantErr {\n                require.Error(t, err)\n                return\n            }\n            require.NoError(t, err)\n            assert.Equal(t, tt.want, got)\n        })\n    }\n}\n```\n\nEvery case has the same shape, the loop body is a few lines, and adding\na case is one struct literal. No branching, no conditionals.\n\n## 2. When NOT to Use Table-Driven Tests\n\n- **Complex per-case setup** — `setupMock`\u002F`setupFunc` function fields in\n  the struct mean the table is hiding complexity. Write explicit subtests.\n- **Fewer than 3 cases** — the struct definition is more code than two\n  plain test functions.\n- **Multiple branching paths** — `if tt.shouldError` \u002F `if tt.wantRedirect`\n  in the loop body means each branch is a different test pretending to\n  share a structure. Split it.\n\nSee `references\u002Frefactoring.md` for before\u002Fafter rewrites of each smell.\n\n## 3. Struct Design Rules\n\n1. **Every field must vary between at least 2 cases.** A field with the\n   same value everywhere is setup — move it outside the table.\n2. **Name the `name` field as a short sentence** describing the scenario:\n   `\"returns error for negative amount\"`, not `\"case1\"` or `\"success\"`.\n3. **`wantErr bool` for \"should it error?\"** — check it first and `return`\n   early in the loop body.\n4. **`wantErrIs error` with a sentinel** when the caller must detect a\n   specific error; assert with `require.ErrorIs`.\n5. **≤5 fields.** More means the scenario is too complex for a table —\n   split into separate test functions.\n\nFull field-pattern examples are in `references\u002Fpatterns.md`.\n\n## 4. The Loop Body Must Be Trivial\n\nThe point of a table test is identical execution logic for every case.\nKeep the loop body under ~10 lines: call, error check, comparison.\nIf it accumulates conditionals or per-case setup, the table has outgrown\nits usefulness — refactor into explicit subtests.\n\n## 5. Parallel Table Tests\n\n```go\nfor _, tt := range tests {\n    t.Run(tt.name, func(t *testing.T) {\n        t.Parallel()\n        got := Transform(tt.input)\n        assert.Equal(t, tt.want, got)\n    })\n}\n```\n\n- Go 1.22+ scopes the loop variable per iteration — `tt := tt` capture is\n  unnecessary. For Go \u003C1.22 the capture is still required.\n- Only use `t.Parallel()` when the function under test has no side\n  effects and no shared mutable state.\n\n## 6. Refactoring Bloated Tables\n\n| Symptom | Fix |\n|---|---|\n| Struct has 8+ fields | Split into multiple test functions by scenario |\n| `setupFunc` field in struct | Extract to separate subtests with explicit setup |\n| `if tt.shouldX` in loop body | Each branch is a different test — split it |\n| Same 3 fields identical in every case | Move to shared setup outside the table |\n| Adding a case requires understanding all others | Table has grown beyond its useful life |\n\n## Decision Flowchart\n\n1. **Is the function pure (input → output, no side effects)?**\n   Yes → table test is probably ideal. Go to 2.\n   No → consider explicit subtests first.\n\n2. **Do all cases share the exact same assertion pattern?**\n   Yes → table test. Go to 3.\n   No → explicit subtests.\n\n3. **Can each case be expressed in ≤5 struct fields?**\n   Yes → table test.\n   No → split by scenario into separate test functions.\n\n4. **Is the loop body ≤10 lines?**\n   Yes → you're golden.\n   No → the table is hiding complexity. Refactor.\n\n## Verification Checklist\n\n1. Table struct has only fields that vary between cases\n2. Every case has a descriptive `name` field\n3. Loop body is ≤10 lines with no branching\n4. No `setupFunc` or `mockFunc` fields in the struct\n5. `wantErr` is a simple bool or sentinel, not a string match\n6. Cases cover: happy path, error path, edge cases (empty, nil, zero, max)\n7. `t.Run` wraps each case for named subtests\n8. `t.Parallel()` used only when function is side-effect-free\n","# Go Table-Driven Tests\n\nTable-driven tests are a powerful Go idiom — when used correctly. Most\ncodebases either underuse them (10 copy-paste tests) or overuse them\n(complex branching logic in a 200-line struct). This skill covers the\nsweet spot.\n\nDetailed reference material, loaded on demand:\n\n- `references\u002Fpatterns.md` — full worked examples: canonical tables,\n  `wantErr`\u002F`wantErrIs`, parallel tables, map-based tables, error-only\n  tables, struct alignment for readability.\n- `references\u002Frefactoring.md` — recognizing bloated tables and rewriting\n  them as explicit subtests, with before\u002Fafter examples.\n\nRead a reference file only when the summary below is not enough for the\ntask at hand.\n\n## 1. When Table-Driven Tests Shine\n\nUse a table only when ALL of these are true:\n\n- **Same function** under test across all cases\n- **Same assertion pattern** — input in, output out, compare\n- **Cases differ only in data**, not in setup or verification logic\n- **3+ cases** — fewer than 3, explicit tests are clearer\n\nCanonical use case: pure functions, parsers, validators, formatters.\n\n```go\nfunc TestParseSize(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   string\n        want    int64\n        wantErr bool\n    }{\n        {name: \"plain bytes\", input: \"1024\", want: 1024},\n        {name: \"kilobytes suffix\", input: \"4KB\", want: 4096},\n        {name: \"empty string\", input: \"\", wantErr: true},\n        {name: \"negative size\", input: \"-1\", wantErr: true},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got, err := ParseSize(tt.input)\n            if tt.wantErr {\n                require.Error(t, err)\n                return\n            }\n            require.NoError(t, err)\n            assert.Equal(t, tt.want, got)\n        })\n    }\n}\n```\n\nEvery case has the same shape, the loop body is a few lines, and adding\na case is one struct literal. No branching, no conditionals.\n\n## 2. When NOT to Use Table-Driven Tests\n\n- **Complex per-case setup** — `setupMock`\u002F`setupFunc` function fields in\n  the struct mean the table is hiding complexity. Write explicit subtests.\n- **Fewer than 3 cases** — the struct definition is more code than two\n  plain test functions.\n- **Multiple branching paths** — `if tt.shouldError` \u002F `if tt.wantRedirect`\n  in the loop body means each branch is a different test pretending to\n  share a structure. Split it.\n\nSee `references\u002Frefactoring.md` for before\u002Fafter rewrites of each smell.\n\n## 3. Struct Design Rules\n\n1. **Every field must vary between at least 2 cases.** A field with the\n   same value everywhere is setup — move it outside the table.\n2. **Name the `name` field as a short sentence** describing the scenario:\n   `\"returns error for negative amount\"`, not `\"case1\"` or `\"success\"`.\n3. **`wantErr bool` for \"should it error?\"** — check it first and `return`\n   early in the loop body.\n4. **`wantErrIs error` with a sentinel** when the caller must detect a\n   specific error; assert with `require.ErrorIs`.\n5. **≤5 fields.** More means the scenario is too complex for a table —\n   split into separate test functions.\n\nFull field-pattern examples are in `references\u002Fpatterns.md`.\n\n## 4. The Loop Body Must Be Trivial\n\nThe point of a table test is identical execution logic for every case.\nKeep the loop body under ~10 lines: call, error check, comparison.\nIf it accumulates conditionals or per-case setup, the table has outgrown\nits usefulness — refactor into explicit subtests.\n\n## 5. Parallel Table Tests\n\n```go\nfor _, tt := range tests {\n    t.Run(tt.name, func(t *testing.T) {\n        t.Parallel()\n        got := Transform(tt.input)\n        assert.Equal(t, tt.want, got)\n    })\n}\n```\n\n- Go 1.22+ scopes the loop variable per iteration — `tt := tt` capture is\n  unnecessary. For Go \u003C1.22 the capture is still required.\n- Only use `t.Parallel()` when the function under test has no side\n  effects and no shared mutable state.\n\n## 6. Refactoring Bloated Tables\n\n| Symptom | Fix |\n|---|---|\n| Struct has 8+ fields | Split into multiple test functions by scenario |\n| `setupFunc` field in struct | Extract to separate subtests with explicit setup |\n| `if tt.shouldX` in loop body | Each branch is a different test — split it |\n| Same 3 fields identical in every case | Move to shared setup outside the table |\n| Adding a case requires understanding all others | Table has grown beyond its useful life |\n\n## Decision Flowchart\n\n1. **Is the function pure (input → output, no side effects)?**\n   Yes → table test is probably ideal. Go to 2.\n   No → consider explicit subtests first.\n\n2. **Do all cases share the exact same assertion pattern?**\n   Yes → table test. Go to 3.\n   No → explicit subtests.\n\n3. **Can each case be expressed in ≤5 struct fields?**\n   Yes → table test.\n   No → split by scenario into separate test functions.\n\n4. **Is the loop body ≤10 lines?**\n   Yes → you're golden.\n   No → the table is hiding complexity. Refactor.\n\n## Verification Checklist\n\n1. Table struct has only fields that vary between cases\n2. Every case has a descriptive `name` field\n3. Loop body is ≤10 lines with no branching\n4. No `setupFunc` or `mockFunc` fields in the struct\n5. `wantErr` is a simple bool or sentinel, not a string match\n6. Cases cover: happy path, error path, edge cases (empty, nil, zero, max)\n7. `t.Run` wraps each case for named subtests\n8. `t.Parallel()` used only when function is side-effect-free\n",{"name":5,"license":15,"metadata":24,"description":27,"allowed-tools":28,"compatibility":29,"user-invocable":30},{"author":25,"version":26},"eduardo-sl","1.2.1","Deep dive on table-driven tests in Go: when to use them, when to avoid them, struct design, subtest naming, advanced patterns like test matrices and shared setup, and refactoring bloated tables into clean ones. Use when writing table-driven tests, refactoring test tables, reviewing table test structure, or deciding whether table-driven is the right approach. Trigger examples: \"table-driven test\", \"table test\", \"test cases struct\", \"test matrix\", \"parametrize tests\", \"data-driven test\", \"refactor test table\". Not for: general test strategy, mocks, golden files, fuzzing (go-test-quality), benchmarks (go-performance-review).\n","Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)","Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.",true,"main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(testing)\u002Fgo-test-table-driven","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi","https:\u002F\u002Fgithub.com\u002Fkongnakornna","http:\u002F\u002Fcmoniot.trueddns.com:52160","Technical Skills and Expertise\r\nLanguages and Frameworks\r\nFrontend: HTML, JavaScript, TypeScript, React, Vue, Angular, Next.js\r\nBackend: Node.js,Python,Golang","2026-10-06 23:01:46",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":30},[41,44,47],{"tool":42,"command":43},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-test-table-driven",{"tool":45,"command":46},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-test-table-driven",{"tool":48,"command":49},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-test-table-driven","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(testing)\u002Fgo-test-table-driven\u002FSKILL.md",[52,58],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fpatterns.md","REFERENCE","参考文档",6487,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(testing)\u002Fgo-test-table-driven\u002Freferences\u002Fpatterns.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Frefactoring.md",4047,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(testing)\u002Fgo-test-table-driven\u002Freferences\u002Frefactoring.md",[63,71,78,85,92,99],{"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":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7A0M4JKY4DEDRP1CBHT00WV","tb-using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-using-git-worktrees\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7A0KZ5HRAQAAT2KXR6146Q7","tb-test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-test-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7A0KW92W3F18E2MRP8H62P2","tb-subagent-driven-development","Use when executing implementation plans with independent tasks in the current session","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-subagent-driven-development\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7A0KKYQCHYYRHA5J5BAP24M","tb-scrutinize","Outsider-perspective end-to-end review of a plan, PR, or code change. First questions intent and whether a simpler\u002Fmore elegant approach would achieve the same goal, then traces the actual code path (not just the diff) to verify the change does what it claims. Output is concise, actionable, and every call carries its rationale. Trigger on \u002Ftb-scrutinize and proactively whenever the user asks to review, audit, sanity-check, or get a second opinion on a plan, PR, diff, design doc, or proposed code change.","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-scrutinize\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7A0KFDR1V3RW7SW1XNHP82P","tb-requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-requesting-code-review\u002FSKILL.md",[],[]]