Endpoint Implementation Plan
Produce a step-by-step implementation plan for one API endpoint that fits your existing code structure, before any code is written.
When to use it
Use it when you are about to add an endpoint to an existing service and want a plan you can check against the codebase first. The plan covers validation, layering, errors, data access and tests, and lists what it needs to confirm rather than guessing file names.
When not to use it: Do not use it for exploratory prototypes where you intend to throw the code away, or when you have not yet decided what the endpoint should do. Settle the contract first.
Required inputs
| Placeholder | What to provide | Example |
|---|---|---|
| {{endpoint_spec}} | What the endpoint does: method, path, inputs, outputs, rules and error cases. | POST /stock-adjustments. Body {sku, delta, reason}. Applies a stock change to one SKU. Reject if the result would be negative. Returns the new quantity. |
| {{code_structure}} | A short description or directory listing of how the service is organised, plus one existing endpoint as a model. | src/routes/*.ts call src/services/*.ts which call src/repositories/*.ts. See routes/skus.ts for the style used. |
| {{stack}} | Language, framework, database and test tools in use. | TypeScript, Express, PostgreSQL via a query builder, Vitest. |
| {{non_functional_needs}} | Concurrency, performance, audit or security needs, or 'none known'. | Two staff may adjust the same SKU at once. Every adjustment must be auditable. |
The prompt
Fill in each {{placeholder}} before you send it.
You are a senior backend engineer planning an implementation. Produce a plan I can review before any code is written.
<endpoint_spec>
{{endpoint_spec}}
</endpoint_spec>
<code_structure>
{{code_structure}}
</code_structure>
<stack>
{{stack}}
</stack>
<non_functional_needs>
{{non_functional_needs}}
</non_functional_needs>
Plan these parts:
1. Request validation: each field, its type and limits, and the error returned for each failure.
2. Layering: what belongs in the route, the service and the data layer, following the structure described above.
3. Business rules and the order in which they are checked.
4. Data access: what is read and written, transaction boundaries, and how concurrent requests are kept consistent.
5. Error handling: each failure case with its HTTP status and error body.
6. Tests: a list of test cases by layer, including at least one concurrency or repeat-request case if relevant.
7. Risks and things to confirm in the codebase before starting.
Rules:
- Use only what the material above states. You cannot see the repository. Never invent file names, function names, table columns or library behaviour. Where the plan depends on something you have not been shown, write "Confirm:" and say what to look for.
- Prefer the smallest change that meets the spec. Do not propose new abstractions or dependencies unless the spec needs them, and justify any you do propose.
- Do not write implementation code. Short pseudo-code for a tricky rule is allowed.
- State assumptions explicitly and mark the ones that would change the plan if wrong.
Output format (use these headings exactly):
Assumptions
Plan (numbered steps, each naming the layer)
Error table (case | status | body summary)
Test cases
Confirm before starting
RisksExpected output
A numbered plan that follows the layering you described, an error table with a status for every failure, a list of test cases grouped by layer, and a short list of things to check in the real codebase. Good output handles the concurrency need explicitly, for example by making the update and the non-negative check a single atomic operation, and does not name files it was never shown.
Assumptions
- Assumption: SKUs are identified by a unique sku column. If they are not, step 4 changes.
Plan
1. Route: validate body (sku non-empty string, delta non-zero integer, reason 1-200 characters). Return 400 on failure.
2. Service: call the repository to apply the adjustment; map a "would go negative" result to a domain error.
3. Repository: perform the update and the non-negative check in one statement, so two simultaneous adjustments cannot both pass the check. Record the audit row in the same transaction.
Error table
unknown SKU | 404 | { code: "sku_not_found" }
result below zero | 409 | { code: "insufficient_stock" }
Confirm before starting
- How existing routes build their error bodies (see routes/skus.ts).Limitations
- The assistant has not seen your repository. The plan is shaped by your description, and any mismatch between that description and the real code produces a plan that does not fit.
- It may suggest library features that do not exist in your version. Check any named API against your dependency's documentation.
- It tends to over-plan. Cut steps that add structure the spec does not need.
- It cannot assess performance under real load. Treat its concurrency advice as a starting point for review, not a guarantee.
How to validate the output
Do these before relying on anything the model returns.
- Written by
- PromptFable Editorial
- Last updated 13 Nov 2026
- Review
- Not yet reviewed
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.