I used to spend about 90 minutes a week on invoicing. Not the billing itself — that's fast — but the admin work around it. Generating the invoice in a template, filling in hours and line items, exporting to PDF, sending it with the right subject line and message, updating my tracker, and following up two weeks later if it hadn't been paid. Multiply that by four clients and it was six hours a month of work I couldn't bill for.
Last year I built an invoice automation system with Claude Code that handles all of it. From generating the invoice to sending it and tracking payment status, the whole process now runs on a script I trigger once at the end of each billing cycle. Here's exactly how I did it, and how you can build the same system for your business.
Why I Stopped Using Invoice Automation Software
Before building my own system, I tried three different SaaS tools: FreshBooks, Wave, and Bonsai. They all worked fine for the basics — creating invoices, sending reminders, accepting payments — but each one had the same problem: I was paying $15–$30 per month for features I didn't need, and the features I did need required custom workflows I couldn't automate without upgrading to enterprise tiers.
The breaking point was realizing that my invoicing needs were extremely simple. I bill the same clients every month, the line items follow the same structure, and I don't need fancy payment gateway integrations because most of my clients pay via Interac e-Transfer or direct deposit. What I needed was a way to turn a spreadsheet of hours into a professional PDF invoice and send it automatically. That's it.
Claude Code gave me that in about four hours of build time. No monthly fees. Full control over the template, branding, and delivery logic. And because it's all running locally, I'm not handing my client data to a third party.
The Core Components of the System
The invoice automation system I built has three main parts:
- Invoice data storage — a simple JSON file that tracks client info, hourly rates, line items, and payment status
- Invoice generation script — reads the JSON, renders an HTML template with the client's branding and line items, and exports it as a PDF
- Email delivery script — attaches the PDF, customizes the email body based on the client, and sends it via SMTP
Each piece is modular, which means I can update the invoice template without touching the email logic, or change how invoices are stored without breaking the PDF generator. That modularity has made it easy to iterate — I've added features like automatic tax calculation and late payment tracking without rewriting the core system.
Step 1: Structuring Your Invoice Data
The first thing I did was move my invoice data out of spreadsheets and into a structured JSON format. Each invoice is an object that looks like this:
{
"invoiceNumber": "INV-2026-042",
"clientName": "Acme Industries",
"clientEmail": "billing@acmeindustries.com",
"issueDate": "2026-06-01",
"dueDate": "2026-06-15",
"lineItems": [
{ "description": "AI Consulting (May 2026)", "hours": 12, "rate": 150, "amount": 1800 },
{ "description": "Claude Code implementation", "hours": 8, "rate": 150, "amount": 1200 }
],
"subtotal": 3000,
"tax": 150,
"total": 3150,
"paymentStatus": "pending"
}
This structure makes it easy to automate calculations. Claude Code reads the line items, multiplies hours by rate, sums the amounts, applies tax, and outputs the total. No manual math errors.
For businesses with more complex billing — retainer clients, project milestones, expense reimbursements — you can extend the schema. The key is to keep the data consistent so the generation script doesn't have to handle edge cases every time.
Step 2: Building the Invoice Template
Once the data is structured, the next step is designing the invoice layout. I use an HTML template because it's easier to style than a PDF library's native syntax, and conversion to PDF is straightforward with tools like Puppeteer or wkhtmltopdf.
The template includes my logo, business address, client details, a table of line items, subtotal and tax calculations, payment instructions, and terms. Claude Code fills in the placeholders with data from the JSON object:
<h1>Invoice #{{invoiceNumber}}</h1>
<p>Issued: {{issueDate}} | Due: {{dueDate}}</p>
<table>
<thead>
<tr><th>Description</th><th>Hours</th><th>Rate</th><th>Amount</th></tr>
</thead>
<tbody>
{{#each lineItems}}
<tr>
<td>{{description}}</td>
<td>{{hours}}</td>
<td>${{rate}}</td>
<td>${{amount}}</td>
</tr>
{{/each}}
</tbody>
</table>
<p>Subtotal: ${{subtotal}}</p>
<p>Tax (5% GST): ${{tax}}</p>
<p><strong>Total Due: ${{total}}</strong></p>
The script processes this template, injects the data, and renders a clean, professional invoice. I've tested it with clients in multiple industries and the feedback has been consistently positive — it looks more polished than the invoices I used to generate manually in Google Docs.
Step 3: Automating PDF Export
To convert the HTML invoice into a PDF, I use Puppeteer, a Node.js library that runs a headless Chrome browser. The script loads the rendered HTML, formats it for print, and saves it as a PDF with the invoice number as the filename.
The entire export process takes about two seconds per invoice. For a batch of 10 invoices, it's done in under 30 seconds — faster than I could manually export a single invoice from a SaaS tool.
One detail worth mentioning: I configure the PDF to include proper margins, page breaks, and a footer with my business name and contact info. These small touches make the invoice look like it came from a professional service, not a script.
Step 4: Sending Invoices via Email
The final piece is email delivery. I use Nodemailer, a library that handles SMTP connections, to send invoices directly from my business email account. The script reads the client's email address from the JSON object, attaches the PDF, and sends a customized message.
The email template varies slightly by client. For recurring clients, I use a shorter, more casual tone. For new clients or larger invoices, I include payment instructions and terms. Claude Code helps me maintain multiple email templates and select the right one based on the client's history.
I also added a tracking feature: when an invoice is sent, the script updates the JSON file with a "sentDate" field and sets "paymentStatus" to "sent". Two weeks later, if the status is still "sent" and not "paid", a follow-up reminder email goes out automatically.
What This System Can't Do (Yet)
This setup handles 90% of my invoicing needs, but there are a few things it doesn't do that a full SaaS platform would:
- Payment processing — I don't accept credit cards, so I haven't built Stripe or PayPal integration. If you need that, you'd add an API call to generate a payment link and include it in the invoice.
- Automatic payment reconciliation — I still manually mark invoices as "paid" when the money hits my account. Automating this would require connecting to my bank's API, which is more complexity than I need right now.
- Multi-currency support — All my clients pay in CAD. If you invoice internationally, you'd need to add currency conversion logic and localized tax rules.
None of these are hard to add — they're just features I haven't needed yet. The beauty of owning the system is that I can extend it whenever a new requirement comes up, without waiting for a vendor to ship an update.
Key Takeaways for Building Your Own System
If you're thinking about automating invoicing with Claude Code, here's what I'd recommend:
- Start with a single client — build the system for one invoice first, make sure it works end-to-end, then scale to your full client list
- Use a standard invoice format — the simpler your template, the easier it is to automate; resist the urge to over-design
- Store invoice data in a structured format from day one — don't try to parse spreadsheets or PDFs; use JSON or a simple database
- Test email delivery carefully — send test invoices to yourself before going live; small mistakes in SMTP config can cause emails to land in spam
The entire system took me about four hours to build and another two hours to refine based on feedback from the first month of use. Since then, it's saved me roughly six hours a month, which compounds to 72 hours a year — almost two full work weeks I can now bill to clients instead of spending on admin.
If you want to see how this kind of automation could work in your business, I walk through setups like this in my AI implementation engagements. And if you have questions about whether invoice automation makes sense for your billing model, the FAQ page covers a lot of the common scenarios.
The best part about building your own invoicing system is that it grows with you. No feature limits, no per-user fees, no vendor lock-in. Just a script that does exactly what you need, every time you run it.