Back to skills
SKILL.md
Api
ASecurity**Template:** `.antigravity/templates/TEMPLATE_API_route.md` for full scaffold (GET/POST with auth, Zod, org scope). **Contracts:** `.antigravity/contracts/CONTRACTS.md` — invariants.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added November 24, 2026
Works with
Security analysis
100/100Pro scans all 5 files and shows the line behind each finding
npx -y skills add iDorgham/Workspace-Factory --skill api --agent claude-codeAre you the author of Api?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/idorgham-api)---
type: Skill
subagents: [core-validator, integrity-bot]
agents: [master-guide, swarm-router]
dependencies: [core-orchestration, global-sync]
version: 1.0.0
---
# Workspace Factory API Routes
**Template:** `.antigravity/templates/TEMPLATE_API_route.md` for full scaffold (GET/POST with auth, Zod, org scope).
**Contracts:** `.antigravity/contracts/CONTRACTS.md` — invariants.
## Route Location
- `apps/client-dashboard/src/app/api/**/route.ts`
- Export `GET`, `POST`, `PUT`, `PATCH`, `DELETE` handlers
## Required Pattern (Every Protected Route)
```typescript
import { NextRequest, NextResponse } from 'next/server';
import { requireAuth } from '@/lib/require-auth';
import { prisma } from '@gate-access/db';
export async function GET(request: NextRequest) {
const auth = await requireAuth(request);
if (auth instanceof NextResponse) return auth;
const { orgId, role } = auth;
// Optional: rate limit
// await rateLimit(request, { max: 10, window: '1m' });
const data = await prisma.model.findMany({
where: { organizationId: orgId, deletedAt: null },
});
return NextResponse.json(data);
}
```
## Auth Check
```typescript
const auth = await requireAuth(request);
if (auth instanceof NextResponse) return auth;
// auth: { sub, email, role, orgId }
```
## Role Check
```typescript
if (auth.role !== 'TENANT_ADMIN') {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
}
```
## Input Validation (Zod)
```typescript
import { z } from 'zod';
const bodySchema = z.object({
name: z.string().min(1).max(100),
projectId: z.string().cuid().optional(),
});
const body = await request.json();
const parsed = bodySchema.safeParse(body);
if (!parsed.success) {
return NextResponse.json(
{ error: 'Validation failed', details: parsed.error.flatten() },
{ status: 400 }
);
}
const { name, projectId } = parsed.data;
```
## Rate Limiting
```typescript
import { rateLimit } from '@/lib/rate-limit';
await rateLimit(request, { max: 10, window: '1m' });
```
## CSRF (State-Changing Requests)
For POST/PUT/DELETE from web forms, include CSRF token. See `@/lib/csrf`.
## Error Responses
```typescript
return NextResponse.json(
{ success: false, message: 'Resource not found' },
{ status: 404 }
);
```
## Streaming/Export
```typescript
return new Response(csvString, {
headers: {
'Content-Type': 'text/csv; charset=utf-8',
'Content-Disposition': `attachment; filename="export.csv"`,
},
});
```
## Checklist
- [ ] requireAuth
- [ ] organizationId scope
- [ ] deletedAt: null filter
- [ ] Zod validation for body/query
- [ ] Rate limit if user-facing
- [ ] Proper status codes (400, 401, 403, 404)
**Reference:** `apps/client-dashboard/src/app/api/`, `.kiro/steering/api_development.md`Files in this skill
- core.py
- manifest.yaml
- skill.md
- skill.md.meta.json
- tests/test_core.py
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.