structured-logging-standardizer — Claude Code skill: how to install
structured-logging-standardizer sets up structured JSON logging with request correlation IDs using AsyncLocalStorage and pino. Keeps backend logs queryable and connected.
MIT 273 installs ★ 64 updated 2026-01-12
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a claude-codeWhat structured-logging-standardizer does
This skill provides a standardized LogEntry interface for backend services. It defines core fields like timestamp, level, service, and environment, alongside tracing attributes including requestId, traceId, and userId.
It instructs the agent to inject an Express-style middleware that reads or generates the x-request-id header. Context is saved to AsyncLocalStorage, which the pino logger reads on every call. The guide explicitly forbids template string interpolation in favor of structured payload objects and snake_case metrics like duration_ms.
The code patterns target Node.js and TypeScript runtimes. Without AsyncLocalStorage support or outside the Node ecosystem, the middleware and logger wrapper must be adapted.
What it helps with
- trace HTTP requests across log lines using x-request-id
- establish a unified LogEntry JSON schema across backend endpoints
- replace template string interpolation with structured metadata objects
- store request and user context automatically via AsyncLocalStorage
Example prompts for the agent
- Implement correlation ID middleware and a structured logger for our backend
- Update error logging to follow the LogEntry schema with stack trace fields
- Refactor string interpolation in log statements into structured context objects
How to install structured-logging-standardizer
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a claude-code2Manually: put the files in place
~/.claude/skills/structured-logging-standardizer/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/structured-logging-standardizer/
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a codex2Manually: put the files in place
.agents/skills/structured-logging-standardizer/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a cursor2Manually: put the files in place
.cursor/skills/structured-logging-standardizer/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install patricio0312rev/skills performance/structured-logging-standardizer/SKILL.md2Manually: put the files in place
.github/skills/structured-logging-standardizer/SKILL.md1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a gemini-cli2Platform CLI
gemini skills install https://github.com/patricio0312rev/skills --path performance/structured-logging-standardizerManually: put the files in place
.devin/skills/structured-logging-standardizer/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about structured-logging-standardizer
How to install structured-logging-standardizer in Claude Code?
Run npx skills add patricio0312rev/skills --skill structured-logging-standardizer -a claude-code. You can also place the skill file directly at ~/.claude/skills/structured-logging-standardizer/SKILL.md.
What does structured-logging-standardizer do?
It instructs your AI assistant to generate standardized structured logs with correlation IDs. It includes a TypeScript schema, an Express middleware snippet, and rules against string interpolation.
Which libraries does this logging setup require?
The included implementation relies on pino for logging, uuid for ID creation, and Node.js AsyncLocalStorage for context propagation.
Source text
SKILL.md · MIT
---
name: structured-logging-standardizer
description: Enforces consistent structured logging with request correlation IDs, standardized log schema, middleware integration, and best practices. Use for "structured logging", "log standardization", "request tracing", or "log correlation".
---
# Structured Logging Standardizer
Implement consistent, queryable, correlated logs.
## Log Schema
```typescript
interface LogEntry {
timestamp: string; // ISO 8601
level: "debug" | "info" | "warn" | "error" | "fatal";
message: string;
service: string;
environment: string;
// Request context
requestId?: string;
traceId?: string;
userId?: string;
// Additional context
[key: string]: any;
}
```
## Request ID Middleware
```typescript
import { v4 as uuidv4 } from "uuid";
app.use((req, res, next) => {
// Generate or use existing request ID
req.id = req.headers["x-request-id"] || uuidv4();
// Add to response headers
res.setHeader("x-request-id", req.id);
// Store in async local storage
asyncLocalStorage.run(new Map(), () => {
asyncLocalStorage.getStore()?.set("requestId", req.id);
next();
});
});
// Logger with request context
const logger = pino({
mixin() {
return {
requestId: asyncLocalStorage.getStore()?.get("requestId"),
};
},
});
```
## Standardized Logger
```typescript
class StandardLogger {
private logger = pino();
info(message: string, context?: Record<string, any>) {
this.logger.info(
{
...this.getContext(),
...context,
},
message
);
}
error(message: string, error?: Error, context?: Record<string, any>) {
this.logger.error(
{
...this.getContext(),
...context,
error: {
message: error?.message,
stack: error?.stack,
name: error?.name,
},
},
message
);
}
private getContext() {
return {
requestId: asyncLocalStorage.getStore()?.get("requestId"),
userId: asyncLocalStorage.getStore()?.get("userId"),
};
}
}
```
## Best Practices
```typescript
// ✅ DO: Structured fields
logger.info({ userId: '123', action: 'purchase', amount: 99.99 }, 'Purchase completed');
// ❌ DON'T: String interpolation
logger.info(\`User 123 purchased for $99.99\`);
// ✅ DO: Consistent field names
logger.info({ duration_ms: 150 }, 'Request completed');
// ❌ DON'T: Inconsistent naming
logger.info({ durationMs: 150 }, 'Request done');
```
## Output Checklist
- [ ] Request ID middleware
- [ ] Structured log schema
- [ ] Correlation IDs
- [ ] Standardized logger
- [ ] Best practices documented
ENDFILE
© patricio0312rev · MIT · patricio0312rev/skills