Skip to content
Skills Library
Programming · Building & coding

go-process-cli

/go-process-cli

Write Go CLIs that manage processes and workloads — daemons, supervisors, job runners, deploy tools, anything that spawns or controls other processes. Use when writing, reviewing, or refactoring Go that handles OS signals, runs children via os/exec, fans out concurrent work, threads context for cancellation, returns exit codes, or builds a flag/cobra command surface. Covers the footguns the standard library makes easy to hit — SIGTERM vs Ctrl-C, SIGKILL-by-default children, orphaned process groups, pipe deadlocks, goroutine leaks, zombie reaping, and os.FindProcess lying about liveness. Trigge

Repository
dot-skills ↗
Licence
MIT
Last repository change
15.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
29
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 15.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Write Go CLIs that manage processes and workloads — daemons, supervisors, job runners, deploy tools, anything that spawns or controls other processes. Use when writing, reviewing, or refactoring Go that handles OS signals, runs children via os/exec, fans out concurrent work, threads context for cancellation, returns exit codes, or builds a flag/cobra command surface. Covers the footguns the standard library makes easy to hit — SIGTERM vs Ctrl-C, SIGKILL-by-default children, orphaned process groups, pipe deadlocks, goroutine leaks, zombie reaping, and os.FindProcess lying about liveness. Trigge

Original author description

Write Go CLIs that manage processes and workloads — daemons, supervisors, job runners, deploy tools, anything that spawns or controls other processes. Use when writing, reviewing, or refactoring Go that handles OS signals, runs children via os/exec, fans out concurrent work, threads context for cancellation, returns exit codes, or builds a flag/cobra command surface. Covers the footguns the standard library makes easy to hit — SIGTERM vs Ctrl-C, SIGKILL-by-default children, orphaned process groups, pipe deadlocks, goroutine leaks, zombie reaping, and os.FindProcess lying about liveness. Trigge

How it works

  1. When to Apply
  2. Categories
  3. Quick Reference
  4. How to Use
  5. Source Authority
  6. Related Skills
Original SKILL.md headings · 55 lines, 578 words
SKILL.md preview
---
name: go-process-cli
description: Write Go CLIs that manage processes and workloads — daemons, supervisors, job runners, deploy tools, anything that spawns or controls other processes. Use when writing, reviewing, or refactoring Go that handles OS signals, runs children via os/exec, fans out concurrent work, threads context for cancellation, returns exit codes, or builds a flag/cobra command surface. Covers the footguns the standard library makes easy to hit — SIGTERM vs Ctrl-C, SIGKILL-by-default children, orphaned process groups, pipe deadlocks, goroutine leaks, zombie reaping, and os.FindProcess lying about liveness. Triggers whenever the task touches process lifecycle, graceful shutdown, subprocess control, or concurrent workload supervision in Go — even if not named.
---

# Go Process-Management CLIs

> Make Go command-line tools that spawn, supervise, and shut down processes correctly — the part the stdlib makes easy to get subtly wrong.

## When to Apply

Reach for this skill when building or reviewing a Go CLI whose job is to *control other processes or concurrent workloads*: a daemon, a process supervisor, a job/worker runner, a deploy or migration tool, a test harness that shells out, or any program that must stop cleanly when an orchestrator says so. It targets **Go 1.22+** on **Unix-like systems** (Linux, macOS); a few rules note where Windows differs. It assumes you already know Go — it only corrects the specific defaults that go wrong in this domain.

## Categories

| # | Category | Prefix | What it covers |
|---|----------|--------|----------------|
| 1 | Signals & Graceful Shutdown | `sig` | Binding a context to SIGINT/SIGTERM; second-signal force-quit |
| 2 | Child Processes | `exec` | `os/exec` lifetime, graceful kill, process groups, pipes, exit codes |
| 3 | Concurrency & Workloads | `work` | errgroup fan-out, bounded concurrency, goroutine-leak discipline, channel ownership |
| 4 | Context Propagation | `ctx` | Explicit context args, `defer cancel()`, cancellable waits |
| 5 | Errors & Exit Codes | `err` | `run() error` for deferred cleanup, aggregating failures |
| 6 | CLI Framework & Flags | `cli` | stdlib `flag` vs cobra, `ExecuteContext`, `RunE`, subcommand patterns |
| 7 | Process State & Supervision | `state` | Liveness probes, atomic PID files, zombie reaping, structured logs |

## Quick Reference

The defaults this skill exists to correct:

