Agent skill

API Route Patterns

by bybren-llc in bybren-llc/safe-agentic-workflow

“API route implementation patterns with RLS, validation, and error handling. Use when creating API routes, implementing CRUD endpoints, adding server-side validation, handling…”

— description from SKILL.md by bybren-llc
MITAuto-check passedBackend & APIs

Install API Route Patterns

skills CLI
$ npx skills add bybren-llc/safe-agentic-workflow --skill api-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install bybren-llc/safe-agentic-workflow api-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/bybren-llc/safe-agentic-workflow.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/api-patterns .claude/skills/api-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
api-patterns
GitHub stars
421
Token cost
~1.6k tokens
SKILL.md length
207 words
Files
4 (incl. scripts, references, assets)
Skills in repo
42
Repo updated
First seen
Licence
MIT

At a glance

  • SKILL.md covers Purpose, When This Skill Applies, Authoritative References (MUST… and Stop-the-Line Conditions, plus 5 more sections

About this skill

“API route implementation patterns with RLS, validation, and error handling. Use when creating API routes, implementing CRUD endpoints, adding server-side validation, handling webhooks, or implementing error handling patterns. Do NOT use for frontend-only changes or database migrations without API involvement.”

— description from SKILL.md by bybren-llc

API Route Patterns is a skill in bybren-llc/safe-agentic-workflow (421 stars). Its SKILL.md is about 1.6k tokens, with 3 other files in the folder (scripts, references, assets). Licence: MIT.

What it can do on your machine

Read from SKILL.md and the folder at commit 26ca58b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/, which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

API Route Patterns loads about 1.6k tokens when it runs. Until then it costs about 81 tokens; SKILL.md has 207 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~81
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from bybren-llc/safe-agentic-workflow at commit 26ca58b, republished under its MIT licence (© bybren-llc). 207 words, ~1,565 tokens.

Download SKILL.mdSave it as .claude/skills/api-patterns/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
api-patterns
description
API route implementation patterns with RLS, validation, and error handling. Use when creating API routes, implementing CRUD endpoints, adding server-side validation, handling webhooks, or implementing error handling patterns. Do NOT use for frontend-only changes or database migrations without API involvement.

API Patterns Skill

TEMPLATE: This skill uses {{PLACEHOLDER}} tokens. Replace with your project values before use.

Purpose

Route to existing API patterns and provide checklists for safe, validated API route implementation. All API routes MUST use RLS context helpers -- see rls-patterns skill.

When This Skill Applies

  • Creating new API routes
  • Implementing CRUD endpoints
  • Adding request/response validation
  • Handling webhooks
  • Implementing error handling patterns

Authoritative References (MUST READ)

PatternLocationPurpose
User Context APIpatterns_library/api/user-context-api.mdUser-scoped operations
Admin Context APIpatterns_library/api/admin-context-api.mdAdmin-scoped operations
Zod Validationpatterns_library/api/zod-validation-api.mdRequest/response validation
Webhook Handlerpatterns_library/api/webhook-handler.mdWebhook processing
Bonus Contentpatterns_library/api/bonus-content-delivery.mdProtected content delivery

Stop-the-Line Conditions

FORBIDDEN Patterns
typescript
// FORBIDDEN: Direct ORM/DB calls (bypass RLS)
const users = await db.user.findMany();
// Must use: withUserContext, withAdminContext, or withSystemContext

// FORBIDDEN: Missing authentication check
export async function GET(req: Request) {
  return getUserData(); // No auth check!
}

// FORBIDDEN: Unvalidated user input
const { userId } = await req.json();
// Must validate with schema validation (Zod, Pydantic, etc.)

// FORBIDDEN: Generic error responses
return new Response("Error", { status: 500 });
// Must use structured error response
CORRECT Patterns
typescript
// CORRECT: RLS context + auth check
export async function GET(req: Request) {
  const { userId } = await auth();
  if (!userId) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }

  const data = await withUserContext(db, userId, async (client) => {
    return client.user.findUnique({ where: { user_id: userId } });
  });

  return NextResponse.json(data);
}

// CORRECT: Schema validation
const schema = z.object({
  email: z.string().email(),
  name: z.string().min(1),
});

const result = schema.safeParse(body);
if (!result.success) {
  return NextResponse.json(
    { error: "Validation failed", details: result.error.flatten() },
    { status: 400 },
  );
}

