go-cli-testing
Design, implement, stabilize, and review Go CLI tests across fresh command trees, pure logic, table-driven cases, streams, typed configuration, files, environment, function-backed HTTP fakes, repositories, subprocesses, capability profiles, race checks, and artifact behavior. Use when adding command tests, diagnosing flaky Go tests, choosing test boundaries, or verifying human-, agent-, and CI-facing CLI contracts.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 490
01 前言 Front Matter
- name
- go-cli-testing
- license
- MIT
- metadata
- { "tags": "go,golang,cli,testing,table-tests,integration-tests,subprocess", "version": "0.4.0", "category": "Go", "displayName": "Go CLI Testing" }
- description
- Design, implement, stabilize, and review Go CLI tests across fresh command trees, pure logic, table-driven cases, streams, typed configuration, files, environment, function-backed HTTP fakes, repositories, subprocesses, capability profiles, race checks, and artifact behavior. Use when adding command tests, diagnosing flaky Go tests, choosing test boundaries, or verifying human-, agent-, and CI-facing CLI contracts.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 9
- 参考文档agents/openai.yaml226 B
- 参考文档guidelines.md3.8 KB
- 参考文档references/cli-testing/checklist.md7.8 KB
- 参考文档references/cli-testing/examples.md4.9 KB
- 参考文档references/cli-testing/knowledge.md7.1 KB
- 参考文档references/cli-testing/patterns.md9.3 KB
- 参考文档references/cli-testing/rules.md7.0 KB
- 参考文档workflows/stabilize-flaky-test.md1.4 KB
- 参考文档workflows/test-cli-command.md4.8 KB
03 SKILL.md 正文
Go CLI Testing
Test observable behavior at the narrowest boundary that proves it. Isolate every mutable resource and reserve executable tests for process-level semantics.
Core Workflow
- Inventory success, invalid, boundary, dependency-failure, and cancellation behavior.
- Map each case to a pure, command, adapter, integration, or binary test.
- Inject arguments, streams, configuration, clocks, and effectful dependencies.
- Isolate files, environment, servers, repositories, ports, and subprocesses.
- Assert stdout, stderr, exit behavior, and errors according to the public contract.
- Gate live or platform-specific tests and make their changes reversible.
- Run standard, race, tagged, and relevant platform checks.
- Execute every supported build profile and smoke-test final artifacts.
- Interpret coverage gaps without treating execution as behavioral proof.
Read Next
| Task | Load |
|---|---|
| Build or overhaul a CLI test suite | guidelines.md, workflows/test-cli-command.md |
| Stabilize a flaky asynchronous test | workflows/stabilize-flaky-test.md |
| Write focused command tests | references/cli-testing/rules.md, references/cli-testing/examples.md |
| Add subprocess, HTTP, repository, or integration tests | references/cli-testing/patterns.md |
| Review coverage, isolation, or flakiness | references/cli-testing/checklist.md |
| Choose the right test boundary | references/cli-testing/knowledge.md |
| Benchmark or profile performance | Use go-performance-testing |
Guardrails
- Do not mutate developer data or depend on fixed temporary paths and ports.
- Do not run parallel tests that replace process-global state.
- Replace timing sleeps with synchronization, deadlines, or fake clocks.
- Use
testing/synctestonly when the minimum Go version supports it and the behavior fits an isolated bubble. - Inspect wrapped errors structurally unless exact diagnostics are contractual.
- Prefer one valuable executable flow over many slow end-to-end tests.
- Construct a fresh command tree and typed configuration for every test.
- Assert both
Executeerrors and stream output.
Source Notes
Guidance is transformed and paraphrased from testing material throughout Ricardo Gerardi, Powerful Command-Line Applications in Go (Pragmatic Bookshelf, 2021), especially Chapters 1-7 and 11. Examples are original.
Book: https://pragprog.com/titles/rggo/powerful-command-line-applications-in-go/
Modern test APIs should be verified against https://pkg.go.dev/testing and the current Go documentation before implementation.
Fresh command-tree, HTTP fake, configuration, and build-profile guidance also incorporates transformed material from Marian Montagnino, Building Modern CLI Applications in Go (Packt, 2023), especially Chapters 4, 6, and 11.
Subtest, coverage, parser, concurrency, HTTP server, and SQL adapter guidance also incorporates transformed material from Inanc Gumus, Go by Example: Programmer's Guide to Idiomatic and Testable Programs (Manning, 2025), Chapters 2-10.
Test categorization, race/shuffle execution, deterministic time, iotest, and
benchmark-correctness guidance also incorporates transformed material from
Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022),
Chapter 11.
04 同仓库更多 Skills
migrate-to-e2e
Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.
e2e
Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.
create-verification-skill
Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.
deja-search
deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.
deja-reflect
End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.
revid
Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.