AGENT SKILL

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
491

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

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

  1. Inventory success, invalid, boundary, dependency-failure, and cancellation behavior.
  2. Map each case to a pure, command, adapter, integration, or binary test.
  3. Inject arguments, streams, configuration, clocks, and effectful dependencies.
  4. Isolate files, environment, servers, repositories, ports, and subprocesses.
  5. Assert stdout, stderr, exit behavior, and errors according to the public contract.
  6. Gate live or platform-specific tests and make their changes reversible.
  7. Run standard, race, tagged, and relevant platform checks.
  8. Execute every supported build profile and smoke-test final artifacts.
  9. 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/synctest only 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 Execute errors 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

hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-review-with-annotations

Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-find-and-synthesize-context

Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-update-docs

Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-manage-records

Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-create-or-manage-interactive-html

Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.

★ 1.6k
hashgraph-online
hashgraph-online/awesome-codex-plugins

worktable-collaborate-threads

Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.

★ 1.6k