Implements table-driven testing patterns in Go to reduce code duplication and improve test coverage for complex logic.
Install
mkdir -p .claude/skills/go-table-driven-tests && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3238" && unzip -o skill.zip -d .claude/skills/go-table-driven-tests && rm skill.zipInstalls to .claude/skills/go-table-driven-tests
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Write Go table-driven tests following Go community best practices and this repository's conventions. Use when writing or refactoring Go tests, especially when you notice repeated test patterns or copy-pasted test code.Key capabilities
- →Define test cases using slice or map patterns
- →Execute subtests using t.Run
- →Implement optional precondition setup functions
- →Run tests in parallel with t.Parallel
- →Compare errors using errors.Is
How it works
It iterates over a defined table of test cases, executing each as a subtest using t.Run to ensure systematic coverage and maintainable code.
Inputs & outputs
When to use go-table-driven-tests
- →Writing repeatable tests for functions with multiple inputs
- →Refactoring legacy test code to reduce duplication
- →Adding edge-case coverage to existing Go functions
About go-table-driven-tests
Provides templates and best practices for creating table-driven tests in Go. It simplifies adding new test cases and helps enforce systematic coverage for functions with multiple input paths.
Write Go table-driven tests following Go community best practices and this repository's conventions. Use when writing or refactoring Go tests, especially when you notice repeated test patterns or copy-pasted test code.
When not to use it
- →Unrelated test scenarios
- →Tests requiring substantially different setup or teardown logic
Limitations
- →Requires named structs for clarity
- →Requires manual range variable capture for Go versions below 1.22
How it compares
Unlike traditional tests that require separate functions for each case, this approach uses a single function to iterate over a data-driven table.
Compared to similar skills
go-table-driven-tests side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| go-table-driven-tests (this skill) | 1 | 9mo | Review | Beginner |
| go-dev-guidelines | 14 | 1y | No flags | Intermediate |
| code-formatting | 1 | 5mo | No flags | Beginner |
| tidb-test-guidelines | 2 | 4mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by Xe
View all by Xe →You might also like
go-dev-guidelines
jumppad-labs
This skill should be used when writing, refactoring, or testing Go code. It provides idiomatic Go development patterns, TDD-based workflows, project structure conventions, and testing best practices using testify/require and mockery. Activate this skill when creating new Go features, services, packages, tests, or when setting up new Go projects.
code-formatting
openshift
MANDATORY: When writing Go tests, you MUST use 'When...it should...' format for ALL test names. When writing any Go code, you MUST remind user to run 'make lint-fix' and 'make verify'. These are non-negotiable HyperShift requirements.
tidb-test-guidelines
pingcap
Decide where to place TiDB tests and how to write them (basic structure, naming, testdata usage). Use when asked about test locations, writing conventions, shard_count limits, casetest categorization, or when reviewing test changes in code review.
run-tests
pgschema
Run pgschema automated tests (go test) to validate diff logic, plan generation, and dump functionality using test fixtures
lsp-hover-testing
MadAppGang
Automated LSP hover validation for Dingo transpiler. Use when testing hover functionality, validating position mappings, checking for hover drift, or debugging LSP issues after sourcemap changes.
go-rig
mudrii
Use this skill when building, reviewing, or refactoring Go code in this repository. It adds process discipline for TDD/ATDD, package boundaries, dependency injection, and review quality, and complements the always-on rules in AGENTS.md.