API Design: Error Codes First
Give request and response examples plus error handling
Prompt
Copy it whole, then replace the brackets with your own contentCode task: API design, define the error codes first. Code/error: [paste] Environment: [language/version/framework] Requirements: give request and response examples and the error handling. Give your diagnosis first, then the changes, then how to verify.
Replace the text in [ ] with your own situation; ask long tasks in stages.
How to get better results
Read this before you fill it inUse before finalizing a new API: spell out error codes, idempotency and pagination.
Give the conclusion and impact scope first, then only the changed snippets (no full files), and finally one check that proves it works. Flag risky spots separately.
Design a "create order" API: idempotent, retry-friendly, and error codes that let the frontend tell "bad parameters" from "out of stock".
No error codes defined, the frontend can only guess No idempotency key, retries duplicate orders No pagination rules, the API changes later
If problems remain after the fix, paste the new error and the changed snippet back; keep debugging on the original approach, don't switch approaches and rewrite.
More like this: Writing code prompts · All prompts