Api Design Spec 标志

Api Design Spec

社区
LuckyOneTwoThree
api-design-spec

在设计 API 规范时使用。根据已确认的数据模型和服务边界,生成 API 设计规范,包括 RESTful/GraphQL 接口契约、安全策略和身份验证方案,并生成 OpenAPI 3.0 规范。基于数据制定契约,API 字段由 ER 模型精准映射而来。内置合规检查,确保 API 安全且合规。关键词:API 设计、接口契约、OpenAPI、RESTful、GraphQL、API 安全、身份验证、JWT、OAuth2、RBAC。

概览

发布者LuckyOneTwoThree
代码仓库vibe-skill
技能名称api-design-spec
星标数
34
复刻数
8
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 LuckyOneTwoThree 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Api Design Spec AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/LuckyOneTwoThree/vibe-skill/tree/main/.codex/skills/api-design-spec
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/LuckyOneTwoThree/vibe-skill.git /tmp/vibe-skill
mkdir -p .claude/skills
cp -r /tmp/vibe-skill/.codex/skills/api-design-spec .claude/skills/api-design-spec
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Api Design Spec,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Api Design Spec。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Api Design Spec 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

API Design Specification

Core Principles

  1. Data-Driven Contracts: API contracts designed based on confirmed data models and service boundaries, field definitions evidence-based
  2. Built-in Security: Security policies and authentication designed alongside interfaces, not patched afterward
  3. Compliance by Default: Privacy compliance checks built-in, ensuring API design meets GDPR/MLPS requirements
  4. RESTful Priority: Prefer RESTful style, consider GraphQL for complex query scenarios
  5. Default Deny: Any request not explicitly allowed is denied

Interaction Mode

AI->Human AI suggests, human approves

Input

Input ItemTypeRequiredSourceDescription
PRDmarkdownYesoutput/pm-design/design-prd/prd.mdProduct requirements document
PRD Structured DataJSONYesoutput/pm-design/design-prd/prd.jsonMachine-consumable PRD version, containing features[]/entities[], for programmatic API design consumption
Data ModelJSONYesoutput/backend-data-architecture/data-architecture-spec/er_model.jsonData entity and relationship definitions, API fields precisely projected from Model
Business Data DictionaryJSONOoutput/backend-data-architecture/data-architecture-spec/data_dictionary.jsonBusiness data standards and entity definitions, for field naming and type alignment
Architecture PlanJSONYesoutput/backend-architecture/backend-architecture-spec/architecture_decision.jsonArchitecture pattern, determines whether API is split by service or unified entry
Service DesignJSONYesoutput/backend-architecture/backend-architecture-spec/service_design.jsonService decomposition + bounded contexts, determines API grouping by service
Tech Stack DecisionJSONOoutput/backend-architecture/backend-architecture-spec/tech_stack_decision.jsonUnified tech stack, determines API framework and middleware style
Business ProcessJSONOoutput/pm-design/design-userflow/userflow.jsonUser flow definitions
Security LevelstringYesUser providedStandard / High Security (Finance/Healthcare)
Compliance RequirementsstringOUser providedGDPR / MLPS / PCI-DSS
Multi-tenant RequirementsstringOUser providedWhether multi-tenant isolation is needed
Frontend Page Data RequirementsJSONOoutput/ui-frontend/page-builder/pages.jsonFrontend page data fetching requirements, ensuring API and frontend alignment (available in UI-first flow)
PRD Page Data RequirementsJSONOoutput/pm-design/design-prd/prd.json -> pages[].data_requirementsPage data operation requirements from PRD (read/create/update/delete, related entity, required fields), consumed when pages.json is unavailable in backend-first flow

Execution Steps

Step 1: Resource Identification and Modeling [Core]

Map API resources directly from ER model:

  • Each core data entity maps to a resource (plural noun)
  • API fields precisely projected from Model fields, no longer derived from PRD
  • Identify relationships between resources (one-to-one/one-to-many/many-to-many)
  • Determine CRUD operation requirements for resources
  • Mark which resources need nested resources (sub-resources)
  • Group API resources by bounded context based on service design (service_design.json)

Page Data Requirements Consumption Priority (resolving backend-first timing conflict):

PriorityData SourceAvailability TimingConsumption Method
1pages.json (UI output)UI-first flowDirectly consume pages.json data_flow fields
2prd.json -> pages[].data_requirementsBackend-first flowConsume PRD page data_operations/related_entity/fields, derive API endpoints
3Neither availablePRD and ER model onlyDesign CRUD interfaces only, mark "pending frontend data requirements supplement"

