Stop 6 of 9 · Weekly
The report pipeline with Claude Code
Describe the twelve-client report job once, let Claude Code build the script, and put a QA step in front of every run.
What it is
Nour writes twelve reports in the first week of every month. Same sections, same math, same file shapes. That is not a chat job, it is a script, and she does not have to write it. Claude Code is Claude working over the files on a machine rather than in a chat, and she describes the job the way she would to a junior who happens to type very fast.
What the job actually is
Before anything is built, the job gets written down: where the exports are, what the file shapes are, what each report must contain, and what happens when something is missing. Vagueness here becomes a bug later.
- Input: exports/ with one folder per client code, each with google.csv, meta.csv and ga4.csv.
- Last month for comparison: exports-prev/ with the same shape.
- Output: reports/C01.md and so on, in the section order of template.md.
- Missing file: write the section with a missing marker rather than failing the run.
The folder exports/ has one subfolder per client code (c01 to c12), each containing google.csv, meta.csv and ga4.csv. exports-prev/ has last month in the same shape. template.md has the section order our reports use. Write report.py. For each client: spend, leads and cost per lead by platform and blended, compared with last month, plus the three campaigns with the largest change in dollars. Write reports/<code>.md following template.md exactly. If a file is missing, write [missing: platform] into that section and keep going. Also write qa.md each run: any client whose blended cost per lead is zero, negative or above $500, any client whose platform totals do not sum to the blended figure, any missing file, and any month over month change above 40 percent. Run it on c01 and c02 only and print both reports and the QA file so I can check them against the platform.
The QA step
The QA file is the point of the whole pipeline. A script that produces twelve plausible reports without one is more dangerous than doing the work by hand, because plausible is exactly what a wrong number looks like at speed. Nour reads qa.md before she reads any report, and the pipeline is allowed to grow only after a month where the QA file caught something she would have missed.
C02 blended cost per lead came out $4 above the platform, which shows $86.40. I think the script is counting the offline conversion import twice. Find it, fix the script rather than the output, rerun c02 and show me the rows behind the new figure.
Read report.py and tell me the three things most likely to produce a wrong number without failing the run. For each, add a check to qa.md and show me the line you added.