addon-observability-nextjs-pino
SKILL.md
Add-on: Next.js Observability with pino
Use this skill when a Next.js or TypeScript server runtime needs package-backed structured logging.
This is the default implementation add-on for Next.js when addon-observability-telemetry is in scope.
Compatibility
- Best fit for
architect-nextjs-bun-app. - Also valid for server-side TypeScript apps and API route handlers.
- Pairs cleanly with
addon-observability-telemetry, which defines the higher-level telemetry contract.
Inputs
Collect:
TELEMETRY_MODE:logs-only|logs+metrics|logs+metrics+traces.LOG_FORMAT: defaultjson; uselogfmtonly when the user explicitly requests it.PII_REDACTION:strict|standard.LOG_BACKEND: defaultpino; only use an explicit equivalent when the user requests it and the tradeoff is documented.
Integration Workflow
- Add package-backed logging dependencies:
# Use the project's package manager (examples):
bun add pino
pnpm add pino
- If the user explicitly wants a framework helper, add the narrowest compatible package instead of building custom request log plumbing.
- If
TELEMETRY_MODEincludes metrics or traces, add the relevant OpenTelemetry packages instead of inventing custom instrumentation helpers.
- Add Next.js observability artifacts:
src/lib/observability/logging.ts
src/lib/observability/context.ts
logging.tsshould configurepino, serializers, redaction, and child logger helpers.context.tsshould handle correlation ID creation or propagation; do not create a custom logger implementation.
- Bind runtime context:
- In route handlers and server actions, create or propagate a correlation ID before emitting logs.
- Use child loggers to attach route, request, or job metadata instead of interpolating free-form strings.
- Standardize event shape:
- emit stable event names
- include
correlation_id - classify levels consistently
- keep errors structured and redacted
Guardrails
- Prefer
pinoas the default production logger for Next.js and server-side TypeScript. - Do not use raw
console.login production request paths except in tests or local-only scripts. - Do not build a custom
logger.tsthat wrapsconsole.logand calls that observability. - Keep the local module limited to
pinoconfiguration, redaction, serializers, and child logger helpers. - Do not leak secrets, auth headers, cookies, or full request bodies.
Validation Checklist
rg -n "from \"pino\"|from 'pino'|require\\(\"pino\"\\)" src
rg -n "correlation_id" src
rg -n "console\\.log" src || true
Manual checks:
- server logs include a correlation identifier
- log output is structured and machine-parseable
- the code configures
pinoinstead of implementing logging from scratch
Decision Justification Rule
- Every non-trivial decision must include a concrete justification.
- Capture the alternatives considered and why they were rejected.
- State tradeoffs and residual risks for the chosen option.
- If justification is missing, treat the task as incomplete and surface it as a blocker.
Weekly Installs
1
Repository
ajrlewis/ai-skillsFirst Seen
4 days ago
Security Audits
Installed on
amp1
cline1
opencode1
cursor1
kimi-cli1
codex1