When prd.json pages[].data_requirements is available, derive API endpoints following these rules:

  • data_operations contains "read" -> corresponding GET endpoint
  • data_operations contains "create" -> corresponding POST endpoint
  • data_operations contains "update" -> corresponding PUT/PATCH endpoint
  • data_operations contains "delete" -> corresponding DELETE endpoint
  • related_entity -> maps to corresponding resource path
  • fields -> serves as subset of response fields or request fields

Resource Naming Conventions:

  • Use plural nouns: /courses not /course
  • Nested resources max 2 levels: /courses/{id}/lessons
  • Use kebab-case: /user-groups not /userGroups

Step 2: Interface and Specification Design [Core]

Design standard interfaces for each resource:

OperationMethodPathDescription
List QueryGET/resourcesPagination + filtering + sorting
Detail QueryGET/resources/{id}Single resource details
CreatePOST/resourcesCreate new resource
Full UpdatePUT/resources/{id}Replace entire resource
Partial UpdatePATCH/resources/{id}Update specified fields
DeleteDELETE/resources/{id}Delete resource

Define unified request/response formats, error code system, and versioning strategy.

Error Code System Specification:

Error Code RangeCategoryExample
10000-19999General errors (validation/auth/rate limiting)10001 Validation failed, 10002 Unauthenticated, 10003 Permission denied, 10004 Rate limited
20000-29999Business logic errors20001 Resource not found, 20002 State conflict, 20003 Business rule violation
30000-39999Data layer errors30001 Unique constraint violation, 30002 Data stale, 30003 Foreign key constraint violation
40000-49999External service errors40001 Downstream timeout, 40002 Third-party service error

Unified Error Response Format:

json
{
  "error": {
    "code": 20001,
    "message": "Resource not found",
    "detail": "Course with id 'abc' not found",
    "trace_id": "req-xxx"
  }
}

Service Boundary Adaptation:

  • Microservices: API split by service, each service generates independent OpenAPI tags or separate files
  • Monolithic: API unified entry, grouped by bounded context using tags
  • BFF pattern: Differentiated API for different frontends (Web/Mobile)

Stage Gate: Each resource has CRUD definition + error code system + service ownership

Step 3: Interface Security Design [Core]

Classify interfaces by sensitivity level:

LevelInterface TypeAccess ControlAudit Requirements
L1-PublicHealth check, public docsNo authenticationNone
L2-AuthenticatedUser personal info, business queriesToken authenticationQuery logs
L3-AuthorizedWrite operations, admin functionsToken + permission checkOperation logs + change records
L4-SensitivePayments, keys, data exportToken + permission + secondary verificationFull audit + alerts

Design rate limiting strategy, data security (encryption/masking/input validation), CORS and security headers.

Stage Gate: 100% of interfaces have security level + rate limiting rules, L4 interface security policies are complete

Step 4: Authentication and Authorization Design [Core]

Select authentication scheme based on business scenario, design permission model, multi-tenant isolation and session management:

Authentication Scheme Selection:

ScenarioRecommended SchemeDescription
Monolithic + self-built user systemJWT + Refresh TokenStateless, easy to scale
Third-party login neededOAuth2 + JWTSupports social account login
Enterprise internal systemSSO (SAML/OIDC)Integrates enterprise identity provider
Microservices + inter-service callsJWT + Service AccountInter-service mTLS or API Key

Permission Model Design:

ModelApplicable ScenarioComplexity
RBACFixed roles (<=10), infrequent permission changesLow
RBAC + Permission GroupsMany roles (10-50), need flexible combinationMedium
ABACContext-dependent permissions (time/location/data attributes)High

Multi-tenant Isolation Strategy:

StrategyApplicable ScenarioIsolation Level
Shared database + tenant_idTenants >100, cost-sensitiveLogical isolation
Schema isolationTenants 10-100, moderate isolation requirementsSchema-level isolation
Separate databaseTenants <10, high security requirementsPhysical isolation

Session Management:

  • Token expiration strategy (short-lived Access Token + long-lived Refresh Token)
  • Concurrent login control (single device / multi-device)
  • Token revocation mechanism (blacklist / version number)

Stage Gate: Authentication scheme + permission model + session management complete

Step 5: Compliance Check [Core]

Built-in privacy compliance assessment:

  • Personal information collection minimum necessity principle check
  • Cross-border data transfer compliance check
  • User consent mechanism design
  • Data retention and deletion policy
  • Generate security requirements checklist

Stage Gate: Compliance check has no P0 issues

Output

Metadata Output: output/backend-api-design/api-design-spec/

Output Files:

  • openapi.yaml -- OpenAPI 3.0 specification
  • security-policy.json -- Security policy
  • auth-scheme.json -- Authentication and authorization scheme
  • compliance-checklist.json -- Compliance checklist
  • api-coverage.json -- PRD/frontend alignment coverage report

api-coverage.json Schema:

