Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

go-process-cli

FreeNo executable scriptsNot checked

Write Go CLIs that manage processes and workloads — daemons, supervisors, job runners, deploy tools, anything that spawns or controls other processes. Use…

pproencaby pproenca★ 231 GitHub stars

About this skill

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.
Full SKILL.md on GitHub

Install go-process-cli in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

AGENTS.mdassets/templates/_template.mdmetadata.jsonreferences/_sections.mdreferences/cli-execute-context-wires-signals.mdreferences/cli-flag-vs-cobra-by-shape.mdreferences/cli-rune-return-errors.mdreferences/cli-stdlib-subcommand-pattern.mdreferences/ctx-cancellable-wait.mdreferences/ctx-defer-cancel.mdreferences/ctx-explicit-argument.mdreferences/err-join-aggregate-workloads.mdreferences/err-run-function-for-deferred-cleanup.mdreferences/exec-cancel-sigterm-before-kill.mdreferences/exec-commandcontext-binds-lifetime.mdreferences/exec-exit-code-from-exiterror.mdreferences/exec-kill-process-group.mdreferences/exec-pipes-without-deadlock.mdreferences/sig-notify-context-for-shutdown.mdreferences/sig-second-signal-force-quit.mdreferences/state-atomic-pidfile.mdreferences/state-reap-children-wait.mdreferences/state-signal-zero-liveness.mdreferences/state-structured-slog-transitions.mdreferences/work-bound-concurrency.mdreferences/work-errgroup-fan-out.mdreferences/work-every-goroutine-has-exit.mdreferences/work-sender-closes-channel.md

FAQ

What does the go-process-cli skill do?

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.

How do I install the go-process-cli skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the go-process-cli skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare go-process-cli with