Moai Ref Api Patterns logo

Moai Ref Api Patterns

OrganizationPopular
modu-ai
moai-ref-api-patterns

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.

Overview

Publishermodu-ai
Repositorymoai-adk
Skill namemoai-ref-api-patterns
Stars
1.2K
Forks
226
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by modu-ai on GitHub. Read the source before you install it.

Installation

Install the Moai Ref Api Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-api-patterns
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/modu-ai/moai-adk.git /tmp/moai-adk
mkdir -p .claude/skills
cp -r /tmp/moai-adk/.claude/skills/moai-ref-api-patterns .claude/skills/moai-ref-api-patterns
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Moai Ref Api Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Moai Ref Api Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Moai Ref Api Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

PrincipleConventionExample
Resource NamingPlural nouns, lowercase, kebab-case/api/v1/user-profiles
CollectionGET returns array with paginationGET /users?page=1&limit=20
Single ResourceGET returns objectGET /users/{id}
CreatePOST to collectionPOST /users
Update (full)PUT to resourcePUT /users/{id}
Update (partial)PATCH to resourcePATCH /users/{id}
DeleteDELETE to resourceDELETE /users/{id}
Nested ResourcesMax 2 levels deep/users/{id}/posts
FilteringQuery params?status=active&role=admin
SortingSort param?sort=-created_at,name
VersioningURL prefix/api/v1/, /api/v2/

HTTP Status Code Guide

CategoryCodeWhen to Use
Success200 OKSuccessful GET, PUT, PATCH, DELETE
Success201 CreatedSuccessful POST (resource created)
Success204 No ContentSuccessful DELETE (no body)
Client Error400 Bad RequestMalformed request, validation failure
Client Error401 UnauthorizedMissing or invalid authentication
Client Error403 ForbiddenAuthenticated but not authorized
Client Error404 Not FoundResource does not exist
Client Error409 ConflictResource state conflict (duplicate)
Client Error422 UnprocessableValid syntax but semantic error
Client Error429 Too ManyRate limit exceeded
Server Error500 InternalUnexpected server error
Server Error503 Service UnavailableMaintenance or overload

Error Response Format

json
{
  "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

json
{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "total_pages": 8,
    "has_next": true,
    "has_prev": false
  }
}

For cursor-based (large datasets):

json
{
  "data": [...],
  "cursor": {
    "next": "eyJpZCI6MTAwfQ==",
    "has_more": true
  }
}

Input Validation Checklist

ValidationMethodTool
Type validationSchema validationZod, Joi, pydantic, Go validator
Length limitsMin/max constraintsSchema min/max
Pattern matchingRegexEmail, URL, phone patterns
Range validationNumber/date boundsmin/max values
EnumerationAllowed valuesenum types
SQL InjectionParameterized queriesORM (Prisma, GORM, SQLAlchemy)
XSSHTML escapingTemplate engines, DOMPurify
Path TraversalPath normalizationfilepath.Clean + whitelist

Rate Limiting Strategy

TargetLimitKey
Auth endpoints5 req/minIP
General API100 req/minUser token
File upload10 req/hourUser token
Public API30 req/minIP

Response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After (on 429).

API Versioning Strategy

StrategyUse CaseExample
URL prefixMost APIs/api/v1/users
HeaderInternal APIsAccept: application/vnd.api+json; version=2
Query paramSimple 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

Common Rationalizations

RationalizationReality
"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.

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

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

Frequently asked questions

What does the Moai Ref Api Patterns AI skill do?

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.

Why use Moai Ref Api Patterns on TypingMind?

Because you install it once and use it with any model. Moai Ref Api Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Moai Ref Api Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-api-patterns. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Moai Ref Api Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Moai Ref Api Patterns?

As many as you like. As long as a model supports skills, you can use Moai Ref Api Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Moai Ref Api Patterns AI skill free?

Yes. It is published on GitHub by modu-ai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