Skip to content

DirectoryPrompts

Claude Opus 5.5

Turn a Spec into Code – Function from a spec prompt for ChatGPT and Claude

Freewith a Recaply account
  • Free with an account
  • Copy filled in or download
  • Updates included
votes views

Claude Opus 5.5

This prompt turns a written spec into working code. Paste your language setup, the spec and the types it must use; you get the assumptions, the function, an edge case table and example calls.

What you get

  • The assumptions it made where your spec was unclear, one line each
  • The function with types and a docstring, using your existing classes and errors
  • A table of 5 to 8 edge cases and what the code does with each
  • 3 to 5 example calls with expected results, ready to paste into a quick test

How to use it

  1. 1
    Describe the setup and the spec

    Name the language, version and allowed libraries, then list every rule the function follows, including the awkward inputs you already know about.

  2. 2
    Paste the code it must fit

    Add the types, classes and helpers it should use, so the function calls real code instead of inventing its own.

  3. 3
    Run the example calls

    Paste the usage examples into a test or a shell, check each expected result, and question any assumption you disagree with.

Better results

  • Send a follow-up: "Write unit tests for this function covering every row of the edge case table" to turn the table into a test file.
  • List the edge cases you already know in the spec. The AI adds the obvious ones, but only you know the odd inputs your system really sees.
  • If the answer writes a stub with a TODO, paste the real helper and ask it to use that instead.

Questions

How do I use ChatGPT for generating code?

Give ChatGPT the language and version, a clear spec with the inputs, output and edge cases, and the existing code the new code must fit. Ask for the code plus example calls, then run those calls yourself before you use it.

How do I write a coding prompt for Claude?

Write it in parts: your setup, the spec, the code it must fit, the rules it must follow and the exact output you want. Claude follows detailed instructions closely, so also say what to leave out, such as new dependencies or a long introduction.

Can AI write code from requirements?

Yes, AI writes good code from clear requirements, especially for a single function or module. It does worse when requirements are vague, so state the inputs, outputs and edge cases, and expect it to list assumptions where your spec leaves gaps.

How do I use Claude for coding in Python?

Tell Claude your Python version and which packages you can use, paste the classes or functions the new code must work with, and describe the job in plain sentences. Ask for type hints and example calls, then run them in your own environment.

Updated 6 Oct 2026

Reviews

No reviews yet
Reviews open soonThey will come only from signed-in people who used this prompt.

Similar prompts

More coding prompts

Image prompts

Video prompts

Trending prompts

Newest prompts

Browse all prompts