API Route Checklist

Before ANY API route:

  • Authentication check
  • Proper 401 response for unauthenticated
  • Request validation with schema (Zod, Pydantic, etc.)
  • RLS context wrapper (withUserContext/withAdminContext/withSystemContext)
  • Structured error responses with appropriate status codes
  • Type-safe request/response definitions

Standard Response Patterns

Success Response
json
{ "data": { ... }, "success": true }
Error Response
json
{
  "error": "Human-readable error message",
  "code": "ERROR_CODE",
  "details": "optional_details"
}
Status Codes
CodeWhen to Use
200Success
201Created (POST)
400Bad request / validation error
401Not authenticated
403Forbidden (authenticated but not authorized)
404Resource not found
500Server error

API Route Template

typescript
import { auth } from "{{AUTH_IMPORT}}";
import { NextResponse } from "next/server";
import { z } from "zod";
import { withUserContext } from "{{RLS_IMPORT}}";
import { db } from "{{DB_IMPORT}}";

// Request validation schema
const RequestSchema = z.object({
  // Define expected fields
});

export async function POST(req: Request) {
  try {
    // 1. Authenticate
    const { userId } = await auth();
    if (!userId) {
      return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
    }

    // 2. Parse and validate request
    const body = await req.json();
    const result = RequestSchema.safeParse(body);
    if (!result.success) {
      return NextResponse.json(
        { error: "Validation failed", details: result.error.flatten() },
        { status: 400 },
      );
    }

    // 3. Execute with RLS context
    const data = await withUserContext(db, userId, async (client) => {
      return client.resource.create({ data: result.data });
    });

    // 4. Return success response
    return NextResponse.json({ data, success: true }, { status: 201 });
  } catch (error) {
    console.error("API error:", error);
    return NextResponse.json(
      { error: "Internal server error" },
      { status: 500 },
    );
  }
}

API Documentation Template

For documenting new endpoints:

markdown
## Endpoint: POST /api/resource

### Description
Creates a new resource for the authenticated user.

### Authentication
Required: {{AUTH_PROVIDER}} session

### Request Body
| Field | Type   | Required | Description   |
| ----- | ------ | -------- | ------------- |
| name  | string | Yes      | Resource name |
| type  | string | No       | Resource type |

### Response
**Success (201)**:
{ "data": { "id": 1, "name": "..." }, "success": true }

**Error (400)**:
{ "error": "Validation failed", "details": {...} }

### RLS Context
Uses `withUserContext` - user can only access own resources.
  • rls-patterns: RLS context helper usage (REQUIRED for all DB operations)
  • security-audit: API security validation
  • testing-patterns: API endpoint testing

© bybren-llc, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references, assets) in .agents/skills/api-patterns of bybren-llc/safe-agentic-workflow.

  • SKILL.md
  • assets/.gitkeep
  • references/.gitkeep
  • scripts/.gitkeep

Open the folder on GitHubat commit 26ca58b

Compare with similar skills

API Route Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

API Route Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
API Route Patterns this skillbybren-llc/safe-agentic-workflow421—~1.6kAutomated safety check: PassMIT
Discover APIrand/cc-polymath1811 repos~1.5kAutomated safety check: PassMIT
Node Backend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2kAutomated safety check: PassMIT
API DesignerJeffallan/claude-skills12k2 repos~2kAutomated safety check: PassMIT
Pangolin CRUD Endpointsfosrl/pangolin23k—~461Automated safety check: PassCustom licence
Email Best Practicesviclafouch/meme-studio1107 repos~787Automated safety check: PassNone

