Communityコーディング&開発github.com

API設計原則

RESTおよびGraphQL API設計の原則を習得し、直感的でスケーラブル、保守性の高いAPIを構築します。新しいAPI設計や仕様レビュー、設計基準策定時に使用します。

API設計原則 とは?

このスキルは、開発者にとって直感的で、スケーラブルかつ保守性に優れたAPIを設計するための、RESTとGraphQL両方の設計原則を網羅的に提供します。主にClaude CodeやCursorといったAIエージェント向けに設計されており、新しいAPIの設計、既存APIのリファクタリング、チーム内での設計基準策定、仕様レビュー、さらにはパラダイム移行(RESTからGraphQLなど)の際にも活用できます。RESTful設計ではリソース指向アーキテクチャとHTTPメソッドの適切なセマンティクスを、GraphQLではスキーマファースト開発とクエリ構造の最適化を重視します。また、URL・ヘッダ・クエリパラメータを使ったバージョニング戦略、HTTPステータスコードの正しい使い方、ページネーション、レート制限、エラーハンドリングなど、実践的なベストプラクティスを多数含んでいます。詳細なパターンや作業例は`references/details.md`に記載されており、必要に応じて参照できます。

対応~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/mianhtsys/landingMod3/tree/HEAD/MODULO_3_DESARROLLO_AL_LADO_DEL_CLIENTE_Y_SERVIDOR_WEB/architecture-skills-framework/.agents/skills/api-design-principles

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

API設計原則 は何をしますか?

RESTおよびGraphQL API設計の原則を習得し、直感的でスケーラブル、保守性の高いAPIを構築します。これにより開発者を喜ばせ、長期的に価値を維持できるAPIを実現します。

このスキルを使用するタイミング

  • 新しいREST APIまたはGraphQL APIの設計時
  • 既存APIの使いやすさ向上のためのリファクタリング時
  • チームのAPI設計基準の策定時
  • 実装前のAPI仕様レビュー時
  • APIパラダイム間の移行時(RESTからGraphQLなど)
  • 開発者に優しいAPIドキュメント作成時
  • 特定のユースケース向けAPIの最適化時(モバイル、サードパーティ統合など)

コアコンセプト

1. RESTful設計原則

リソース指向アーキテクチャ

  • リソースは名詞(users、orders、products)であり、動詞ではない
  • アクションにはHTTPメソッドを使用(GET、POST、PUT、PATCH、DELETE)
  • URLはリソース階層を表現する
  • 一貫した命名規則

HTTPメソッドのセマンティクス:

  • GET: リソースの取得(べき等、安全)
  • POST: 新規リソースの作成
  • PUT: リソース全体の置き換え(べき等)
  • PATCH: リソースの部分更新
  • DELETE: リソースの削除(べき等)

2. GraphQL設計原則

スキーマファースト開発

  • 型(Type)がドメインモデルを定義する
  • クエリ(Query)でデータを読み取る
  • ミューテーション(Mutation)でデータを変更する
  • サブスクリプション(Subscription)でリアルタイム更新を扱う

クエリ構造:

  • クライアントは必要なデータだけを要求する
  • 単一エンドポイント、複数操作
  • 強く型付けされたスキーマ
  • イントロスペクションが組み込み

3. APIバージョニング戦略

URLバージョニング:

/api/v1/users
/api/v2/users

ヘッダーバージョニング:

Accept: application/vnd.api+json; version=1

クエリパラメータバージョニング:

/api/users?version=1

詳細パターンと作業例

詳細なパターンのドキュメントは references/details.md にあります。上記のナビゲーション階層だけでは不十分な場合にそのファイルを参照してください。

ベストプラクティス

REST API

  1. 一貫した命名: コレクションには複数形の名詞を使用する(/users、/userではない)
  2. ステートレス: 各リクエストに必要な情報をすべて含める
  3. HTTPステータスコードを正しく使用: 2xx成功、4xxクライアントエラー、5xxサーバーエラー
  4. APIのバージョニング: 初日から破壊的変更に備える
  5. ページネーション: 大きなコレクションは常にページネーションする
  6. レート制限: レート制限でAPIを保護する
  7. ドキュメント: インタラクティブドキュメントにOpenAPI/Swaggerを使用する

GraphQL API

  1. スキーマファースト: リゾルバを書く前にスキーマを設計する
  2. N+1問題を回避: DataLoaderを使用して効率的にデータを取得する
  3. 入力バリデーション: スキーマとリゾルバの両方のレベルで検証する
  4. エラーハンドリング: ミューテーションペイロードで構造化エラーを返す
  5. ページネーション: カーソルベースのページネーションを使用する(Relay仕様)
  6. 非推奨化: 段階的移行のために@deprecatedディレクティブを使用する
  7. モニタリング: クエリの複雑さと実行時間を追跡する

