Lesson 5.4 — Multi-Step Agents: Plan, Act, Check
Introduction to AI · Module 5: AI Agents · About 90 min · Windows PC, PowerShell 5, Claude Code (Max)
Goal: have an agent plan first, then turn a folder of receipts into a CSV plus a one-page summary, with 2 or fewer interventions from you.
Before you start
Step 1 · Make 10 fake receipts (⏱ 0:00–0:10)
Paste the whole block:
mkdir receipts -Force | Out-Null
$data = @(
"2026-10-01,Woolworths,Groceries,84.20",
"2026-10-03,Shell,Fuel,71.50",
"2026-10-05,Bunnings,Home,39.98",
"2026-10-08,Coles,Groceries,62.15",
"2026-10-10,Energex,Utilities,188.40",
"2026-10-12,Chemist Warehouse,Health,23.99",
"2026-10-15,Ampol,Fuel,68.00",
"2026-10-18,Aldi,Groceries,45.60",
"2026-10-21,Telstra,Utilities,89.00",
"2026-10-24,Kmart,Home,27.50")
$i = 1
foreach ($d in $data) {
$f = $d.Split(",")
"RECEIPT`r`nStore: $($f[1])`r`nDate: $($f[0])`r`nItems: assorted`r`nTOTAL AUD `$$($f[3])" |
Out-File ("receipts\r{0:D2}.txt" -f $i) -Encoding utf8
$i++
}
(dir receipts).CountYou should see 10. Open one with notepad receipts\r01.txt to see what a receipt looks like.
Step 2 · Write the checker (⏱ 0:10–0:20)
@'
$ok = $true
if (-not (Test-Path out\receipts.csv)) { "missing out\receipts.csv"; $ok = $false }
else {
$rows = @(Import-Csv out\receipts.csv)
if ($rows.Count -ne 10) { "expected 10 rows, got $($rows.Count)"; $ok = $false }
foreach ($c in "date","store","category","total") {
if (-not ($rows[0].PSObject.Properties.Name -contains $c)) { "missing column $c"; $ok = $false } }
$sum = ($rows | % { [double]$_.total } | Measure-Object -Sum).Sum
if ([math]::Abs($sum - 700.32) -gt 0.01) { "total is $sum, expected 700.32"; $ok = $false }
}
if (-not (Test-Path out\summary.md)) { "missing out\summary.md"; $ok = $false }
if ($ok) { "PASS" } else { "FAIL" }
'@ | Out-File check-receipts.ps1 -Encoding utf8
.\check-receipts.ps1You should see missing out\receipts.csv, missing out\summary.md and FAIL. Correct for now.
Step 3 · Plan mode first (⏱ 0:20–0:35)
claudePress Shift+Tab until the bottom of the screen says plan mode. Then type:
Read every file in receipts\. Create out\receipts.csv with columns
date,store,category,total (categories: Groceries, Fuel, Home, Utilities, Health)
and out\summary.md (one page: total spend, spend per category, biggest purchase,
one money tip). Then run .\check-receipts.ps1 and fix anything until it prints PASS.
Never edit or delete files in receipts\.You should see a numbered plan. Read it. Is anything missing or wrong? If so, say so (that counts as 1 intervention).
Step 4 · Let it execute (⏱ 0:35–1:05)
Approve the plan (choose the option to proceed). Watch the loop: read → write → check → fix. Approve tool use when asked. Approving doesn't count as an intervention; correcting it does.
When it reports PASS, leave Claude: **type /exit and press Enter. Wait until you see PS C:\...> before the next command.** Then confirm:
.\check-receipts.ps1
Import-Csv out\receipts.csv | Format-TableYou should see PASS and a 10-row table.
Step 5 · Open in Excel and read the summary (⏱ 1:05–1:15)
start out\receipts.csv
notepad out\summary.mdYou should see 10 rows in Excel, and a summary showing a total of $700.32 with the biggest purchase being Energex $188.40.
Step 6 · Reflect (⏱ 1:15–1:25)
- Interventions used: ____ (target ≤ 2)
- What did planning first change? ______________________
✅ Pass check
Troubleshooting
| Problem | Fix |
|---|---|
| Can't find plan mode | Press Shift+Tab repeatedly (it cycles modes). Or just start with: "First write a plan and wait for my OK." |
| Total is wrong | Tell it: "the checker says the total is X; re-read each receipt and fix it." (1 intervention) |
| Excel shows everything in one column | Your region uses a different list separator. Use Data → From Text/CSV and choose comma. |
| Running scripts is disabled | Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, then Y. |
Finish this lesson
Nice work! Pick your next step: