Passo-a-passo detalhado do skill, referenciando as fases cognitivas:
1SENSE — Identificar recursos e operações
Listar entidades: `User`, `Product`, `Order`, `Review`
Mapear endpoints: `GET /users`, `POST /users`, `GET /users/{id}`, `PATCH /users/{id}`
2RECOMMEND — Projetar URL structure
```
/api/v1/users GET (list+filter+pagination) POST (create)
/api/v1/users/{id} GET (single) PATCH (update) DELETE
/api/v1/users/{id}/orders GET (nested resource)
```
3RECOMMEND — Gerar schema OpenAPI 3.1
```yaml
openapi: 3.1.0
info:
title: My API
version: 1.0.0
paths:
/users:
get:
parameters:
name: cursor
in: query
schema: { type: string }
name: limit
in: query
schema: { type: integer, default: 20, maximum: 100 }
responses:
'200':
content:
application/json:
schema:
type: object
properties:
data: { type: array, items: { $ref: '#/components/schemas/User' } }
nextCursor: { type: string, nullable: true }
```
4RECOMMEND — Implementar com Express + Zod
```typescript
const getUsersSchema = z.object({
cursor: z.string().optional(),
limit: z.number().int().min(1).max(100).default(20),
});
router.get('/users', async (req, res) => {
const { cursor, limit } = getUsersSchema.parse(req.query);
const users = await db.user.findMany({
take: limit + 1, // pega 1 a mais para saber se há próxima página
cursor: cursor ? { id: cursor } : undefined,
orderBy: { createdAt: 'desc' },
});
const hasNext = users.length > limit;
res.json({
data: hasNext ? users.slice(0, -1) : users,
nextCursor: hasNext ? users[limit - 1].id : null,
});
});
```
5EVALUATE — Testar endpoints
```typescript
it('GET /users returns cursor pagination', async () => {
const res = await request(app).get('/api/v1/users?limit=2').expect(200);
expect(res.body.data).toHaveLength(2);
expect(res.body.nextCursor).toBeTruthy();
});
```
6REFLECT — Documentar e validar
```bash
npx @redocly/cli lint openapi.yaml # Validar schema
npx @redocly/cli build-docs openapi.yaml # Gerar docs
```
Reportar telemetria via mcp-skillschain