scaffolding-api-routes
Skill416 starsChanged 31 days agoApache-2.0View on GitHub
Reads API_Contracts.md artifacts and rebuilds the legacy Express routes as modern Next.js Route Handlers or Server Actions. Use when following a legacy audit artifact to scaffold out a new Express API routes.
In this repository83 other files it gives its agents.
- agents/charm-persona-quiz-for-agents/AGENTS.mdAGENTS.md
- agents/newsroom-harness/AGENTS.mdAGENTS.md
- codelabs/ai-toolkit-lab-2/hackathon-judge/frontend/.agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- codelabs/ai-toolkit-lab-2/hackathon-judge/frontend/.agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- codelabs/bwg002-devrel-2/AGENTS.mdAGENTS.md
- agents/charm-persona-quiz-for-agents/llms.txtllms.txt
- calendar-exportSkill
- session-notesSkill
- calendar-exportSkill
- session-notesSkill
- calendar-exportSkill
- session-notesSkill
- calendar-exportSkill
- session-notesSkill
- compare-subagent-mcp-visibilitySkill
- batch-executing-test-suitesSkill
- circuit-breaker-reporterSkill
- generating-mock-imagesSkill
- making-forms-demoSkill
- multi-step-workflow-reporterSkill
- auditing-inventorySkill
- newsroom-harnessSkill
- verify-sourcesSkill
- write-bulletinSkill
- repo-walkthroughSkill
- go-project-setupSkill
- latest-software-versionSkill
- video-descriptionSkill
- adk-memory-bank-initializerSkill
- agent-containerizerSkill
- cloud-run-agent-architectSkill
- gcp-agent-eval-engine-runnerSkill
- gcp-agent-eval-metric-configuratorSkill
- gcp-agent-golden-dataset-builderSkill
- gcp-agent-model-armor-shieldSkill
- gcp-agent-safety-gatekeeperSkill
- gcp-agent-sdp-template-factorySkill
- gcp-agent-shadow-deployerSkill
- gcp-agent-tool-trajectory-evaluatorSkill
- gcp-production-secret-handlerSkill
- mcp-connector-generatorSkill
- go-architectSkill
- go-backend-devSkill
- go-reviewerSkill
- go-test-expertSkill
- vercel-composition-patternsSkill
- vercel-react-best-practicesSkill
- lab-helperSkill
- start-frontendSkill
- brand-guidelinesSkill
- brand-guidelinesSkill
- kubernetes-1-37-manifestsSkill
- knowledge_catalog_governanceSkill
- banana-breadSkill
- cheese-breadSkill
- drawingsSkill
- paintingsSkill
- photographySkill
- ticket-triageSkill
- adding-easter-eggSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Create the folder structure in src/app/api/ representing the resources.
- Very specific: line 43
Use the Zod Schemas defined in src/lib/models/schema.ts (from Step 3) to validate req.json().
- Very specific: line 44
Ensure the API returns a standard 422 Unprocessable Entity or 400 Bad Request with a detailed error payload if validation fails.
- Very specific: line 47
Write the GET, POST, PUT, PATCH, and DELETE functions.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scaffolding Modern API Routes
Translate legacy Express route definitions and middleware chains into modern Next.js Route Handlers with built-in validation and unified session management.
Objective
Rebuild the documented API surface to ensure 1:1 functional parity with the legacy system, focusing on mapping Express Middlewares to Next.js Route Guards.
Instructions for the Scaffold Subagent
Copy this checklist and track your progress:
Task Progress:
- [ ] Step 1: Analyze API Contracts
- [ ] Step 2: Establish Route Architecture
- [ ] Step 3: Map Middleware to Guards
- [ ] Step 4: Implement Zod-Backed Request Validation
- [ ] Step 5: Implement Resource HandlersStep 1. Analyze API Contracts
Locate and read docs/legacy-audit/API_Contracts.md. Identify:
- Primary Routes & Sub-routes: Map these to the Next.js App Router (e.g.,
/api/[resource]/[sub-resource]/route.ts). - Legacy Middleware Requirements: Identify routes protected by Passport, custom "owner-only" checks, or roles.
Step 2. Establish Route Architecture
Create the folder structure in src/app/api/ representing the resources. Ensure that:
- Dynamic Segments (e.g.,
[id]) are used for resource-specific operations (GET single, PUT, DELETE). - Index Segments (e.g.,
/api/posts/route.ts) are used for collection operations (GET list, POST new).
Step 3. Map Middleware to Guards
Translate legacy Express middleware chains into Modular Route Guards:
- Authentication: Map
requiresLoginto agetServerSession(authOptions)check. - Authorization (Ownership): Map
resourceAuth.hasAuthorizationto a "Resource Ownership Guard" (e.g.,if (resource.user_id !== session.user.id) throw Unauthorized). - Authorization (Roles): Map role-specific middleware to logic that checks
session.user.role.
Step 4. Implement Zod-Backed Request Validation
For every incoming request (POST, PUT, PATCH):
- Use the Zod Schemas defined in
src/lib/models/schema.ts(from Step 3) to validatereq.json(). - Ensure the API returns a standard
422 Unprocessable Entityor400 Bad Requestwith a detailed error payload if validation fails.
Step 5. Implement Resource Handlers
Write the GET, POST, PUT, PATCH, and DELETE functions.
- Strict Response Envelopes: Match the Common Response Envelope identified in the audit (e.g., whether to return a raw object or a wrapped
{ data: ... }). - Pagination & Sorting: Implement
skip,limit, andsortparameters to mirror the legacy behavior precisely. - Status Code Parity: Match the exact success and error status codes documented in
API_Contracts.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

