💼 BackendDevガイドライン
Node.jsやExpress、TypeScriptを使ったバックエンド開発において
📺 まず動画で見る(YouTube)
▶ 【自動化】AIガチ勢の最新活用術6選がこれ1本で丸分かり!【ClaudeCode・AIエージェント・AI経営・Skills・MCP】 ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
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.
🇯🇵 日本人クリエイター向け解説
Node.jsやExpress、TypeScriptを使ったバックエンド開発において
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o backend-dev-guidelines.zip https://jpskill.com/download/319.zip && unzip -o backend-dev-guidelines.zip && rm backend-dev-guidelines.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/319.zip -OutFile "$d\backend-dev-guidelines.zip"; Expand-Archive "$d\backend-dev-guidelines.zip" -DestinationPath $d -Force; ri "$d\backend-dev-guidelines.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
backend-dev-guidelines.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
backend-dev-guidelinesフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › backend-dev-guidelines を使って、最小構成のサンプルコードを示して
- › backend-dev-guidelines の主な使い方と注意点を教えて
- › backend-dev-guidelines を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[スキル名] backend-dev-guidelines
バックエンド開発ガイドライン
目的
最新のNode.js/Express/TypeScriptパターンを使用して、バックエンドのマイクロサービス(blog-api、auth-service、notifications-service)全体で一貫性とベストプラクティスを確立します。
このスキルを使用するタイミング
以下の作業時に自動的に有効になります。
- ルート、エンドポイント、APIの作成または変更
- コントローラー、サービス、リポジトリの構築
- ミドルウェア(認証、バリデーション、エラー処理)の実装
- Prismaを使用したデータベース操作
- Sentryを使用したエラー追跡
- Zodを使用した入力バリデーション
- 設定管理
- バックエンドのテストとリファクタリング
クイックスタート
新規バックエンド機能チェックリスト
- [ ] ルート: クリーンな定義、コントローラーへの委譲
- [ ] コントローラー:
BaseControllerを拡張 - [ ] サービス: DIを使用したビジネスロジック
- [ ] リポジトリ: データベースアクセス(複雑な場合)
- [ ] バリデーション: Zodスキーマ
- [ ] Sentry: エラー追跡
- [ ] テスト: 単体テスト + 結合テスト
- [ ] 設定:
unifiedConfigを使用
新規マイクロサービスチェックリスト
- [ ] ディレクトリ構造(architecture-overview.mdを参照)
- [ ] Sentry用の
instrument.ts - [ ]
unifiedConfigのセットアップ - [ ]
BaseControllerクラス - [ ] ミドルウェアスタック
- [ ] エラーバウンダリ
- [ ] テストフレームワーク
アーキテクチャ概要
階層型アーキテクチャ
HTTP Request
↓
Routes (ルーティングのみ)
↓
Controllers (リクエスト処理)
↓
Services (ビジネスロジック)
↓
Repositories (データアクセス)
↓
Database (Prisma)
主要原則: 各レイヤーは1つの責任を持ちます。
完全な詳細はarchitecture-overview.mdを参照してください。
ディレクトリ構造
service/src/
├── config/ # UnifiedConfig
├── controllers/ # リクエストハンドラー
├── services/ # ビジネスロジック
├── repositories/ # データアクセス
├── routes/ # ルート定義
├── middleware/ # Expressミドルウェア
├── types/ # TypeScript型
├── validators/ # Zodスキーマ
├── utils/ # ユーティリティ
├── tests/ # テスト
├── instrument.ts # Sentry (最初のインポート)
├── app.ts # Expressセットアップ
└── server.ts # HTTPサーバー
命名規則:
- コントローラー:
PascalCase-UserController.ts - サービス:
camelCase-userService.ts - ルート:
camelCase + Routes-userRoutes.ts - リポジトリ:
PascalCase + Repository-UserRepository.ts
コア原則(7つの主要ルール)
1. ルートはルーティングのみ、コントローラーは制御のみ
// ❌ 絶対にしない: ルートにビジネスロジックを記述
router.post('/submit', async (req, res) => {
// 200行のロジック
});
// ✅ 常に: コントローラーに委譲
router.post('/submit', (req, res) => controller.submit(req, res));
2. すべてのコントローラーは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. すべてのエラーをSentryに送信する
try {
await operation();
} catch (error) {
Sentry.captureException(error);
throw error;
}
4. unifiedConfigを使用し、process.envは絶対にしない
// ❌ 絶対にしない
const timeout = process.env.TIMEOUT_MS;
// ✅ 常に
import { config } from './config/unifiedConfig';
const timeout = config.timeouts.default;
5. すべての入力をZodでバリデーションする
const schema = z.object({ email: z.string().email() });
const validated = schema.parse(req.body);
6. データアクセスにはリポジトリパターンを使用する
// サービス → リポジトリ → データベース
const users = await userRepository.findActive();
7. 包括的なテストが必須
describe('UserService', () => {
it('should create user', async () => {
expect(user).toBeDefined();
});
});
共通のインポート
// 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 { asyncErrorWrapper } from './middleware/errorBoundary';
クイックリファレンス
HTTPステータスコード
| コード | ユースケース |
|---|---|
| 200 | 成功 |
| 201 | 作成済み |
| 400 | 不正なリクエスト |
| 401 | 未認証 |
| 403 | 禁止 |
| 404 | 見つかりません |
| 500 | サーバーエラー |
サービステンプレート
Blog API (✅ 成熟) - REST APIのテンプレートとして使用 Auth Service (✅ 成熟) - 認証パターンのテンプレートとして使用
避けるべきアンチパターン
❌ ルートにビジネスロジック
❌ process.envの直接使用
❌ エラー処理の欠如
❌ 入力バリデーションなし
❌ どこでも直接Prismaを使用
❌ Sentryの代わりにconsole.log
ナビゲーションガイド
| 必要なこと... | これを読む |
|---|---|
| アーキテクチャを理解する | architecture-overview.md |
| ルート/コントローラーを作成する | routing-and-controllers.md |
| ビジネスロジックを整理する | services-and-repositories.md |
| 入力をバリデーションする | validation-patterns.md |
| エラー追跡を追加する | sentry-and-monitoring.md |
| ミドルウェアを作成する | middleware-guide.md |
| データベースアクセス | database-patterns.md |
| 設定を管理する | configuration.md |
| 非同期/エラーを処理する | async-and-errors.md |
| テストを書く | testing-guide.md |
| 例を見る | [complete-examples.md](complete-exam |
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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 { asyncErrorWrapper } from './middleware/errorBoundary';
Quick Reference
HTTP Status Codes
| Code | Use Case |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 500 | Server Error |
Service Templates
Blog API (✅ Mature) - Use as template for REST APIs Auth Service (✅ Mature) - Use as template for authentication patterns
Anti-Patterns to Avoid
❌ Business logic in routes ❌ Direct process.env usage ❌ Missing error handling ❌ No input validation ❌ Direct Prisma everywhere ❌ console.log instead of Sentry
Navigation Guide
| Need to... | Read this |
|---|---|
| Understand architecture | architecture-overview.md |
| Create routes/controllers | routing-and-controllers.md |
| Organize business logic | services-and-repositories.md |
| Validate input | validation-patterns.md |
| Add error tracking | sentry-and-monitoring.md |
| Create middleware | middleware-guide.md |
| Database access | database-patterns.md |
| Manage config | configuration.md |
| Handle async/errors | async-and-errors.md |
| Write tests | testing-guide.md |
| See examples | complete-examples.md |
Resource Files
architecture-overview.md
Layered architecture, request lifecycle, separation of concerns
routing-and-controllers.md
Route definitions, BaseController, error handling, examples
services-and-repositories.md
Service patterns, DI, repository pattern, caching
validation-patterns.md
Zod schemas, validation, DTO pattern
sentry-and-monitoring.md
Sentry init, error capture, performance monitoring
middleware-guide.md
Auth, audit, error boundaries, AsyncLocalStorage
database-patterns.md
PrismaService, repositories, transactions, optimization
configuration.md
UnifiedConfig, environment configs, secrets
async-and-errors.md
Async patterns, custom errors, asyncErrorWrapper
testing-guide.md
Unit/integration tests, mocking, coverage
complete-examples.md
Full examples, refactoring guide
Related Skills
- database-verification - Verify column names and schema consistency
- error-tracking - Sentry integration patterns
- skill-developer - Meta-skill for creating and managing skills
Skill Status: COMPLETE ✅ Line Count: < 500 ✅ Progressive Disclosure: 11 resource files ✅