observability-and-errors
Skill2 starsChanged 6 months agoMITView on GitHub
Use when adding logging, error tracking, or product analytics — capture errors with context to Sentry, emit structured logs with a request/tenant id, and track key events without leaking PII or secrets.
In this repository14 other files it gives its agents.
- api-routes-and-validationSkill
- authenticationSkill
- authorization-rbacSkill
- background-jobsSkill
- data-access-layerSkill
- database-schemaSkill
- deployment-and-ciSkill
- environment-and-configSkill
- file-uploads-and-storageSkill
- multi-tenancySkill
- payments-stripeSkill
- project-scaffoldingSkill
- subscription-billingSkill
- transactional-emailSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
Use Next.js error.tsx / global-error.tsx boundaries to show a friendly fallback and report the error.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Observability & Errors
Overview
You can't fix what you can't see. A production SaaS needs three signals: error tracking (Sentry) for exceptions with stack + context, structured logs (JSON with a correlation id) for tracing a request, and product analytics (PostHog) for what users actually do. Add a global error boundary, attach tenant/user/request context to every signal, and scrub secrets and PII before anything leaves the process.
When to use
- Standing up a new app's logging/monitoring.
- Debugging issues you can't reproduce locally.
- You need to know which features are used or where users drop off.
Structured logging with context
// src/server/log.ts
import "server-only";
export function logger(ctx: { requestId: string; orgId?: string; userId?: string }) {
const base = { ...ctx, ts: new Date().toISOString() };
return {
info: (msg: string, data?: object) => console.log(JSON.stringify({ level: "info", msg, ...base, ...data })),
error: (msg: string, err?: unknown) =>
console.error(JSON.stringify({ level: "error", msg, ...base, err: serializeError(err) })),
};
}Generate a requestId per request and thread it (and orgId) through logs and into Sentry's scope — now one search reconstructs a whole request across services.
Error tracking
import * as Sentry from "@sentry/nextjs";
Sentry.withScope((scope) => {
scope.setTag("orgId", org.id);
scope.setUser({ id: user.id }); // id only, not email/PII
Sentry.captureException(err);
});Use Next.js error.tsx / global-error.tsx boundaries to show a friendly fallback and report the error.
Analytics (sparingly)
- Track meaningful events (
project_created,subscription_upgraded), not every click. - Identify by stable user id; set org as a group. Keep a typed event list so names don't drift.
Pitfalls
- Logging secrets/PII — tokens, passwords, full request bodies, card data. Scrub before logging; send ids, not emails.
console.logsoup — unstructured strings are ungreppable. Emit JSON with a correlation id.- Swallowing errors —
catch {}hides outages. Capture with context, then handle. - No source maps in prod — Sentry stack traces are useless without them; upload on build.
- Tracking everything — noisy analytics cost money and bury the signal. Track decisions, not clicks.
Hand-off
Errors, logs, and events you can actually act on. deployment-and-ci wires source maps + env keys; background-jobs and payments-stripe report failures here.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

