Loading lesson…
A prompt that writes a poem is not the same as a prompt that ships working code. Code has hidden standards. You need to make them explicit.
A poem about loneliness can be five lines or fifty and still work. A function that adds two numbers has to return the exact right number, in the exact right type, or the program breaks. Prompts for code have to be more precise, because code is less forgiving.
| Weak | Strong |
|---|---|
| Write a function to sort things | Write a TypeScript function sortByDate(items: {id: string, created: Date}[]) that returns the array sorted oldest first. Do not mutate the input. |
| Make me an API | Write a Node.js Express route POST /signup that takes {email, password}, hashes the password with bcrypt, and returns 201 with {id, email}. |
| Fix this bug | This function returns NaN when items is empty. Expected behavior is to return 0. Fix the bug and keep the signature. |
Task: Write a function `slugify(text: string): string`. Language: TypeScript. Behavior: - Lowercase the input. - Replace spaces with hyphens. - Strip characters that are not a-z, 0-9, or hyphen. - Collapse multiple hyphens into one. Example: slugify("Hello, World!") === "hello-world" slugify(" A B ") === "a-b" Constraints: - Pure function. - No external dependencies.A prompt you could paste into any AI coding tool and get a reliable, testable function back.The best programmers write the spec before the code, whether or not an AI is helping.
— A staff engineer
The big idea: code is a contract, so a code prompt must be a contract too. Inputs, outputs, examples, constraints. Nail those, and the AI stops guessing and starts delivering.
8 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-prompting-for-code-builders
What is the main idea of "Prompting for Code Is Different From Prompting for Prose"?
Which concept is most central to "Prompting for Code Is Different From Prompting for Prose"?
Which use of AI fits this topic best?
What should a careful learner remember about "Include an example"?
You want to use AI after this lesson. What is the safest next step?
How should AI output about code prompts be treated?
Name one way to verify an AI answer about code prompts.
Which action would help you apply "Prompting for Code Is Different From Prompting for Prose" responsibly?