backend-dev-guidelines

Enforces layered architecture and error handling standards for Node.js Express backend services.

Updated May 8, 2026
One-click install
npx skills add https://github.com/kiprotichgidii/agent-skills --skill backend-dev-guidelines-kiprotichgidii
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: backend-dev-guidelines
Source: https://github.com/kiprotichgidii/agent-skills/tree/main/skills/backend-dev-guidelines
Command: npx skills add https://github.com/kiprotichgidii/agent-skills --skill backend-dev-guidelines-kiprotichgidii

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Backend codebases often degrade into inconsistent patterns: business logic leaking into routes, direct database access from controllers, scattered process.env usage, and swallowed errors. This Skill enforces a strict, production-grade architecture for Node.js, Express, and TypeScript microservices so every route, controller, service, and repository follows the same enforceable rules. ## Core Features & Use Cases - Layered Architecture Enforcement: Mandates the Routes → Controllers → Services → Repositories flow with no layer skipping, BaseController inheritance, and dependency injection. - BFRI Risk Scoring: Provides a Backend Feasibility & Risk Index formula to assess whether a feature is safe to implement, needs tests, or requires redesign before coding. - Operational Standards: Requires Zod input validation, unifiedConfig instead of process.env, Sentry error capture, asyncErrorWrapper for async routes, and mandatory unit/integration tests. - Use Case: When asked to add a new Express endpoint with Prisma database access, the Skill produces a clean route delegating to a BaseController-based controller, a service with business rules, and a repository encapsulating Prisma queries, all validated with Zod and tracked in Sentry. ## Quick Start Apply the backend development guidelines to review or implement my Express route, controller, service, and Prisma repository for the new user endpoint.

Frequently Asked Questions about backend-dev-guidelines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure an Express backend with clean architecture?▼

Use a layered flow of Routes → Controllers → Services → Repositories → Database. Routes only register paths and middleware, controllers handle requests via a BaseController, services hold business logic with dependency injection, and repositories encapsulate all Prisma queries.

How to handle errors in Express async route handlers?▼

Wrap every async route handler with an asyncErrorWrapper that forwards rejections to next(error), and register an error boundary middleware after all routes. Capture every error to Sentry and never swallow exceptions or use console.log for failures.

Should controllers call Prisma directly in Node.js?▼

No, Prisma must never be used directly in controllers. Repositories encapsulate all Prisma operations, transactions, and query optimization, exposing intent-based methods like findActiveUsers that services consume.

Why avoid process.env in TypeScript backend services?▼

Direct process.env usage lacks type safety, validation, and defaults, causing runtime errors from typos. A unifiedConfig module provides a single typed configuration source validated at startup with fallback values.

What is the BFRI score used for in backend development?▼

BFRI (Backend Feasibility & Risk Index) scores a feature from -10 to +10 using architectural fit, complexity, data risk, operational risk, and testability. Scores of 6-10 proceed, 3-5 need tests and monitoring, and below 0 requires redesign before coding.

When should I not use the repository pattern with Prisma?▼

Repositories can be skipped for simple one-off queries or early prototyping, then refactored in later. They are required when queries are complex, reused in multiple places, need caching, or must be mocked for testing.