重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
integration-spec by dengineproblem/agents-monorepo
npx skills add https://github.com/dengineproblem/agents-monorepo --skill integration-spec擅长编写全面的集成规范,作为系统间的契约。
每个集成规范必须包含:
# 集成规范:[系统 A] ↔ [系统 B]
**版本:** 1.0.0
**最后更新:** [日期]
**作者:** [姓名]
**状态:** [草案/评审中/已批准/生产环境]
## 1. 概述
### 1.1 目的
[简要描述此集成存在的原因]
### 1.2 范围
- 范围内:[此集成涵盖的内容]
- 范围外:[此集成不涵盖的内容]
### 1.3 架构图
[包含展示系统、数据流和关键组件的图表]
## 2. 认证与授权
### 2.1 认证方法
[OAuth 2.0 / API 密钥 / JWT / mTLS]
### 2.2 凭证管理
[如何获取、存储和轮换凭证]
## 3. 端点
[详细的端点规范]
## 4. 数据模型
[完整的模式定义]
## 5. 错误处理
[错误代码和恢复流程]
## 6. 速率限制
[节流规则和配额]
## 7. 测试
[测试场景和验证标准]
authentication:
type: "Bearer Token (OAuth 2.0)"
flow: "Client Credentials"
endpoints:
token:
url: "https://api.example.com/oauth/token"
method: "POST"
content_type: "application/x-www-form-urlencoded"
request:
grant_type: "client_credentials"
client_id: "{CLIENT_ID}"
client_secret: "{CLIENT_SECRET}"
scope: "read write"
response:
access_token: "string"
token_type: "Bearer"
expires_in: 3600
scope: "read write"
usage:
header: "Authorization: Bearer {access_token}"
content_type: "application/json"
token_refresh:
automatic: true
threshold_seconds: 300 # 在过期前 5 分钟刷新
retry_attempts: 3
retry_delay_seconds: 5
security_requirements:
- "将凭证存储在安全保险库中(不在代码中)"
- "所有请求都使用 HTTPS"
- "实现令牌缓存以减少认证调用"
- "记录认证失败以便监控"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# POST /api/v1/orders
endpoint:
method: "POST"
path: "/api/v1/orders"
description: "在系统中创建新订单"
headers:
required:
Authorization: "Bearer {access_token}"
Content-Type: "application/json"
X-Request-ID: "string (UUID) - 用于请求追踪"
optional:
X-Idempotency-Key: "string - 防止重复处理"
request:
body:
type: "object"
required: ["customer_id", "items"]
properties:
customer_id:
type: "string"
description: "唯一的客户标识符"
constraints: "最多 50 个字符,字母数字"
example: "CUST-12345"
items:
type: "array"
minItems: 1
maxItems: 100
items:
type: "object"
required: ["product_id", "quantity"]
properties:
product_id:
type: "string"
description: "产品 SKU"
example: "SKU-001"
quantity:
type: "integer"
minimum: 1
maximum: 999
example: 2
unit_price:
type: "number"
format: "decimal"
description: "单价(2 位小数)"
example: 29.99
shipping_address:
type: "object"
required: ["street", "city", "postal_code", "country"]
properties:
street:
type: "string"
maxLength: 100
city:
type: "string"
maxLength: 50
postal_code:
type: "string"
pattern: "^\\d{5}(-\\d{4})?$"
country:
type: "string"
format: "ISO 3166-1 alpha-2"
responses:
201:
description: "订单创建成功"
body:
order_id: "ORD-12345678"
status: "pending"
total_amount: 299.99
currency: "USD"
created_at: "2024-01-15T10:30:00Z"
estimated_delivery: "2024-01-20T10:00:00Z"
tracking_url: "https://api.example.com/orders/ORD-12345678/track"
400:
description: "无效请求"
body:
error_code: "VALIDATION_ERROR"
message: "请求验证失败"
details:
- field: "items[0].quantity"
error: "必须介于 1 和 999 之间"
401:
description: "认证失败"
body:
error_code: "UNAUTHORIZED"
message: "访问令牌无效或已过期"
409:
description: "冲突"
body:
error_code: "DUPLICATE_ORDER"
message: "具有此幂等性键的订单已存在"
existing_order_id: "ORD-12345678"
429:
description: "超出速率限制"
headers:
Retry-After: "60"
X-RateLimit-Limit: "100"
X-RateLimit-Remaining: "0"
X-RateLimit-Reset: "1704067200"
error_format:
standard_response:
error_code: "string - 机器可读的错误代码"
message: "string - 人类可读的描述"
details: "array - 具体的字段错误(可选)"
request_id: "string - 用于支持参考"
timestamp: "string - ISO 8601 日期时间"
error_codes:
VALIDATION_ERROR:
http_status: 400
description: "请求体验证失败"
retry_strategy: "不要重试 - 修复请求并重新提交"
resolution: "检查错误详情以了解具体的字段问题"
INVALID_CUSTOMER:
http_status: 400
description: "未找到客户 ID 或客户处于非活动状态"
retry_strategy: "不要重试 - 验证客户数据"
resolution: "验证客户是否存在且状态为活动"
UNAUTHORIZED:
http_status: 401
description: "认证无效或已过期"
retry_strategy: "刷新令牌并重试一次"
resolution: "获取新的访问令牌"
FORBIDDEN:
http_status: 403
description: "权限不足"
retry_strategy: "不要重试"
resolution: "联系管理员验证 API 范围"
NOT_FOUND:
http_status: 404
description: "请求的资源不存在"
retry_strategy: "不要重试"
resolution: "验证资源 ID 是否正确"
CONFLICT:
http_status: 409
description: "资源状态冲突"
retry_strategy: "获取当前状态并进行协调"
resolution: "检查现有资源并合并更改"
RATE_LIMIT_EXCEEDED:
http_status: 429
description: "请求过多"
retry_strategy: "等待 Retry-After 头指定的持续时间"
resolution: "实现指数退避"
headers:
Retry-After: "重试前等待的秒数"
X-RateLimit-Reset: "限制重置的 Unix 时间戳"
INTERNAL_ERROR:
http_status: 500
description: "意外的服务器错误"
retry_strategy: "使用指数退避重试(最多 3 次尝试)"
resolution: "如果持续存在,请携带 request_id 联系支持人员"
SERVICE_UNAVAILABLE:
http_status: 503
description: "服务暂时不可用"
retry_strategy: "使用指数退避重试"
resolution: "检查状态页面,延迟后重试"
webhooks:
overview:
description: "通过 HTTP POST 进行实时事件通知"
delivery: "至少一次交付保证"
format: "带有 HMAC 签名的 JSON 负载"
configuration:
endpoint_url: "您的 HTTPS 端点"
secret_key: "用于签名验证的共享密钥"
events: ["order.created", "order.updated", "order.cancelled"]
security:
signature_header: "X-Webhook-Signature"
signature_algorithm: "HMAC-SHA256"
timestamp_header: "X-Webhook-Timestamp"
replay_prevention: "如果时间戳 > 5 分钟则拒绝"
verification_example:
python: |
import hmac
import hashlib
def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(
secret.encode(),
payload,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
payload_structure:
event_id: "string - 唯一事件标识符"
event_type: "string - 例如,order.created"
timestamp: "string - ISO 8601"
data:
object_type: "string - 例如,order"
object_id: "string - 资源标识符"
changes: "object - 更改的字段(针对更新事件)"
retry_policy:
attempts: 5
schedule:
- "立即"
- "1 分钟后"
- "5 分钟后"
- "30 分钟后"
- "2 小时后"
success_criteria: "30 秒内收到 HTTP 2xx 响应"
failure_action: "事件已记录,发送警报,可手动重试"
expected_response:
status: "30 秒内返回 2xx"
body: "可选 - 忽略"
events:
order.created:
description: "创建新订单时触发"
payload:
order_id: "string"
customer_id: "string"
total_amount: "number"
items: "array"
created_at: "string"
order.updated:
description: "订单状态更改时触发"
payload:
order_id: "string"
previous_status: "string"
current_status: "string"
updated_at: "string"
rate_limits:
default:
requests_per_minute: 100
requests_per_day: 10000
burst_allowance: "在 30 秒内允许 150% 的突发流量"
per_endpoint:
"/api/v1/orders":
method: "POST"
limit: "100 次请求/分钟"
reason: "写操作 - 资源成本较高"
"/api/v1/orders":
method: "GET"
limit: "300 次请求/分钟"
reason: "读操作 - 缓存响应"
"/api/v1/search":
limit: "60 次请求/分钟"
reason: "昂贵的搜索操作"
headers:
X-RateLimit-Limit: "每个时间窗口允许的请求数"
X-RateLimit-Remaining: "剩余的请求数"
X-RateLimit-Reset: "时间窗口重置的 Unix 时间戳"
exceeded_response:
status: 429
body:
error_code: "RATE_LIMIT_EXCEEDED"
message: "超出速率限制"
retry_after: 60
best_practices:
- "实现客户端速率限制"
- "对 429 响应使用指数退避"
- "尽可能缓存响应"
- "在可用时进行批量操作"
sequenceDiagram
participant Client
participant API Gateway
participant Order Service
participant Payment Service
participant Inventory Service
participant Notification Service
Client->>API Gateway: POST /api/v1/orders
API Gateway->>API Gateway: Validate Token
API Gateway->>Order Service: Create Order
Order Service->>Inventory Service: Reserve Items
Inventory Service-->>Order Service: Reservation Confirmed
Order Service->>Payment Service: Process Payment
Payment Service-->>Order Service: Payment Success
Order Service->>Order Service: Update Order Status
Order Service-->>API Gateway: Order Created (201)
API Gateway-->>Client: Order Response
Order Service--)Notification Service: order.created Event
Notification Service--)Client: Webhook: order.created
test_scenarios:
happy_path:
name: "成功创建订单"
preconditions:
- "存在有效的客户账户"
- "产品有库存"
- "支付方式有效"
request:
method: "POST"
path: "/api/v1/orders"
body: "{valid order payload}"
expected:
status: 201
response_contains: ["order_id", "status", "total_amount"]
postconditions:
- "在数据库中创建了订单记录"
- "库存已预留"
- "支付已处理"
- "已发送 Webhook"
validation_errors:
- name: "缺少必填字段"
request: "{order without customer_id}"
expected_status: 400
expected_error: "VALIDATION_ERROR"
- name: "无效数量"
request: "{order with quantity: 0}"
expected_status: 400
expected_error: "VALIDATION_ERROR"
edge_cases:
- name: "库存不足"
setup: "将产品库存设置为 0"
expected_status: 409
expected_error: "INSUFFICIENT_INVENTORY"
- name: "支付失败"
setup: "配置支付服务以拒绝"
expected_status: 402
expected_error: "PAYMENT_FAILED"
postcondition: "库存预留已释放"
idempotency:
name: "重复请求处理"
steps:
- "发送带有 X-Idempotency-Key: abc123 的订单"
- "响应:201 Created,order_id: ORD-001"
- "使用相同的幂等性键发送相同的请求"
- "响应:200 OK,order_id: ORD-001(相同订单)"
environments:
sandbox:
base_url: "https://api-sandbox.example.com"
purpose: "开发和测试"
rate_limits: "生产环境限制的 10 倍"
data: "测试数据,每天 UTC 00:00 重置"
credentials: "独立的沙箱 API 密钥"
staging:
base_url: "https://api-staging.example.com"
purpose: "预生产验证"
rate_limits: "与生产环境相同"
data: "匿名的类生产数据"
production:
base_url: "https://api.example.com"
sla:
uptime: "99.9%"
response_time_p95: "<200ms"
response_time_p99: "<500ms"
maintenance_window: "UTC 时间星期日 02:00-04:00"
support: "support@example.com"
每周安装量
42
仓库
GitHub 星标数
3
首次出现
2026年1月21日
安全审计
安装于
github-copilot41
gemini-cli40
codex40
kimi-cli40
amp40
opencode40
Expert in writing comprehensive integration specifications that serve as contracts between systems.
Every integration spec must include:
# Integration Specification: [System A] ↔ [System B]
**Version:** 1.0.0
**Last Updated:** [Date]
**Authors:** [Names]
**Status:** [Draft/Review/Approved/Production]
## 1. Overview
### 1.1 Purpose
[Brief description of why this integration exists]
### 1.2 Scope
- In Scope: [What this integration covers]
- Out of Scope: [What this integration does not cover]
### 1.3 Architecture Diagram
[Include diagram showing systems, data flow, and key components]
## 2. Authentication & Authorization
### 2.1 Authentication Method
[OAuth 2.0 / API Key / JWT / mTLS]
### 2.2 Credential Management
[How credentials are obtained, stored, and rotated]
## 3. Endpoints
[Detailed endpoint specifications]
## 4. Data Models
[Complete schema definitions]
## 5. Error Handling
[Error codes and recovery procedures]
## 6. Rate Limiting
[Throttling rules and quotas]
## 7. Testing
[Test scenarios and validation criteria]
authentication:
type: "Bearer Token (OAuth 2.0)"
flow: "Client Credentials"
endpoints:
token:
url: "https://api.example.com/oauth/token"
method: "POST"
content_type: "application/x-www-form-urlencoded"
request:
grant_type: "client_credentials"
client_id: "{CLIENT_ID}"
client_secret: "{CLIENT_SECRET}"
scope: "read write"
response:
access_token: "string"
token_type: "Bearer"
expires_in: 3600
scope: "read write"
usage:
header: "Authorization: Bearer {access_token}"
content_type: "application/json"
token_refresh:
automatic: true
threshold_seconds: 300 # Refresh 5 min before expiry
retry_attempts: 3
retry_delay_seconds: 5
security_requirements:
- "Store credentials in secure vault (not in code)"
- "Use HTTPS for all requests"
- "Implement token caching to reduce auth calls"
- "Log authentication failures for monitoring"
# POST /api/v1/orders
endpoint:
method: "POST"
path: "/api/v1/orders"
description: "Create a new order in the system"
headers:
required:
Authorization: "Bearer {access_token}"
Content-Type: "application/json"
X-Request-ID: "string (UUID) - for request tracing"
optional:
X-Idempotency-Key: "string - prevents duplicate processing"
request:
body:
type: "object"
required: ["customer_id", "items"]
properties:
customer_id:
type: "string"
description: "Unique customer identifier"
constraints: "max 50 characters, alphanumeric"
example: "CUST-12345"
items:
type: "array"
minItems: 1
maxItems: 100
items:
type: "object"
required: ["product_id", "quantity"]
properties:
product_id:
type: "string"
description: "Product SKU"
example: "SKU-001"
quantity:
type: "integer"
minimum: 1
maximum: 999
example: 2
unit_price:
type: "number"
format: "decimal"
description: "Price per unit (2 decimal places)"
example: 29.99
shipping_address:
type: "object"
required: ["street", "city", "postal_code", "country"]
properties:
street:
type: "string"
maxLength: 100
city:
type: "string"
maxLength: 50
postal_code:
type: "string"
pattern: "^\\d{5}(-\\d{4})?$"
country:
type: "string"
format: "ISO 3166-1 alpha-2"
responses:
201:
description: "Order created successfully"
body:
order_id: "ORD-12345678"
status: "pending"
total_amount: 299.99
currency: "USD"
created_at: "2024-01-15T10:30:00Z"
estimated_delivery: "2024-01-20T10:00:00Z"
tracking_url: "https://api.example.com/orders/ORD-12345678/track"
400:
description: "Invalid request"
body:
error_code: "VALIDATION_ERROR"
message: "Request validation failed"
details:
- field: "items[0].quantity"
error: "Must be between 1 and 999"
401:
description: "Authentication failed"
body:
error_code: "UNAUTHORIZED"
message: "Invalid or expired access token"
409:
description: "Conflict"
body:
error_code: "DUPLICATE_ORDER"
message: "Order with this idempotency key already exists"
existing_order_id: "ORD-12345678"
429:
description: "Rate limit exceeded"
headers:
Retry-After: "60"
X-RateLimit-Limit: "100"
X-RateLimit-Remaining: "0"
X-RateLimit-Reset: "1704067200"
error_format:
standard_response:
error_code: "string - machine-readable error code"
message: "string - human-readable description"
details: "array - specific field errors (optional)"
request_id: "string - for support reference"
timestamp: "string - ISO 8601 datetime"
error_codes:
VALIDATION_ERROR:
http_status: 400
description: "Request body failed validation"
retry_strategy: "Do not retry - fix request and resubmit"
resolution: "Check error details for specific field issues"
INVALID_CUSTOMER:
http_status: 400
description: "Customer ID not found or inactive"
retry_strategy: "Do not retry - verify customer data"
resolution: "Validate customer exists and has active status"
UNAUTHORIZED:
http_status: 401
description: "Invalid or expired authentication"
retry_strategy: "Refresh token and retry once"
resolution: "Obtain new access token"
FORBIDDEN:
http_status: 403
description: "Insufficient permissions"
retry_strategy: "Do not retry"
resolution: "Contact admin to verify API scopes"
NOT_FOUND:
http_status: 404
description: "Requested resource does not exist"
retry_strategy: "Do not retry"
resolution: "Verify resource ID is correct"
CONFLICT:
http_status: 409
description: "Resource state conflict"
retry_strategy: "Fetch current state and reconcile"
resolution: "Check existing resource and merge changes"
RATE_LIMIT_EXCEEDED:
http_status: 429
description: "Too many requests"
retry_strategy: "Wait for Retry-After header duration"
resolution: "Implement exponential backoff"
headers:
Retry-After: "Seconds to wait before retry"
X-RateLimit-Reset: "Unix timestamp when limit resets"
INTERNAL_ERROR:
http_status: 500
description: "Unexpected server error"
retry_strategy: "Retry with exponential backoff (max 3 attempts)"
resolution: "If persists, contact support with request_id"
SERVICE_UNAVAILABLE:
http_status: 503
description: "Service temporarily unavailable"
retry_strategy: "Retry with exponential backoff"
resolution: "Check status page, retry after delay"
webhooks:
overview:
description: "Real-time event notifications via HTTP POST"
delivery: "At-least-once delivery guarantee"
format: "JSON payload with HMAC signature"
configuration:
endpoint_url: "Your HTTPS endpoint"
secret_key: "Shared secret for signature verification"
events: ["order.created", "order.updated", "order.cancelled"]
security:
signature_header: "X-Webhook-Signature"
signature_algorithm: "HMAC-SHA256"
timestamp_header: "X-Webhook-Timestamp"
replay_prevention: "Reject if timestamp > 5 minutes old"
verification_example:
python: |
import hmac
import hashlib
def verify_webhook(payload: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(
secret.encode(),
payload,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
payload_structure:
event_id: "string - unique event identifier"
event_type: "string - e.g., order.created"
timestamp: "string - ISO 8601"
data:
object_type: "string - e.g., order"
object_id: "string - resource identifier"
changes: "object - changed fields (for update events)"
retry_policy:
attempts: 5
schedule:
- "Immediate"
- "1 minute"
- "5 minutes"
- "30 minutes"
- "2 hours"
success_criteria: "HTTP 2xx response within 30 seconds"
failure_action: "Event logged, alert sent, manual retry available"
expected_response:
status: "2xx within 30 seconds"
body: "Optional - ignored"
events:
order.created:
description: "Fired when a new order is created"
payload:
order_id: "string"
customer_id: "string"
total_amount: "number"
items: "array"
created_at: "string"
order.updated:
description: "Fired when order status changes"
payload:
order_id: "string"
previous_status: "string"
current_status: "string"
updated_at: "string"
rate_limits:
default:
requests_per_minute: 100
requests_per_day: 10000
burst_allowance: "150% for up to 30 seconds"
per_endpoint:
"/api/v1/orders":
method: "POST"
limit: "100 requests/minute"
reason: "Write operation - higher resource cost"
"/api/v1/orders":
method: "GET"
limit: "300 requests/minute"
reason: "Read operation - cached responses"
"/api/v1/search":
limit: "60 requests/minute"
reason: "Expensive search operation"
headers:
X-RateLimit-Limit: "Requests allowed per window"
X-RateLimit-Remaining: "Requests remaining"
X-RateLimit-Reset: "Unix timestamp when window resets"
exceeded_response:
status: 429
body:
error_code: "RATE_LIMIT_EXCEEDED"
message: "Rate limit exceeded"
retry_after: 60
best_practices:
- "Implement client-side rate limiting"
- "Use exponential backoff on 429 responses"
- "Cache responses where possible"
- "Batch operations when available"
sequenceDiagram
participant Client
participant API Gateway
participant Order Service
participant Payment Service
participant Inventory Service
participant Notification Service
Client->>API Gateway: POST /api/v1/orders
API Gateway->>API Gateway: Validate Token
API Gateway->>Order Service: Create Order
Order Service->>Inventory Service: Reserve Items
Inventory Service-->>Order Service: Reservation Confirmed
Order Service->>Payment Service: Process Payment
Payment Service-->>Order Service: Payment Success
Order Service->>Order Service: Update Order Status
Order Service-->>API Gateway: Order Created (201)
API Gateway-->>Client: Order Response
Order Service--)Notification Service: order.created Event
Notification Service--)Client: Webhook: order.created
test_scenarios:
happy_path:
name: "Successful order creation"
preconditions:
- "Valid customer account exists"
- "Products are in stock"
- "Payment method is valid"
request:
method: "POST"
path: "/api/v1/orders"
body: "{valid order payload}"
expected:
status: 201
response_contains: ["order_id", "status", "total_amount"]
postconditions:
- "Order record created in database"
- "Inventory reserved"
- "Payment processed"
- "Webhook sent"
validation_errors:
- name: "Missing required field"
request: "{order without customer_id}"
expected_status: 400
expected_error: "VALIDATION_ERROR"
- name: "Invalid quantity"
request: "{order with quantity: 0}"
expected_status: 400
expected_error: "VALIDATION_ERROR"
edge_cases:
- name: "Insufficient inventory"
setup: "Set product stock to 0"
expected_status: 409
expected_error: "INSUFFICIENT_INVENTORY"
- name: "Payment failure"
setup: "Configure payment service to decline"
expected_status: 402
expected_error: "PAYMENT_FAILED"
postcondition: "Inventory reservation released"
idempotency:
name: "Duplicate request handling"
steps:
- "Send order with X-Idempotency-Key: abc123"
- "Response: 201 Created, order_id: ORD-001"
- "Send same request with same idempotency key"
- "Response: 200 OK, order_id: ORD-001 (same order)"
environments:
sandbox:
base_url: "https://api-sandbox.example.com"
purpose: "Development and testing"
rate_limits: "10x production limits"
data: "Test data, reset daily at 00:00 UTC"
credentials: "Separate sandbox API keys"
staging:
base_url: "https://api-staging.example.com"
purpose: "Pre-production validation"
rate_limits: "Same as production"
data: "Anonymized production-like data"
production:
base_url: "https://api.example.com"
sla:
uptime: "99.9%"
response_time_p95: "<200ms"
response_time_p99: "<500ms"
maintenance_window: "Sundays 02:00-04:00 UTC"
support: "support@example.com"
Weekly Installs
42
Repository
GitHub Stars
3
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot41
gemini-cli40
codex40
kimi-cli40
amp40
opencode40
lark-cli 共享规则:飞书资源操作指南与权限配置详解
48,600 周安装