add-api-route-whatifwedigdeeper-application-tracker
Create Next.js API route with validation and error handling
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
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-api-route-whatifwedigdeeper-application-tracker/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-api-route-whatifwedigdeeper-application-tracker Compares
| Feature / Agent | add-api-route-whatifwedigdeeper-application-tracker | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/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.tsRelated Skills
adding-a-new-app-route
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
Add unit tests for a component or function
add-route-context
为Flutter页面添加路由上下文记录功能,支持日期等参数的AI上下文识别。当需要让AI助手通过"询问当前上下文"功能获取页面状态(如日期、ID等参数)时使用。适用场景:(1) 日期驱动的页面(日记、活动、日历等),(2) ID驱动的页面(用户详情、订单详情等),(3) 任何需要AI理解当前页面参数的场景
add-openrouter-model
Fetch OpenRouter model details and provide guidance for adding models to acai-ts provider configuration.
add-hook-whatifwedigdeeper-application-tracker
Create a custom React hook with TypeScript and tests
add-api-route
Create Next.js API route with validation and error handling
astro
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.
vly-money
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.
thor-skills
An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.
modal-deployment
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.
lets-go-rss
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.
ontopo
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.