Generate endpoint
Skill vthinkdeveloper/vthink-agent-toolkit/skills/generate-endpoint
Generate a complete CRUD endpoint for a new resource. Auto-detects project structure (routes, models, test framework) and adapts to Express, Fastify, Flask, and similar frameworks. Use when asked to generate or scaffold a new API endpoint.From its SKILL.md
npx -y skills add vthinkdeveloper/vthink-agent-toolkit --skill generate-endpointAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.6 KB, as published. Nobody here has run it
Generate Endpoint
Generate a complete CRUD endpoint for a new resource, adapting to the project's existing structure and conventions.
Step 1: Detect Project Structure
Before generating anything, explore the project to understand how it's organized:
Find the routes/controller layer
Search for common patterns:
Glob: src/routes/*.js, app/routes/*.py, routes/*.js, controllers/*.js
Grep: "router.get\|app.get\|@app.route\|@router.get"
Find the database/model layer
Glob: src/db.js, src/models/*.js, db/*.js, models/*.py, prisma/schema.prisma
Grep: "CREATE TABLE\|sequelize.define\|mongoose.model\|db.prepare"
Find the test layer
Glob: tests/*.test.js, __tests__/*.js, test_*.py, spec/**/*.js
Check package.json / requirements for framework clues
Read package.json or requirements.txt to identify the framework and test runner.
If structure is ambiguous
Ask the user:
- "Where should I add the routes? (e.g.,
src/app.js,src/routes/)" - "Where should I add the database queries? (e.g.,
src/db.js,src/models/)" - "What test framework is this project using?"
Step 2: Ask for Resource Details
Ask the user:
- What is the resource name? (should be lowercase plural, e.g.,
products,orders) - What columns/fields does this resource need beyond
idandcreated_at?
Example prompt:
"I'll generate a CRUD endpoint for
products. What fields does a product have? For example:name (text),price (decimal),in_stock (boolean). I'll includeidandcreated_atautomatically."
Step 3: Read Existing Patterns
Read 1-2 existing route handlers and db functions to understand the conventions:
- How are responses structured?
{ data: [...] }or flat arrays? - How are errors handled? Try/catch with status codes? Error middleware?
- What HTTP status codes are used for create (201 vs 200)?
- What is the naming style for functions?
getAllProductsvsfetchProductsvslist_products?
Follow the patterns you find. Do not introduce new patterns.
Step 4: Generate the Code
Generate the following, adapted to the detected framework and conventions:
Database / Model Layer
Add CRUD functions for the new resource:
getAll<Resource>()— fetch all recordsget<Resource>ById(id)— fetch single recordcreate<Resource>(data)— insert new recordupdate<Resource>(id, data)— update existing recorddelete<Resource>(id)— delete record
If using SQL, include table creation (IF NOT EXISTS). If using an ORM, define the model/schema.
Routes / Controller Layer
Add RESTful routes:
GET /api/<resource>— list allGET /api/<resource>/:id— get by IDPOST /api/<resource>— createPUT /api/<resource>/:id— updateDELETE /api/<resource>/:id— delete
Include appropriate status codes and error handling matching the project's existing pattern.
Tests
Add tests for all CRUD operations following the project's existing test style:
- Happy path for each route
- 404 for unknown ID (get, update, delete)
- Validation errors for missing required fields (create, update)
Step 5: Apply the Changes
Edit the relevant files directly. Do not create separate files unless the project uses one-file-per-resource patterns.
After applying changes, summarize what was added:
- Which files were modified
- What routes are now available
- How to test them (e.g.,
curlexamples or test command)