Instruments code paths with newline-delimited JSON logs for precise runtime debugging.
Install
mkdir -p .claude/skills/slog && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17474" && unzip -o skill.zip -d .claude/skills/slog && rm skill.zipInstalls to .claude/skills/slog
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Structured logging workflow for debugging code paths with per-run log files in `.context/slog`. Use when the user says "use slog", asks for structured logging, wants you to instrument a flow, run it, and inspect logs. Triggers on requests like "use slog", "add structured logs", "log this flow", or "debug with slog".Key capabilities
- →Create a fresh run file for structured logs.
- →Inject focused structured logs near decisions and boundaries.
- →Exercise the code path to generate logs.
- →Read and summarize log files.
- →Compare log outputs between different runs.
- →Remove temporary instrumentation after debugging.
How it works
This skill facilitates debugging by creating run-specific structured log files, instrumenting code paths with focused logs, executing the path, and then reading and summarizing the generated output.
Inputs & outputs
When to use slog
- →Debug a failing flow
- →Verify runtime logic
- →Trace decision boundaries
- →Add structured logs
About this skill
Structured Logging with slog
Use this skill to debug or verify a concrete code path by writing newline-delimited JSON logs to a run-specific file in .context/slog, exercising the path, and then reading the output.
In this repo, treat slog as a default self-verification tool:
- Use it when fixing bugs.
- Use it when building new features.
- Use it during planning when you need to verify your understanding of the current runtime path before making changes.
- Prefer it whenever the task depends on what the code actually does at runtime, not just what it appears to do from static reading.
Default workflow
- Create a fresh run file. Do not reuse the previous file.
bun .codex/skills/slog/scripts/slog.ts new signup-before-fix
- The helper also writes
.context/slog/current.env. In this repo, the local dev scripts source that file automatically viascripts/load-worktree-env.sh, so a normal restart ofweb,trigger,hocuspocus,admin, ordesktopis enough to pick up the new slog target. - Use the printed
THOUGHTFUL_SLOG_FILE,THOUGHTFUL_SLOG_RUN_ID, andTHOUGHTFUL_SLOG_LABELvalues only for one-shot commands that do not go through the shared dev scripts. - Add focused structured logs near decisions, boundaries, and surprising state changes.
- Trigger the code path yourself when possible.
- Read the log file and summarize what changed.
- For the next run, mint a new file name again instead of appending to the previous run.
This is the default verification loop:
- Form a hypothesis about the current behavior or the behavior you expect after a change.
- Mint a fresh slog run.
- Add focused logs around the branch or boundary that should prove or disprove that hypothesis.
- Exercise the real path.
- Read the slog file and confirm what happened.
Per-run file naming
The helper script creates files like:
.context/slog/20260402T193501Z-a1b2c3d-dirty-signup-before-fix.jsonl
The name captures:
- Timestamp
- Current git SHA
- Dirty/clean state
- Human label for the run
This makes it easy to compare log output across code changes.
Standard log shape
Use JSONL. Write one JSON object per line with stable keys.
{
"ts": "2026-04-02T19:35:01.123Z",
"runId": "20260402T193501Z-a1b2c3d-dirty-signup-before-fix",
"source": "apps/web/src/server/example.ts",
"event": "signup.user-created",
"step": "after-insert",
"data": {
"userId": "123",
"workspaceId": "456"
}
}
Rules:
- Keep keys stable across runs so diffs are meaningful.
- Prefer small scalar fields and shallow objects.
- Do not log secrets, tokens, cookies, raw auth headers, or full request bodies unless the user explicitly asks and the data is safe.
- Include IDs, counts, branch decisions, and error summaries.
TypeScript helper pattern
Use a small local helper when the code path does not already have one:
import fs from "node:fs";
import path from "node:path";
function appendSlog(
source: string,
event: string,
data: Record<string, unknown> = {},
step?: string,
): void {
const file = process.env.THOUGHTFUL_SLOG_FILE;
if (!file) return;
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.appendFileSync(
file,
JSON.stringify({
ts: new Date().toISOString(),
runId: process.env.THOUGHTFUL_SLOG_RUN_ID ?? "manual",
source,
event,
step,
data,
}) + "\n",
);
}
Guidance:
- Prefer adding logs at system boundaries: request entry, parsed input, DB read/write result, branch selection, downstream call, returned output, caught error.
- If the code already uses a logger, keep it. Add file logging alongside it only for the investigation.
- Default to removing temporary instrumentation after the debugging session unless the user wants to keep it.
Triggering the code path
After instrumenting, try to run the code path yourself.
Preferred order:
- Existing unit or integration test
- Small targeted script
- Existing CLI command
- Local HTTP request
- Browser flow using
agent-browser
If you cannot trigger it directly, give the user exact steps:
- The command to create a fresh slog run
- Whether the relevant service needs a restart to pick up
.context/slog/current.env - The exact action to perform manually
- The command to read the log file afterward
Reading logs
Use the helper to recover the latest run:
bun .codex/skills/slog/scripts/slog.ts latest
bun .codex/skills/slog/scripts/slog.ts latest file
bun .codex/skills/slog/scripts/slog.ts list
Useful follow-up commands:
tail -n 200 "$(bun .codex/skills/slog/scripts/slog.ts latest file)"
jq -c . "$(bun .codex/skills/slog/scripts/slog.ts latest file)"
rg '"event"' "$(bun .codex/skills/slog/scripts/slog.ts latest file)"
Comparing runs
When behavior changes between edits:
- Create a new run file with a label that captures the hypothesis, such as
before-null-guardorafter-parse-fix. - Keep the old file.
- Compare the normalized outputs.
Example:
jq -S . .context/slog/20260402T193501Z-a1b2c3d-dirty-before-null-guard.jsonl > /tmp/run-a.jsonl
jq -S . .context/slog/20260402T194122Z-e4f5g6h-dirty-after-null-guard.jsonl > /tmp/run-b.jsonl
diff -u /tmp/run-a.jsonl /tmp/run-b.jsonl
Completion standard
Do not stop after adding logs. The full slog workflow is:
- Create a new run file
- Instrument the code path
- Run the path if possible
- Read the file
- Explain what the logs say
If step 3 is impossible in the current environment, explicitly say what the user needs to do manually.
When not to use it
- →Do not reuse previous log files.
- →Do not log secrets, tokens, cookies, raw auth headers, or full request bodies unless explicitly asked and safe.
- →Do not stop after only adding logs.
Limitations
- →The skill requires manual triggering of the code path if existing tests or commands are not available.
- →It does not automatically remove temporary instrumentation.
- →It does not log sensitive data unless explicitly instructed and safe.
How it compares
This skill provides a structured, per-run logging workflow with automatic file naming and comparison capabilities, offering a more systematic approach to runtime verification than ad-hoc print statements.
Compared to similar skills
slog side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| slog (this skill) | 0 | 3mo | Review | Beginner |
| analyzing-logs | 14 | 10d | Review | Beginner |
| sentry | 10 | 3mo | Caution | Beginner |
| obsidian-incident-runbook | 3 | 10d | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
analyzing-logs
jeremylongshore
Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.
sentry
openai
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.
obsidian-incident-runbook
jeremylongshore
Troubleshoot Obsidian plugin failures with systematic incident response. Use when plugins crash, data is corrupted, or users report critical issues with your Obsidian plugin. Trigger with phrases like "obsidian crash", "obsidian plugin broken", "obsidian incident", "debug obsidian failure", "obsidian emergency".
obsidian-observability
jeremylongshore
Set up comprehensive logging and monitoring for Obsidian plugins. Use when implementing debug logging, tracking plugin performance, or setting up error reporting for your Obsidian plugin. Trigger with phrases like "obsidian logging", "obsidian monitoring", "obsidian debug", "track obsidian plugin".
langsmith-observability
davila7
LLM observability platform for tracing, evaluation, and monitoring. Use when debugging LLM applications, evaluating model outputs against datasets, monitoring production systems, or building systematic testing pipelines for AI applications.
network-info
UKGovernmentBEIS
Gather network configuration and connectivity information including interfaces, routes, and DNS