api-design-knowledge
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "api-design-knowledge":https://skillpi.com/zh/skills/deepskill-929a97a4234cf5c79c39fb2e48bf7fdb1a1bf3793b1fe338390b6bf462cf955c。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
API 设计知识库。提供 REST 约束、Richardson 成熟度模型、HTTP 语义、内容协商,以及与 GraphQL 和 gRPC 的对比,用于 API 审计和生成。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 限制与区别
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: api-design-knowledge
description: API Design knowledge base. Provides REST constraints, Richardson Maturity Model, HTTP semantics, content negotiation, and GraphQL/gRPC comparison for API audits and generation.API Design Knowledge Base
Quick reference for API design patterns, REST best practices, and PHP implementation guidelines.
Core Principles
REST Constraints
| Constraint | Description | Implication |
|---|---|---|
| Client-Server | Separation of concerns | Independent evolution |
| Stateless | No server-side session state | Each request contains all info |
| Cacheable | Responses declare cacheability | Reduces server load |
| Uniform Interface | Standard resource operations | Predictable API surface |
| Layered System | Client can't tell if connected directly | Proxy, gateway, CDN support |
| Code on Demand (optional) | Server can send executable code | Rarely used in APIs |
Richardson Maturity Model
| Level | Name | Description | Example |
|---|---|---|---|
| 0 | Swamp of POX | Single endpoint, RPC-style | POST /api with action in body |
| 1 | Resources | Multiple endpoints per resource | GET /orders/123 |
| 2 | HTTP Verbs | Proper use of HTTP methods + status codes | DELETE /orders/123 → 204 |
| 3 | HATEOAS | Hypermedia controls in responses | Links to related actions |
HTTP Methods Semantics
| Method | Safe | Idempotent | Request Body | Typical Use |
|---|---|---|---|---|
| GET | Yes | Yes | No | Retrieve resource |
| HEAD | Yes | Yes | No | Check resource existence |
| POST | No | No | Yes | Create resource, trigger action |
| PUT | No | Yes | Yes | Replace resource entirely |
| PATCH | No | No | Yes | Partial update |
| DELETE | No | Yes | No | Remove resource |
| OPTIONS | Yes | Yes | No | CORS preflight, capabilities |
Status Code Guide
| Range | Category | Common Codes |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created, 202 Accepted, 204 No Content |
| 3xx | Redirection | 301 Moved Permanently, 304 Not Modified |
| 4xx | Client Error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable Entity, 429 Too Many Requests |
| 5xx | Server Error | 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout |
Content Negotiation
| Header | Purpose | Example |
|---|---|---|
| Accept | Client requests format | Accept: application/json |
| Content-Type | Body format declaration | Content-Type: application/json |
| Accept-Language | Localization | Accept-Language: en-US |
| Accept-Encoding | Compression | Accept-Encoding: gzip, br |
API Style Comparison
| Aspect | REST | GraphQL | gRPC |
|---|---|---|---|
| Protocol | HTTP/1.1+ | HTTP/1.1+ | HTTP/2 |
| Data format | JSON | JSON | Protobuf |
| Schema | OpenAPI (optional) | SDL (required) | .proto (required) |
| Caching | HTTP caching native | Complex (POST only) | Manual |
| Over-fetching | Common | Solved (client picks fields) | Solved (defined messages) |
| Under-fetching | Common (multiple calls) | Solved (nested queries) | Separate RPCs |
| Learning curve | Low | Medium | High |
| Best for | Public APIs, CRUD | Client-driven UIs, BFF | Internal services, streaming |
Quick Checklists
API Design Checklist
- [ ] Resources use nouns, not verbs (
/ordersnot/getOrders) - [ ] Consistent naming convention (kebab-case or camelCase)
- [ ] Proper HTTP methods for operations
- [ ] Meaningful status codes (not always 200)
- [ ] Pagination for list endpoints
- [ ] Filtering and sorting support
- [ ] Versioning strategy defined
- [ ] Error responses follow RFC 7807
- [ ] Rate limiting with proper headers
- [ ] CORS configured for browser clients
Security Checklist
- [ ] Authentication on all endpoints (except public)
- [ ] Authorization checks per resource
- [ ] Input validation at API boundary
- [ ] Rate limiting per client/IP
- [ ] HTTPS only (no HTTP)
- [ ] No sensitive data in URLs
- [ ] Proper CORS policy
- [ ] Security headers set
Detection Patterns
# REST endpoint definitions
Grep: "#\[Route|@Route|->get\(|->post\(|->put\(|->delete\(" --glob "**/*.php"
Glob: **/Controller/**/*.php
Glob: **/Action/**/*.php
# Status code usage
Grep: "->setStatusCode\(|Response\(.*[0-9]{3}|JsonResponse\(" --glob "**/*.php"
# Content negotiation
Grep: "Accept|Content-Type|application/json" --glob "**/*.php"
# API versioning
Grep: "/v[0-9]/|api-version|Accept.*vnd\." --glob "**/*.php"
# Error handling
Grep: "ProblemDetails|RFC7807|application/problem" --glob "**/*.php"
Grep: "JsonResponse.*4[0-9]{2}|JsonResponse.*5[0-9]{2}" --glob "**/*.php"
# Pagination
Grep: "page|per_page|limit|offset|cursor" --glob "**/Controller/**/*.php"
Advanced API Patterns
Cursor-Based Pagination (High-Load)
| Aspect | Offset-Based | Cursor-Based |
|---|---|---|
| URL | ?page=5&per_page=20 |
?cursor=abc123&limit=20 |
| Performance at scale | Degrades (OFFSET N) | Constant (WHERE id > X) |
| Consistency | Misses/duplicates on insert | Stable, no gaps |
| Random page access | Yes | No (sequential only) |
| Use case | Admin panels | Feeds, large datasets |
API Rate Limiting Algorithms
| Algorithm | Precision | Burst | PHP Implementation |
|---|---|---|---|
| Token Bucket | Medium | Allows burst | Redis Lua script |
| Sliding Window | High | Smooth | Redis sorted set |
| Fixed Window | Low | Edge burst | Redis INCR + EXPIRE |
| Leaky Bucket | High | No burst | Redis list |
Rate Limit Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After (on 429).
gRPC for PHP
| Factor | Choose REST | Choose gRPC |
|---|---|---|
| Client type | Browser, third-party | Internal services |
| Payload | Small-medium JSON | Large binary data |
| Streaming | Not needed | Real-time updates |
| PHP ecosystem | Mature | Limited (ext-grpc) |
GraphQL N+1 Prevention
| Technique | How | Complexity |
|---|---|---|
| DataLoader | Batch + cache per request | Medium |
| Query depth limit | Max 5-7 nesting levels | Low |
| Complexity scoring | Cost per field, reject expensive | Medium |
| Persisted queries | Whitelist allowed queries | Low |
References
For detailed information, load these reference files:
references/rest-patterns.md— Richardson Maturity details, HATEOAS, pagination, filtering, versioning strategiesreferences/error-handling.md— RFC 7807 Problem Details, error response patterns, GraphQL errors, PHP implementationreferences/advanced-api.md— Cursor-based pagination, API rate limiting (token bucket, sliding window), gRPC PHP integration, GraphQL N+1 solutions
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 REST 约束、Richardson 成熟度模型、HTTP 语义等核心知识,适用于 API 审计与生成
- 涵盖 GraphQL/gRPC 对比及高级模式如游标分页、限流算法,实用性强
亮点
- description 明确描述功能为 API 设计知识库,用于审计与生成,触发词精准完整
待提升项
-
description写错位置 原报告严重程度:轻微
顶层 frontmatter 中 description 字段为空,实质描述内容位于 skill_body 内部
改进建议:将 description 内容移至顶层 frontmatter 的 description 字段,保持规范一致
亮点
- 文档结构清晰,分章节组织,含表格、代码块、清单,frontmatter 完整
待提升项
-
引用文件缺失 原报告严重程度:轻微
SKILL.md 引用了 references/rest-patterns.md、references/error-handling.md、references/advanced-api.md 三个文件,但未传入
改进建议:请补充所引用的参考文件,或移除引用以避免用户困惑
亮点
- 内容为通用标准知识库,无外部工具依赖,参数与示例正确,可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。