Similar skills

  • Discover API

    rand/cc-polymath

    Automatically discover API design skills when working with REST APIs, GraphQL schemas, API authentication, OAuth, JWT, rate limiting, API versioning, error handling, or endpoint design.

    181 GitHub starsUsed in 1 repo~1.5k tokens
    Backend & APIsAuto-check passed
  • Node Backend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Sets layered architecture and coding rules for Node.js, Express and TypeScript microservices, covering routes, controllers, services, repositories, Prisma, Sentry and Zod.

    10k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • API Designer

    Jeffallan/claude-skills

    Designs REST and GraphQL APIs from resource modeling to an OpenAPI 3.1 contract, with versioning, pagination and RFC 7807 error handling.

    12k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • Use whenever asked to add, create, or scaffold a CRUD endpoint, router, or entity in this repo's server (create/list/get/update/delete handlers, new…

    23k GitHub stars~461 tokensUpdated today
    Backend & APIsAuto-check passed
  • Email Best Practices

    viclafouch/meme-studio

    A skill your agent uses when building email features, emails going to spam, high bounce rates, setting up SPF/DKIM/DMARC authentication, implementing email capture, ensuring compliance (CAN-SPAM…

    110 GitHub starsUsed in 7 repos~787 tokens
    Backend & APIsAuto-check passed
  • Checklist for adding, changing, deprecating or removing Saleor GraphQL fields, mutations, enums and webhook event types so the change passes review first time.

    23k GitHub stars~1.2k tokensUpdated yesterday
    Backend & APIsAuto-check passed

More from bybren-llc/safe-agentic-workflow

All 42 skills in this repo
  • Multi-Agent Coordination Template

    bybren-llc/safe-agentic-workflow

    Agent assignment matrix, blocker escalation, and TDM coordination patterns. Use when assigning work to specialist agents, managing blockers across agents…

    421 GitHub stars~1.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Technical Documentation Templates

    bybren-llc/safe-agentic-workflow

    Documentation templates for ADRs, runbooks, architecture docs, and knowledge transfer documents. Use when creating Architecture Decision Records, writing…

    421 GitHub stars~1.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Deployment SOP Checklist

    bybren-llc/safe-agentic-workflow

    Deployment workflows, pre-deploy validation, smoke testing, and rollback procedures. Use when deploying to staging or production, running smoke tests…

    421 GitHub stars~950 tokensUpdated 2 mo ago
    Auto-check passed
  • Frontend Patterns Template

    bybren-llc/safe-agentic-workflow

    Frontend patterns for modern web frameworks, component libraries, auth flows, and analytics. Use when building UI components, creating pages, implementing…

    421 GitHub stars~2k tokensUpdated 2 mo ago
    Auto-check passed
  • Advanced Git Operations

    bybren-llc/safe-agentic-workflow

    Advanced git operations including rebase, bisect, cherry-pick, and conflict resolution. Use when rebasing feature branches, debugging with bisect…

    421 GitHub stars~1.6k tokensUpdated 2 mo ago
    Auto-check passed
  • Linear Ticket SOP

    bybren-llc/safe-agentic-workflow

    Ticket management best practices for Linear or equivalent project tracker. Use when creating issues, updating ticket status, attaching evidence, parsing…

    421 GitHub stars~1.8k tokensUpdated 2 mo ago
    Auto-check passed

Works with

Categories

Questions about API Route Patterns

How do I install API Route Patterns in Claude Code?

Run `npx skills add bybren-llc/safe-agentic-workflow --skill api-patterns -a claude-code`. Or copy the skill folder (.agents/skills/api-patterns in bybren-llc/safe-agentic-workflow) into .claude/skills/api-patterns in your project. Claude Code loads it when a task matches its description.

How do I install API Route Patterns in Codex?

Run `npx skills add bybren-llc/safe-agentic-workflow --skill api-patterns -a codex`. Or copy the skill folder (.agents/skills/api-patterns in bybren-llc/safe-agentic-workflow) into .agents/skills/api-patterns in your project. Codex loads it when a task matches its description.

Can I use API Route Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add bybren-llc/safe-agentic-workflow --skill api-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/api-patterns, .gemini/skills/api-patterns, .github/skills/api-patterns and .opencode/skills/api-patterns in your project.

What does API Route Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: API Route Patterns is instructions for the agent only.

Does API Route Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is API Route Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does API Route Patterns use?

API Route Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does API Route Patterns use?

About 1.6k tokens (SKILL.md is roughly 6.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to API Route Patterns?

Skills that share tags, products or a category with API Route Patterns: Discover API (rand/cc-polymath, 181 stars), Node Backend Development Guidelines (diet103/claude-code-infrastructure-showcase, 10k stars), API Designer (Jeffallan/claude-skills, 12k stars) and Pangolin CRUD Endpoints (fosrl/pangolin, 23k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains API Route Patterns?

bybren-llc (a GitHub organization) maintains it in bybren-llc/safe-agentic-workflow, which has 421 GitHub stars. The repository holds 42 skills in this directory. The repository was last updated on July 20, 2026.

Source: bybren-llc/safe-agentic-workflow on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.