What problem does it solve?
Building internal admin tooling often leads to inconsistent authorization checks that leak the existence of privileged surfaces. This Skill enforces a uniform pattern for adding staff-only /backoffice features in the Latitude codebase, where every non-admin request is indistinguishable from a random 404.
Core Features & Use Cases
- Three-layer guard enforcement: Route loader guard (
requireAdminSession), server-function guard (adminMiddleware on every createServerFn), and database guard (getAdminPostgresClient with the system organization scope that bypasses RLS).
- Anti-fingerprinting error discipline: All guard failures throw
NotFoundError instead of 401/403/redirects, so non-admins cannot enumerate or fingerprint the admin surface.
- Impersonation support: A dedicated
impersonatingMiddleware for stopImpersonating, which gates on session.impersonatedBy since the active session carries the target user's role during impersonation.
- Use Case: When adding a cross-organisation user search feature for support staff, follow the package layout (
@domain/admin feature folders, apps/web/src/domains/admin/*.functions.ts, routes under routes/backoffice/<feature>/) so the guards, adapter discipline, and test strategy are applied consistently.
Quick Start
Add a new backoffice server function for searching users across all organisations, making sure it attaches adminMiddleware and uses the admin Postgres client.