logging
Skill1 starsChanged 9 months agoMITView on GitHub
Designs structured logging strategies. Covers log levels, formatting, correlation IDs, sensitive data handling, log aggregation, and debugging with logs. Use when setting up logging, debugging production issues, or reviewing logging practices.
14 other projects use a version of this.
Adopted by
Most recently taken up by
- lawless-m/claude-skillstheir own version, first seen Oct 4, 2026
- yeaboi-ai/yeaboi.aitheir own version, first seen Sep 20, 2026
- anmolnagpal/devops-skillstheir own version, first seen Aug 29, 2026
- mattstruble/skillstheir own version, first seen Jul 22, 2026
- codewithmukesh/dotnet-claude-kittheir own version, first seen Jul 22, 2026
- gabrielbauman/skillstheir own version, first seen Jul 16, 2026
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- codewithmukesh/dotnet-claude-kit★ 750same name
- anmolnagpal/devops-skills★ 8same name
- lawless-m/claude-skills★ 6same name
- yeaboi-ai/yeaboi.ai★ 4same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- mattstruble/skills★ 2same name
- Pradnyeshp/Claude-Skills★ 2same name
- BigPapiCB/Universal-Claude-Skills★ 1same name
- diego-tobalina/vibe-coding★ 1same name
- gabrielbauman/skills★ 1same name
4 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- cachingSkill
- ci-cdSkill
- config-managementSkill
- containerizeSkill
- database-designSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- error-handlingSkill
- estimateSkill
- feature-flag-opsSkill
- git-recoverySkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 6 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
ERROR: If no one needs to do anything about it, it's not an error.
- Distinctive: line 22
INFO: Should tell the story at a glance.
- Distinctive: line 23
DEBUG: Never in production by default.
- Distinctive: line 76
Every request gets a unique ID that follows it through every service and log line.
- Distinctive: line 93
Add context once, include it in every log within that scope:
- Distinctive: line 125
When investigating an issue:
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Logging
Logs are for answering questions after the fact. Every log line should help answer "what happened and why?"
Log Levels
| Level | When to Use | Example |
| ERROR | Something failed and needs human attention. Action required. | Database connection failed, payment processing error |
| WARN | Something unexpected happened but was handled. Worth investigating if frequent. | Retry succeeded after timeout, deprecated API used |
| INFO | Significant application events. The story of what the system did. | Request handled, user logged in, job completed, deploy started |
| DEBUG | Detailed diagnostic information. Useful during development. | SQL queries, cache hits/misses, internal state |
| TRACE | Extremely detailed. Function entry/exit, full payloads. | Only enable temporarily for deep debugging |
Rules
- ERROR: If no one needs to do anything about it, it's not an error. Connection retries that succeed? WARN.
- INFO: Should tell the story at a glance. Read just the INFO logs - can you understand what happened?
- DEBUG: Never in production by default. Enable per-service or per-request when needed.
- Production should run at INFO level. DEBUG/TRACE enabled temporarily for investigation.
Structured Logging
Always log structured data (JSON) in production. Unstructured text is unparseable at scale.
Bad
[2024-03-15 10:23:45] INFO: User john@example.com placed order #1234 for $99.50Good
{
"timestamp": "2024-03-15T10:23:45.123Z",
"level": "info",
"message": "order_placed",
"user_id": "usr_abc123",
"order_id": "ord_1234",
"amount_cents": 9950,
"currency": "USD",
"request_id": "req_xyz789"
}Why Structured?
- Searchable:
order_id = "ord_1234"not regex on free text - Aggregatable: "count all ERROR logs per service per hour"
- Parseable: Machines can process JSON, not prose
- Consistent: Same fields, same types, every time
What to Log
Always Log
- Request received (method, path, user, request ID)
- Request completed (status, duration, request ID)
- Authentication events (login, logout, failed attempts)
- State transitions (order created → paid → shipped)
- External service calls (what, to where, duration, success/failure)
- Job/task start and completion
- Errors with full context
Never Log
- Passwords, tokens, API keys, secrets
- Full credit card numbers (log last 4 only)
- Personal data without necessity (emails, names, addresses)
- Request/response bodies containing user data
- Health check requests (noise)
- Successful individual retries (log only final outcome)
Correlation IDs
Every request gets a unique ID that follows it through every service and log line.
Request arrives → assign request_id: "req_abc123"
→ API log: { request_id: "req_abc123", message: "order_placed" }
→ Payment service log: { request_id: "req_abc123", message: "charge_created" }
→ Email service log: { request_id: "req_abc123", message: "confirmation_sent" }Implementation:
- Generate at the edge (API gateway, load balancer, or first service)
- Pass via HTTP header (
X-Request-ID) - Include in every log line
- Return in error responses (so users can report it)
Context Enrichment
Add context once, include it in every log within that scope:
# Set context at request start
logger = logger.bind(
request_id="req_abc123",
user_id="usr_456",
service="order-api"
)
# Every subsequent log includes this context automatically
logger.info("order_placed", order_id="ord_789")
# → { request_id: "req_abc123", user_id: "usr_456", service: "order-api", message: "order_placed", order_id: "ord_789" }Log Aggregation
Setup
- Application writes structured JSON logs to stdout
- Log shipper (Fluentd, Filebeat, Vector) collects and forwards
- Log store (Elasticsearch, Loki, CloudWatch) indexes and stores
- Dashboard (Kibana, Grafana, CloudWatch) for search and visualization
Retention
| Environment | Retention | Rationale |
| Production | 30-90 days | Cover incident investigation window |
| Staging | 7-14 days | Enough for debugging |
| Development | 1-3 days | Just for active development |
Debugging with Logs
When investigating an issue:
- Start with the request ID - find all logs for that request
- Read chronologically - understand the sequence of events
- Look for the gap - where does the expected sequence break?
- Check timing - are there unexpected delays between steps?
- Widen the scope - same error from other requests? Same time? Same user?
Anti-Patterns
| Anti-Pattern | Problem | Fix |
| Log and throw | Same error logged multiple times up the call stack | Log at the handling point, not every catch block |
| Logging in a loop | Millions of lines per minute | Log summary after loop, or sample |
| Catch-log-rethrow | Duplicate error context, confusing stack traces | Let exceptions propagate, log at boundary |
| String interpolation in hot path | CPU wasted building strings that may never be written | Use lazy evaluation or check level first |
| No log rotation | Disk fills up | Configure rotation by size or time |
Review Checklist
- Structured logging (JSON) in production
- Appropriate log levels (ERROR means action required)
- Correlation/request ID on every log line
- No sensitive data in logs (passwords, tokens, PII)
- External calls logged with duration and outcome
- Error logs include enough context to diagnose without reproducing
- Log volume manageable (no hot-path logging in production)
- Log retention configured per environment
Utility Scripts
scripts/log_audit.sh [directory]- Find unstructured log statements, logs missing context, potential secrets in logs, and log level usage. Supports JS/TS, Python, Go, and Java.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

