Codex CLI script builder — describe the automation, get the script
Tell Codex what you want to automate in plain English and it writes the complete script — with argument parsing, error handling, progress output, and dry-run mode — ready to run without cleanup.
Paste into the Codex CLI: 'Write a [bash / Python / Node.js] script that does the following: TASK: [DESCRIBE THE AUTOMATION IN PLAIN ENGLISH] INPUTS: [What the script takes — files, directories, API keys, user arguments] OUTPUTS: [What it produces — files, API calls, stdout, exit codes] Environment: [OS, any dependencies already installed, credentials available as env vars] The script must include: 1. ARGUMENT PARSING: - Named flags for every configurable option (e.g. --input, --output, --verbose) - A --help flag that prints usage - A --dry-run flag that logs what WOULD happen without making changes 2. INPUT VALIDATION: - Check that required arguments are provided before doing any work - Validate file paths exist before reading; validate directories before writing - Exit with a non-zero code and a clear error message on any validation failure 3. PROGRESS OUTPUT: - Print what the script is doing at each major step - For batch operations, show progress (e.g. "Processing 3/47: filename.csv") - In --verbose mode, print additional detail 4. ERROR HANDLING: - Catch errors from external calls (API, file I/O, subprocess) - On error: print the specific failure, clean up any partial output, exit with code 1 - Never silently swallow an error 5. IDEMPOTENCY: - The script should be safe to run twice on the same input without corrupting output - Skip or overwrite (with a logged warning) rather than duplicating or crashing Output only the script — no explanation, no markdown code block, just runnable code.' Tip: start by describing the task in one messy sentence — Codex handles ambiguity better than most engineers expect; then refine by saying 'add a --filter flag that only processes files matching [pattern]' to iterate on the spec without rewriting from scratch.
- Source
- promptfork seed
- License
- CC-BY-4.0
- Published
- 6/22/2026