No slash command · from go-specialist
Detects white box Go tests (same package name) and suggests converting them to black box tests (package foo_test), creating export_test.go bridges when internal symbols need external access.
Ships in go-specialist. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Detect Go test files using white box testing (same package name) and propose conversion to black box testing (package foo_test). Creates export_test.go bridge files when internal symbols need external test access.
*_test.go files during implementation.go file and one *_test.go file to analyze.go listgo list already reports the in-package/external split per package, and honours
build constraints. Use it rather than globbing:
go list -f '{{.ImportPath}} {{.Name}} white={{.TestGoFiles}} black={{.XTestGoFiles}}' ./...
| Field | Package clause | Classification |
|---|---|---|
TestGoFiles | package foo | White box — candidate for conversion |
XTestGoFiles | package foo_test | Black box — already correct |
Two rules when reading the output:
export_test.go from the white box set. It is a bridge file and belongs
to the source package by design, so it is never a conversion candidate.TestGoFiles and
XTestGoFiles for the same package is normal, not a defect.Why not Glob **/*_test.go and read package lines: a test file behind a
constraint like //go:build linux is matched by Glob on any OS but correctly
excluded by go list, so the manual approach both over- and under-reports. go list also names the source package directly, removing the need to read sibling
non-test files to infer it.
For each directory containing test files, check whether an export_test.go already exists.
Present a summary table:
| File | Package | Classification | export_test.go |
|---|---|---|---|
calc_test.go | calculator | White box | No |
math_test.go | calculator_test | Black box | N/A |
internal_test.go | parser | White box | Yes |
For each white box test file identified:
Read the test file and identify references to unexported symbols (lowercase-initial identifiers) from the package under test:
Case A — No unexported symbols used:
package foo to package foo_testAdd(1, 2) → calculator.Add(1, 2))Case B — Unexported symbols used:
package foo to package foo_test in the test fileexport_test.go in the same directory with package foo (no _test suffix) that exports needed internals:package foo
// Exported for testing in foo_test package.
var (
TestableInternalFunc = internalFunc
TestableInternalVar = internalVar
)
Case C — Heavy internal coupling (>10 unexported references):
After conversion, run:
go test ./...
go vet ./...
If tests fail, diagnose: missing imports, renamed references, or unexported symbols not yet bridged via export_test.go.
export_test.go (Go convention)_test suffix) — this is what makes it a bridgeexport_test.go only during go testTestable or use the capitalized form of the original name// Exported for testing in <pkg>_test package. header comment| Condition | Action |
|---|---|
No go.mod found | Abort: "Not a Go module." |
| No test files found | Report: "No test files found. Nothing to analyze." |
| All tests already black box | Report: "All test files use black box naming. No conversion needed." |
| Test compilation fails after conversion | Diagnose missing imports or unexported references. Attempt fix (max 2 retries). |
go vet fails after conversion | Display errors and suggest manual review. |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sgaunet/claude-plugins --plugin go-specialist11 skills in this plugin
/gen-forgejo-dirGenerate complete .forgejo/workflows directory with Forgejo Actions workflows (test, lint, release) for Go projects/gen-github-dirGenerate complete .github directory with workflows, dependabot, and funding configs for Go projects/gen-gitlab-ciGenerate GitLab CI/CD pipeline configuration for Go projects with testing, coverage, and automated releases/gen-goreleaserGenerate GoReleaser configuration with multi-arch Docker builds and release automationOther plugins' skills for the same job