Community程式設計與開發github.com

mianhtsys/landingMod3

精通 REST 與 GraphQL API 設計原則,打造直觀、可擴展且易於維護的 API,讓開發者愛不釋手。適用於設計新 API、審查 API 規格或制定 API 設計標準。

landingMod3 是什麼?

此技能為開發者與 AI 代理提供一套完整的 API 設計原則,涵蓋 REST 與 GraphQL 兩大主流範式。其核心目標是協助使用者設計出直觀、可擴展且長期易於維護的 API,無論是從零開始設計、重構既有系統、建立團隊標準,還是進行 API 規範審查,都能發揮作用。技能內容深入探討了資源導向架構、HTTP 方法語義、Schema 優先開發等核心概念,並詳細說明了 URL 版本、標頭版本等多種 API 版本化策略。此外,它還提供了超過 60 個具體的最佳實踐與常見陷阱分析,例如 REST 的一致命名與分頁、GraphQL 的 DataLoader 與遊標分頁等,有助於避免過度/不足擷取、破壞性變更、錯誤格式不一致等常見問題。該技能適用於 Claude Code、Cursor 等主要 AI 代理工具,透過結構化的標記語言和參考文件提供即時指引。

相容平台~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 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

API 設計原則

精通 REST 與 GraphQL API 設計原則,打造直觀、可擴展且易於維護的 API,讓開發者愛不釋手,經得起時間考驗。

何時使用此技能

  • 設計新的 REST 或 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 設計原則

Schema 優先開發

  • 類型定義領域模型
  • 查詢用於讀取資料
  • 修改用於變更資料
  • 訂閱用於即時更新

查詢結構:

  • 客戶端精確請求所需資料
  • 單一端點、多種操作
  • 強型別 schema
  • 內建自省機制

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. Schema 優先:在撰寫解析器之前先設計 schema
  2. 避免 N+1:使用 DataLoader 實現高效資料擷取
  3. 輸入驗證:在 schema 和解析器層級進行驗證
  4. 錯誤處理:在修改負載中回傳結構化錯誤
  5. 分頁:使用基於遊標的分頁(Relay 規範)
  6. 棄用:使用 @deprecated 指示詞進行逐步遷移
  7. 監控:追蹤查詢複雜度和執行時間

常見陷阱

  • 過度/不足擷取(REST):GraphQL 已解決,但需要 DataLoader
  • 重大變更:版本化 API 或使用棄用策略
  • 錯誤格式不一致:標準化錯誤回應
  • 缺少速率限制:無限制的 API 容易遭到濫用
  • 文件不足:未記錄的 API 會讓開發者感到沮喪
  • 忽略 HTTP 語義:對冪等操作使用 POST 會違反預期
  • 緊密耦合:API 結構不應直接反映資料庫 schema

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.

相關技能