Skip to content
Skillpedia
APIs & servers (backend)33k Β· #8726

backend-dev-guidelines

What it does

This skill gives your AI agent backend rules for Node.js, Express and TypeScript services. It is for developers who want routes, services and data access kept organized.

When to use it

  • βœ“When you add new routes, controllers or services to an Express API.
  • βœ“When you set up a new microservice with error tracking and configuration.
  • βœ“When you add database access with Prisma or input validation with Zod.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/backend-dev-guidelines/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/backend-dev-guidelines/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œAdd a new endpoint for creating invoices in my Express API, following our layered structure.”

5 new skills a week. 1 minute to read.

How it works

The skill shows the agent a layered approach where routes only route, controllers handle requests, services hold business logic and repositories access data. The agent follows it when writing or changing code.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Backend Development Guidelines

Purpose

Establish consistency and best practices across backend microservices (blog-api, auth-service, notifications-service) using modern Node.js/Express/TypeScript patterns.

When to Use This Skill

Automatically activates when working on:

  • Creating or modifying routes, endpoints, APIs
  • Building controllers, services, repositories
  • Implementing middleware (auth, validation, error handling)
  • Database operations with Prisma
  • Error tracking with Sentry
  • Input validation with Zod
  • Configuration management
  • Backend testing and refactoring

Quick Start

New Backend Feature Checklist

  • Route: Clean definition, delegate to controller
  • Controller: Extend BaseController
  • Service: Business logic with DI
  • Repository: Database access (if complex)
  • Validation: Zod schema
  • Sentry: Error tracking
  • Tests: Unit + integration tests
  • Config: Use unifiedConfig

New Microservice Checklist

  • Directory structure (see architecture-overview.md)
  • instrument.ts for Sentry
  • unifiedConfig setup
  • BaseController class
  • Middleware stack
  • Error boundary
  • Testing framework

Architecture Overview

Layered Architecture

HTTP Request
    ↓
Routes (routing only)
    ↓
Controllers (request handling)
    ↓
Services (business logic)
    ↓
Repositories (data access)
    ↓
Database (Prisma)

Key Principle: Each layer has ONE responsibility.

See architecture-overview.md for complete details.


Directory Structure

service/src/
β”œβ”€β”€ config/              # UnifiedConfig
β”œβ”€β”€ controllers/         # Request handlers
β”œβ”€β”€ services/            # Business logic
β”œβ”€β”€ repositories/        # Data access
β”œβ”€β”€ routes/              # Route definitions
β”œβ”€β”€ middleware/          # Express middleware
β”œβ”€β”€ types/               # TypeScript types
β”œβ”€β”€ validators/          # Zod schemas
β”œβ”€β”€ utils/               # Utilities
β”œβ”€β”€ tests/               # Tests
β”œβ”€β”€ instrument.ts        # Sentry (FIRST IMPORT)
β”œβ”€β”€ app.ts               # Express setup
└── server.ts            # HTTP server

Naming Conventions:

  • Controllers: PascalCase - UserController.ts
  • Services: camelCase - userService.ts
  • Routes: camelCase + Routes - userRoutes.ts
  • Repositories: PascalCase + Repository - UserRepository.ts

Core Principles (7 Key Rules)

1. Routes Only Route, Controllers Control

// ❌ NEVER: Business logic in routes
router.post('/submit', async (req, res) => {
    // 200 lines of logic
});

// βœ… ALWAYS: Delegate to controller
router.post('/submit', (req, res) => controller.submit(req, res));

2. All Controllers Extend BaseController

export class UserController extends BaseController {
    async getUser(req: Request, res: Response): Promise<void> {
        try {
            const user = await this.userService.findById(req.params.id);
            this.handleSuccess(res, user);
        } catch (error) {
            this.handleError(error, res, 'getUser');
        }
    }
}

3. All Errors to Sentry

try {
    await operation();
} catch (error) {
    Sentry.captureException(error);
    throw error;
}

4. Use unifiedConfig, NEVER process.env

// ❌ NEVER
const timeout = process.env.TIMEOUT_MS;

// βœ… ALWAYS
import { config } from './config/unifiedConfig';
const timeout = config.timeouts.default;

5. Validate All Input with Zod

const schema = z.object({ email: z.string().email() });
const validated = schema.parse(req.body);

6. Use Repository Pattern for Data Access

// Service β†’ Repository β†’ Database
const users = await userRepository.findActive();

7. Comprehensive Testing Required

describe('UserService', () => {
    it('should create user', async () => {
        expect(user).toBeDefined();
    });
});

Common Imports

// Express
import express, { Request, Response, NextFunction, Router } from 'express';

// Validation
import { z } from 'zod';

// Database
import { PrismaClient } from '@prisma/client';
import type { Prisma } from '@prisma/client';

// Sentry
import * as Sentry from '@sentry/node';

// Config
import { config } from './config/unifiedConfig';

// Middleware
import { SSOMiddlewareClient } from './middleware/SSOMiddleware';
import {
FAQ

What is the layered structure?

It separates routes, controllers, services and repositories, so each layer has one job.

What tools does it cover?

It covers Prisma, Zod, Sentry, unified configuration and dependency injection.

Does it include testing?

Yes, the checklist includes unit and integration tests.

Details

Original description by the author

Comprehensive backend development guide for Node.js/Express/TypeScript microservices. Use when creating routes, controllers, services, repositories, middleware, or working with Express APIs, Prisma database access, Sentry error tracking, Zod validation, unifiedConfig, dependency injection, or async patterns. Covers layered architecture (routes β†’ controllers β†’ services β†’ repositories), BaseController pattern, error handling, performance monitoring, testing strategies, and migration from legacy patterns.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#8726
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills