本文へスキップ
Skillpedia
APIとサーバー(バックエンド)48k · #4006

backend-dev-guidelines

できること

データやロジックを扱うアプリの「見えない」部分であるバックエンドシステムを、整理された信頼性の高い方法で構築するためのガイドです。コードの書き方に明確なルールを設け、理解や保守がしやすく、エラーを早期に発見できるようにします。

使う場面

  • ✓バックエンドの新しい機能を作るとき。
  • ✓既存のシステムのバグを修正するとき。
  • ✓バックエンドのコードを整理・再構成するとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/backend-dev-guidelines/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“新しいログイン機能のコードを、どのような構造にすればよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

このガイドは「階層構造(レイヤー)」を採用します。各コードには、ルート、コントローラー、サービスなど、それぞれ決まった役割があります。また、すべてのエラーはSentryというシステムに記録し、バグを防ぐためにZodを使って入力データを検証することを求めます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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)

…
よくある質問

「Backend Feasibility & Risk Index(BFRI)」とは何ですか?

新しい機能を安全に実装できるか、それとも設計し直す必要があるかを判断するためのスコアです。複雑さ、データのリスク、コードのテストのしやすさなどの要素を考慮します。

なぜルートに直接ロジックを書いてはいけないのですか?

ルートはリクエストを振り分けるだけの役割を持つべきだからです。ロジックを書くと、整理やテストが難しくなります。ビジネスロジックは「サービス」に置くべきです。

バックエンド開発における「レイヤー」とは何ですか?

作業の分担のようなものです。リクエストはまず「ルート」に届き、「ルート」が「コントローラー」を呼び出し、「コントローラー」が「サービス」を呼び出してロジックを実行します。「サービス」は「リポジトリ」を使ってデータベースにアクセスします。各レイヤーには、それぞれ固有の責任があります。

詳細

作者による元の説明

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

人気

GitHubのスター
48k
ランキング
#4006
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル