logging-tracing-design
Logging + tracing for a service — structured JSON logs, log levels, correlation ids, OpenTelemetry spans + attributes + events + links, W3C Trace Context propagation, sampling (head / tail / rate), log↔trace linking, PII redaction, retention.
What this skill does
# Logging + Tracing Design
You design how a service emits logs + traces so operators can investigate incidents and track user journeys. Component-level; system-wide concerns go to `observability-strategy`.
## Core rules
- **Structured, not free-text** — JSON logs only
- **Correlate via trace_id** — every log line carries it
- **Trace the caller, not just the server** — propagate W3C Trace Context
- **OpenTelemetry over vendor lock-in** — OTLP + OpenTelemetry SDK default
- **Sample smart, not small** — tail sampling for errors; head sampling elsewhere
- **PII redacted** — declared at schema level, enforced by filter
- **Retention by policy + cost** — not unlimited
- **No fabricated log events** — work from supplied behavior
## Input handling
| Dimension | Required | Default |
|---|---|---|
| **Component / service** | Yes | — |
| **Runtime + language** | Yes | — |
| **Dependencies** (DBs, brokers, external) | Yes | — |
| **Traffic profile** | No | Asked |
| **Existing observability backend** | No | Asked |
| **Regulatory context (PII, GDPR)** | No | Asked |
## Phase 1 — Setup
```
**Component**: [service name]
**Runtime**: [Go / Node / Python / JVM / .NET / Rust]
**Dependencies**: [list]
**Traffic**: [req/s peak]
**Existing backend**: [Datadog / Grafana stack / Honeycomb / Splunk / CloudWatch / ...]
**Regulatory**: [GDPR, HIPAA, PCI — fields]
**Budget**: [ingestion + retention ballpark]
```
Ask render mode per `diagram-rendering` mixin and output path (default: `/documentation/[case]/logging-tracing-design/[component]/`).
## Phase 2 — Structured log schema
Baseline fields (every record):
| Field | Type | Notes |
|---|---|---|
| `timestamp` | RFC 3339 UTC | ISO-8601 strict |
| `level` | enum | TRACE / DEBUG / INFO / WARN / ERROR / FATAL |
| `service` | string | stable service name |
| `env` | string | `prod` / `staging` / `dev` |
| `version` | string | build / git-sha |
| `message` | string | concise human text |
| `trace_id` | string | W3C Trace Context |
| `span_id` | string | W3C Trace Context |
| `tenant_id` | string? | when applicable |
| `user_id` | string? | only where useful + authorized |
| `request_id` | string? | if independent of trace |
| `event` | string? | machine-readable event code |
| `error` | object? | `{ class, message, stack }` (stack only in non-prod or internal) |
Extras per event; camelCase or snake_case consistent across the service.
Avoid:
- Stringly-typed bags (`context: "lots of stuff"`)
- Unstructured concatenation
- PII in the `message` field — put in structured field with explicit flag
## Phase 3 — Log levels
| Level | Usage |
|---|---|
| TRACE | development only; very verbose |
| DEBUG | off by default in prod; enabled per-request / feature flag |
| INFO | normal events (request completed, worker started) |
| WARN | unexpected but recoverable |
| ERROR | action failed, user-affecting |
| FATAL | process terminating |
Rules:
- ERROR requires `trace_id` + actionable info
- Don't log at ERROR for validation failures (that's INFO or WARN per policy)
- Rate-limit noisy loggers
## Phase 4 — Tracing with OpenTelemetry
### Span model
- One span per logical unit of work
- Spans form a tree via parent/child
- Attributes: key/value metadata on spans
- Events: time-stamped marks within a span (e.g. `cache_miss`, `retry_attempt`)
- Links: relate spans across traces (e.g. batch processor linking N inputs)
### Span attributes (semantic conventions)
Follow OpenTelemetry semantic conventions:
- HTTP: `http.method`, `http.route`, `http.status_code`
- DB: `db.system`, `db.statement` (redacted), `db.operation`
- Messaging: `messaging.system`, `messaging.destination`, `messaging.operation`
- RPC: `rpc.system`, `rpc.service`, `rpc.method`
- Error: `otel.status_code=ERROR`, `exception.type`, `exception.message`
### Propagation
- W3C Trace Context (`traceparent`, `tracestate`) over HTTP + gRPC
- `baggage` header for cross-cutting context (tenant_id, user_id, feature flags)
- Propagate across async boundaries: queue producer embeds trace context in headers; consumer extracts + continues
### Export
- OTLP (gRPC or HTTP/JSON) to collector
- Collector (opentelemetry-collector) handles: batching, sampling, transforms, multi-exporter
- Do not export directly to vendor — collector gives swap flexibility
## Phase 5 — Sampling
### Head sampling (decide at root)
- Parent-based: respect caller's decision (default)
- Rate-based: sample 1 in N
- Probabilistic: p = 0.1 means 10%
- Pros: cheap; predictable
- Cons: may drop slow / error traces
### Tail sampling (decide at collector after seeing full trace)
- Keep 100% of errors + slow traces
- Keep small % of happy traces
- Pros: error / slow coverage without 100% cost
- Cons: requires buffered collector; memory + cpu cost
### Recommended defaults
- Errors: 100%
- Slow (p99 latency): 100%
- Happy: 1–10% depending on budget
- Always-on for critical paths (payments, auth) during incidents
## Phase 6 — Log ↔ trace linking
- Every log line carries `trace_id` + `span_id` of the enclosing span
- Observability backend joins logs + traces in UI
- Jump from a trace span to its logs, and vice versa
- This is the single most valuable observability feature — worth the wiring
## Phase 7 — PII + sensitive data
| Class | Handling |
|---|---|
| Direct identifier (email, phone) | redact to domain / last-4 / hash |
| Auth tokens / secrets | never logged; ensure HTTP client scrubs |
| Card numbers / PII | PCI / GDPR obligations — block ingestion |
| Audit-required PII | separate store with access controls + retention policy |
Implementation:
- Central redaction library used by all log/span attributes
- Fail-closed: unknown field with PII-looking content → redacted
- PII allowlist maintained + reviewed
Hand off to `data-governance-policy`.
## Phase 8 — Retention + cost
| Tier | Retention | When |
|---|---|---|
| Hot (last 24–72 h) | full fidelity | active investigation |
| Warm (30 d) | sampled / rolled-up | recent analysis |
| Cold (90 d – 7 y) | archived / indexed partially | compliance |
Cost controls:
- Log levels tuned per environment
- Sampled tracing
- Aggregate metrics preferred over raw events where pattern holds
- Periodic review of top N log producers + offenders
## Phase 9 — Health + lifecycle events
Beyond request logs — include:
- Process start / stop + version + config fingerprint
- Config reload
- Background worker activity (heartbeat, backlog)
- Dependency health checks (DB connect, broker connect)
- Graceful shutdown progress
## Phase 10 — Testing + validation
- Unit: redaction rules
- Integration: end-to-end trace from edge to dependency
- Load: log ingestion cost at peak
- Chaos: verify observability survives dependency outage (collector, backend)
## Phase 11 — Diagrams
### Log/trace pipeline
```mermaid
flowchart LR
App[Service] -->|OTLP| Col[OTel Collector]
App -->|JSON logs| Agent[Log Agent]
Col -->|traces| Vendor1[Tracing Backend]
Col -->|metrics| Vendor2[Metrics Backend]
Agent -->|logs| Vendor3[Log Backend]
Vendor1 -.trace_id.- Vendor3
```
### Context propagation
```mermaid
sequenceDiagram
Client->>Edge: traceparent + baggage
Edge->>Service: traceparent + baggage
Service->>DB: trace span (child)
Service->>Q: produce (headers: traceparent)
Q->>Worker: consume + extract traceparent
Worker->>Ext: call (traceparent)
```
## Phase 12 — Diagram rendering
Per `diagram-rendering` mixin.
## Phase 13 — Report assembly and approval
```markdown
# Logging + Tracing Design: [Component]
**Date**: [date]
**Component**: [...]
**Runtime**: [...]
## Scope
[Component, deps, traffic, regulatory, budget]
## Structured Log Schema
[Baseline fields + per-event extras]
## Log Levels
[Policy per level]
## Tracing with OpenTelemetry
[Spans + attributes + events + links + propagation + export]
## Sampling
[Head / tail; policies; defaults]
## Log ↔ Trace Linking
[How it works + UI story]
## PII + Sensitive Data
[Redaction + alRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.