よくある落とし穴

  • 過剰取得/過少取得(REST): GraphQLで解決されるが、DataLoaderが必要
  • 破壊的変更: APIのバージョニング、または非推奨化戦略を使用する
  • 一貫性のないエラー形式: エラー応答を標準化する
  • レート制限の欠如: 制限のないAPIは悪用されやすい
  • 貧弱なドキュメント: ドキュメント化されていないAPIは開発者をいらだたせる
  • HTTPセマンティクスの無視: べき等操作にPOSTを使うと期待を裏切る
  • 密結合: API構造がデータベーススキーマをそのまま反映すべきではない

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

mianhtsys/landingMod3

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

mianhtsys/landingMod3

Diseña y compara alternativas arquitectónicas trazables a RF/RNF sin implementar código.

mianhtsys/landingMod3

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

mianhtsys/landingMod3

Revisión adversarial de la arquitectura contra RF/RNF, detectando contradicciones, cobertura faltante y complejidad innecesaria.

mianhtsys/landingMod3

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

mianhtsys/landingMod3

>- Generate grounded-and-verified, engine-agnostic database documentation that reaches 100% parity with the real schema. Introspects the LIVE database as ground truth and cross-validates it against ORM models, migrations, generated types, seeds, and application queries, then proves completeness by diffing the docs back against the database. Produces ER diagrams (mermaid), per-table data dictionaries, and a machine-readable schema.json. Works with PostgreSQL, MySQL, SQL Server, and SQLite across any ORM (Prisma, TypeORM, Drizzle, Sequelize, Knex, Django, Rails) or raw SQL. Use when asked to document a database, produce an ERD or data dictionary, write db/schema docs, audit schema drift, or refresh existing DB docs.

mianhtsys/landingMod3

Compara estrategias de persistencia y motores de datos según consistencia, concurrencia, volumen, recuperación y operación.

mianhtsys/landingMod3

Design robust, scalable database schemas for SQL and NoSQL databases. Provides normalization guidelines, indexing strategies, migration patterns, constraint design, and performance optimization. Ensures data integrity, query performance, and maintainable data models.

mianhtsys/landingMod3

Consolida análisis especializados en una recomendación arquitectónica, matriz de decisión, ADR y plan de validación.

mianhtsys/landingMod3

Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.

mianhtsys/landingMod3

Build and maintain web frontends — component architecture, state management, API integration, responsive layout, client-side performance, and frontend testing patterns. Framework agnostic, focused on web frontend implementation. Do not use for backend service implementation, data engineering, or platform infrastructure work.

mianhtsys/landingMod3

Evalúa despliegue, contenedores, escalado, alta disponibilidad, observabilidad, backup, recuperación y CI/CD de forma proporcional.

mianhtsys/landingMod3

Execute read-only SQL queries against multiple Microsoft SQL Server databases. Use when: (1) querying MSSQL/SQL Server databases, (2) exploring database schemas/tables, (3) running SELECT queries for data analysis, (4) checking database contents. Supports multiple database connections with descriptions for intelligent auto-selection. Blocks all write operations (INSERT, UPDATE, DELETE, DROP, etc.) for safety.

mianhtsys/landingMod3

Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.

mianhtsys/landingMod3

PHP 8.0+ development — XAMPP, RESTful APIs, PDO/MySQL/MariaDB, and authentication. Use when building PHP backends, creating API endpoints, configuring XAMPP, or integrating PHP with databases.

mianhtsys/landingMod3

Use this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

mianhtsys/landingMod3

Analiza requisitos funcionales y no funcionales, reglas, restricciones, capacidad y ambigüedades antes de seleccionar tecnologías.

mianhtsys/landingMod3

Implement modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first breakpoint strategies. Use when building adaptive interfaces, implementing fluid layouts, or creating component-level responsive behavior.

mianhtsys/landingMod3

>- Use when designing or implementing software securely: define security requirements, threat-model a feature, choose secure defaults, design authentication and authorization, handle untrusted data and secrets, evaluate dependencies, design multi-tenant trust boundaries, or review security-sensitive changes. Use for prevention during requirements, design, implementation, and review; not for post-build security assessments or scanning an existing codebase.

mianhtsys/landingMod3

Revisa seguridad arquitectónica, identidad, autorización, secretos, APIs, auditoría, fraude y resiliencia antes de implementar.

関連スキル