An overnight inventory agent that catches stockouts before the team wakes up
We built a Claude Code agent that runs at 23:00 AEST every night, audits the brand's Shopify inventory, and posts findings to Slack. ~$5 AUD/month to run.
Overnight Shopify stockouts and image gaps were getting caught hours after they should have been, by the team's morning standup at 9am AEST instead of when the data was actually fresh.
An overnight agent now flags everything before 7am AEST, Slack-pinged to the ops lead. Average response time on a stockout dropped from 8+ hours to under 30 minutes.
Every night at 23:00 AEST, a headless Claude Code session on a Hetzner VPS pulls the brand’s Shopify inventory state, runs three sanity checks, and posts a one-line summary to Slack, under $5 AUD/month to run, ~30 minutes of human time saved per week, and dramatically faster response to overnight stockouts.
The problem
Our client, a Melbourne Shopify skincare brand, sells direct-to-consumer skincare across Shopify, Amazon Australia and a growing wholesale footprint (national grocery retail being the big one). The Shopify inventory is the system of truth, Amazon stock and wholesale stock both reconcile against it overnight.
The issue: stockouts kept getting noticed at the morning standup, not when they happened. A SKU goes to zero at midnight on a Tuesday → the team finds out at 9am Wednesday → by then Meta Ads has spent ad budget pushing traffic to an out-of-stock product for 9 hours. On top-10 SKUs, that’s $300-600 AUD of wasted ad spend per incident, plus the customer frustration of clicking through to a sold-out PDP.
Manual fixes didn’t stick. A nightly checklist on the ops team’s Notion got skipped during busy weeks. A Zapier flow caught explicit stockouts but missed the more nuanced “this is about to stock out” + “this product still has no image after the bulk upload” cases.
What we built
A single Claude Code agent that runs once a night.
The shape:
23:00 AEST → cron → /opt/agents/skincare-inventory/run.sh
→ headless Claude Code session
→ reads Shopify inventory via the official MCP server
→ runs 3 checks (stockouts, image gaps, 24h price changes)
→ drafts a Slack message in the brand's voice
→ posts to #overnight-inventory via Slack webhook
→ exits cleanly
Same pattern as the building your first Claude Code agent tutorial, that tutorial is a generic version of this exact agent.
Why headless Claude Code and not a custom script
We could have written a Python script that hit Shopify, did the math, posted to Slack. We chose Claude Code because:
- The interpretive layer. Claude looks at “Product X went from 24 units to 0 in 18 hours” and writes “Heads up: Hydrating Day Serum hit zero overnight, faster than expected, likely the Meta campaign spike. Worth pausing the ad until restock lands Friday.” That sentence isn’t in our Python script. It’s the model’s pattern recognition.
- Iteration speed. When we wanted to add the “product with no image” check, it was one line in
checks.md. No deploy, no PR, no schema change. - Failure handling. Claude reports failures conversationally. “I couldn’t reach the Shopify API at 23:00:32. Two retries failed. Escalating.” That’s the Slack ping we get when something breaks. No log-parsing needed.
What it cost
| Item | One-off | Monthly |
|---|---|---|
| Claude Code install + setup | ~3 hours of build time | , |
| Hetzner VPS (shared with our other ops bots) | , | $0 marginal cost |
| Claude API (Sonnet 4.6 with prompt caching, 30 runs/month) | , | ~$4-6 AUD |
| Shopify Custom App (free) | , | , |
| Slack webhook (free) | , | , |
| Total | ~3 hours | ~$5 AUD/month |
What it delivered
Hard numbers over the 90 days the agent has been running:
- Stockouts caught and acted on before 7am AEST: 14 (vs 3 in the prior 90 days under manual processes)
- Images-missing flagged after a bulk product upload: 22 (the team would never have caught most of these manually)
- Price-change anomalies caught: 2 (both Shopify-to-Xero sync bugs that would have caused tax-time pain)
- Estimated protected Meta Ads spend on stockouts: ~$2,400 AUD across the 90 days
- Team time saved on morning inventory triage: ~30-45 min/week
Even ignoring the soft wins, the ad-spend protection alone returns ~$800 AUD/month of value against a $5 AUD/month run cost. The 3-hour build paid back in days.
What we’d do differently
Three things, in priority order:
-
Build the agent before the next big retail launch, not after. We built this 2 months after a major retail launch when the team had already had the inventory pain. Should have done it 2 weeks before, not after.
-
Set up the failure-alert side first. Our first version of the agent posted clean-run messages reliably but didn’t have a separate UptimeRobot watching the log file. If the agent had silently failed to run (cron break, server reboot, API key expired), we wouldn’t have known for a week.
-
Add the per-SKU thresholds earlier. The first version flagged any zero. The current version knows that “this is a slow-mover, zero is expected on Wednesdays” vs “this is a top-10 SKU, zero is an emergency.” That contextual logic lives in the CLAUDE.md, not in code.
Why this matters for other AU SMBs
This same pattern works for any business with daily-changing data and a team that needs to know about exceptions:
- An accounting practice → overnight Xero reconciliation agent → Slack message on anomalies
- A real estate office → overnight REA listing performance agent → vendor reports drafted
- An allied health practice → overnight Cliniko agent → next-day appointment prep emails drafted
- A trades business → overnight Xero AR agent → invoice follow-up emails queued for morning send
The build time is similar (3-8 hours). The run cost is similar (under $10 AUD/month). The use is the same: have a competent assistant do the night-time triage so the humans wake up to a short, sorted list instead of a fire.
If you want help building a similar agent for your business, book a free audit, happy to scope it.
- Claude Code (headless)
- Shopify MCP
- Slack webhook
- Hetzner VPS
- cron
Want a build like this in your business?
Book a free 30-minute audit. We'll map your business and show you which automation would land the biggest result first.
Book my free AI audit