Skip to content
Development
Skill

/golang-logging

Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.

From plugin
agent-skills-standard
583200 skills21 agents33 commands1 MCP

Claude Code

$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill golang-logging --agent claude-code

SKILL.md

golang-logging.SKILL.md
name: golang-logging
description: Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.
metadata:
  triggers:
    files:
    - 'go.mod'
    - 'pkg/logger/**'
    keywords:
    - logging
    - slog
    - structured logging
    - zap

Golang Logging Standards

**Priority: P1 (HIGH)**

Principles

  • **Structured Logging**: Use JSON or structured key-value attributes. Machine-readable and filterable.
  • **Strict Single-Log Boundary**: Log errors once where they are handled or translated at the boundary (service or handler level). **Never double-log** in repository, utility, or deep helper functions—wrap and return errors instead.
  • **Typed Context Keys**: Always use private typed keys (`type ctxKey string`) for storing and retrieving request-scoped logger attributes.
  • **Business Traceability vs PII Redaction**: Include non-sensitive business identifiers (e.g. tenant ID, organization code, order number) for traceability. Strictly redact credentials, API tokens, passwords, and sensitive PII.
  • **Leveled Logging**: Debug, Info, Warn, Error.
  • **No `log.Fatal`**: Avoid terminating apps inside libraries. Return errors instead; only `main()` should handle process exit.

Libraries

  • **`log/slog` (Recommended Stdlib)**: Stdlib since Go 1.21. Fast, structured, zero-dep.
  • **Zap (`uber-go/zap`)**: Production-grade structured logger for high-throughput microservices.
  • **Zerolog**: Zero allocation, fast JSON logger.

Workflow: Set Up Structured Logging

1. Initialize structured logger at startup in `main()` with standard JSON output. 2. Inject request correlation IDs (TraceID, RequestID) via middleware using typed context keys. 3. Pass logger via context (`logger.FromContext(ctx)`) or constructor injection. 4. Log at the application boundary on error; wrap errors upstream without intermediate logging.

See [slog setup and usage examples](references/slog-patterns.md)

Anti-Patterns

  • **No Double-Logging**: Do not log an error in the repository/database helper AND log it again in the service/handler.
  • **No fmt.Println in production**: Use structured, leveled loggers.
  • **No Untyped Context Keys**: Avoid `context.WithValue(ctx, "logger", l)` with raw string keys.
  • **No Secrets in Logs**: Redact bearer tokens, passwords, and sensitive personal info.
  • **No log.Fatal in libraries**: Return errors; only `main()` should call `os.Exit`.

References

  • [Slog Patterns](references/slog-patterns.md)
Read more
@hoangnguyen0403
Ships withagent-skills-standard

The portable standards layer for AI coding agents. Sync once, then work in your own runtime.

583200 skills21 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
583
Star history of hoangnguyen0403/agent-skills-standard on GitHub, a chart by star-history.com

Other skills on agent-skills-standard.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills13d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react4d252k
@facebook@facebookInstall Skill

Questions about golang-logging.

Which coding agents can use golang-logging?
golang-logging installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.