Community编程与开发github.com

mianhtsys/landingMod3

掌握REST和GraphQL API设计原则,构建直观、可扩展且易于维护的API,让开发者爱不释手。适用于设计新API、审查API规范或制定API设计标准。

landingMod3 是什么?

该技能旨在帮助开发者精通REST和GraphQL API的设计原则,从而构建出直观、可扩展且易于长期维护的API。它涵盖了从资源导向的REST架构到架构优先的GraphQL开发,以及多种API版本控制策略(如URL、头部、查询参数)。对于REST,它强调一致的命名规范、正确的HTTP方法语义和状态码使用;对于GraphQL,则侧重于模式先行、避免N+1查询和使用游标分页。此外,该技能还提供了详细的实践指南与常见陷阱警告。支持平台包括但不限于Claude Code、Cursor、Codex等任何支持Markdown技能的AI代理。用户可依据此技能设计新API、重构现有API、建立团队标准或审查规范。

兼容平台~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 设计原则

模式优先开发

  • 类型定义您的领域模型
  • 查询用于读取数据
  • 变更用于修改数据
  • 订阅用于实时更新

查询结构:

  • 客户端精确请求所需内容
  • 单一端点,多个操作
  • 强类型模式
  • 内置自省功能

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.

相关技能