Skip to main content

jaw-dev-backend

MUST USE for backend, API, server, or database work — API design, architecture, database optimization, security hardening, error handling, middleware, observability, queues, and long-lived connections. Triggers: backend, API, REST, GraphQL, schema, migration, query optimization, middleware, OTel, caching, Result pattern, server, 백엔드, API 작업, 마이그레이션, 쿼리 최적화.

ソース情報

リポジトリ
lidge-jun/cli-jaw-skills
ソースの最終更新活動
2026年10月8日 02:02
検出された SKILL.md の言語
英語
スター
5
フォーク
1

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。

ファイルエクスプローラー
20 ファイル

SKILL.md を表示中

SKILL.md
ソースの指示 · 読み取り専用プレビュー
name
jaw-dev-backend
description
MUST USE for backend, API, server, or database work — API design, architecture, database optimization, security hardening, error handling, middleware, observability, queues, and long-lived connections. Triggers: backend, API, REST, GraphQL, schema, migration, query optimization, middleware, OTel, caching, Result pattern, server, 백엔드, API 작업, 마이그레이션, 쿼리 최적화.
metadata
{"short-description":"Framework-agnostic backend guidance for APIs, architecture, data access, and operations.","keywords":"API, REST, endpoint, middleware, database, ORM, cache, queue, error handling, observability","last-verified":"2026-07-02"}
# Dev-Backend — Production-Grade Backend Engineering Build reliable, secure, and maintainable server-side applications. This skill has modular references for specialized guidance — read the relevant ones before coding. It activates by change surface whenever work primarily touches APIs, servers, services, jobs, data access, schemas, migrations, or operational backend behavior. > **C0/C1 work (small local patches):** See `jaw-dev` §0.0 Work Classifier + §0.1 Patch Fast-Path before reading references. > **`jaw-dev` is canonical:** `jaw-dev` §0.2 Rule Classes, §3 Verification Gate, and §5 Safety Rules apply to all work governed by this skill. ## Modular References | File | When to Read | What It Covers | | -------------------------------------- | ------------------------------ | ---------------------------------------------------------------------- | | `references/core/crud-api.md` | C2 ordinary CRUD/resource endpoints | Route/schema/service/query basics, five operations, error+permission mapping | | `references/core/api-design.md` | New/changed API style, or C3+ API work (C2 ordinary slice: `crud-api.md` alone suffices) | REST conventions, response envelopes, HTTP status, pagination, GraphQL, gRPC, tRPC | | `references/core/api-lifecycle.md` | API versioning, deprecation, migration | Versioning strategy, RFC 9745/8594 lifecycle, oasdiff CI gate | | `references/core/architecture.md` | New features at C3+ (C2 ordinary slice: `crud-api.md` alone suffices) | Layered architecture, DDD, SOLID, when to split, monolith vs micro | | `references/core/anti-slop-backend.md` | New endpoints, classes, or modules | Banned patterns: god classes, raw SQL in services, magic numbers, etc. | | `references/core/observability.md` | Production deployments | OpenTelemetry, structured logging, distributed tracing, alerting | | `references/core/health-checks.md` | Production/long-lived services | Liveness, readiness, startup probes, dependency checks | | `references/core/process-isolation.md` | CPU-bound or untrusted work | worker_threads vs child_process vs separate service, communication, resource limits | | `references/core/caching.md` | Performance optimization | Redis-compatible (Valkey/Redis) patterns, CDN, connection pooling, cache invalidation | | `references/stacks/node.md` | Node.js/TypeScript projects | Express/Fastify, middleware, Zod validation, ESM, error handling | | `references/stacks/python.md` | Python projects | FastAPI/Django, Pydantic, async patterns, testing | | `references/stacks/database.md` | Database design/optimization | PostgreSQL, MongoDB, indexing, N+1, migrations, ORM comparison | | `references/core/ml-serving.md` | ML model deployment, GPU inference | vLLM/SGLang runtime selection, FastAPI+GPU patterns, dynamic batching, quantization | | `references/core/llm-integration.md` | RAG, LLM API integration, prompt engineering | Chunking, hybrid search, vector DB, structured output, LangChain/LlamaIndex 2026 | | `references/core/mobile-api.md` | Mobile app API patterns | BFF, push notifications, offline sync, mobile auth, API optimization | Read `api-design.md` + `anti-slop-backend.md` first, then the relevant stack file. For C2 ordinary slices, `crud-api.md` alone suffices; read `api-design.md`/`architecture.md` for new API styles or C3+ work. When backend decisions depend on current external API docs, API lifecycle changes, LLM/RAG provider behavior, dependency freshness, or package/source evidence, read the active `jaw-search` skill and follow its query-rewrite, source-fetch, and evidence-status rules. --- ## 0. Stack Detection & Architecture Clarification ### Auto-detect (existing projects) | File Found | Project Type | | ----------------------------------- | ----------------- | | `tsconfig.json` | TypeScript (Node) | | `package.json` (no ts) | JavaScript (Node) | | `pyproject.toml`/`requirements.txt` | Python | | `go.mod` | Go | | `Cargo.toml` | Rust | If config files exist → detect silently and proceed. ### Architecture Clarification (new or ambiguous projects) When the request has **unspecified technology or unclear scope**, clarify before coding: 1. **Identify what's ambiguous** from this list: | Dimension | Options to present | | ------------ | ----------------------------------------------------------------------------------- | | API style | REST (default) · GraphQL (BFF/mobile) · gRPC (internal microservices) · tRPC (TS monorepo) | | Database | PostgreSQL (default, ACID) · MongoDB (flexible schema) · SQLite (embedded) | | Auth method | JWT + refresh (stateless) · Session-based (simple) · OAuth 2.1 (3rd party) | | Realtime | Not needed (default) · WebSocket · SSE · Polling | | Architecture | Monolith (default) · Modular monolith · Microservices | 2. **Recommend one with reasoning**: cite project context. e.g., "Small team → monolith + PostgreSQL + JWT is the simplest starting point." 3. **Over-engineering guard**: A CRUD API *probably* doesn't need GraphQL + microservices + event sourcing. Simple → complex, not the reverse. 4. **One round limit**: 2-3 options → recommend → confirm → proceed. If the user already specifies clear tech (e.g. "FastAPI로 REST API 만들어줘"), **skip this entirely**. **Node/framework defaults (verified 2026-07-02):** production uses Active/Maintenance LTS — Node 24 (Active LTS) for new services, Node 22 (Maintenance). Framework: Fastify for greenfield Node APIs (schema/Pino/plugin structure); Express 5 for legacy/ecosystem compatibility; Hono for edge/serverless/multi-runtime Web-Standards APIs. New TS validation baseline is Zod v4 (read the migration guide before upgrading v3 projects). Sources: `references/stacks/node.md` § Sources. For new Node backend source files, prefer `.ts` when the repo supports TypeScript or is greenfield. Inherit `jaw-dev` TypeScript strict-compatibility rules. If backend boundaries are unclear, read existing source-of-truth docs/logs first, then document routes, services, repositories, data stores, and runtime commands in the repo's existing SOT before broad implementation. --- ## 1. Architecture Decision Before coding, identify the right pattern: | Team Size | Default Starting Point | | --------- | ----------------------- | | 1-3 devs | Modular monolith | | 4-10 devs | Modular monolith or SOA | | 10+ devs | Consider microservices | **Default to monolith.** Extract only when you have a proven need (different scaling, independent deployment, technology mismatch). See `references/core/architecture.md` for full decision matrices. ### API Protocol Decision | Protocol | Choose When | Avoid When | |----------|-------------|------------| | **REST** | Public/partner APIs, simple CRUD, caching matters | Clients need flexible data shapes | | **GraphQL** | Mobile/BFF client aggregation, multiple resources per request | Simple CRUD, server-to-server, file uploads | | **gRPC** | Internal microservices, high-perf binary, bidirectional streaming | Browser clients (without gRPC-Web), public APIs | | **tRPC** (v11) | TypeScript shared end-to-end: monorepo, internal tools | Polyglot environments, public APIs | **Hybrid pattern (verified 2026-07-02):** ``` Public/Partner → REST (OpenAPI 3.1+; prefer 3.2 where tooling supports it) Mobile/Web BFF → GraphQL (client aggregation; Apollo Federation ONLY when multiple independently-owned subgraphs must compose into a supergraph) Internal services → gRPC (Protobuf contracts) TS internal tools → tRPC v11 (zero-codegen type safety) ``` Deprecations: emit `Deprecation` (RFC 9745) and optional `Sunset` (RFC 8594) headers, but client adoption is uneven — always pair with OpenAPI/changelog dates and deprecated- endpoint traffic dashboards. See `references/core/api-design.md` for protocol-specific patterns. ### Long-Lived Connection Operation Rules for SSE, WebSocket, and any connection held open beyond a single request-response cycle. **Lifecycle examples (HEURISTIC):** tune heartbeat, cap, drain, and duration to protocol, proxy, capacity, and product needs. The common six-connection browser limit concerns HTTP/1.x; HTTP/2 stream limits are negotiated. These values are not universal failure thresholds. | Parameter | Default | Rationale | |-----------|---------|-----------| | Heartbeat interval | Route-specific | Keep the stream observable within proxy limits | | Reconnection backoff | Exponential 1s-30s with jitter | Prevent thundering herd on server restart | | Max connection duration | Route-specific | Rebalance within the declared proxy and resource budget | | Connections per client | Route-specific | Account for HTTP version and server capacity | **Server-Side Requirements:** - **Connection tracking:** Track active connections as needed for capacity, drain, and debugging; use the repository’s established registry. - **Graceful drain on deploy:** Stop accepting new connections, finish or close streams within the route budget, and let clients reconnect by their existing protocol. Do not invent a wire frame. - **Memory budget:** Bound per-connection buffers, monitor total use, and reject new connections at the established capacity limit. - **Backpressure:** If a client stops consuming, use the route-defined bounded buffer and loss/disconnect policy. **Pattern — "202 + Job ID" when the API defines an asynchronous job:** For that contract, instead of holding a connection open for the work: ``` POST /generate → 202 { jobId: "j_abc123" } GET /jobs/j_abc123 → { status: "processing", progress: 0.6 } → { status: "complete", result: {...} } ``` A job API may push status over SSE/WebSocket; an existing streaming API may deliver its own operation result. For example, cli-jaw `GET /api/events` preserves data-only SSE, flushes headers promptly, rejects at capacity with 503, and sends a visible data ping. Do not add an `event:` field or fixed one-hour cutoff to that route. **Banned:** | Banned | Fix | |--------|-----| | Unbounded connections (no cap, no registry) | Track clients and enforce protocol-aware capacity limits | | No heartbeat where proxy/clients require visibility | Use the route-defined heartbeat interval and frame format | | Blocking event loop per connection (sync work in message handler) | Offload to worker thread or queue; handler stays async | | Work exceeding the declared response budget or blocking the event loop | Queue, stream, or isolate according to the route contract | | No reconnection logic on client side | Implement exponential backoff with jitter | --- ## 2. Layered Architecture (Default; Allow Serverless Handlers, Vertical Slices, and Small Scripts When Appropriate) ``` Routes → Controllers → Services → Repositories → Database │ │ │ │ │ │ │ └── Data access only │ │ └── Business logic (validation at controller boundary — service trusts caller per jaw-dev-architecture §4) │ └── Parse HTTP, format response └── URL mapping, middleware ``` **Rules:** - Routes: URL patterns + middleware only. No logic. - Controllers: parse input, call services, format output. No business rules. - Services: receive/return plain data (not `req`/`res`). All logic here. - Repositories: abstract DB access. Services access data through repositories only. ### Repository Pattern (Interface Abstraction) **Boundary parsing contract (BACKEND-BOUNDARY-01, DEFAULT).** Parse once at ingress and trust boundaries; inside that boundary, typed values are proof. Do not duplicate schema validation, null defense, or defensive parsing in services unless the data crosses a **new** trust boundary. Canonical boundary-defense ownership stays with `jaw-dev-architecture` §4; this is the backend stub. The reason to state it as a rule rather than a preference: duplicated validation reads as prudence and behaves as ambiguity — with two checks, neither one is the boundary, and a later change can remove whichever looks redundant. **Server runtime safety (BACKEND-RUNTIME-01, DEFAULT).** Production server runtimes set explicit read, write, request/idle, and graceful-shutdown timeouts. Drain on SIGTERM or deploy: stop accepting new work, let in-flight work finish within the shutdown budget, then close. Propagate the request id from ingress into structured logs, traces, queued work, and outbound calls wherever the stack supports it — an id that stops at the queue boundary is the one you will miss during an incident. Use repository interfaces so services depend on abstractions, enabling mocking and swapping implementations. ### Async Task Queue Patterns When work exceeds what an HTTP response cycle should hold open, use a queue. **Decision: Queue vs Direct:** | Condition | Use Queue | Use Direct | |-----------|-----------|------------| | Work exceeds the measured request/proxy budget (5s is only an example) | Usually | Streaming or bounded direct work may fit | | Must be retryable on failure | Yes | No | | Fire-and-forget (caller doesn't wait) | Yes | No | | <1s, idempotent, caller needs immediate result | No | Yes | | Real-time user-facing validation | No | Yes | **Pattern — Accept, Queue, Notify:** ``` 1. Client → POST /tasks → Server validates, enqueues 2. Server → 202 { jobId } → Client receives immediately 3. Worker → picks from queue → executes task 4. Client → GET /tasks/{id} → polls status (or receives webhook/SSE push) 5. Worker → completes → writes result, triggers notification ``` **Queue Selection Guide:** | Queue | When | Notes | |-------|------|-------| | **BullMQ** (Redis-compatible) | Node.js, need retries + priorities + rate limiting | Most mature Node queue; needs Redis/Valkey | | **Celery** (Redis/RabbitMQ) | Python, distributed workers, periodic tasks | De facto Python standard | | **pg-boss** (PostgreSQL) | Node.js, Postgres is the durable system of record, moderate scale | No extra infra; SKIP_LOCKED-based | | **Simple DB queue** (polling) | Small scale (<100 jobs/min), any language | `status` column + `SELECT FOR UPDATE SKIP LOCKED` | | **SQS / Cloud Tasks** | Serverless, managed, very high scale | No infra to manage; at-least-once delivery | | **Temporal** | Durable multi-step workflows: sagas, human-in-loop, long-running AI/business processes | Workflow engine, NOT a default queue replacement | **Required Safeguards:** | Safeguard | Rule | |-----------|------| | Idempotency key | Every enqueue call must include a unique idempotency key; dedup on insert | | Dead letter queue (DLQ) | Failed 3x (configurable) → move to DLQ → alert → manual review |
GitHubで見る
この SKILL.md は非常に大きいため、SkillsMP では最初のセクションだけを表示しています。 GitHubで見る