backend-dev-guidelines
Skill này làm gì
Skill này cung cấp cho AI của bạn các quy tắc backend cho dịch vụ Node.js, Express và TypeScript. Nó dành cho lập trình viên muốn route, service và truy cập dữ liệu được tổ chức gọn gàng.
Khi nào nên dùng
- ✓Khi bạn thêm route, controller hoặc service mới vào API Express.
- ✓Khi bạn thiết lập một microservice mới với theo dõi lỗi và cấu hình.
- ✓Khi bạn thêm truy cập cơ sở dữ liệu bằng Prisma hoặc kiểm tra dữ liệu đầu vào bằng Zod.
Liên kết skill
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/backend-dev-guidelines/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy thêm một endpoint mới để tạo hóa đơn trong API Express của tôi, theo cấu trúc nhiều lớp của chúng tôi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill cho agent thấy cách tiếp cận nhiều lớp, trong đó route chỉ định tuyến, controller xử lý yêu cầu, service chứa logic nghiệp vụ, và repository truy cập dữ liệu. Agent tuân theo cách này khi viết hoặc thay đổi code.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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 {
Câu hỏi thường gặp
Cấu trúc nhiều lớp là gì?
Nó tách route, controller, service và repository, để mỗi lớp chỉ có một nhiệm vụ.
Skill bao gồm những công cụ nào?
Nó bao gồm Prisma, Zod, Sentry, cấu hình thống nhất và dependency injection.
Có bao gồm kiểm thử không?
Có. Danh sách kiểm tra có bao gồm unit test và integration test.
Chi tiết
Mô tả gốc của tác giả
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.
Độ phổ biến
- Sao GitHub
- 33k
- Vị trí xếp hạng
- #8726
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
owasp-security
33kDạy agent hướng dẫn bảo mật OWASP cho ứng dụng web, API, di động, container và agent AI, để nhận ra các điểm yếu phổ biến và gợi ý cách sửa.
agent-management
33kCho phép agent của bạn tạo, liệt kê, cho ngủ đông, đánh thức, đổi tên và xóa các agent AI bằng dòng lệnh AI Maestro, quản lý vòng đời của từng agent.
agent-messaging
33kCho phép agent của bạn gửi, nhận và trả lời tin nhắn có chữ ký giữa các agent AI, dùng Agent Messaging Protocol, chủ yếu trên máy của bạn.
docs-search
33kCho phép agent của bạn tìm trong tài liệu code được tạo tự động, như chữ ký hàm, định nghĩa lớp và chú thích, để kiểm tra API thật trước khi sửa code.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.