Handing a weekly spreadsheet chore to Claude Code

Christian Drexler

Every company has one of these. An export lands in a folder on Monday, somebody opens it, pastes it into the right tab of a sheet, adds a week column, fixes the three rows that always come in wrong, and sends the totals to whoever asked. Forty minutes, every week, nobody's actual job. It never gets automated properly because it is just slightly too fiddly for a script and just slightly too boring for a person to keep doing well.

This is the shape of task that Claude Code is good at, provided you do one thing first: write the procedure down as if for a new hire who starts next week and cannot ask you anything.

The procedure file

One markdown file in the folder where the export lands. It says what the inputs are, where they come from, what each step does, what the finished result looks like, and how to tell whether it is right. The last part is the one most people skip, and it is the only part that matters.

# Weekly merge

Input: the newest file matching export-*.csv in ./inbox
Target: ./weekly.xlsx, tab "raw", append below the last row
Steps:
1. Add a column "week" = ISO week of the file date.
2. Rows where "amount" is empty: set 0, note the row id in ./log.md.
3. Append. Never overwrite existing rows.
Done when:
- row count in "raw" grew by exactly the input's row count
- sum of "amount" in the appended rows equals the input's sum
- ./log.md has today's entry

The agent runs with that file as its brief. claude -p "Follow PROCEDURE.md" from a scheduled job on Monday morning, output to a log. That is the entire integration. No API wiring, no custom tool, no framework.

The check is a script, not a sentence

"Done when" in prose is good for a human and useless for a loop. So the three conditions also exist as a tiny Python script that reads the input and the target and exits non-zero if any of them fails. The agent runs it as its last step. If the check fails, the run is marked failed in the log and nothing is sent; a person looks at it. If it passes, the totals go out.

The point of splitting the check from the work is that the thing doing the work should not be the thing grading it. An agent that is asked "did you do this right" will say yes. A script that counts rows does not have an opinion.

The first three weeks

I read every result for the first three runs, side by side with the input. Not because the agent gets it wrong, but because the procedure is wrong in ways I only see when the result is in front of me. Week one it put the week number in the wrong format. Week two the export had a new column and the procedure did not say what to do with new columns. Each time the fix went into the procedure file, not into a conversation. By week four the file was complete enough that I stopped reading and started trusting the check.

That is the actual lesson. The agent is not the asset. The procedure file plus the check are the asset, and they get better every time the task runs, which is the opposite of how a chore normally behaves.

The longer version, with the full procedure template and what to do when the input format changes under you, is on LogOffEarly.