Api Style Guide
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Organization-wide API design standards (REST/GraphQL): URL patterns, naming, versioning, pagination, and filtering that make every API work consistently.
Why This Matters
- Consistency: Clients know how to use API without reading docs every time
- Predictability: Can guess what endpoint looks like
- Tooling: Auto-generate clients
- Maintainability: Easy to change maintainers
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
Quick Start
Assumptions
- Organization uses REST and/or GraphQL APIs
- Teams need consistent API patterns
- API clients include web, mobile, and third-party integrations
- API documentation is required
- Versioning strategy needed for long-term API evolution
Compatibility
- REST: HTTP/1.1, HTTP/2
- GraphQL: GraphQL spec latest
- OpenAPI: 3.0.3+
- JSON: JSON:API or custom envelope
- Authentication: OAuth2, JWT, mTLS
Test Scenario Matrix
| Scenario |
Input |
Expected Output |
Verification |
| List resources |
GET /api/v1/users |
Paginated list of users |
Response structure |
| Create resource |
POST /api/v1/users |
Created user with 201 status |
Location header |
| Update resource |
PATCH /api/v1/users/{id} |
Updated user with 200 status |
Response body |
| Delete resource |
DELETE /api/v1/users/{id} |
Deleted with 204 status |
No response body |
| Filter resources |
GET /api/v1/users?status=active |
Filtered list |
Query parameters |
| Invalid request |
POST with invalid data |
400 error response |
Error shape |
Technical Guardrails
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done
An API is complete when:
Anti-patterns
- Verbs in URLs:
/api/getUsers instead of /api/users
- Inconsistent casing:
userId vs user_id
- No versioning: Breaking changes break clients
- Different pagination: Cursor here, offset there
- No standard envelope: Different response structures
- Inconsistent error shapes: Different error formats
- Missing authentication: Unprotected endpoints
- No rate limiting: API abuse possible
Reference Links
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: amnadtaowsoam-cerebraskills-api-style-guide3description: Api Style Guide4---56# Api Style Guide78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Organization-wide API design standards (REST/GraphQL): URL patterns, naming, versioning, pagination, and filtering that make every API work consistently.1819## Why This Matters20- **Consistency**: Clients know how to use API without reading docs every time21- **Predictability**: Can guess what endpoint looks like22- **Tooling**: Auto-generate clients23- **Maintainability**: Easy to change maintainers2425## Core Concepts & Rules2627### 1. Core Principles28- Follow established patterns and conventions29- Maintain consistency across codebase30- Document decisions and trade-offs3132### 2. Implementation Guidelines33- Start with the simplest viable solution34- Iterate based on feedback and requirements35- Test thoroughly before deployment363738## Inputs / Outputs / Contracts39* **Inputs**:40 - <e.g., env vars, request payload, file paths, schema>41* **Entry Conditions**:42 - <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>43* **Outputs**:44 - <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>45* **Artifacts Required (Deliverables)**:46 - <e.g., Code Diff, Unit Tests, Migration Script, API Docs>47* **Acceptance Evidence**:48 - <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>49* **Success Criteria**:50 - <e.g., p95 < 300ms, coverage ≥ 80%>5152## Skill Composition53* **Depends on**: [api-design](../../01-foundations/api-design/SKILL.md), [error-handling](../../03-backend-api/error-handling/SKILL.md)54* **Compatible with**: [validation](../../03-backend-api/validation/SKILL.md), [contract-test-gates](../68-quality-gates-ci-policies/contract-test-gates/SKILL.md)55* **Conflicts with**: None56* **Related Skills**: [openapi-spec](../../03-backend-api/openapi-spec/SKILL.md), [graphql-best-practices](../../03-backend-api/graphql-best-practices/SKILL.md)5758## Quick Start59#6061## Assumptions62- Organization uses REST and/or GraphQL APIs63- Teams need consistent API patterns64- API clients include web, mobile, and third-party integrations65- API documentation is required66- Versioning strategy needed for long-term API evolution6768## Compatibility69- **REST**: HTTP/1.1, HTTP/270- **GraphQL**: GraphQL spec latest71- **OpenAPI**: 3.0.3+72- **JSON**: JSON:API or custom envelope73- **Authentication**: OAuth2, JWT, mTLS7475## Test Scenario Matrix76| Scenario | Input | Expected Output | Verification |77|----------|-------|-----------------|--------------|78| List resources | GET /api/v1/users | Paginated list of users | Response structure |79| Create resource | POST /api/v1/users | Created user with 201 status | Location header |80| Update resource | PATCH /api/v1/users/{id} | Updated user with 200 status | Response body |81| Delete resource | DELETE /api/v1/users/{id} | Deleted with 204 status | No response body |82| Filter resources | GET /api/v1/users?status=active | Filtered list | Query parameters |83| Invalid request | POST with invalid data | 400 error response | Error shape |8485## Technical Guardrails86#8788## Agent Directives & Error Recovery89*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*9091- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.92- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.93- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.94- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.959697## Definition of Done98An API is complete when:99100- [ ] URLs follow naming conventions (kebab-case, plural nouns)101- [ ] HTTP methods used correctly102- [ ] Versioning strategy documented and implemented103- [ ] Request/response formats follow standards104- [ ] Pagination implemented consistently105- [ ] Error responses follow error shape taxonomy106- [ ] Authentication and authorization implemented107- [ ] OpenAPI/GraphQL specification maintained108- [ ] API documentation complete109- [ ] Contract tests written and passing110111## Anti-patterns1121. **Verbs in URLs**: `/api/getUsers` instead of `/api/users`1132. **Inconsistent casing**: `userId` vs `user_id`1143. **No versioning**: Breaking changes break clients1154. **Different pagination**: Cursor here, offset there1165. **No standard envelope**: Different response structures1176. **Inconsistent error shapes**: Different error formats1187. **Missing authentication**: Unprotected endpoints1198. **No rate limiting**: API abuse possible120121## Reference Links122- [Google API Design Guide](https://cloud.google.com/apis/design)123- [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines)124- [JSON:API Specification](https://jsonapi.org/)125- [OpenAPI Specification](https://swagger.io/specification/)126- [GraphQL Best Practices](https://graphql.org/learn/best-practices/)127128## Versioning & Changelog129130* **Version**: 1.0.0131* **Changelog**:132 - 2026-02-22: Initial version with complete template structure133134---135> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.136<!-- tomevault:4.0:skill_md:2026-04-13 -->