Code prompts
Coding prompts for reviews, tests, refactors, debugging and documentation, for chat assistants and AI code editors.
No prompts match that search
Try a broader word, or clear a filter.
-
Act as a senior TypeScript engineer doing a careful code review. The code below is part of a production web API. Check, in this order: 1. Correctness: bugs, edge cases, off-by-one errors, unhandled errors and race conditions. 2. Security: injection, unsafe input handling, exposed secrets and missing permission checks. 3. Performance: needless work, N+1 queries and anything that will not scale. 4. Readability: naming, structure and anything a new teammate would trip over. For each finding give the severity (high, medium or low), the line or function, what is wrong, and a corrected snippet. List high-severity findings first. Do not comment on code that is fine. End with a three-line summary of the most important changes. Pay extra attention to: error handling and input validation. Code: (paste your code here)
Editor’s pick
Senior-level code review
A prioritised code review that checks correctness, security and performance, with a fixed snippet for every finding.
-
Act as a senior Python engineer who writes clear, reliable tests. Write unit tests for the code below using pytest. Steps: 1. In two or three lines, state what the code is meant to do, based on its names, types and logic. 2. List the cases to cover: normal inputs, edge cases (empty, zero, negative, very large or missing values) and expected errors. 3. Write the tests: one behaviour per test, descriptive test names and the arrange, act, assert pattern. 4. Mock only external dependencies, such as network calls, files, the clock and randomness. Pay extra attention to: boundary values and invalid input. Rules: the tests must run as written, with every import included. Do not change the code under test. If the code looks buggy, write a test that exposes the bug, label it clearly and explain the problem in one line instead of making the test pass. Code: (paste your function here)
Editor’s pick
Write unit tests for this function
Thorough unit tests covering normal cases, edge cases and errors, with suspected bugs flagged; change the language, framework and focus.
-
Act as a patient senior Python developer helping me debug. My experience level: beginner. What I was doing when the error appeared: running a script that reads a CSV file and adds up one column. Error message: (paste the full error message here) Relevant code: (paste the code around the error here) Answer in this order: 1. What the error means, in plain words, in two or three sentences. 2. The most likely cause in my code, pointing to the exact line or function. 3. The fix: a corrected snippet with a short comment on what changed. 4. How to check that it is fixed. 5. Other possible causes, most likely first, in case the fix does not work. Match the depth of your explanation to my level. If you need more information, such as another file, the full stack trace or the library versions, tell me exactly what to share instead of guessing.
Editor’s pick
Explain and fix this error
Explains an error in plain words, finds the likely cause and gives a fix with a way to check it; change the language, your level and the context.
-
You are a careful data analyst who writes correct, readable SQL. Write a PostgreSQL query that answers this question: Which 10 customers spent the most in the last 90 days, and how many orders did each place? Schema (tables and columns): customers (id integer, name text, country text, created_at timestamp); orders (id integer, customer_id integer, status text, total_amount numeric, created_at timestamp) Notes on the data: only orders with the status paid count, amounts are in GBP and timestamps are stored in UTC. Steps: 1. Restate the question in one sentence and list your assumptions, such as how you handle duplicates, nulls, time zones and cancelled records. 2. Write the query using only the tables and columns in the schema, with clear aliases, CTEs for multi-step logic and a short comment above each step. 3. Explain in plain words what the query does, step by step. 4. Suggest one quick check that the result is right, such as a row count or a sample of rows. Do not invent tables or columns. If the schema lacks something the question needs, say what is missing instead of guessing. Keep the query read-only: no INSERT, UPDATE, DELETE or DROP.
Editor’s pick
SQL query from plain English
Turns a plain-English question into a commented, read-only SQL query with its assumptions spelled out; change the dialect, schema and question.