Back to Recipe Book
Coding 🍳 Home Cook

Turn Ideas into Working Python Scripts

Describe what you want to automate β€” get back a production-ready Python script with type hints, docstrings, robust error handling, and modular design.

Best for Automation tasks, data processing scripts, API integrations, CLI tools, anything you want to build in Python
When to use When you know what you want the script to do but want clean, maintainable code instead of something that only works once
Pythonautomationscriptingsoftware engineeringclean codetype hints

The difference between a script that works and a script that’s maintainable comes down to a handful of engineering standards: type hints, proper error handling, modular structure, and clear documentation. This recipe applies all of them by default.

The Recipe

Act as an expert Python Automation Engineer and Solutions Architect. I have an idea for a script/tool, and I want you to write a clean, production-ready, Pythonic script to implement it.

My idea/requirements are: [INSERT DETAILS HERE]

Please write the script adhering to the highest professional software standards:
- Type Hinting & Docstrings: Use explicit type hints (PEP 484) and clear Google-style docstrings for every function.
- Error Handling: Avoid bare except: blocks. Wrap external I/O, API calls, or data transformations in robust try-except blocks with meaningful logging or fallback mechanisms.
- Modular Design: Break the logic into single-responsibility functions or classes rather than one giant procedural script.
- Virtual Environment & Dependencies: Include a commented-out section at the very top listing the required external libraries and the exact command to install them.

Ensure the code is clean, deeply commented, and ready to copy-paste into an IDE.

What each standard actually does for you

StandardWhy it matters
Type hintsCatches errors in your IDE before runtime; makes function signatures self-documenting
Google-style docstringsTells the next person (or future-you) what every function expects and returns
Specific exceptionsBare except: swallows bugs silently; named exceptions make failures debuggable
Single-responsibility functionsEach function does one thing β€” easier to test, easier to change
Dependencies block at topNobody has to grep the file to figure out what to pip install

How to write a good requirements description

Vague: β€œA script that processes CSV files.”
Good: β€œA script that reads a CSV file of customer records, validates that the email column is a valid email format, deduplicates rows by email address, and writes the cleaned output to a new CSV. Should log how many rows were removed and why.”

The more specific the input, the more directly the script maps to your actual problem.

πŸ” Leftover Remixes

🌢️ Spicy: β€œNow add a CLI interface using argparse so I can pass the input file path and output path as command-line arguments, with sensible defaults and a β€”verbose flag.”

🧊 Mild: β€œWrite just the core processing function β€” not the full script. I’ll wire it in myself.”

πŸ’° Budget: β€œWhat’s the Pythonic way to handle [specific pattern] β€” with and without a library?”