Vibe coding and a precise spec
Vibe coding is a way of building a program by talking with artificial intelligence: you say what you need and the tool proposes code. But responsibility for the code stays with you: if you do not check that it works correctly, you cannot rely on it. The result depends on how precisely the task is written.
A precise spec has four parts: what goes in (input), what should come out (output), 2–3 concrete examples and edge cases (for example an empty list, 0 or the largest value). For choosing by a condition Python has if, elif, else. The line after the condition is also indented by 4 spaces.
yosh = 20
if yosh >= 18:
print("kattalar")
else:
print("bolalar")OutputkattalarEdge cases are where mistakes happen most often. For example, if you write “adults over 18”, say clearly whether a person who is exactly 18 counts as an adult. Precise examples make both the spec and the later testing easier.
Remember
- Vibe coding: you give the task, checking the code stays with you.
- Spec = input + output + examples + edge cases.
- Condition:
if,elif,else.
Exercise
Which of these is a good spec?
Answer and explanation
- “Write me a function that checks age.”the input, output and limits are unknown.
- “The function
yosh_toifa(yosh)returnsbolafor ages under 18,kattalarfor 18–64 andkeksafor 65 and over. Example: 10 → bola, 65 → keksa.” (correct answer)the input, output, limits and examples are given. - “Make the code beautiful.”beauty is not a checkable criterion.
Code exercises
- Write the function
yosh_toifa(yosh): it returnsbolafor ages under 18,kattalarfor 18 to 64 andkeksafor 65 and over.
Hint:if yosh < 18:, thenelif yosh < 65:, andelse:at the end.returnin each branch.
Do the exercise in the app.
Practical task
Write a spec for a small function (for example, deciding whether a number is even): input, output and 3 examples, including one edge case.
- I wrote the input and output
- I wrote 3 examples
- I added one edge case
Glossary
Interactive mode: search, progress and Python exercises.
