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.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-prompting-for-code-builders
What is the core idea behind "Prompting for Code Is Different From Prompting for Prose"?
Which term best describes a foundational idea in "Prompting for Code Is Different From Prompting for Prose"?
A learner studying Prompting for Code Is Different From Prompting for Prose would need to understand which concept?
Which of these is directly relevant to Prompting for Code Is Different From Prompting for Prose?
Which of the following is a key point about Prompting for Code Is Different From Prompting for Prose?
Which of these does NOT belong in a discussion of Prompting for Code Is Different From Prompting for Prose?
Which statement is accurate regarding Prompting for Code Is Different From Prompting for Prose?
What is the key insight about "Include an example" in the context of Prompting for Code Is Different From Prompting for Prose?
Which statement accurately describes an aspect of Prompting for Code Is Different From Prompting for Prose?
What does working with Prompting for Code Is Different From Prompting for Prose typically involve?
Which best describes the scope of "Prompting for Code Is Different From Prompting for Prose"?
Which section heading best belongs in a lesson about Prompting for Code Is Different From Prompting for Prose?
Which section heading best belongs in a lesson about Prompting for Code Is Different From Prompting for Prose?
Which section heading best belongs in a lesson about Prompting for Code Is Different From Prompting for Prose?
Which section heading best belongs in a lesson about Prompting for Code Is Different From Prompting for Prose?