← Prompt library

Python Automation Prompt: Dry Runs, Logs and Safe Changes

Design a small automation script with a dry-run mode, useful logs and clear boundaries. Test file operations on a disposable sample first.

Copyable promptPractical instructions
Python Automation Prompt: Dry Runs, Logs and Safe Changes

Illustrative cover; not a verified result from this prompt.

Read the full prompt

Write a Python [VERSION] script to automate [TASK] within [EXPLICIT INPUT LOCATION]. Explain inputs, outputs and failure cases first. Use a simple structure suited to the task, configuration only where useful and a clear CLI. For file changes, include a dry-run option, collision handling and a record of intended actions. Do not delete originals by default. Add tests for important boundary cases and document dependencies. State which behavior remains untested.

Define what the script is allowed to change

Specify the input folder, allowed file types and expected output. “Organize my files” is too broad when the script can rename or move valuable data. A dry run should report proposed actions without performing them.

Example: rename scanned receipts

Use a disposable folder containing receipt-1.pdf, receipt-2.pdf and notes.txt. Ask to copy only PDF files into a new output folder using names such as receipt-001.pdf. Keep originals untouched and stop or choose a documented alternative if a destination name already exists.

Check that notes.txt is ignored and that running the script twice does not overwrite a previous result unexpectedly. Use a filename containing spaces to catch path-handling mistakes.

Review the logs and failures

Logs should identify which file failed and why without exposing document contents. Test a missing folder, a read-only destination and an empty input set. Simple functions may be clearer than a class hierarchy for a small task. Only run against your real folder after the sample output and rollback approach are understood.