Skip to content

Results for “function”

16 prompts

Act as a senior [language] developer. Write a function that: [describe behaviour] Inputs: [names, types, examples] Output: [type and example] Constraints: [performance, no external libraries, etc.] Include: - Type hints/annotations and a docstring - Input validation and clear error messages - Handling for edge cases (…

ChatGPT
Coding & Development

Write a function from a plain-English description

Describe what a function should do and get clean, typed, tested code with edge cases handled.

Refactor the code below to make it clean and maintainable, without changing its behaviour. Language: [language] Style guide or conventions: [e.g. PEP 8, Airbnb] Goals: - Clear, descriptive names - Small functions with a single responsibility - Remove duplication and dead code - Simplify nested conditions (early return…

Claude
Coding & Development

Refactor messy code for readability

Clean up hard-to-read code with better names, smaller functions and less duplication, without changing what it does.

You are a senior software engineer writing a technical spec. Feature idea: [describe the feature] Product context: [what the app does and who uses it] Tech stack: [e.g. Next.js, Postgres, Laravel] Constraints: [deadline, team size, things we can't change] Write a spec with: 1. Goal and success metrics 2. User stories…

Claude
Coding & Development

Turn a feature idea into a technical spec

Go from a one-paragraph feature idea to a developer-ready spec with user stories, data model, API endpoints, edge cases and a task breakdown.

Write unit tests for the function below. Language: [language] Testing framework: [e.g. Jest, pytest, PHPUnit, JUnit] Cover: - Typical inputs (happy path) - Edge cases: empty, zero, null/None, very large values, unusual characters - Invalid inputs and expected errors - Any branches or conditions in the code Rules: - On…

Copilot
Coding & Development

Write unit tests for any function

Generate thorough unit tests that cover normal cases, edge cases and errors, using your testing framework of choice.