Langsung ke konten
Skillpedia
API & server (backend)48k Β· #4006

backend-dev-guidelines

Fungsinya

Panduan ini mengajarkan cara membangun sistem backend (bagian 'tak terlihat' dari sebuah aplikasi yang mengurus data dan logika) secara terorganisir dan andal. Panduan ini menetapkan aturan yang jelas tentang cara menulis kode agar mudah dipahami dan dipelihara, serta memastikan error cepat terdeteksi.

Kapan dipakai

  • βœ“Saat membuat fitur backend baru.
  • βœ“Saat memperbaiki bug pada sistem yang sudah ada.
  • βœ“Saat merapikan atau menyusun ulang kode backend.

Link skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/backend-dev-guidelines/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/backend-dev-guidelines/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBagaimana cara menyusun kode untuk fitur login pengguna yang baru?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Panduan ini menerapkan struktur 'berlapis' di mana setiap bagian kode memiliki tugas spesifik (routes, controllers, services, dan lainnya). Panduan ini juga mewajibkan semua error dicatat ke sistem bernama Sentry, dan data input divalidasi menggunakan Zod untuk mencegah bug.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Backend Development Guidelines

(Node.js Β· Express Β· TypeScript Β· Microservices)

You are a senior backend engineer operating production-grade services under strict architectural and reliability constraints.

Your goal is to build predictable, observable, and maintainable backend systems using:

  • Layered architecture
  • Explicit error boundaries
  • Strong typing and validation
  • Centralized configuration
  • First-class observability

This skill defines how backend code must be written, not merely suggestions.


1. Backend Feasibility & Risk Index (BFRI)

Before implementing or modifying a backend feature, assess feasibility.

BFRI Dimensions (1–5)

Dimension Question
Architectural Fit Does this follow routes β†’ controllers β†’ services β†’ repositories?
Business Logic Complexity How complex is the domain logic?
Data Risk Does this affect critical data paths or transactions?
Operational Risk Does this impact auth, billing, messaging, or infra?
Testability Can this be reliably unit + integration tested?

Score Formula

BFRI = (Architectural Fit + Testability) βˆ’ (Complexity + Data Risk + Operational Risk)

Range: -10 β†’ +10

Interpretation

BFRI Meaning Action
6–10 Safe Proceed
3–5 Moderate Add tests + monitoring
0–2 Risky Refactor or isolate
< 0 Dangerous Redesign before coding

When to Use

Automatically applies when working on:

  • Routes, controllers, services, repositories
  • Express middleware
  • Prisma database access
  • Zod validation
  • Sentry error tracking
  • Configuration management
  • Backend refactors or migrations

2. Core Architecture Doctrine (Non-Negotiable)

1. Layered Architecture Is Mandatory

Routes β†’ Controllers β†’ Services β†’ Repositories β†’ Database
  • No layer skipping
  • No cross-layer leakage
  • Each layer has one responsibility

2. Routes Only Route

// ❌ NEVER
router.post('/create', async (req, res) => {
  await prisma.user.create(...);
});

// βœ… ALWAYS
router.post('/create', (req, res) =>
  userController.create(req, res)
);

Routes must contain zero business logic.


3. Controllers Coordinate, Services Decide

  • Controllers:

    • Parse request
    • Call services
    • Handle response formatting
    • Handle errors via BaseController
  • Services:

    • Contain business rules
    • Are framework-agnostic
    • Use DI
    • Are unit-testable

4. All Controllers Extend BaseController

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

No raw res.json calls outside BaseController helpers.


5. All Errors Go to Sentry

catch (error) {
  Sentry.captureException(error);
  throw error;
}

❌ console.log ❌ silent failures ❌ swallowed errors


6. unifiedConfig Is the Only Config Source

// ❌ NEVER
process.env.JWT_SECRET;

// βœ… ALWAYS
import { config } from '@/config/unifiedConfig';
config.auth.jwtSecret;

7. Validate All External Input with Zod

  • Request bodies
  • Query params
  • Route params
  • Webhook payloads
const schema = z.object({
  email: z.string().email(),
});

const input = schema.parse(req.body);

No validation = bug.


3. Directory Structure (Canonical)

src/
β”œβ”€β”€ config/              # unifiedConfig
β”œβ”€β”€ controllers/         # BaseController + controllers
β”œβ”€β”€ services/            # Business logic
β”œβ”€β”€ repositories/        # Prisma access
β”œβ”€β”€ routes/              # Express routes
β”œβ”€β”€ middleware/          # Auth, validation, errors
β”œβ”€β”€ validators/          # Zod schemas
β”œβ”€β”€ types/               # Shared types
β”œβ”€β”€ utils/               # Helpers
β”œβ”€β”€ tests/               # Unit + integration tests
β”œβ”€β”€ instrument.ts        # Sentry (FIRST IMPORT)

…
Pertanyaan umum

Apa itu 'Backend Feasibility & Risk Index (BFRI)'?

BFRI adalah skor yang membantu memutuskan apakah sebuah fitur baru aman untuk diterapkan atau perlu dirancang ulang. Skor ini mempertimbangkan faktor seperti kompleksitas, risiko data, dan kemudahan kode untuk diuji.

Mengapa logika tidak boleh langsung ditulis di routes?

Routes hanya bertugas mengarahkan permintaan. Jika logika ditaruh di sana, organisasi kode dan proses pengujian menjadi sulit. Logika bisnis sebaiknya berada di 'services'.

Apa itu 'layers' dalam pengembangan backend?

Layers adalah pembagian tugas. Permintaan masuk ke 'routes', lalu diteruskan ke 'controllers', yang kemudian memanggil 'services' untuk menjalankan logika, dan 'services' menggunakan 'repositories' untuk mengakses database. Setiap layer memiliki tanggung jawab yang berbeda.

Detail

Deskripsi asli dari pembuat

You are a senior backend engineer operating production-grade services under strict architectural and reliability constraints. Use when routes, controllers, services, repositories, express middleware, or prisma database access.

repo: sickn33/agentic-awesome-skills

Popularitas

Bintang GitHub
48k
Peringkat
#4006
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa