Vibe Coding
Write Better Prompts
A good prompt names the goal, the files, the constraints, and what done looks like.
The four-part prompt
- Goal — one sentence of what should exist when you are done.
- Context — which files, functions, or docs to use.
- Constraints — what not to touch, libraries, style, tests.
- Done — how you will check: command, test name, or UI behavior.
Weak vs strong
Weak
Make a notes app and make it good.Strong
Add a CLI notes app in notes.py.
Goal: `python notes.py add "buy milk"` saves a note,
and `python notes.py list` prints them one per line.
Context: empty repo, Python 3.12. Use argparse.
Store notes in notes.json in the project root.
Constraints:
- Do not add dependencies.
- Keep functions small and typed.
- Include tests in test_notes.py.
Done: pytest -q passes, and both commands work.Prompt patterns that work
| Pattern | When | Example opener |
|---|---|---|
| Implement | You already know the design | "Add function X in file Y that..." |
| Plan only | More than one file | "Do not write code. List steps and files." |
| Explain | You are lost in a module | "Summarize this file. Then list risks." |
| Fix | You have an error | "Here is the command, traceback, and expected result." |
| Review | After a generation | "Review this diff for bugs, extra files, and secrets." |
Be specific about shape
If you care about the API, show it. Models copy examples more reliably than adjectives like "clean" or "simple."
Implement this exact function signature and keep it:
def parse_tags(raw: str) -> list[str]:
"""Split a comma-separated tag string, strip spaces, drop empties."""
Example: parse_tags("python, ai, ") == ["python", "ai"]One goal per prompt
"Add login, redesign the homepage, and migrate the database" is three projects. Split them. The model will otherwise touch everything and finish none of it well.
If a prompt needs more than a short paragraph of constraints, the task is too big. Plan first, then implement one step.
How you write a prompt in the editor
- Type the four parts in the chat box. Do not send a one-liner and hope.
- Add
@mentions for the files in Context (or name the paths in a CLI agent). If you cannot name them, explore first. - Send. If the model asks product questions, answer them in the next message — do not say “just pick.”
- If the reply is a plan, approve or correct it. If it already started coding and you asked for a plan, say “stop, plan only.”
Keep a scratch note of your four parts. Copy it into chat. After a week you will type them from memory.
Try it yourself
Rewrite this weak prompt using the four parts: “Fix my Python script, it doesn’t work.” Assume the script is total.py and the error is a TypeError when summing strings.
Show solution
@total.py
Goal: sum the numbers in a list of digit strings without crashing.
Context: total.py, function total(values: list[str]) -> int.
The command `python -c "from total import total; print(total(['1','2']))"`
should print 3. Right now it raises TypeError.
Constraints: do not add dependencies; keep the function name.
Done: that command prints 3, and pytest -q passes if tests exist.Key takeaways
- Goal, context, constraints, done.
- Show the API or example output. Do not only say “make it nice.”
- One change per prompt. Split the rest.
- You write the four parts. The agent fills the files. You still review.