一键导入
logging-sucks
Use when adding, refactoring, or reviewing logging code and callsites across a codebase. Ensures structured, queryable, context-rich logging.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when adding, refactoring, or reviewing logging code and callsites across a codebase. Ensures structured, queryable, context-rich logging.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create or improve agent skills. Load when creating SKILL.md files, writing skill descriptions, or structuring skill content for OpenCode or Claude.
Build stateful AI agents using the Cloudflare Agents SDK. Load when creating agents with persistent state, scheduling, RPC, MCP servers, email handling, or streaming chat. Covers Agent class, AIChatAgent, state management, and Code Mode for reduced token usage.
Reviews code changes for bugs, security regressions, type-safety issues, and maintainability. Use when asked to review uncommitted changes, the last commit, a PR/MR, a diff, or specific changed files.
Performs security-focused differential review of code changes (PRs, commits, diffs). Load for security audit, regression review, auth/crypto/access-control changes, validation removal, blast-radius analysis, adversarial review, or comprehensive markdown reports. Use standard code-reviewer for ordinary quick reviews.
Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC methods, SQLite storage, alarms, WebSockets, or reviewing DO code for best practices. Covers Workers integration, wrangler config, and testing with Vitest.
Manages GitLab merge requests, CI/CD pipelines, and issues via glab CLI. Load before running glab commands, creating MRs, debugging pipeline failures, checking CI status, or any GitLab operation. Triggers on "merge request", "pipeline", "CI failure", "glab", or when git remote contains "gitlab".
| name | logging-sucks |
| description | Use when adding, refactoring, or reviewing logging code and callsites across a codebase. Ensures structured, queryable, context-rich logging. |
| license | MIT |
| compatibility | opencode |
| metadata | {"source":"https://loggingsucks.com/","author":"Boris Tane"} |
This skill is adapted from "Logging sucks. And here's how to make it better." by Boris Tane.
When helping with logging, observability, or debugging strategies, first identify the current logger, transport, schema, and deployment/runtime constraints. Then follow these principles:
Instead of scattering 10-20 log lines throughout a request, emit one comprehensive event per request per service. This is the most important concept for effective logging.
Example wide event structure:
{
"timestamp": "2025-01-15T10:23:45.612Z",
"request_id": "req_8bf7ec2d",
"trace_id": "abc123",
"service": "checkout-service",
"method": "POST",
"path": "/api/checkout",
"status_code": 500,
"duration_ms": 1247,
"user": {
"id": "user_456",
"subscription": "premium",
"account_age_days": 847
},
"cart": {
"id": "cart_xyz",
"item_count": 3,
"total_cents": 15999
},
"error": {
"type": "PaymentError",
"code": "card_declined",
"message": "Card declined by issuer"
},
"feature_flags": {
"new_checkout_flow": true
}
}
This enables queries like: "Show all checkout failures for premium users where new_checkout_flow was enabled, grouped by error code."
"Payment failed for user 123"{"event": "payment_failed", "user_id": "123", "reason": "insufficient_funds", "amount": 99.99}timestamp — RFC3339 with timezone (e.g., 2025-01-24T20:00:00Z)level — debug, info, warn, error (be consistent, don't invent new levels)event — machine-readable event name, snake_case (e.g., user_login_success)request_id or trace_id — for correlating logs across a single requestservice — which service/application emitted this logenvironment — prod, staging, devuser_id, org_id, account_id — who is affectedrequest_id, trace_id, span_id — for distributed tracingorder_id, transaction_id, job_id — domain-specific identifiersThese fields are what make logs actually queryable during incidents. Without them, you're grepping through millions of lines blindly.
Look for opportunities for high-cardinality fields that can help you identify the root cause of an issue quickly.
debug — Verbose details for local development, usually disabled in productioninfo — Normal operations worth recording (user actions, job completions, deploys)warn — Something unexpected happened but the system handled it (retries, fallbacks)error — Something failed and likely needs human attention (exceptions, failed requests)Don't log errors for expected conditions (e.g., user enters wrong password)
| Runtime | Preferred pattern |
|---|---|
| Node/TypeScript | Use structured loggers such as pino, winston JSON format, or platform-native structured logs; pass context objects, not interpolated strings. |
| Python | Use structlog or logging with JSON formatter and extra fields. |
| Go | Use log/slog with typed attributes and request-scoped context. |
| Cloudflare Workers | Emit JSON via console.log(JSON.stringify(event)) only after redacting secrets and keeping payload sizes bounded. |
user_id, not userId or user-idpayment_completed, not complete_paymentauth.login_failed, billing.invoice_createdUse tail sampling — make the sampling decision after the request completes based on its outcome:
This ensures you never lose the events that matter during incidents while keeping costs manageable.
When reviewing logging changes: