building-reliable-node-api-boundaries
Skill1 starsChanged 3 months agoMITView on GitHub
Use when implementing or reviewing Node.js API or service endpoints that cross trust or data boundaries and require explicit validation, authorization, failure semantics, observability, or retry behavior.
In this repository65 other files it gives its agents.
- analyzing-change-blast-radiusSkill
- analyzing-developer-career-opportunitiesSkill
- art-directing-web-interfacesSkill
- assessing-developer-proficiencySkill
- auditing-dependency-riskSkill
- auditing-pixel-perfect-frontendSkill
- bootstrapping-modern-web-appsSkill
- brag-slimSkill
- building-brand-guidelinesSkill
- building-conversion-product-pagesSkill
- building-developer-career-roadmapsSkill
- building-hybrid-game-assetsSkill
- building-premium-nextjs-interfacesSkill
- building-project-showcasesSkill
- building-regression-testsSkill
- choosing-application-architectureSkill
- craft-premium-motionSkill
- creating-character-sprite-pipelinesSkill
- defining-brand-strategySkill
- designing-action-combatSkill
- designing-developer-portfolio-evidenceSkill
- designing-relational-data-modelsSkill
- designing-software-boundariesSkill
- designing-test-strategiesSkill
- designing-ui-systemsSkill
- designing-visual-identitiesSkill
- documenting-architecture-decisionsSkill
- editing-for-clarity-and-toneSkill
- engineering-gsap-animationsSkill
- evaluating-developer-proficiencySkill
- evolving-postgres-schemas-safelySkill
- humanizing-generated-proseSkill
- implementing-reference-faithful-uiSkill
- investigating-codebase-semanticallySkill
- managing-implementation-slicesSkill
- mapping-existing-codebase-structureSkill
- naming-brands-and-productsSkill
- optimizing-frontend-motion-performanceSkill
- orchestrating-cinematic-web-motionSkill
- planning-codebase-changes-with-evidenceSkill
- planning-engineering-workSkill
- planning-launch-distributionSkill
- planning-safe-refactorsSkill
- planning-written-communicationSkill
- preparing-project-launchSkill
- profiling-postgres-query-performanceSkill
- reconstructing-images-as-threejsSkill
- reviewing-api-securitySkill
- reviewing-apple-platform-interfacesSkill
- reviewing-pull-requestsSkill
- reviewing-web-securitySkill
- selecting-working-methodsSkill
- shipping-github-vercel-changesSkill
- teaching-developer-conceptsSkill
- testing-integration-boundariesSkill
- testing-playable-gamesSkill
- testing-web-applications-end-to-endSkill
- threat-modeling-applicationsSkill
- tracing-code-execution-pathsSkill
- translating-figma-to-nextjsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
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
- Distinctive: line 9
Treat every API boundary as a trust boundary.
- Distinctive: line 15
Keep one clear business operation per boundary.
- Very specific: line 18
Add request correlation and structured diagnostics.
- Distinctive: line 19
Put timeouts, cancellation, pagination, and resource ceilings around downstream or potentially expensive work.
- Distinctive: line 26
Do not rely on a client to hide forbidden identifiers or fields.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Building Reliable Node API Boundaries
Core principle
Treat every API boundary as a trust boundary. Make authentication, authorization, validation, mutation scope, and failure behavior explicit before optimizing handler structure or framework ergonomics.
Request path
- Parse the request into a bounded shape. Reject malformed or oversized input before business work begins.
- Authenticate the caller, then authorize the requested object and properties. Never infer object-level authorization only from a valid session.
- Validate domain input separately from transport parsing. Reject fields the caller is not allowed to set instead of mass-assigning request bodies.
- Keep one clear business operation per boundary. Put atomic database mutations inside an intentional transaction boundary.
- For externally retryable writes, define idempotency or conflict semantics before shipping the endpoint.
- Map internal failures to stable public error responses without leaking implementation details.
- Add request correlation and structured diagnostics. Use framework context when adequate; otherwise Node.js
AsyncLocalStoragecan carry request-scoped context across asynchronous work. - Put timeouts, cancellation, pagination, and resource ceilings around downstream or potentially expensive work.
Authorization checks
Cover both:
- object-level access: may this caller act on this specific record?
- property/function-level access: may this caller read or mutate these fields or operations?
Do not rely on a client to hide forbidden identifiers or fields.
Verification
Exercise at minimum:
- a valid request;
- malformed and oversized input;
- valid identity with unauthorized object access;
- partial/property-level permission failure;
- repeated write or replay behavior where relevant;
- downstream timeout/failure;
- transaction rollback after a mid-operation error.
Logs should carry correlation and outcome context without storing secrets or unnecessary personal data.
References
- Node.js AsyncLocalStorage: https://nodejs.org/api/async_context.html
- OWASP API Security Top 10 2023: https://owasp.org/API-Security/editions/2023/en/0x11-t10/
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.

