agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/golang/go-testing/SKILL.md

go-testing

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through authoring, running, and debugging Go tests using table-driven tests, subtests (t.Run), and race detection (-race).

13 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use go-performance, chained-pr and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • els0rSkill

    go-performance

    Go performance analysis: memory allocation, CPU bottlenecks, concurrency contention, struct alignment, escape analysis, and benchmarking patterns. Use this skill whenever writing performance-sensitive Go code, reviewing Go code for efficiency, discussing allocations or GC pressure, benchmarking, profiling with pprof, or optimizing hot paths. Also trigger when the user mentions sync.Pool, atomic operations, pre-allocation, or escape analysis — even without saying "performance."

    Also in 4 projects that use this

  • joeldevzSkill

    chained-pr

    Split large changes (>400 lines OR >5 slices) into a series of reviewable PRs. Two strategies — stacked-to-main and feature-branch-chain. Prevents the 100-conflict merge disaster.

    Also in 3 projects that use this

  • wpankSkill

    go-concurrency

    Production Go concurrency patterns — goroutines, channels, sync primitives, context, worker pools, pipelines, and graceful shutdown. Use when building concurrent Go applications or debugging race conditions.

    Also in 4 projects that use this

  • joeldevzSkill

    work-unit-commits

    Commit discipline. Each commit is a self-contained, reviewable work unit — code + tests + docs together. Stops the 190-commit PR disaster before it starts.

    Also in 3 projects that use this

  • Gentleman-ProgrammingSkill

    branch-pr

    Also in 3 projects that use this

  • Gentleman-ProgrammingSkill

    issue-creation

    Also in 3 projects that use this

  • +2 more from joeldevz

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Very specific:

    Do not use for Python or TS tests.

    line 20
  3. Very specific:

    Do not use for static linting.

    line 21
  4. Very specific:

    If package_path is missing: default to ./....

    line 28
  5. Distinctive:

    Never write empty test functions without assertions.

    line 29
  6. Distinctive:

    Follow these numbered actions:

    line 32
  7. Very specific:

    Look for t.Errorf("got %v, want %v", got, want) outputs.

    line 38
  8. Very specific:

    If concurrency is tested: always pass -race flag.

    line 45
  9. Very specific:

    When writing table tests: use for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { ...

    line 46
  10. Distinctive:

    Stop and ask the user when:

    line 72

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go Testing (go test)

Guides agents through executing, isolating, and debugging Go test suites. Enforces canonical table-driven test patterns, subtests (t.Run), and data race detection (-race).

1. Purpose

Execute and debug Go tests. A "Table-Driven Test" iterates over a slice of test case structs containing name, inputs, and expected outcomes.

2. When to Use

Use this skill when:

  • Running tests in Go projects (go test ./...).
  • Running a single targeted Go test using -run.
  • Checking for concurrent race conditions using go test -race.

3. When Not to Use

  • Do not use for Python or TS tests; use py-testing or ts-testing.
  • Do not use for static linting; use go-lint-and-vet.

4. Required Inputs

  • package_path: Go package path (e.g. ./internal/auth or ./...).
  • test_name: Optional regex pattern for -run.

5. Missing-Input Behavior

  1. If package_path is missing: default to ./....
  2. Never write empty test functions without assertions.

6. Procedure

Follow these numbered actions:

  1. Action 1: Run Targeted Test
    • Execute: go test -v -run "^<test_name>$" <package_path>
  2. Action 2: Check for Concurrency Data Races
    • Execute: go test -race <package_path>
  3. Action 3: Trace Assertion Failure
    • Look for t.Errorf("got %v, want %v", got, want) outputs.
  4. Action 4: Apply Fix & Verify
    • Re-run test until PASS.
  5. Action 5: Run Entire Package Suite
    • Execute go test ./....

7. Decision Rules

  • If concurrency is tested: always pass -race flag.
  • When writing table tests: use for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { ... }) }.

8. Output Format

Emit the report using this template:

### Go Test Report: [Package]

- **Command**: `go test -v -run "[pattern]" [package]`
- **Status**: [PASS | FAIL]
- **Race Check**: [PASS | DETECTED]

#### Results
- [Summary of passed/failed tests]

9. Verification Checklist

  • go test executed with clean PASS.
  • go test -race passes with zero data races.
  • Tests follow table-driven structure.

10. Common Failures and Recovery

Failure SymptomCauseRecovery Action
Loop variable capture in t.Parallel()Pre-Go 1.22 loop closureBind tc := tc inside loop body.

11. Stop or Escalation Conditions

Stop and ask the user when:

  • Tests require external CGO bindings or proprietary database connections.

12. Examples

Example 1: Successful Execution

Input:

Package: ./pkg/math
Test: TestAdd

Output:

### Go Test Report: ./pkg/math

- **Command**: `go test -v -run "^TestAdd$" ./pkg/math`
- **Status**: PASS
- **Race Check**: PASS

#### Results
- `=== RUN   TestAdd`
- `--- PASS: TestAdd (0.00s)`

Example 2: Ambiguous or Missing Input

Input:

Test go.

Output:

### Go Test Report: Halted - Ambiguous Package

- **Status**: Halted

Please specify the Go package to test (e.g. `./cmd/...` or `./internal/auth`).

Example 3: Expected Final Output

Output:

### Go Test Report: ./internal/cache

- **Command**: `go test -race ./internal/cache`
- **Status**: PASS
- **Race Check**: PASS

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.