Instructions
When to Use
- Use for
error.tsx,not-found,loading,global-errorUX. - Prefer
next-server-patternsfor data/error boundary placement. - Prefer
observability-handbookfor logging inside error UI.
Design App Router UX for failures and slow routes: error.tsx, not-found, loading.tsx, global-error.tsx.
error.tsx: client boundary - must reset viareset()pattern; log server-side in Route Handlers or server actions, not onlyconsole.errorin production without a sink.not-found: usenotFound()from server code; ensure marketing URLs return 404 not 200 empty shell.loading.tsx: skeletons that match final layout dimensions to reduce CLS; avoid fake progress bars unless truthful.global-error.tsx: minimal HTML shell when root layout throws; keep copy short and support link.- Nested layouts: errors bubble to nearest
error.tsx; document which segments need their own file vs inherited.
Outcomes
- File tree (
app/.../error.tsxetc.) + when each runs + logging hook suggestion.
Output Rules
Use headings: Errors · Not found · Loading · Global. No stack traces in user-visible UI.
Scope and boundaries
- In scope: Next App Router special files, UX copy, structure.
- Out of scope: APM vendor setup, log aggregation infrastructure.
Safety
- repo-files only in scope user names; never log PII or tokens in error payloads.
Troubleshooting
- Infinite error loop: error boundary itself throws - simplify UI, move risky UI out.
- 404 as 500: missing
notFound()call or swallowed errors upstream.
Related skills
next-server-patterns- error boundaries vs data layerobservability-handbook- logging in error.tsxsemantic-html-css- accessible error UI
GitHub: https://github.com/bh611627/skillcodex/tree/main/skills/error-loading-not-found/SKILL.md
npm: https://www.npmjs.com/package/@skillcodex/skills