Function From Requirements

A typed, documented function built to spec — with three unit tests covering the edge and error cases.

Beginner1 min read

Customize

Fill these in and the prompt below updates as you type. Anything you leave blank stays as a placeholder.

The programming language of the code

The behavior you want instead

The shape of the input, with types

The shape the result must take

Inputs likely to break it

The speed or resource limit this must meet

The conventions to write in

Your prompt

Write a {{language}} function that {{what_it_should_do}}.

Requirements:
- Input: {{input_spec}}
- Output: {{output_spec}}
- Edge cases to handle: {{edge_cases}}
- Performance constraint: {{performance_constraint}}

Include: type annotations/hints, a docstring with parameters and return type, and 3 unit test cases covering normal input, edge case, and error case.

Follow {{style_guide}} conventions.

Similar prompts

Document a Function or Module

Complete JSDoc or docstrings with precise types, throws, constraints, and a usage example.

Document What You Built

Update docs strictly from the diff, with no invented features.

Feature From a Specification

Build exactly the listed requirements against your existing patterns — and nothing more.

Fix a Bug Without Breaking Things

Find every affected code path and the same bug elsewhere before landing the minimal fix.