json
{
  "type": "object",
  "required": ["prd_coverage", "frontend_coverage"],
  "properties": {
    "prd_coverage": {
      "type": "object",
      "required": ["total_features", "covered_features", "coverage_rate", "uncovered"],
      "properties": {
        "total_features": { "type": "integer" },
        "covered_features": { "type": "integer" },
        "coverage_rate": { "type": "string" },
        "uncovered": { "type": "array", "items": { "type": "object", "properties": { "feature": { "type": "string" }, "reason": { "type": "string" } } } }
      }
    },
    "frontend_coverage": {
      "type": "object",
      "properties": {
        "total_pages": { "type": "integer" },
        "covered_pages": { "type": "integer" },
        "uncovered": { "type": "array", "items": { "type": "object", "properties": { "page": { "type": "string" }, "missing_apis": { "type": "array", "items": { "type": "string" } } } } }
      }
    }
  }
}

Decision Rules

ConditionDecision
Many-to-many relationship between resourcesCreate association resource
Query conditions >=5Consider providing GraphQL endpoint
Security level = High SecurityL3+ interfaces all require request signing + full audit
Number of roles <=10 and fixedUse RBAC
Number of roles >10 or frequently changingUse RBAC + permission groups
Multi-tenant + tenant count >100Shared database + tenant_id
Involves personal privacy dataMandatory masking + encrypted storage + compliance check
Compliance requirements include GDPRData export interface + data deletion interface

Quality Checks

  • Each resource has complete CRUD interface definition
  • API resources correspond one-to-one with ER model entities
  • API request/response fields 100% have Model field support
  • API grouping consistent with service boundaries
  • 100% of interfaces have security level annotation
  • L2+ interfaces 100% have authentication requirements
  • Authentication scheme covers all user scenarios
  • Permission model covers all roles and permissions
  • Compliance check has no P0 issues
  • Sensitive fields 100% have masking or encryption strategy
  • PRD feature points 100% have API endpoint coverage
  • Frontend page data requirements 100% have API correspondence (when frontend input or PRD page data requirements exist)

Degradation Strategy

Missing Upstream InputDegradation PlanOutput Impact
Data model missingDerive core entities from PRD, mark "pending data model confirmation"Resource definitions based on derivation, fields may be incomplete
Architecture plan missingDefault monolithic architecture, API unified entryAPI splitting strategy may not match
Service design missingDesign API by resource independently, mark "service ownership pending confirmation"API grouping may be inconsistent with service boundaries
Tech stack decision missingDefault Express + TypeScriptAPI framework style may not match
Business process missingDesign CRUD interfaces onlyMissing cross-resource business interfaces
PRD missingCannot design APIOutput is empty
Security level not specifiedDefault standard levelMay not meet high security requirements
Frontend page data requirements missingPrefer consuming prd.json pages[].data_requirements to derive API endpoints; if PRD also lacks page data, design CRUD interfaces based on PRD and ER model onlyMay lack frontend-specific data aggregation interfaces and pagination/filtering requirements

Upstream Change Response

Upstream ChangeImpact ScopeResponse Strategy
PRD feature points added/removedAPI endpoints added/removedMark affected API endpoints, generate change list
Data model changeAPI request/response structureMark affected fields, assess backward compatibility
Architecture plan changeAPI grouping and entry strategyRe-evaluate API splitting strategy by service
Service design changeAPI resource ownershipRe-divide API groups, assess cross-service API adjustments
API Change TypeCompatibilityNotification ScopeNotification Method
New endpointBackward compatibleapi-design-implMark new endpoint, implementation Skill can incrementally generate
Deleted endpointBreaking changeapi-design-implMust have human confirmation, provide migration plan
Modified field typeBreaking changeapi-design-implMust have human confirmation, provide compatibility plan

常见问题

Api Design Spec AI 技能有什么作用?

在设计 API 规范时使用。根据已确认的数据模型和服务边界,生成 API 设计规范,包括 RESTful/GraphQL 接口契约、安全策略和身份验证方案,并生成 OpenAPI 3.0 规范。基于数据制定契约,API 字段由 ER 模型精准映射而来。内置合规检查,确保 API 安全且合规。关键词:API 设计、接口契约、OpenAPI、RESTful、GraphQL、API 安全、身份验证、JWT、OAuth2、RBAC。

为什么在 TypingMind 中使用 Api Design Spec?

因为您只需安装一次,就能搭配任何模型使用。Api Design Spec 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Api Design Spec?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/LuckyOneTwoThree/vibe-skill/tree/main/.codex/skills/api-design-spec。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Api Design Spec?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Api Design Spec 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Api Design Spec 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Api Design Spec AI 技能免费吗?

是的。LuckyOneTwoThree 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