
The quality of AI-written code depends mostly on the quality of your description. Here is a template that works.
Advertisement
The six-part description
- Goal β one sentence: what problem does this solve?
- Input β file type, where it is, a sample.
- Output β exact file name, columns, format.
- Rules β every business rule, written as a list.
- Examples β 2β3 input rows and the output you expect.
- Done when β how you will check it.
Before
Make a script to clean my vendor file.
After
Goal: clean the monthly vendor export so it can be loaded into Tally.
Input: sample/vendors.csv (UTF-8, comma separated, header row).
Output: output/vendors_clean.csv with columns Name, GSTIN, State, Phone.
Rules:
- Trim spaces; Name in Title Case.
- GSTIN: 15 characters, uppercase; if invalid, keep it but add "CHECK" in a new Remarks column.
- State: derive from the first two digits of GSTIN (27 = Maharashtra, 07 = Delhi, ...).
- Phone: digits only, keep the last 10.
- Remove exact duplicate rows; keep the first.
Example: " acme traders ","27aapfa1234b1z5",... -> "Acme Traders","27AAPFA1234B1Z5","Maharashtra",...
Done when: running it on sample/vendors.csv gives exactly expected/vendors_clean.csv.
The second prompt takes three minutes longer to write and saves an hour of back-and-forth.
When something is wrong
Be specific and give evidence:
- Bad: “It doesn’t work.”
- Good: “Row 14 (Sharma & Sons) has State blank but GSTIN starts with 09 β that should be Uttar Pradesh. Fix the lookup and add a test for it.”
Ask for explanations
After it works, ask: “Explain what this script does in 8 bullet points, for a non-programmer.” If the explanation surprises you, you have found a bug in the requirements or the code.
β¨ Ask AI about this article
Stuck on a step? Ask a question and the AI answers using this article.
Free Β· AI can be wrong