{"course":{"slug":"prompting","title":"Getting Real Work out of a Model","url":"https://addaly.com/learn/prompting","level":"beginner","track":"start"},"lesson":{"slug":"code-you-cannot-write","title":"Asking for code you could not have written","url":"https://addaly.com/learn/prompting/code-you-cannot-write","position":69,"of":72,"minutes":9,"answer":"Ask for commented code with setup instructions, run it on a copy with a dry run first.","keyIdea":"Ask for commented code with setup instructions, run it on a copy with a dry run first, and verify by counting rows and spot-checking three: reading a script for deletions and network calls is a much smaller skill than writing one."},"body":{"format":"markdown","text":"## You do not need to become a programmer\n\nYou need to get a specific job done: rename 400 files, pull data out of 30 PDFs, convert a folder of images, split one spreadsheet into twelve. These are twenty-line scripts, and asking for one is now realistic for somebody who has never written code.\n\nWhat you do need is the ability to run it safely and to tell whether it worked. That is a much smaller skill than programming, and this lesson is that skill.\n\n## Asking well\n\n> I am on macOS and have never used Python. Write a script that goes through every PDF in a folder, pulls out the invoice number and total, and writes them to a CSV.\n>\n> Tell me: what to install, exactly what to type to run it, and what should happen. Add a comment on every line explaining what it does. Do not delete or modify any original file. Print the number of files processed at the end.\n\nFive things doing work: your platform and level, the task, the setup instructions, comments per line, and (most importantly) the instruction that nothing gets modified or deleted.\n\n## The safety rules, which are not optional\n\n**1. Work on a copy.** Always. Copy the folder first, run the script on the copy. This one habit makes every other risk survivable.\n\n**2. Never let a first run delete, overwrite or move.** Ask for a dry run: \"print what it would do, do not do it.\" Read the output. Then run it for real.\n\n**3. Read the script for four things**, even if you do not understand the rest:\n   - Anything that says `delete`, `remove`, `rm`, `unlink`, `overwrite`, `w` mode on a file you care about.\n   - Any path outside the folder you intended.\n   - Any network address: a script for local files should not be sending anything anywhere.\n   - Any request for a password, key or account credential.\n\n**4. Never paste in a credential.** If a script wants a password or an API key, that is a moment to stop and ask somebody, not a step to complete.\n\n**5. Do not run something you cannot explain in one sentence.** If you cannot say what it does, ask for it to be explained until you can. \"I don't understand it but it worked\" is how people lose a folder.\n\n## Checking that it worked\n\n- **Count.** 400 files in, 400 rows out. A short count is the commonest failure and the easiest check.\n- **Spot-check three.** One from the start, one from the middle, one from the end. Open the original and compare.\n- **Look for empties.** A column that is blank for 40 rows means the extraction failed for those, silently.\n- **Try a deliberate oddity.** Put one badly formatted file in and see whether it is reported or ignored. A script that skips what it cannot parse without saying so is worse than one that crashes.\n\n## When it does not run\n\nPaste the entire error message. Not a description of it: the whole thing, including the file name and line number. Add what you typed and what you expected. This is the context lesson applied to your terminal, and it usually resolves in one turn.\n\n## The free path, and what it costs\n\nPython is free and pre-installed on macOS and most Linux systems; on Windows it is a small download. VS Code is free. So is everything you need for this.\n\nThe honest cost is that generated code often works on the happy path and fails on the ragged edges of real data: the file with no text layer, the row with a comma in the wrong place, the encoding that is not UTF-8. Expect to go two or three rounds, and expect the failures to be about your specific data rather than about the logic.\n\n## Where to stop\n\nAnything touching production systems, customer data, payments, or a database somebody else depends on is not a place to run code you cannot read. That is not caution for its own sake: the failure mode there is not a lost afternoon, and the person who has to unpick it will not be you."},"check":{"question":"A user gets a script to tidy 400 invoice files. What is the single most important thing to do before running it?","options":[{"text":"Copy the folder and run it on the copy, with a dry run that prints what it would do.","correct":true},{"text":"Read the whole script to understand the logic.","correct":false,"tempting":"Valuable and often not achievable for a beginner; a targeted read plus a copy achieves more with less."},{"text":"Ask the model to confirm the script is safe.","correct":false,"tempting":"A self-assessment from the party that wrote it, and no substitute for the copy."},{"text":"Check that Python is the most suitable language for the task.","correct":false,"tempting":"A preference question that has no bearing on whether the original files survive."}]},"prev":{"slug":"messy-spreadsheet-data","title":"The spreadsheet somebody else built","url":"https://addaly.com/learn/prompting/messy-spreadsheet-data"},"next":{"slug":"learning-something-with-it","title":"Using it to learn, without fooling yourself","url":"https://addaly.com/learn/prompting/learning-something-with-it"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Asking for code you could not have written', in Getting Real Work out of a Model. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/prompting/code-you-cannot-write (Accessed: 13 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Asking for code you could not have written","courseTitle":"Getting Real Work out of a Model","module":{"index":8,"slug":"the-work-you-actually-have","title":"The work you actually have"},"answer":null,"keyIdea":"Ask for commented code with setup instructions, run it on a copy with a dry run first, and verify by counting rows and spot-checking three: reading a script for deletions and network calls is a much smaller skill than writing one.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"you-do-not-need-to-become-a-programmer","runs":[{"text":"You do not need to become a programmer"}]},{"t":"p","runs":[{"text":"You need to get a specific job done: rename 400 files, pull data out of 30 PDFs, convert a folder of images, split one spreadsheet into twelve. These are twenty-line scripts, and asking for one is now realistic for somebody who has never written code."}]},{"t":"p","runs":[{"text":"What you do need is the ability to run it safely and to tell whether it worked. That is a much smaller skill than programming, and this lesson is that skill."}]},{"t":"h2","id":"asking-well","runs":[{"text":"Asking well"}]},{"t":"quote","runs":[{"text":"I am on macOS and have never used Python. Write a script that goes through every PDF in a folder, pulls out the invoice number and total, and writes them to a CSV."}]},{"t":"quote","runs":[]},{"t":"quote","runs":[{"text":"Tell me: what to install, exactly what to type to run it, and what should happen. Add a comment on every line explaining what it does. Do not delete or modify any original file. Print the number of files processed at the end."}]},{"t":"p","runs":[{"text":"Five things doing work: your platform and level, the task, the setup instructions, comments per line, and (most importantly) the instruction that nothing gets modified or deleted."}]},{"t":"h2","id":"the-safety-rules-which-are-not-optional","runs":[{"text":"The safety rules, which are not optional"}]},{"t":"p","runs":[{"text":"1. Work on a copy.","b":true},{"text":" Always. Copy the folder first, run the script on the copy. This one habit makes every other risk survivable."}]},{"t":"p","runs":[{"text":"2. Never let a first run delete, overwrite or move.","b":true},{"text":" Ask for a dry run: “print what it would do, do not do it.” Read the output. Then run it for real."}]},{"t":"p","runs":[{"text":"3. Read the script for four things","b":true},{"text":", even if you do not understand the rest:"}]},{"t":"ul","items":[[{"text":"Anything that says "},{"text":"delete","code":true},{"text":", "},{"text":"remove","code":true},{"text":", "},{"text":"rm","code":true},{"text":", "},{"text":"unlink","code":true},{"text":", "},{"text":"overwrite","code":true},{"text":", "},{"text":"w","code":true},{"text":" mode on a file you care about."}],[{"text":"Any path outside the folder you intended."}],[{"text":"Any network address: a script for local files should not be sending anything anywhere."}],[{"text":"Any request for a password, key or account credential."}]]},{"t":"p","runs":[{"text":"4. Never paste in a credential.","b":true},{"text":" If a script wants a password or an API key, that is a moment to stop and ask somebody, not a step to complete."}]},{"t":"p","runs":[{"text":"5. Do not run something you cannot explain in one sentence.","b":true},{"text":" If you cannot say what it does, ask for it to be explained until you can. “I don’t understand it but it worked” is how people lose a folder."}]},{"t":"h2","id":"checking-that-it-worked","runs":[{"text":"Checking that it worked"}]},{"t":"ul","items":[[{"text":"Count.","b":true},{"text":" 400 files in, 400 rows out. A short count is the commonest failure and the easiest check."}],[{"text":"Spot-check three.","b":true},{"text":" One from the start, one from the middle, one from the end. Open the original and compare."}],[{"text":"Look for empties.","b":true},{"text":" A column that is blank for 40 rows means the extraction failed for those, silently."}],[{"text":"Try a deliberate oddity.","b":true},{"text":" Put one badly formatted file in and see whether it is reported or ignored. A script that skips what it cannot parse without saying so is worse than one that crashes."}]]},{"t":"h2","id":"when-it-does-not-run","runs":[{"text":"When it does not run"}]},{"t":"p","runs":[{"text":"Paste the entire error message. Not a description of it: the whole thing, including the file name and line number. Add what you typed and what you expected. This is the context lesson applied to your terminal, and it usually resolves in one turn."}]},{"t":"h2","id":"the-free-path-and-what-it-costs","runs":[{"text":"The free path, and what it costs"}],"role":"free"},{"t":"p","runs":[{"text":"Python is free and pre-installed on macOS and most Linux systems; on Windows it is a small download. VS Code is free. So is everything you need for this."}]},{"t":"p","runs":[{"text":"The honest cost is that generated code often works on the happy path and fails on the ragged edges of real data: the file with no text layer, the row with a comma in the wrong place, the encoding that is not UTF-8. Expect to go two or three rounds, and expect the failures to be about your specific data rather than about the logic."}]},{"t":"h2","id":"where-to-stop","runs":[{"text":"Where to stop"}]},{"t":"p","runs":[{"text":"Anything touching production systems, customer data, payments, or a database somebody else depends on is not a place to run code you cannot read. That is not caution for its own sake: the failure mode there is not a lost afternoon, and the person who has to unpick it will not be you."}]}],"check":{"question":[{"text":"A user gets a script to tidy 400 invoice files. What is the single most important thing to do before running it?"}],"options":[{"text":[{"text":"Copy the folder and run it on the copy, with a dry run that prints what it would do."}],"correct":true,"tempting":null},{"text":[{"text":"Read the whole script to understand the logic."}],"correct":false,"tempting":[{"text":"Valuable and often not achievable for a beginner; a targeted read plus a copy achieves more with less."}]},{"text":[{"text":"Ask the model to confirm the script is safe."}],"correct":false,"tempting":[{"text":"A self-assessment from the party that wrote it, and no substitute for the copy."}]},{"text":[{"text":"Check that Python is the most suitable language for the task."}],"correct":false,"tempting":[{"text":"A preference question that has no bearing on whether the original files survive."}]}],"order":[3,2,0,1],"why":null},"prev":{"slug":"messy-spreadsheet-data","title":"The spreadsheet somebody else built","minutes":9},"next":{"slug":"learning-something-with-it","title":"Using it to learn, without fooling yourself","minutes":9}}}