# logging-best-practices

logging-best-practices teaches the agent to write structured Pino logs: context-first signature, levels for different scenarios, workflow-safe wrapper.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 111 installs · ★ 23 repo stars
- Author: andrelandgraf
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/andrelandgraf/fullstackrecipes/tree/HEAD/skills/logging-best-practices/SKILL.md
- Updated: 2026-06-08
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/andrelandgraf-logging-best-practices

## What it does

The skill defines the Pino logger call signature: context object first, message second. Errors go into the context under `err`. It describes log levels (`info`, `warn`, `error`, `debug`, `fatal`) and shows how to log from API routes with request timing.

Workflow runtimes cannot import Node modules, so the skill proposes wrapping the logger in a `"use step"` function. Without Pino in the project, the skill is useless: you need an existing `@/lib/logging/logger` module.

The `LOG_LEVEL` environment variable sets the threshold: defaults to `info`, recommends `warn` for production.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add andrelandgraf/fullstackrecipes --skill logging-best-practices -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/logging-best-practices/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/logging-best-practices/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add andrelandgraf/fullstackrecipes --skill logging-best-practices -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/logging-best-practices/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add andrelandgraf/fullstackrecipes --skill logging-best-practices -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/logging-best-practices/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install andrelandgraf/fullstackrecipes skills/logging-best-practices
```

2. **Manually: put the files in place**
- File: `.github/skills/logging-best-practices/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add andrelandgraf/fullstackrecipes --skill logging-best-practices -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/andrelandgraf/fullstackrecipes --path skills/logging-best-practices
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/logging-best-practices/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add andrelandgraf/fullstackrecipes --skill logging-best-practices -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/andrelandgraf/fullstackrecipes/tree/HEAD/skills/logging-best-practices/SKILL.md

## When to use it
- add structured logs with context to route handlers
- log an error with full request context
- call the logger from a workflow via step wrapper
- set log level threshold via environment variable
- measure request duration and record it in logs

## Example prompts
- Log a successful request to `/api/chat` with duration and status
- Wrap the logger in a `"use step"` function for workflows
- Add `logger.error` with `err` and `userId` context to the error handler

## Similar
- [structured-logging-standardizer](https://affpapa.org/en/nevibecode/skills/structured-logging-standardizer.md) — skill · 273 installs
- [pino-logging](https://affpapa.org/en/nevibecode/skills/pino-logging.md) — skill · 217 installs
- [review-logging-patterns](https://affpapa.org/en/nevibecode/skills/review-logging-patterns.md) — skill · 767 installs
- [pii-redaction-logging-policy-builder](https://affpapa.org/en/nevibecode/skills/pii-redaction-logging-policy-builder.md) — skill · 283 installs
- [monitoring-observability](https://affpapa.org/en/nevibecode/skills/travisjneuman-monitoring-observability.md) — skill · 146 installs
- [encore-logging](https://affpapa.org/en/nevibecode/skills/encore-logging.md) — skill · 168 installs

## Other versions with the same name
- [logging-best-practices · boristane](https://affpapa.org/en/nevibecode/skills/logging-best-practices.md) — 5000 installs
- [logging-best-practices · aj-geddes](https://affpapa.org/en/nevibecode/skills/aj-geddes-logging-best-practices.md) — 744 installs
- [logging-best-practices · mindrally](https://affpapa.org/en/nevibecode/skills/mindrally-logging-best-practices.md) — 842 installs
- [logging-best-practices · secondsky](https://affpapa.org/en/nevibecode/skills/secondsky-logging-best-practices.md) — 415 installs
- [logging-best-practices · ncklrs](https://affpapa.org/en/nevibecode/skills/ncklrs-logging-best-practices.md) — 148 installs

From the same set: [andrelandgraf/fullstackrecipes](https://affpapa.org/en/nevibecode/by/andrelandgraf/fullstackrecipes.md) — 9 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
