go-cli-errors-observability
Design and review recoverable Go CLI errors, exit semantics, structured logging, debug modes, traces, profiles, redaction, and user-consented diagnostic bundles. Use when a CLI needs actionable failures, safe support evidence, production troubleshooting, or observability that does not corrupt command output or expose secrets.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- go-cli-errors-observability
- license
- MIT
- metadata
- { "tags": "go,golang,cli,errors,observability,logging,diagnostics", "version": "0.3.0", "category": "Go", "displayName": "Go CLI Errors and Observability" }
- description
- Design and review recoverable Go CLI errors, exit semantics, structured logging, debug modes, traces, profiles, redaction, and user-consented diagnostic bundles. Use when a CLI needs actionable failures, safe support evidence, production troubleshooting, or observability that does not corrupt command output or expose secrets.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 7
- 参考文档agents/openai.yaml255 B
- 参考文档guidelines.md1.5 KB
- 参考文档references/errors-observability/examples.md1.6 KB
- 参考文档references/errors-observability/knowledge.md3.0 KB
- 参考文档references/errors-observability/rules.md2.2 KB
- 参考文档workflows/add-safe-diagnostics.md1.5 KB
- 参考文档workflows/design-error-recovery.md974 B
03 SKILL.md 正文
Go CLI Errors and Observability
Design failures for recovery first, then add the minimum safe evidence needed to diagnose them. Keep internal detail out of the normal user contract.
Core Workflow
- Classify failures by user action, dependency, cancellation, and internal defect.
- Preserve machine-checkable causes with wrapping, types, or sentinels.
- Map causes to concise user messages and stable exit behavior at the boundary.
- Assign one terminal owner to render, log, and map each failure.
- Preserve material cleanup failures without hiding the primary cause.
- Add opt-in verbosity and structured logs on stderr or a dedicated sink.
- Allowlist and redact diagnostic evidence; require consent before collection or upload.
- Test recovery guidance, output separation, redaction, and cancellation.
Read Next
| Task | Load |
|---|---|
| Design error taxonomy and recovery | guidelines.md, workflows/design-error-recovery.md |
| Add logging or support diagnostics | references/errors-observability/rules.md, workflows/add-safe-diagnostics.md |
| Review code patterns | references/errors-observability/examples.md |
| Understand layering and privacy | references/errors-observability/knowledge.md |
Guardrails
- Never log secrets, authorization headers, raw config, or unreviewed environment data.
- Do not make normal stdout depend on log level.
- Preserve cancellation and timeout identity with
errors.Is. - Do not both log and return the same failure at intermediate layers.
- Do not use panic for ordinary validation, dependency, or user errors.
- Do not collect or upload diagnostics without a visible allowlist and consent.
- Protect profiling or debug servers; default them off and bind locally.
Source Notes
Guidance is transformed and paraphrased from Marian Montagnino, Building Modern CLI Applications in Go (Packt, 2023), especially Chapter 9, and Ricardo Gerardi, Powerful Command-Line Applications in Go (2021).
Handler composition, context correlation, and joined-error guidance also incorporates transformed material from Inanc Gumus, Go by Example: Programmer's Guide to Idiomatic and Testable Programs (Manning, 2025), Chapter 9.
Error ownership, panic boundaries, and cleanup-failure guidance also incorporates transformed material from Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022), Chapter 7.
Verify current logging APIs against https://pkg.go.dev/log/slog and error APIs against the current Go standard library documentation.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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.