Agent skill
logging-config
MANDATORY - All logging code must use slog with structured fields. Load before writing any logging.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/logging-config
SKILL.md
Structured Logging Standards
Requirements
- Use
log/slogexclusively - Never use
log.Printf(),fmt.Print(), or visual formatting (===, empty lines) - Use structured fields, not string interpolation
- Single format: JSON to stdout
// Wrong
logger.Printf("WARNING: Failed to fetch %s", url)
// Right
slog.Warn("upstream fetch failed", "upstream", url, "error", err)
Setup
cooked uses a single JSON handler writing to stdout:
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelInfo,
}))
slog.SetDefault(logger)
No log streams, no OTel/ECS formats, no object storage — just structured JSON to stdout.
Request Log Example
Every request is logged with structured fields:
{
"time": "2026-02-06T12:00:00Z",
"level": "INFO",
"msg": "request",
"method": "GET",
"path": "/https://cgit.internal/repo/plain/README.md",
"upstream": "https://cgit.internal/repo/plain/README.md",
"status": 200,
"cache": "hit",
"upstream_ms": 0,
"render_ms": 12,
"total_ms": 14,
"content_type": "markdown",
"bytes": 14832
}
Cache field values: hit, miss, revalidated, expired.
Log Message Style Guide
| Rule | Guideline | Example |
|---|---|---|
| Tense | Past for events, present for conditions | upstream fetched, cache full |
| Case | lowercase start (no capital unless proper noun) | config loaded, mermaid block found |
| Punctuation | No trailing period (fragments, not sentences) | request completed not Request completed. |
| Redundancy | No severity prefix (level conveys this) | upstream unreachable not Error: upstream unreachable |
| Specificity | State what failed, not generic failure | upstream fetch failed not operation failed |
| Brevity | Omit articles and filler words | file too large not The file was too large |
| Action | Use verb-noun or noun-verb pattern | config loaded, invalid upstream url |
Severity Levels
| Level | When to use | Examples |
|---|---|---|
| ERROR | Unrecoverable failures requiring attention | template parse failed, listen failed |
| WARN | Degraded but recoverable situations | upstream returned 5xx, cache eviction failed |
| INFO | Normal business events | request, server started, config loaded |
| DEBUG | Internal details for troubleshooting | cache hit, rewriting relative url, mdx import stripped |
Structured Fields
- Use snake_case for field names:
upstream_ms,content_type,cache_status - Suffix units:
_ms,_bytes,_count - Boolean fields:
has_mermaid,has_toc - Avoid embedding data in message string; use fields instead
// Bad
slog.Info(fmt.Sprintf("fetched %s in %dms", url, dur))
// Good
slog.Info("upstream fetched", "upstream", url, "duration_ms", dur)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?