add-api-route-whatifwedigdeeper-application-tracker

Create Next.js API route with validation and error handling

181 stars

Best use case

add-api-route-whatifwedigdeeper-application-tracker is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Create Next.js API route with validation and error handling

Teams using add-api-route-whatifwedigdeeper-application-tracker should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/add-api-route-whatifwedigdeeper-application-tracker/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/add-api-route-whatifwedigdeeper-application-tracker/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/add-api-route-whatifwedigdeeper-application-tracker/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How add-api-route-whatifwedigdeeper-application-tracker Compares

Feature / Agentadd-api-route-whatifwedigdeeper-application-trackerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Create Next.js API route with validation and error handling

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Add API Route: $ARGUMENTS

Create a Next.js API route with proper validation, error handling, and types.

## Process

### 1. Determine Route Structure

Parse arguments to determine:
- Route path (e.g., `users`, `posts/[id]`)
- HTTP methods (GET, POST, PUT, DELETE)
- Dynamic segments if any

### 2. Create Route File

**App Router (Next.js 13+):**
```
app/api/[route]/route.ts
```

**Pages Router:**
```
pages/api/[route].ts
```

### 3. Generate Route Handler

**App Router template:**

```typescript
import { NextRequest, NextResponse } from 'next/server';

// Types
interface RequestBody {
  // define expected body shape
}

interface ResponseData {
  // define response shape
}

// GET handler
export async function GET(request: NextRequest) {
  try {
    // Implementation
    return NextResponse.json({ data: [] });
  } catch (error) {
    console.error('GET error:', error);
    return NextResponse.json(
      { error: 'Internal server error' },
      { status: 500 }
    );
  }
}

// POST handler
export async function POST(request: NextRequest) {
  try {
    const body: RequestBody = await request.json();

    // Validate
    if (!body.requiredField) {
      return NextResponse.json(
        { error: 'Missing required field' },
        { status: 400 }
      );
    }

    // Implementation
    return NextResponse.json({ success: true }, { status: 201 });
  } catch (error) {
    console.error('POST error:', error);
    return NextResponse.json(
      { error: 'Internal server error' },
      { status: 500 }
    );
  }
}
```

### 4. Add Type Definitions

Add to `types/api.ts` or `types/index.ts`:

```typescript
export interface [Route]Request {
  // request body type
}

export interface [Route]Response {
  // response type
}
```

### 5. Create Tests

```typescript
// __tests__/api/[route].test.ts
describe('API /api/[route]', () => {
  test('GET returns data', async () => {
    const response = await fetch('/api/[route]');
    expect(response.status).toBe(200);
  });

  test('POST validates input', async () => {
    const response = await fetch('/api/[route]', {
      method: 'POST',
      body: JSON.stringify({}),
    });
    expect(response.status).toBe(400);
  });
});
```

### 6. Validate

```bash
npm run build
npm test
```

## Patterns

**Dynamic route:** `app/api/users/[id]/route.ts`

**Nested route:** `app/api/posts/[postId]/comments/route.ts`

**With middleware:** Add validation/auth in route or middleware.ts

Related Skills

adding-a-new-app-route

181
from majiayu000/claude-skill-registry

Fully wires up a new route with required boilerplate, following this repo's conventions for subapps. Use when user wants to add a new route or app or subapp or page or screen.

add-test-whatifwedigdeeper-application-tracker

181
from majiayu000/claude-skill-registry

Add unit tests for a component or function

add-route-context

181
from majiayu000/claude-skill-registry

为Flutter页面添加路由上下文记录功能,支持日期等参数的AI上下文识别。当需要让AI助手通过"询问当前上下文"功能获取页面状态(如日期、ID等参数)时使用。适用场景:(1) 日期驱动的页面(日记、活动、日历等),(2) ID驱动的页面(用户详情、订单详情等),(3) 任何需要AI理解当前页面参数的场景

add-openrouter-model

181
from majiayu000/claude-skill-registry

Fetch OpenRouter model details and provide guidance for adding models to acai-ts provider configuration.

add-hook-whatifwedigdeeper-application-tracker

181
from majiayu000/claude-skill-registry

Create a custom React hook with TypeScript and tests

add-api-route

181
from majiayu000/claude-skill-registry

Create Next.js API route with validation and error handling

astro

159
from majiayu000/claude-skill-registry

This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.

Coding & Development

vly-money

159
from majiayu000/claude-skill-registry

Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.

Fintech & CryptoClaude

thor-skills

159
from majiayu000/claude-skill-registry

An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.

SecurityClaude

modal-deployment

159
from majiayu000/claude-skill-registry

Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.

DevOps & Infrastructure

lets-go-rss

159
from majiayu000/claude-skill-registry

A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.

Content & Documentation

ontopo

159
from majiayu000/claude-skill-registry

An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.

General Utilities