AGENT SKILL

go-cli-process-control

Execute and supervise external programs safely from Go CLIs with explicit arguments, typed failure classification, working directories, environments, bounded streams, deadlock-safe pipes, contexts, timeouts, signals, platform adapters, descendant cleanup, runner seams, and lifecycle tests. Use when wrapping a command, diagnosing start or exit failures, hangs, deadlocks, or orphan processes, or implementing cancellable cross-platform CLI workflows.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 1.6k
Forks
491

01 前言 Front Matter

name
go-cli-process-control
license
MIT
metadata
{ "tags": "go,golang,cli,os-exec,subprocess,signals,cancellation", "version": "0.3.0", "category": "Go", "displayName": "Go CLI Process Control" }
description
Execute and supervise external programs safely from Go CLIs with explicit arguments, typed failure classification, working directories, environments, bounded streams, deadlock-safe pipes, contexts, timeouts, signals, platform adapters, descendant cleanup, runner seams, and lifecycle tests. Use when wrapping a command, diagnosing start or exit failures, hangs, deadlocks, or orphan processes, or implementing cancellable cross-platform CLI workflows.
compatibility
Codex, Claude Code, and other Agent Skills-compatible clients.

02 资源文件 8

03 SKILL.md 正文

Go CLI Process Control

Treat child-process lifecycle as correctness. Observe the terminal result, propagate cancellation, and clean up every process, pipe, and temporary resource.

Core Workflow

  1. Define the child executable, argv, environment, directory, streams, and success contract.
  2. Use an explicit shell only when shell semantics are actually required.
  3. Inject a runner boundary and propagate the caller's context.
  4. Observe startup and completion; preserve status and useful redacted stderr.
  5. Bound captured output, cancellation, and shutdown time.
  6. Account for descendants and wait for every pipeline stage.
  7. Test missing tools, bad exits, malformed output, cancellation, signals, and cleanup.

Read Next

Task Load
Implement or repair process supervision guidelines.md, workflows/supervise-external-command.md
Apply modern execution and cancellation rules references/process-control/rules.md
Use runner, pipeline, signal, or cleanup patterns references/process-control/patterns.md
Start from focused code examples references/process-control/examples.md
Review a subprocess boundary references/process-control/checklist.md
Understand lifecycle and shell semantics references/process-control/knowledge.md

Guardrails

  • Pass executable arguments separately; never assume exec.Command invokes a shell.
  • Do not treat Start as success; inspect the terminal result.
  • Do not assume context cancellation terminates an entire process tree.
  • Close owned pipes and wait for every started process.
  • Distinguish lookup, start, exit, timeout, cancellation, and cleanup failures.
  • Treat Cmd.String() as diagnostic text, never shell-safe replay or secret-safe output.
  • Avoid mutable package-level command hooks in concurrent tests.

Source Notes

Guidance is transformed and paraphrased from Ricardo Gerardi, Powerful Command-Line Applications in Go (Pragmatic Bookshelf, 2021), especially Chapter 6. Examples are original adaptations.

Book: https://pragprog.com/titles/rggo/powerful-command-line-applications-in-go/

Verify current behavior against https://pkg.go.dev/os/exec and https://pkg.go.dev/os/signal, including Cmd.Cancel, WaitDelay, and signal.NotifyContext.

Failure taxonomy, pipe ordering, and platform-adapter guidance also incorporates transformed material from Marian Montagnino, Building Modern CLI Applications in Go (Packt, 2023), especially Chapter 6.

In-process cancellation boundary guidance also incorporates transformed material from Inanc Gumus, Go by Example: Programmer's Guide to Idiomatic and Testable Programs (Manning, 2025), Chapters 6-7.

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