Skip to main content Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/CleanExpo/NodeJS-Starter-V1 --skill structured-loggingEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Más de este repositorio Route complex requests to the right specialist agent or chain of agents. This skill acts as the central brain of an agent swarm — it analyses what the user needs, determines which specialist domain(s) are required, and coordinates parallel or sequential agent execution. Use this skill when a request spans multiple domains (e.g., "research competitors and create a pitch deck"), when you need to decide which specialist should handle an ambiguous request, or when a task requires a multi-step pipeline across different skills. Triggers on: multi-step requests, cross-domain tasks, "coordinate", "plan this out", "I need help with multiple things", or any complex request that touches more than one specialist area. Also triggers when the user seems unsure which tool or approach to use.
>-
Hybrid DAG execution primitive combining deterministic and agentic nodes with hard iteration caps
Explorador de archivos
9 archivos Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
id structured-logging name structured-logging type skill version 1.0.0 created 20/03/2026 modified 20/03/2026 status active metadata {"author":"NodeJS-Starter-V1","version":"1.0.0","locale":"en-AU"} description >- context fork
Structured Logging - Observability Patterns
Consistent, machine-readable logging across the full stack. The backend uses structlog with JSON output; the frontend uses a custom Logger class. This skill codifies conventions for both and adds correlation IDs, log context, and level guidelines.
Description
Enforces JSON-structured logging with correlation IDs, consistent log levels, and contextual metadata across the FastAPI backend (structlog) and Next.js frontend (Logger class). Covers sensitive data redaction, request tracing, and observability best practices.
When to Apply
Positive Triggers
Adding logging to new modules or API endpoints
Reviewing existing log statements for consistency
Implementing request tracing or correlation IDs
Debugging production issues via log analysis
Setting up log aggregation or monitoring pipelines
User mentions: "logging", "logs", "observability", "tracing", "monitoring", "debug"
Negative Triggers
Implementing error response formats (use error-taxonomy instead)
Designing metrics/dashboards (use metrics-collector when available)
Configuring CI/CD pipelines (use ci-cd-patterns when available)
Core Directives
Always Structured, Never Unstructured
logger.info("Document created" , document_id=doc.id , user_id=user.id )
logger.info(f"Document {doc.id } created by user {user.id } " )
print (f"Created doc: {doc.id } " )
Log Levels
Level When to Use Example ERROR Operation failed, needs attention Database connection lost, agent execution failed
WARNING Recoverable issue, degraded behaviour Rate limit approaching, fallback provider used
INFO Significant business events User logged in, document created, agent run completed
DEBUG Development-only detail Query parameters, intermediate computation results
What NOT to Log
Passwords, tokens, API keys, or session IDs
Full request/response bodies (log summaries instead)
Personal information beyond what's needed for debugging
High-frequency events without sampling (e.g., every heartbeat)
Backend Patterns (structlog)
Existing Setup The project configures structlog in apps/backend/src/utils/logging.py:
Debug mode : ConsoleRenderer() (human-readable)
Production mode : JSONRenderer() (machine-readable)
Context vars : merge_contextvars enables request-scoped context
Getting a Logger from src.utils import get_logger
logger = get_logger(__name__)
Correlation IDs Add a middleware that generates a correlation ID per request and binds it to structlog context:
import uuid
import structlog
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
class CorrelationIdMiddleware (BaseHTTPMiddleware ):
"""Attach a correlation ID to every request for log tracing."""
async def dispatch (self, request: Request, call_next ):
correlation_id = request.headers.get(
"X-Correlation-ID" ,
str (uuid.uuid4())
)
structlog.contextvars.clear_contextvars()
structlog.contextvars.bind_contextvars(
correlation_id=correlation_id,
)
response = await call_next(request)
response.headers["X-Correlation-ID" ] = correlation_id
return response
Register in apps/backend/src/api/main.py:
from .middleware.correlation import CorrelationIdMiddleware
app.add_middleware(CorrelationIdMiddleware)
Request Logging Log every API request with timing:
import time
from src.utils import get_logger
logger = get_logger(__name__)
class RequestLoggingMiddleware (BaseHTTPMiddleware ):
"""Log request method, path, status, and duration."""
async def dispatch (self, request: Request, call_next ):
start = time.perf_counter()
response = await call_next(request)
duration_ms = (time.perf_counter() - start) * 1000
logger.info(
"Request completed" ,
method=request.method,
path=request.url.path,
status=response.status_code,
duration_ms=round (duration_ms, 2 ),
)
return response
Agent Execution Logging Log agent lifecycle events consistently:
logger = get_logger(__name__)
async def execute_agent (agent_name: str , task: str ):
logger.info("Agent started" , agent=agent_name, task=task[:100 ])
try :
result = await agent.run(task)
logger.info(
"Agent completed" ,
agent=agent_name,
status="success" ,
duration_ms=result.duration_ms,
)
return result
except TimeoutError:
logger.error(
"Agent timed out" ,
agent=agent_name,
error_code="AGENT_RUNTIME_TIMEOUT" ,
)
raise
except Exception as exc:
logger.error(
"Agent failed" ,
agent=agent_name,
error_code="AGENT_RUNTIME_FAILED" ,
error=str (exc),
)
raise
JSON Output Format In production, each log line is a single JSON object:
{
"timestamp" : "2026-02-13T09:30:00.000Z" ,
"level" : "info" ,
"event" : "Request completed" ,
"logger" : "src.api.middleware.logging" ,
"correlation_id" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890" ,
"method" : "POST" ,
"path" : "/api/documents" ,
"status" : 201 ,
"duration_ms" : 42.5
}
Frontend Patterns (Logger)
Existing Setup The project has a Logger class in apps/web/lib/logger.ts:
Level filtering via LOG_LEVEL env var
ISO timestamp formatting
JSON context serialisation
Usage Convention import { logger } from '@/lib/logger' ;
logger.info ('Document created' , { documentId : doc.id , userId : user.id });
logger.warn ('API response slow' , { endpoint : '/api/agents' , durationMs : 2500 });
logger.error ('Failed to fetch documents' , error, { userId : user.id });
logger.debug ('API response' , { status : response.status , body : data });
Correlation ID Propagation Pass the correlation ID from backend responses to subsequent requests:
let correlationId : string | null = null ;
export async function apiRequest (path : string , options ?: RequestInit ) {
const headers : Record <string , string > = {
'Content-Type' : 'application/json' ,
...(correlationId ? { 'X-Correlation-ID' : correlationId } : {}),
};
const response = await fetch (`${BACKEND_URL} ${path} ` , {
...options,
headers : { ...headers, ...options?.headers },
});
correlationId = response.headers .get ('X-Correlation-ID' );
return response;
}
Replacing console.log All console.log, console.error, and console.warn calls should use the logger instead:
console .log ('User logged in' );
console .error ('Failed to load' , error);
logger.info ('User logged in' , { userId : user.id });
logger.error ('Failed to load' , error, { component : 'Dashboard' });
Log Context Standards
Required Fields Every log entry should include (automatically via middleware or manually):
Field Source Example timestampAuto (structlog/Logger) 2026-02-13T09:30:00.000ZlevelAuto info, error, warn, debugeventFirst argument "Document created"correlation_idMiddleware "a1b2c3d4-..."
Recommended Fields (per domain) Domain Fields API requests method, path, status, duration_msAuthentication user_id, action (login/logout/token_refresh)Agent execution agent, task (truncated), status, duration_msDatabase operations table, operation (select/insert/update/delete), row_countExternal services service, endpoint, status, duration_ms
Logging Checklist When adding or reviewing logging:
Anti-Patterns Pattern Problem Correct Approach Unstructured log.info(f"User {id} logged in") strings Not machine-parseable, breaks log aggregation Use structured key-value pairs: logger.info("User logged in", user_id=id) Logging sensitive data (passwords, tokens, API keys) Security breach via log exposure Redact sensitive fields; never log credentials or session tokens No correlation IDs across requests Cannot trace a request through backend and frontend Use CorrelationIdMiddleware and propagate X-Correlation-ID header Inconsistent log levels (ERROR for warnings, INFO for debug) Noisy alerts, missed critical errors Follow the log level table: ERROR/WARNING/INFO/DEBUG Using console.log instead of the Logger class No level filtering, no structured context, no timestamps Import logger from @/lib/logger and use its methods
Checklist
Response Format [AGENT_ACTIVATED]: Structured Logging
[PHASE]: {Implementation | Review | Configuration}
[STATUS]: {in_progress | complete}
{logging analysis or implementation guidance}
[NEXT_ACTION]: {what to do next}
Integration Points
Error Taxonomy Error logs should include error_code from the error taxonomy:
logger.error("Agent failed" , error_code="AGENT_RUNTIME_FAILED" , agent=name)
Council of Logic (Shannon Check)
Log messages must be concise — maximum signal, minimum noise
Avoid logging the same event at multiple levels
Use sampling for high-frequency events (e.g., log 1 in 100 health checks)
Australian Localisation (en-AU)
Timestamps : ISO 8601 (UTC) in log output, DD/MM/YYYY in human reports
Spelling : behaviour, colour, organisation, analyse, centre, serialisation
Compliance : Logs must not contain data subject to Privacy Act 1988 without justification