RESTful API Design

VerifiedSafe

Design and implementation of RESTful APIs following best practices. Includes type definitions, database schemas, routing, and API clients.

Sby Skills Guide Bot
DevelopmentIntermediate
3/9/2026
Claude CodeCursorWindsurf
#rest-api#api-design#backend#typescript#express

Recommended for

Automated summary

Guides the design and implementation of TypeScript REST APIs, from shared type definitions through to the frontend client, following a fixed step order.

Strengths

  • Explicit implementation order (shared types → DB schema → route → registration → client) that prevents skipped layers
  • Ready-to-paste code samples for Express, Drizzle/SQLite and nanoid
  • Consistent conventions for response shape (data / error) and HTTP status codes
  • Ships an inventory of the project's existing routes so new endpoints are not duplicated

Limitations

  • Tightly bound to one stack (Express, Drizzle, SQLite, nanoid) and awkward to adapt to Fastify, NestJS or Prisma
  • Covers neither authentication, schema validation (zod), pagination nor versioning
  • No OpenAPI documentation or API test generation
When to use it

Use it when adding or changing a REST endpoint in a TypeScript project built on Express and Drizzle, keeping types, routes and client in sync.

When not to use it

Avoid it if the project uses a different framework or ORM, or when the task is designing a GraphQL or gRPC API.

Security analysis

Safe
Quality score78/100

The skill is a conventional REST API design guide containing only documentation and illustrative TypeScript code snippets. It declares Bash and Task tools, but no instruction in the body invokes shell commands, network calls, credential handling, or destructive operations. There is no obfuscation, no exfiltration, and no attempt to disable safety controls, so listing it carries no meaningful execution risk.

No concerns found

How this analysis is made

Examples

Add a resource endpoint
Add a full CRUD endpoint for 'projects' to the API: shared types, DB schema, Express routes, mount the router, and a matching frontend client in apps/web/src/lib/api.ts.
Follow REST conventions
Review the /api/sessions routes and make them consistent with the REST conventions in this skill (methods, path patterns, status codes, { data } / { error } response shape).
Wire up a new sub-resource
Create GET and POST /api/sessions/:id/labels endpoints and register them, reusing the existing sessions router pattern.

name: api-designer description: "API design and implementation. Use for 'API', 'endpoint', 'route' requests" allowed-tools: Read, Write, Edit, Grep, Glob, Bash, Task

API Designer Skill

Role

Backend developer who designs and implements RESTful APIs

API Design Principles

RESTful Rules

| Method | Purpose | Path Pattern | |--------|---------|--------------| | GET | Retrieve | /api/resources, /api/resources/:id | | POST | Create | /api/resources | | PATCH | Partial update | /api/resources/:id | | PUT | Full replace | /api/resources/:id | | DELETE | Delete | /api/resources/:id |

Response Format

// Success
{ data: T }
{ data: T[], total?: number }

// Error
{ error: string, details?: unknown }

HTTP Status Codes

| Code | Purpose | |------|---------| | 200 | Success | | 201 | Created | | 400 | Bad request | | 404 | Not found | | 500 | Server error |

Implementation Order

1. Type Definition (packages/shared)

// packages/shared/src/index.ts
export type CreateFeatureRequest = {
  name: string;
  description?: string;
};

export type FeatureResponse = {
  id: string;
  name: string;
  description: string | null;
  createdAt: string;
};

2. DB Schema (if needed)

// packages/db/src/schema.ts
export const features = sqliteTable('features', {
  id: text('id').primaryKey(),
  name: text('name').notNull(),
  description: text('description'),
  createdAt: text('created_at').notNull(),
});

3. Route Implementation

// apps/server/src/routes/features.ts
import { Router } from 'express';
import { db } from '@local-review/db';
import { features } from '@local-review/db/schema';
import { nanoid } from 'nanoid';

const router = Router();

// GET /api/features
router.get('/', async (req, res) => {
  try {
    const result = await db.select().from(features);
    res.json(result);
  } catch (error) {
    res.status(500).json({ error: 'Failed to fetch features' });
  }
});

// POST /api/features
router.post('/', async (req, res) => {
  try {
    const { name, description } = req.body;

    if (!name) {
      return res.status(400).json({ error: 'Name is required' });
    }

    const newFeature = {
      id: nanoid(),
      name,
      description: description ?? null,
      createdAt: new Date().toISOString(),
    };

    await db.insert(features).values(newFeature);
    res.status(201).json(newFeature);
  } catch (error) {
    res.status(500).json({ error: 'Failed to create feature' });
  }
});

export default router;

4. Register Route

// apps/server/src/index.ts
import featuresRouter from './routes/features';
app.use('/api/features', featuresRouter);

5. Frontend API Client

// apps/web/src/lib/api.ts
export const featureApi = {
  list: () => fetchJson<FeatureResponse[]>('/api/features'),
  create: (data: CreateFeatureRequest) =>
    fetchJson<FeatureResponse>('/api/features', {
      method: 'POST',
      body: JSON.stringify(data),
    }),
};

Existing API Reference

Current project API structure:

  • GET /api/git/branches - Branch list
  • GET/POST /api/sessions - Session CRUD
  • GET/POST /api/sessions/:id/comments - Comments
  • PATCH /api/sessions/:id/files/*/status - File status

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/restful-api-design-mmio717l/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/restful-api-design-mmio717l' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/restful-api-design-mmio717l/download' --output '.skill-downloads/restful-api-design-mmio717l/SKILL.md.part' && mv '.skill-downloads/restful-api-design-mmio717l/SKILL.md.part' '.skill-downloads/restful-api-design-mmio717l/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Write, Edit, Grep, Glob, Bash, Task

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/restful-api-design-mmio717l/SKILL.md' && test -s '.skill-downloads/restful-api-design-mmio717l/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/api-designer' && cp -R '.skill-downloads/restful-api-design-mmio717l' '.claude/skills/api-designer'

Cursor
test -f '.skill-downloads/restful-api-design-mmio717l/SKILL.md' && test -s '.skill-downloads/restful-api-design-mmio717l/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/api-designer' && cp -R '.skill-downloads/restful-api-design-mmio717l' '.cursor/skills/api-designer'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/restful-api-design-mmio717l'

openskills read 'restful-api-design-mmio717l'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/restful-api-design-mmio717l/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills