Go CLI Rules

Go CLI Rules

Gives an AI coding assistant conventions for building Go command-line tools: Cobra, exit codes, output streams, config order and testing.

Go CLI taste of a developer who ships single-binary command-line tools

  • Use Cobra for tools with subcommands; use the standard flag package for single-purpose tools. Confidence: 0.80
  • Keep main.go tiny: build the root command, run it, and map the returned error to an exit code. Confidence: 0.90
  • Put command wiring in cmd/ and real logic in internal/ packages that know nothing about flags or the terminal. Confidence: 0.85
  • Return errors from RunE instead of calling os.Exit or log.Fatal inside commands. Confidence: 0.90
  • Exit with 0 on success, 1 for runtime failures and 2 for usage errors. Confidence: 0.85
  • Write results to stdout and diagnostics to stderr; never mix progress output into data streams. Confidence: 0.95
  • Offer --output json for scripting and keep the JSON shape stable across minor versions. Confidence: 0.85
  • Detect a TTY before using colors, spinners or interactive prompts, and respect NO_COLOR. Confidence: 0.90
  • Read configuration in a clear order: flags, then environment variables, then config file, then defaults. Confidence: 0.85
  • Store config files under os.UserConfigDir() and caches under os.UserCacheDir(), not in the home directory root. Confidence: 0.80
  • Pass context.Context through every operation and cancel it on SIGINT/SIGTERM with signal.NotifyContext. Confidence: 0.90
  • Use log/slog for debug logging behind a --verbose flag; keep default output quiet. Confidence: 0.80
  • Inject io.Writers and the environment into commands so they can be tested without touching the real terminal. Confidence: 0.85
  • Write table-driven tests for logic and golden-file tests for command output, with an -update flag to refresh goldens. Confidence: 0.85
  • Build static binaries with CGO_ENABLED=0 and -trimpath whenever the tool doesn't need cgo. Confidence: 0.85
  • Embed version, commit and build date via -ldflags or debug.ReadBuildInfo, and expose them in a version command. Confidence: 0.90
  • Release with GoReleaser: cross-compiled archives, checksums and a Homebrew tap from one tagged commit. Confidence: 0.80
  • Ship shell completions for bash, zsh and fish generated from the command tree. Confidence: 0.80
  • Make destructive commands ask for confirmation in a TTY and require --yes or --force in scripts. Confidence: 0.90
  • Keep dependencies few and run go vet, staticcheck and govulncheck in CI. Confidence: 0.85
  • Keep startup fast: no network calls or heavy initialization before a command actually needs them. Confidence: 0.80

Public domain (CC0 1.0) · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…