Using Claude Code for One-Off Scripts

Automation scripts are where Claude Code pays for itself fastest. Here's the workflow.

The highest return-on-investment use of Claude Code, in my experience, is one-off scripts. Not application code — scripts. Data migrations, bulk operations, file transforms, report generators, cleanup utilities.

Scripts have low stakes for review mistakes (they usually run once on non-production data first), clear success criteria (did it produce the right output?), and a well-defined scope. Claude produces good scripts quickly.

What to include in a script prompt

Scripts need even more specific input/output specs than application code because they often transform data, and getting the transformation wrong silently is the worst outcome.

Good script prompt format:

Write a Node.js script that:
- Reads [input file/source]
- Does [transformation/operation]
- Outputs [what, where, in what format]
- Logs [what progress information]
- Handles [specific error cases]

Sample input:
[paste a few rows or examples]

Expected output for that sample:
[paste what the output should look like]

The sample input/output is the most important part. It removes ambiguity about the transformation and gives Claude a concrete test case to verify against.

Always add a dry-run flag

For any script that modifies data, I ask Claude to add a --dry-run flag that prints what would happen without doing it. This is low-effort to add and high-value for safety. Run with --dry-run first, review the output, then run for real.

For data migrations: add a --limit flag

Process the first 10 rows, verify they're correct, then run the full set. Adding a --limit N parameter to migration scripts is something I ask for on every data operation. Bugs in bulk operations are expensive. Bugs on 10 rows are cheap.

Progress logging matters

For scripts that process thousands of records, I ask Claude to add progress logging every N records. "Processed 1000/50000 records" lets you know the script is running and estimate completion time. Without it you're staring at a blank terminal hoping it's not stuck.

The scripts that aren't worth doing by hand anymore

Each of these would take 30-60 minutes to write correctly by hand. With Claude, it's 5-10 minutes including review and testing.