backend-logging-traceability
Skill9 starsChanged 6 months agoApache-2.0View on GitHub
Backend logging and traceability standard for BE Dev. Use when implementing, refactoring, or reviewing backend handlers/controllers, services, repositories, workers, schedulers, jobs, queue consumers/producers, external integrations, auth paths, state transitions, retries, or error handling, especially when code has sparse logs, poor operator traceability, missing debug/info/warn/error coverage, missing correlation/request IDs, or weak incident-diagnosis evidence.
In this repository61 other files it gives its agents.
- rules/CLAUDE.mdCLAUDE.md
- acceptance-criteria-authorSkill
- adr-authorSkill
- api-contract-authorSkill
- ba-design-completenessSkill
- ba-ingestion-pipelineSkill
- ba-iteration-planningSkill
- ba-mode-augmentSkill
- ba-mode-external-sourceSkill
- ba-mode-multi-docSkill
- ba-mode-requirements-folderSkill
- ba-mode-reverse-engineerSkill
- ba-mode-single-docSkill
- ba-post-implementationSkill
- be-framework-coding-standardSkill
- c4-authorSkill
- codebase-inventorySkill
- data-lifecycle-contractsSkill
- design-system-authorSkill
- docker-deploymentSkill
- external-integration-adequacySkill
- fe-framework-coding-standardSkill
- figma-canvas-layoutSkill
- figma-design-handoffSkill
- figma-requirements-extractionSkill
- figma-srs-mappingSkill
- flutter-implementationSkill
- flutter-performanceSkill
- flutter-platform-integrationSkill
- format-boundary-contractsSkill
- git-commitSkill
- incident-debuggingSkill
- intent-archaeologySkill
- kubernetes-deploymentSkill
- local-deploymentSkill
- migration-safetySkill
- observability-readinessSkill
- playwright-authorSkill
- qa-author-by-taskSkill
- qa-author-by-usSkill
- qa-execution-runnerSkill
- react-native-implementationSkill
- react-native-performanceSkill
- react-native-platform-integrationSkill
- release-readinessSkill
- rollback-readinessSkill
- sa-architecture-designSkill
- sa-brownfield-extractSkill
- secrets-config-auditSkill
- security-compliance-checklistSkill
- solution-defaultsSkill
- ssh-remote-operationsSkill
- staging-deploymentSkill
- task-sizingSkill
- <kebab-case-name-matching-folder>Skill
- test-case-authorSkill
- third-party-dependency-evaluationSkill
- ui-test-executionSkill
- ui-ux-page-scopingSkill
- user-story-authorSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 12 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use the project's existing logger, context propagation, metrics, and tracing conventions.
- Distinctive: line 20
Use this skill whenever BE Dev changes or reviews backend runtime behavior: HTTP/gRPC handlers, service/application methods, repositories, …
- Distinctive: line 32
start/received log with operation name and safe identifiers.
- Very specific: line 38
Review levels: Use the taxonomy below; do not put everything at info.
- Very specific: line 39
Verify: Use log-capture tests where the project has them.
- Distinctive: line 52
Prefer existing project field names.
- Distinctive: line 69
Never log secrets, credentials, tokens, cookies, auth headers, OAuth codes, private keys, raw trace baggage, signed URLs, payment data, …
- Distinctive: line 71
Never swallow an error after logging it.
- Distinctive: line 72
Avoid duplicate error logs at every stack layer.
- Distinctive: line 73
Keep log messages stable and grep-friendly.
- Distinctive: line 74
Do not add noisy logs inside high-frequency loops without aggregation, sampling, or debug level.
- Very specific: line 78
Before writing plan-update.json, confirm:
- Distinctive: line 80
Every changed backend operation has start, success, and failure observability.
- Distinctive: line 81
Every new error branch logs or is covered by a higher-level ownership-boundary log.
- Very specific: line 82
Every changed worker/job/consumer logs batch start/end, counts, retries, poison/DLQ path, and duration.
- Very specific: line 83
Every external dependency call has result/duration/error classification.
- Distinctive: line 84
Every state transition that affects downstream behavior is logged with previous/next state and safe actor/resource IDs.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Backend Logging Traceability
Goal
Make every backend change diagnosable by maintainers and operators without reading source code first. Logs must explain what operation ran, which path it took, what changed, which dependency was involved, how long it took, and why it failed.
Use the project's existing logger, context propagation, metrics, and tracing conventions. Do not introduce a new logging library unless an ADR or architecture task already approved it.
When to use
Use this skill whenever BE Dev changes or reviews backend runtime behavior: HTTP/gRPC handlers, service/application methods, repositories, workers, schedulers, queue consumers/producers, external integrations, retries, state transitions, and error paths. Load it alongside be-framework-coding-standard before editing source and again before ready-for-deploy.
Inputs and outputs
- Inputs: assigned task, SRS US/FR/NFR IDs, architecture components, instrumentation contract when present, current backend logger/middleware, error envelope, auth context, data contracts, and existing log format.
- Outputs: backend code with structured debug/info/warn/error logs, correlation/request/trace propagation, safe fields, log-aware tests or smoke evidence, and implementation notes naming the important log events added.
Logging coverage procedure
- Map operations before editing. List each changed endpoint, worker, job, consumer, producer, scheduler, service method, repository operation, external call, transaction, and state transition.
- Preserve the logging substrate. Reuse existing logger injection, middleware, context keys, trace/span handling, request ID, correlation ID, and redaction helpers. If none exists, use the framework/stdlib logger already in the stack and file an open issue for a structured-logging foundation.
- Add boundary logs. Each changed operation needs:
- start/received log with operation name and safe identifiers;
- success/completed log with status/result class, changed-counts where useful, and duration;
- failure log on every propagated error path with error code/class and enough context to route ownership.
- Add decision logs. Log branch decisions that matter during incident diagnosis: validation rejection, auth/authz denial, idempotency duplicate, feature flag branch, skipped work, retry scheduling, fallback, circuit/degraded dependency path, no-op due to state, and partial-success handling.
- Add dependency logs. For database, queue, cache, object storage, and external service calls, log the dependency name, operation, attempt number, timeout/retry classification, result class, duration, and safe resource IDs.
- Add state-change logs. For create/update/delete, lifecycle transitions, gate-field writes, moderation/actions, billing/payment-like flows, and irreversible operations, log previous state, next state, actor/system source, reason, and idempotency key when present.
- Review levels. Use the taxonomy below; do not put everything at
info. - Verify. Use log-capture tests where the project has them. Otherwise run a focused unit/integration/smoke path and record representative emitted events in the task notes or QA handoff without secrets or PII.
Level taxonomy
| Level | Use for | Do not use for |
debug | Internal branch decisions, sanitized payload shape/counts, query/filter choices, retry classifier inputs, feature-flag evaluation, cache hit/miss, no-op reason. | Secrets, full request/response bodies, high-cardinality spam in hot loops without sampling. |
info | Operation received/completed, business state transition, job/consumer batch summary, external dependency success, admin/moderation action, data migration step, important lifecycle event. | Expected per-field validation noise or every line inside a tight loop. |
warn | Recoverable anomaly, transient dependency failure before retry, fallback/degraded mode, duplicate idempotency key, skipped unsafe work, rate limit, partial success, stale/out-of-order message. | Fatal failures that stop the operation. |
error | Operation failed and returns/propagates an error, retry budget exhausted, message moved to DLQ, transaction rollback, invariant violation, unexpected panic/exception, dependency outage after classification. | Expected user validation failures that are handled normally. |
Required fields
Prefer existing project field names. If the project has no convention, use these names consistently:
| Field | Purpose |
operation | Stable name such as admin.config.update, activity.ingest.consume, or account.delete.request. |
component / service | Owning service/component from architecture. |
request_id, correlation_id, trace_id | Request and cross-service traceability where available. |
actor_id, tenant_id, runner_id, admin_id | Include only safe internal IDs and only when useful for ownership/routing. |
resource_type, resource_id | Safe domain resource reference. |
status, result, error_code, error_class | Outcome and routable failure class. |
duration_ms | Latency for request, dependency call, job, transaction, or batch. |
attempt, max_attempts, retryable | Retry and queue diagnostics. |
idempotency_key | Include when already part of the contract and safe to log. |
changed_count, skipped_count, batch_size | Batch/job/operator summaries. |
Safety rules
- Never log secrets, credentials, tokens, cookies, auth headers, OAuth codes, private keys, raw trace baggage, signed URLs, payment data, full addresses, health data, or full request/response bodies.
- Mask or omit PII. If an identifier is not already safe in existing logs, hash or omit it.
- Never swallow an error after logging it. Return, propagate, retry, or explicitly mark it handled.
- Avoid duplicate error logs at every stack layer. Log once at the ownership boundary with enough context; lower layers may log debug details only when useful.
- Keep log messages stable and grep-friendly. Prefer structured fields over prose-only messages.
- Do not add noisy logs inside high-frequency loops without aggregation, sampling, or debug level.
Ready-for-deploy checklist
Before writing plan-update.json, confirm:
- Every changed backend operation has start, success, and failure observability.
- Every new error branch logs or is covered by a higher-level ownership-boundary log.
- Every changed worker/job/consumer logs batch start/end, counts, retries, poison/DLQ path, and duration.
- Every external dependency call has result/duration/error classification.
- Every state transition that affects downstream behavior is logged with previous/next state and safe actor/resource IDs.
- Correlation/request IDs are propagated into services, repositories, external clients, and async jobs where the stack supports it.
- Tests or smoke evidence exercised at least one success and one failure/edge log path for high-risk behavior.
Related skills
../be-framework-coding-standard/SKILL.md- framework and track-specific backend implementation.../api-contract-author/SKILL.md- API contract updates when logged errors reflect public error models.../data-lifecycle-contracts/SKILL.md- gate-field writes that require explicit state-change logs.../format-boundary-contracts/SKILL.md- deterministic conversion failures that should be classified, not retried.
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.

