Prompts producing Python programs.
28votes
0answers
4.2kviews

One prompt for a polite, resumable web scraper that won't get me IP-banned

I needed to pull a few thousand product pages for a price-history side project. My first scraper hammered the site with 50 concurrent requests, got a 429, then kept retrying instantly and made it wors
26votes
1answers
2.2kviews

Prompt for a pandas cleaning script that validates the schema before it trusts the CSV

I get monthly CSV exports from a vendor and the columns silently drift: a header gets renamed, a numeric column arrives with stray $ and commas, dates flip between MM/DD and DD/MM. My old script assum
24votes
2answers
3.0kviews

Prompt that writes the migration AND a reversible down-migration, not just the ALTER

Models are great at spitting out ALTER TABLE statements and terrible at remembering that migrations run on live data with existing rows. I got burned adding a NOT NULL column with no default to a tabl
23votes
2answers
2.9kviews

Prompt for a log-tailing CLI that parses, filters, and summarizes without loading the whole file

I wanted a small tool to slice gigabyte-sized JSON-lines logs by level and time range and print a summary, but the first version the model gave me did open(f).read() and json.loads on the whole thing,
22votes
1answers
2.2kviews

Debugging an intermittent asyncio race the model kept papering over

Had a flaky test that failed maybe 1 in 30 runs. Every model I tried "fixed" it by adding an await asyncio.sleep(0.1) somewhere, which is not a fix, it is a bribe. The real bug was two coroutines muta
20votes
1answers
5.2kviews

Bounding concurrency in an asyncio scraper so I stop opening 5000 sockets at once

I asked for an async version of a fetcher and the model gleefully did await asyncio.gather([fetch(u) for u in urls]) over 5000 URLs. It opened every connection simultaneously, the event loop thrashed,
18votes
2answers
3.1kviews

Prompt for a production-grade Python CLI with argparse, exit codes, and a self-check

Every weekend project starts with me asking a model for "a Python script that does X" and getting back a 20-line toy: no argument parsing, prints stack traces at users, returns 0 even when it failed.
18votes
1answers
2.2kviews

Prompt for docstrings that document the WHY and the gotchas, not just the params

Auto-generated docstrings are useless: they restate the function signature in English. def add(a, b): """Adds a and b.""". Thanks. I wrote a prompt that reads the function body and forces it to docume
17votes
1answers
2.4kviews

Safely refactoring a 600-line god-function CLI without changing its behavior

Inherited a single def run() that was 600 lines: arg parsing, file IO, business logic, and printing all tangled together. Management wanted features added but touching it was Russian roulette. Asking
16votes
1answers
1.7kviews

Prompt for a CSV-to-chart tool that picks the chart type instead of me

I wanted an internal tool where an analyst pastes any CSV and gets a defensible chart without choosing a type. My first attempt just always drew a bar chart, which is nonsense for two numeric columns.
13votes
0answers
1.5kviews

Making the model generate a config loader with validation instead of raw os.environ reads

Half our incidents traced back to config: an env var typo'd to an empty string, a port that was actually the literal text "8080" compared against an int, a feature flag that was the string "false" (wh
12votes
0answers
1.3kviews

Measure-before-optimize prompt so the model stops tuning cold code

I asked a local Llama-3 70B to "make this data pipeline faster" and it micro-optimized a list comprehension that runs once at startup while ignoring the O(n^2) join in the hot loop. Textbook: it optim
12votes
1answers
1.4kviews

Prompt for a bulk file-rename CLI with a regex, a dry-run, and collision detection

Batch renaming is exactly the kind of task where a model gives you a confident three-liner that renames files in a loop and, halfway through, renames a.txt to b.txt on top of an existing b.txt, or ren
10votes
3answers
2.0kviews

Prompt for an idempotent cron/systemd maintenance script that's safe to run twice

Our nightly cleanup job used to assume it ran exactly once and finished. Then a run overlapped with the next one, they both deleted the same temp files, and one crashed mid-way leaving a half-cleaned
9votes
1answers
1.7kviews

Forcing the model to write the failing test first instead of the impl

I do strict TDD and I wanted the model to do it with me, not for me. Default behavior with GPT is: ask for a feature, get the implementation plus some tests it wrote to match the code it just wrote. T