- **`signal.NotifyContext(ctx, SIGINT, SIGTERM)`** — not a channel that only watches Ctrl-C. Orchestrators send SIGTERM.
- **`exec.CommandContext` + `cmd.Cancel`/`cmd.WaitDelay`** — plain `CommandContext` SIGKILLs children with no cleanup.
- **`Setpgid` + `kill(-pgid)`** — signalling the direct child orphans grandchildren (`sh -c`, `make`, `npm`).
- **`cmd.Output()`** for capture — reading a pipe after `Wait()` deadlocks.
- **`errgroup.WithContext` + `SetLimit(n)`** — a goroutine per task means a *process* per task: PID/FD exhaustion.
- **`ctx` as an argument** — never a struct field; **`defer cancel()`** on every derived context.
- **`select { case <-ticker.C: case <-ctx.Done(): }`** — `time.Sleep` makes shutdown wait out the interval.
- **`main → run() error → os.Exit(1)`** — `log.Fatal`/`os.Exit` deep in code skip every `defer`.
- **`proc.Signal(syscall.Signal(0))`** — `os.FindProcess` always succeeds on Unix; it never proves liveness.
- **`os.OpenFile(O_CREATE|O_EXCL)`** for PID files — check-then-create is a race; **`cmd.Wait()`** every child or it zombifies.

## How to Use

1. Identify which category your task falls under (see table above).
2. Read the relevant rule files in `references/` — each is a focused, self-contained pattern naming the wrong default it corrects.
3. Apply the pattern; follow the `Reference` link in each rule for the authoritative source.

Rules cross-link (e.g. graceful shutdown ties signals → context → child-process kill → cleanup), so follow the links when a task spans categories.

When extending this skill, copy `assets/templates/_template.md`: WHY first, one canonical example with realistic names, a foil only if the wrong way is a genuine trap.

## Source Authority

Every rule cites primary sources — the Go standard library reference on pkg.go.dev, the official Go blog (go.dev/blog), and the cobra documentation — chosen because they are maintainer-authored and version-current. No content farms, listicles, or undated tutorials.

## Related Skills

- `radical-simplification` — when a supervisor design has accreted accidental complexity.
- `unix-cli` / `cli-for-agents` — broader CLI ergonomics beyond process management.
Files in this package (29)
  • AGENTS.md 5 KB
  • SKILL.md 5 KB
  • metadata.json 1 KB
  • assets/templates/_template.md 1 KB
  • references/_sections.md 3 KB
  • references/cli-execute-context-wires-signals.md 2 KB
  • references/cli-flag-vs-cobra-by-shape.md 2 KB
  • references/cli-rune-return-errors.md 2 KB
  • references/cli-stdlib-subcommand-pattern.md 2 KB
  • references/ctx-cancellable-wait.md 2 KB
  • references/ctx-defer-cancel.md 1 KB
  • references/ctx-explicit-argument.md 2 KB
  • references/err-join-aggregate-workloads.md 1 KB
  • references/err-run-function-for-deferred-cleanup.md 2 KB
  • references/exec-cancel-sigterm-before-kill.md 2 KB
  • references/exec-commandcontext-binds-lifetime.md 1 KB
  • references/exec-exit-code-from-exiterror.md 2 KB
  • references/exec-kill-process-group.md 2 KB
  • references/exec-pipes-without-deadlock.md 2 KB
  • references/sig-notify-context-for-shutdown.md 2 KB
  • references/sig-second-signal-force-quit.md 1 KB
  • references/state-atomic-pidfile.md 2 KB
  • references/state-reap-children-wait.md 2 KB
  • references/state-signal-zero-liveness.md 2 KB
  • references/state-structured-slog-transitions.md 2 KB
  • references/work-bound-concurrency.md 2 KB
  • references/work-errgroup-fan-out.md 2 KB
  • references/work-every-goroutine-has-exit.md 2 KB
  • references/work-sender-closes-channel.md 2 KB

Versions

The database has no other skills named go-process-cli.

Database snapshot: 13.11.2026 · package version 43fe29b52edc (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100go-cli
    Build command-line tools in Go: flag handling, subcommands, stdin/stdout discipline, exit codes, signal handling, and when Cobra/Viper earn their weight over the standard library. Use when: "build a CLI", "add a subcommand", "parse flags", "exit codes", "handle Ctrl+C", "cobra…
  • 100golang-cli
    Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI…
  • 100golang-cli
    Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI…
  • 100cobra-viper
    Expert skill for building CLI applications with Cobra and Viper, authored by spf13 — the original creator of both libraries. Covers command-first architecture, decoupled business logic, configuration management, environment variable binding, context-aware commands, and in-memory…
  • 100golang-spf13-cobra
    Golang CLI command tree library using spf13/cobra — cobra.Command, RunE vs Run, PersistentPreRunE hook chain, Args validators (NoArgs, ExactArgs, MatchAll, custom), persistent vs local flags, command groups, ValidArgsFunction, RegisterFlagCompletionFunc, ShellCompDirective,…
  • 100dart-build-cli-app
    Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.