Every Friday afternoon, someone in your organization compiles a weekly report. They pull numbers from a CRM, a project management tool, and a spreadsheet. They copy the numbers into a template. They write a few sentences of narrative. They email it to a distribution list. The entire process takes 2 to 3 hours.
On Monday, the recipients glance at the report for 30 seconds and go back to their work. The 2-3 hours of compilation produced 30 seconds of attention.
This tutorial shows you how to automate the compilation, generate the report, and send it — all with Claude Code in one afternoon.
What you need before you start
You need three things: access to the systems that contain your data, a clear understanding of what the report contains, and Claude Code installed on your machine.
For this tutorial, I will use a common scenario: a weekly sales report that pulls data from a CRM (we will use HubSpot's API as the example), a project tracker (Asana's API), and a Google Sheet that contains targets. The same approach works for any combination of data sources that have APIs or export capabilities.
If your systems do not have APIs, you can still automate. Export your data as CSV files on Friday morning, and the tool reads the CSVs instead of calling APIs. The automation is not as seamless, but it still eliminates the manual compilation step.
Step 1: Describe the report to Claude Code
Open Claude Code in a new project directory and describe what the report contains:
"I need to build a weekly reporting tool. Every Friday, it should generate a report that contains: total new deals created this week from HubSpot, total deal value of closed-won deals this week, number of active projects from Asana with their status, actual versus target comparison from a Google Sheet, and a 4-week trend showing the same metrics for the past four weeks."
"The output should be an HTML email that I can send to my team. It should include a summary section at the top with the key numbers, a trend section with a simple table showing the 4-week history, and a brief auto-generated narrative that highlights what went up and what went down compared to last week."
Claude Code will start building. It will create the API connection files, the data retrieval functions, the report template, and the email generation logic. Let it work through the first pass.
Step 2: Set up the data connections
Claude Code will need API credentials for each system. For HubSpot, you will need an API key or private app access token. For Asana, you will need a personal access token. For Google Sheets, you will need a service account with access to the sheet.
Tell Claude Code: "I have my HubSpot API key, Asana token, and Google Sheets credentials. Set up environment variables for each one and show me where to put them."
Claude Code will create a .env file structure and show you where to paste each credential. It will also create the API client files that use those credentials to fetch data.
Test each connection: "Run the HubSpot connection and show me this week's deals." Verify the data matches what you see in HubSpot. Do the same for Asana and Google Sheets. Getting the connections right is the most important step. Everything after this is formatting.
Step 3: Build the report template
Once the data connections work, tell Claude Code what the report should look like:
"The report email should have a clean, professional design. At the top, show the four key metrics in large numbers with arrows indicating up or down compared to last week. Below that, show a table with the 4-week trend. Below the table, write two to three sentences summarizing the notable changes. Use green for improvements and red for declines. Keep it simple — no charts, just numbers and arrows."
Claude Code will build the HTML email template with the styling, the data insertion points, and the narrative generation. Review the output. If the layout is not right, describe what you want changed: "Move the trend table above the narrative. Make the metric numbers bigger. Add the percentage change next to each arrow."
Step 4: Generate the narrative
The narrative section is where AI adds the most value beyond simple automation. Tell Claude Code:
"The narrative should compare this week to last week and highlight the most significant changes. If new deals increased by more than 20%, mention it as a strong week for pipeline. If closed-won value dropped, note it and mention whether the pipeline suggests recovery next week. Keep the tone professional and brief — three sentences maximum."
This narrative is generated from the data, not from a template. It adapts to what actually happened. A week where everything improved gets a different narrative than a week where deals increased but revenue dropped. The recipients read the narrative in 10 seconds and know whether to dig into the details.
Step 5: Automate the send
Tell Claude Code: "Set this up to run every Friday at 4 PM and email the report to this list of recipients: [your list]. Use nodemailer with our SMTP settings."
Claude Code will create the scheduling logic and the email sending function. For a simple setup, this can be a cron job on your machine or a scheduled task. For a more robust setup, Claude Code can deploy it as a small server that runs the job on schedule.
Test it by running the report manually: "Generate and send the report now so I can verify it looks correct." Check your inbox. Review the numbers against the source systems. Verify the narrative makes sense.
Step 6: Handle edge cases
After the first report sends successfully, think about what can go wrong:
"What happens if the HubSpot API is down on Friday afternoon? Add a retry that tries three times with a 5-minute delay. If all three fail, send me an alert email instead of the report."
"What happens during a week with no closed deals? Make sure the report handles zero values gracefully and the narrative says something appropriate instead of calculating a negative-infinity percentage change."
"What happens on a holiday week when Friday is a day off? Add a configuration option to run the report on Thursday instead when I set a flag."
Each of these instructions produces a specific improvement to the tool. After addressing the edge cases, the tool is robust enough to run unattended.
What you built in one afternoon
In 3 to 4 hours, you built a tool that replaces 2 to 3 hours of work every Friday. The tool pays for itself in the second week. By the end of the month, you have recovered 8 to 12 hours.
But the real value is not the time savings. The real value is consistency. The tool generates the report the same way every week. It never forgets a metric. It never transposes a number. It never delays the report because someone had a busy Friday.
The recipients get a better report because the data is always current, the comparisons are always accurate, and the narrative is always based on what actually happened rather than what the report compiler remembered to mention.
What to automate next
Once you have automated one report, you will see other reports that follow the same pattern: pull data from multiple sources, format it consistently, and distribute it on a schedule. Monthly board reports. Daily operations summaries. Quarterly client reviews.
Each one follows the same steps: describe the report, connect the data sources, build the template, generate the narrative, automate the send. The first report takes an afternoon. The second takes 2 hours. The third takes an hour. The pattern accelerates because you have already solved the common problems.
Get posts like this in your inbox
No spam. New articles on AI strategy, governance, and building with AI for small business.
Keep Reading
How to set up CLAUDE.md for your project: a practical guide with real examples
CLAUDE.md is the file that tells Claude Code how to behave in your codebase. Here is exactly what to put in it, what to leave out, and why the decisions matter.
Tutorial: Build a Claude Code project from zero to deployed in one session
A step-by-step walkthrough of starting a Next.js project with Claude Code, building a real feature, and deploying it to production. No shortcuts, no magic, just the actual process.