Learn AI Curriculum Cookbook

Ship Something 20 min

Build · A personal script

A Python tool on your machine via a coding CLI. ~20 min.

You'll build a real Python CLI on your machine via a coding CLI. The assistant will read files, run commands, and write the script — asking for your approval each time. Finished result: a tool that organises a folder of photos by date.

0 of 10 steps
1

Install a coding CLI (one of)

Pick the one you'd use day-to-day. All work similarly.

Quick install commands
# Claude Code:
npm install -g @anthropic-ai/claude-code

# Codex CLI:
npm install -g @openai/codex

# aider:
pip install aider-chat
You should see

Running the CLI prints help (e.g. claude --version works). If install fails, ask the CLI itself for help once it's running — they're great at fixing their own setup issues.

2

Sign in / set your API key

Claude Code and Codex open a browser for OAuth on first run. aider reads an env var.

If using aider
export ANTHROPIC_API_KEY=sk-ant-…   # or OPENAI_API_KEY for GPT models
You should see

The CLI shows a prompt waiting for you to type. No auth errors.

3

Make a fresh project folder

In your terminal:

Shell
mkdir ~/photo-renamer && cd ~/photo-renamer
You should see

You're in an empty directory. ls returns nothing.

4

Start the CLI in this folder

Run whichever you installed. The CLI now sees only this folder.

Pick one
claude
# or
codex
# or
aider
You should see

An interactive prompt — or similar — ready for your first instruction.

5

Paste the build prompt

Copy and paste this whole block. Hit Enter.

Build prompt
Write a Python script called rename.py that I'll run as:

    python rename.py <folder>

Behavior:
- Find every .jpg, .jpeg, .png file (case-insensitive) in <folder>.
- For each, read the EXIF DateTimeOriginal. If missing, fall back to the file's mtime.
- Sort all files by that date, ascending.
- Build a new filename: YYYY-MM-DD__NNN.ext (NNN is a zero-padded 3-digit counter per day, restarting at 001 each new date).
- Before renaming anything, print a clear plan: "old → new" for every file, then ask "Proceed? [y/N]" and read one line of stdin.
- If the answer isn't 'y' or 'Y', exit without changes.
- After renaming, print a one-line summary: "Renamed N files."

Implementation notes:
- Single .py file. Use Pillow for EXIF (or piexif if Pillow isn't available); install via pip.
- No external dependencies beyond Pillow.
- No destructive operations other than the renames the user just approved.
- Handle the case where two files would get the same target name (don't overwrite — print an error and abort).

After writing the script, create a samples/ folder with two empty .jpg files (use touch), then run the script against samples/ as a smoke test. Answer 'n' to the proceed prompt so nothing is renamed — we just want to see the plan.
6

Approve tool actions as they come up

The CLI will ask for permission before each side-effect:

  • Write rename.py — allow
  • Run pip install Pillow — allow (or run yourself)
  • Run mkdir samples / touch samples/*.jpg — allow
  • Run python rename.py samples — allow

Read each prompt before saying yes. This is the whole safety model — never click through blindly.

You should see

You see the CLI write the file, install Pillow, create samples/, run the script, and print a "would rename" plan. You answer 'n' to its proceed prompt; nothing actually changed.

7

Run it on real photos

Open a separate terminal (or exit the CLI with Ctrl+C twice). Then:

Real test
cd ~/photo-renamer
python rename.py ~/Pictures/SomeFolder
You should see

The plan shows old → new for every photo. Answer 'y' if you want to commit; 'n' to bail.

8

Add --dry-run

Go back into the CLI (it's still in the same folder). Ask for an enhancement:

Iteration 1
Add a --dry-run flag. When set, do everything you'd do up to the "Proceed?" prompt but never actually rename — just print the plan and exit. Update the README block at the top of the file to document the flag.
You should see

The CLI edits rename.py in place. Test it: python rename.py samples --dry-run — should print the plan and exit without prompting.

9

Add thumbnails (optional)optional

One more, for fun:

Iteration 2
Add a --thumbs flag. When set, after a successful rename, generate a 200x200 thumbnail of each renamed image into a thumbs/ subfolder of the input folder, preserving the new filename (so 2026-05-21__001.jpg becomes thumbs/2026-05-21__001.jpg). Skip thumbnails for non-image files. Use Pillow.
You should see

After a real rename, a thumbs/ folder appears with 200×200 JPEGs.

10

Make it a real tool

Add a one-line shebang and put it on your PATH:

Make it runnable
# In rename.py, add to the very top:
#!/usr/bin/env python3

# Then:
chmod +x rename.py
mv rename.py ~/.local/bin/photo-renamer

# Now from anywhere:
photo-renamer ~/Pictures/SomeFolder --dry-run
You should see

You typed photo-renamer … from any folder and it just worked. You shipped a CLI tool.

What you just learned. Building real tools with a coding CLI follows the same loop: prompt → review the plan → approve actions → test → iterate. The tools you build are yours forever — no subscription, no platform lock-in. Commit them to git the moment they're useful.