BoilerPrompt
Cursor

Cursor prompt to build a REST API

This prompt sends Cursor's agent after a full CRUD REST API: five endpoints, boundary validation, pagination, and a repository layer over your database. Because it ends with a test-and-report step, you get integration tests actually executed and a list of changed files, not just generated code you have to audit blind.

Last updated

Prompt
Build a REST API for managing {{resource}} records in {{language}}, using the framework already in this codebase, or scaffold a minimal new project if none exists. Implement five endpoints: GET /{{resource}} with pagination (limit and offset query params, default limit 20, max 100), GET /{{resource}}/:id, POST, PUT or PATCH, and DELETE. Validate request bodies at the boundary and return 400 with a field-level error list, 404 for unknown ids, and 201 with a Location header on create. Store data in {{database}} behind a small repository layer so handlers stay thin. Add integration tests covering the happy path plus invalid payloads and missing ids, then run the test suite and list every file you created or changed.

Customize it

Runs in your browser. Nothing you type here is sent anywhere.

Your customized prompt
Build a REST API for managing users records in TypeScript, using the framework already in this codebase, or scaffold a minimal new project if none exists. Implement five endpoints: GET /users with pagination (limit and offset query params, default limit 20, max 100), GET /users/:id, POST, PUT or PATCH, and DELETE. Validate request bodies at the boundary and return 400 with a field-level error list, 404 for unknown ids, and 201 with a Location header on create. Store data in PostgreSQL behind a small repository layer so handlers stay thin. Add integration tests covering the happy path plus invalid payloads and missing ids, then run the test suite and list every file you created or changed.

Same task in other tools

Questions about this prompt

Does Cursor pick the framework, or should I name one?

If the repo already has Express, Fastify, FastAPI, or similar, the agent detects it from package files and imports and follows suit. In an empty project it will pick a mainstream default, so add one line like "use Fastify" if you have a preference.

How do I get nested routes like /users/:id/orders instead of flat ones?

Edit the endpoint list in the prompt to spell out the nesting and which parent id scopes each query. The agent handles nested resources fine when the path structure is written out, but it tends to flatten routes if you leave the shape implicit.

The agent wrote the API but skipped the tests. What went wrong?

That usually happens when no test runner is configured, so there is nothing for it to execute. Install and configure one first, or tell Cursor to set up the runner as part of the task, and the verification step at the end of the prompt will then run.

Related prompts