moai-ref-api-patterns
Skill1.2k starsChanged 3 months agoApache-2.0View on GitHub
REST/GraphQL API design patterns, error handling conventions, and input validation reference for backend development. Agent-extending skill that amplifies backend domain work (spawned via Agent(general-purpose) with backend instructions) with production-grade API patterns. Use when designing APIs, implementing endpoints, or reviewing backend code. NOT for: frontend development, DevOps, database schema design, security audits.
Trending
Quiet since September.thin dataabout the whole repository
Who's talking about modu-ai/moai-adk
- Ven0m0/claude-config“Add a structured external integration plan to the root TODO backlog”GitHub · Mar 18, 2026 · 4 reactions
- Ven0m0/claude-config“TODO list”GitHub · Jan 31, 2026 · 1 reactions
- sudosubin/agents.nix“agent-skills.github.modu-ai.moai-adk: init at 3.1.2”GitHub · Sep 30, 2026
- anthropics/claude-code“Worktree-isolation Bash check folds command substitutions in quoted-delimiter heredoc bodies but refuses …”GitHub · Sep 7, 2026
- bjw202/minidiscord“docs(t41): moai gate 종료 코드 합류 — upstream 이슈 문안 (제출 안 함)”GitHub · Sep 6, 2026
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on GitHub (13 times).
On GitHub · 13
- Mar 18, 2026Add a structured external integration plan to the root TODO backlog — Ven0m0/claude-config4 reactions · 4 comments
- Jan 31, 2026TODO list — Ven0m0/claude-config1 reaction · 18 comments
- Sep 30, 2026agent-skills.github.modu-ai.moai-adk: init at 3.1.2 — sudosubin/agents.nix0 reactions
- Sep 7, 2026Worktree-isolation Bash check folds command substitutions in quoted-delimiter heredoc bodies but refuses braces there, though such bodies cannot expand — anthropics/claude-code0 reactions
- Sep 6, 2026docs(t41): moai gate 종료 코드 합류 — upstream 이슈 문안 (제출 안 함) — bjw202/minidiscord0 reactions
8 more on GitHub
- Jul 23, 2026Hands-on eval: promote MoAI-ADK to core tier — cameronsjo/spec-compare0 reactions
- Apr 22, 2026Add MoAI-ADK to Collections & Libraries — travisvn/awesome-claude-skills0 reactions
- Apr 22, 2026Add MoAI-ADK to Meta & Orchestration category — VoltAgent/awesome-claude-code-subagents0 reactions
- Apr 22, 2026Add MoAI-ADK — SPEC-first Agentic Development Kit — jqueryscript/awesome-claude-code0 reactions
- Apr 22, 2026Add MoAI-ADK — SPEC-first AI-assisted coding framework — wsxiaoys/awesome-ai-coding0 reactions
- Apr 22, 2026Add MoAI-ADK — SPEC-first Agentic Development Kit for Claude Code — e2b-dev/awesome-ai-agents0 reactions
- Nov 19, 2025Issue #1: Estructura base del proyecto .NET 9 — mjcuadrado/mjcuadrado-net-sdk0 reactions
- Nov 13, 2025fix: resolve conflitos Git + remove hooks SYNC bloqueantes (Windows f… — PedroGiudice/lex-vector0 reactions
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- hns-lsel-applierSkill
- hns-lsel-curatorSkill
- hns-moaiadk-best-practicesSkill
- hns-moaiadk-dev-referenceSkill
- hns-moaiadk-patternsSkill
- hns-oss-docs-i18n-rulesSkill
- hns-oss-docs-readme-syncSkill
- hns-oss-docs-structure-mapSkill
- hns-oss-docs-verifySkill
- hns-workflow-ci-loopSkill
- moai-domain-backendSkill
- moai-domain-databaseSkill
- moai-domain-design-dnaSkill
- moai-domain-frontendSkill
- moai-domain-html-reportSkill
- moai-domain-humanizeSkill
- moai-domain-svg-infographicSkill
- moai-foundation-ccSkill
- moai-foundation-coreSkill
- moai-foundation-qualitySkill
- moai-foundation-thinkingSkill
- moai-harness-learnerSkill
- moai-kanban-foremanSkill
- moai-meta-harnessSkill
- moai-ref-cross-model-auditSkill
- moai-ref-git-workflowSkill
- moai-ref-llm-securitySkill
- moai-ref-owasp-checklistSkill
- moai-ref-react-patternsSkill
- moai-ref-secopsSkill
- moai-ref-seoSkill
- moai-ref-supply-chainSkill
- moai-ref-testing-pyramidSkill
- moai-ref-ui-polishSkill
- moaiSkill
- moai-workflow-dddSkill
- moai-workflow-docs-claim-checkSkill
- moai-workflow-loopSkill
- moai-workflow-projectSkill
- moai-workflow-specSkill
- moai-workflow-tddSkill
- moai-workflow-testingSkill
- moai-workflow-worktreeSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 87
Never expose stack traces or internal details in production
- Distinctive: line 88
Always include request_id for traceability
- Distinctive: line 89
Use consistent error codes (ENUM, not free text)
- Distinctive: line 173
Hyrum's Law: Every observable API behavior will eventually be depended on by clients.
- Distinctive: line 182
No pagination on list endpoints that can return unbounded results
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Patterns Reference
Target Spawn
Backend domain work spawned via Agent(general-purpose) with backend instructions - Applies these patterns directly to API implementation and review.
RESTful API Design Conventions
| Principle | Convention | Example |
| Resource Naming | Plural nouns, lowercase, kebab-case | /api/v1/user-profiles |
| Collection | GET returns array with pagination | GET /users?page=1&limit=20 |
| Single Resource | GET returns object | GET /users/{id} |
| Create | POST to collection | POST /users |
| Update (full) | PUT to resource | PUT /users/{id} |
| Update (partial) | PATCH to resource | PATCH /users/{id} |
| Delete | DELETE to resource | DELETE /users/{id} |
| Nested Resources | Max 2 levels deep | /users/{id}/posts |
| Filtering | Query params | ?status=active&role=admin |
| Sorting | Sort param | ?sort=-created_at,name |
| Versioning | URL prefix | /api/v1/, /api/v2/ |
HTTP Status Code Guide
| Category | Code | When to Use |
| Success | 200 OK | Successful GET, PUT, PATCH, DELETE |
| Success | 201 Created | Successful POST (resource created) |
| Success | 204 No Content | Successful DELETE (no body) |
| Client Error | 400 Bad Request | Malformed request, validation failure |
| Client Error | 401 Unauthorized | Missing or invalid authentication |
| Client Error | 403 Forbidden | Authenticated but not authorized |
| Client Error | 404 Not Found | Resource does not exist |
| Client Error | 409 Conflict | Resource state conflict (duplicate) |
| Client Error | 422 Unprocessable | Valid syntax but semantic error |
| Client Error | 429 Too Many | Rate limit exceeded |
| Server Error | 500 Internal | Unexpected server error |
| Server Error | 503 Service Unavailable | Maintenance or overload |
Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Input validation failed",
"details": [
{"field": "email", "message": "Must be a valid email address"},
{"field": "age", "message": "Must be between 0 and 150"}
],
"request_id": "req_abc123"
}
}Rules:
- Never expose stack traces or internal details in production
- Always include request_id for traceability
- Use consistent error codes (ENUM, not free text)
- Login failures: "Invalid email or password" (never reveal which)
Pagination Pattern
{
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"total_pages": 8,
"has_next": true,
"has_prev": false
}
}For cursor-based (large datasets):
{
"data": [...],
"cursor": {
"next": "eyJpZCI6MTAwfQ==",
"has_more": true
}
}Input Validation Checklist
| Validation | Method | Tool |
| Type validation | Schema validation | Zod, Joi, pydantic, Go validator |
| Length limits | Min/max constraints | Schema min/max |
| Pattern matching | Regex | Email, URL, phone patterns |
| Range validation | Number/date bounds | min/max values |
| Enumeration | Allowed values | enum types |
| SQL Injection | Parameterized queries | ORM (Prisma, GORM, SQLAlchemy) |
| XSS | HTML escaping | Template engines, DOMPurify |
| Path Traversal | Path normalization | filepath.Clean + whitelist |
Rate Limiting Strategy
| Target | Limit | Key |
| Auth endpoints | 5 req/min | IP |
| General API | 100 req/min | User token |
| File upload | 10 req/hour | User token |
| Public API | 30 req/min | IP |
Response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After (on 429).
API Versioning Strategy
| Strategy | Use Case | Example |
| URL prefix | Most APIs | /api/v1/users |
| Header | Internal APIs | Accept: application/vnd.api+json; version=2 |
| Query param | Simple APIs | /users?version=2 |
Breaking changes that require version bump:
- Removing or renaming fields
- Changing field types
- Removing endpoints
- Changing authentication methods
Non-breaking changes (no version bump needed):
- Adding new optional fields
- Adding new endpoints
- Adding new query parameters
<!-- moai:evolvable-start id="rationalizations" -->Common Rationalizations
| Rationalization | Reality |
| "REST naming conventions are just aesthetics" | Consistent resource naming is how clients discover and predict endpoints. Inconsistency multiplies documentation burden. |
| "GraphQL solves over-fetching, so I do not need to design response shapes" | GraphQL shifts complexity to the resolver layer. Poorly designed schemas create N+1 queries and authorization gaps. |
| "Error codes are internal details, clients just need the message" | Clients need machine-readable error codes for programmatic handling. Messages are for humans, codes are for code. |
| "PATCH and PUT are interchangeable" | PATCH applies partial updates; PUT replaces the entire resource. Using them incorrectly breaks idempotency expectations. |
| "I will version the API when it becomes necessary" | Versioning after breaking changes forces emergency migrations. Plan versioning from the first release. |
Hyrum's Law: Every observable API behavior will eventually be depended on by clients. Undocumented response fields, error formats, and timing characteristics become implicit contracts.
<!-- moai:evolvable-end --><!-- moai:evolvable-start id="red-flags" -->Red Flags
- API returns different error formats across endpoints
- Resource names use verbs instead of nouns (e.g., /getUser instead of /users/:id)
- No pagination on list endpoints that can return unbounded results
- Breaking change deployed without API version bump
- GraphQL schema allows unbounded depth or circular queries without limits
<!-- moai:evolvable-end --><!-- moai:evolvable-start id="verification" -->Verification
- All endpoints follow consistent naming convention (nouns, plurals, nested resources)
- Error responses use a standard format with machine-readable error code
- List endpoints implement pagination with documented limits
- API versioning strategy present and enforced (URL path, header, or query param)
- Breaking vs non-breaking change classification documented for recent changes
- Input validation returns 400 with specific field-level error details
<!-- moai:evolvable-end -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

