kova-ops
Production automation for a one-person ice cream company: two PreToolUse safety hooks with 97 tests, an MCP server for traffic-aware delivery routing, and the…
The automation layer that runs Kova, a small ice cream company in Los Angeles. I'm the founder. I don't write code by hand: every line here was generated by Claude Code to my spec, and the section How this was built below says exactly what is mine. Everything here is production code — it schedules deliveries, guards a live storefront from bad deploys, and runs a set of AI agents against the business systems I actually operate on: Shopify, Xero, Square, Notion, Gmail, Google Calendar, Cloudflare. This repository is a curated, sanitized subset of that stack, published as a work sample.
Summary extracted from the README.
kova-ops
The automation layer that runs Kova, a small ice cream company in Los Angeles.
I'm the founder. I don't write code by hand: every line here was generated by Claude Code to my spec, and the section How this was built below says exactly what is mine. Everything here is production code — it schedules deliveries, guards a live storefront from bad deploys, and runs a set of AI agents against the business systems I actually operate on: Shopify, Xero, Square, Notion, Gmail, Google Calendar, Cloudflare.
This repository is a curated, sanitized subset of that stack, published as a work sample. The private version carries customer addresses, financial detail, and API credentials; none of that is here. What is here runs, and is tested.
97/97 tests passing across two safety hooks
23/23 on the MCP server (16 of them without an API key)
How this was built
Every line of code in this repository was generated by Claude Code. I did not write it by hand and I
do not claim to. What is mine: the problem, the spec, the operating rules, the acceptance tests, the
decision about what to automate and what to leave manual, and the production testing — including
the three bugs I found by sending crafted payloads at my own guards. The Co-Authored-By: Claude
trailers in the git log are accurate. In ai-disclosure
terms: ai-generated, human-directed and human-verified. Ask me to walk through any file. I can tell
you what it does and why it exists, not how I would type it.
Why this exists
Kova's storefront is a Shopify theme on a repo whose main branch is GitHub-connected. Merging
main publishes to the live store immediately — no preview, no staging gate. I use AI agents heavily
for day-to-day work, which means an agent holding a shell can publish to a live storefront by
accident.
The written policy said don't do that. Prose does not stop a git push. So I built the
mechanical version.
That is the theme of this repo: turning a rule into something that cannot be quietly broken.
What's here
hooks/ — two PreToolUse safety guards
Python hooks that intercept shell commands before an agent runs them.
| Hook | Stops |
|---|---|
theme-push-guard.py |
Anything that could publish a live site — push/merge to main in either deploy-connected repo, gh pr merge, shopify theme push |
git-destructive-guard.py |
Destructive git in any repo — hard resets, forced working-tree wipes, branch deletion |
Both ship with their own test suite (*.test.py, 61 and 36 cases). Run them directly:
python3 hooks/theme-push-guard.py < payload.json # reads a hook payload on stdin
python3 hooks/theme-push-guard.test.py # 61/61
python3 hooks/git-destructive-guard.test.py # 36/36
Three design decisions worth explaining, because they're the interesting part:
1. Fail safe, not fail open. Some commands are unambiguous from the string alone (git push origin main). Others need to know the current branch (git push with no arguments). If that branch
lookup fails, the guard asks rather than allows — we already know we're looking at a push inside
the theme repo, so the safe default is to interrupt.
2. The verdict depends on who's watching. These hooks return ask normally and deny under
bypassPermissions. The reason: an ask only works when a human is at the keyboard. In an
unattended run it asks nobody — the run pauses forever on a prompt nothing will answer, and a
stall becomes indistinguishable from a clean pass. Under bypassPermissions the prompt machinery is
exactly what's skipped, so deny is the only verdict that holds, and it lets the run finish and
report what it was stopped from doing.
Every fire appends to a local log recording the real permission mode, so the undocumented cases can be closed with evidence instead of a guess.
3. They follow cd. This one was a bug, and finding it is the part I'd want to be judged on.
Both hooks read the payload's cwd — which is where the shell was before the command runs. So any
compound command containing a cd was being judged against the wrong repository. Two different
failures, one cause: the theme guard blocked a legitimate push in an unrelated docs repo (safe, but
a guard that cries wolf gets routed around), while the destructive guard silently allowed a
forced working-tree wipe of a dirty repo reached by cd from a clean one.
Separately, the theme guard's parser skipped any command segment without a git token — so
gh pr merge returned a silent ALLOW. A live deploy path the documentation already claimed was
guarded.
All three were found by probing the hooks with crafted payloads. Reading the code said they were fine. That's why the test suites exist and why they're this large.
routing/ — traffic-aware delivery routing
route.mjs solves the delivery run against the Google Routes API. It answers two questions a
straight-line distance model can't:
- What's the best stop order at a given departure time, in real traffic?
- What's the latest departure that still lands every drop before the courtesy cutoff?
The second is a binary search over departure times. It costs about six API calls, and the script refuses to exceed a hard call ceiling in a single run so a bug can't run up a bill.
sample-stops.json is synthetic. Real stop files are generated per delivery day from unfulfilled
paid orders and are gitignored — they're customer addresses.
mcp/ — the routing, exposed as an MCP server
routing/route.mjs answers its two questions in a terminal. mcp/ answers them for an agent. It is
an MCP server over stdio with two tools, solve_route and latest_departure, and one command wires
it into Claude Code:
claude mcp add kova-route -- node /absolute/path/to/kova-ops/mcp/server.mjs
Then I can ask how late I can leave with five drops to make, and Claude calls the tool and reads back the order, each ETA, and the window to quote every customer.
Everywhere else in this repo I consume MCP servers other people wrote: Shopify, Xero, Notion, Gmail. This one is mine. The protocol itself is small, because the tools declare a schema and the SDK handles the handshake. What changes when a script becomes a server:
CLI (routing/route.mjs) |
server (mcp/) |
|---|---|
process.exit(1) on bad input |
throws, and the tool answers with the reason |
| prints a table | returns structured data against a declared output schema |
| counts API calls in one variable | a budget per request, and a ceiling per process |
The CLI is the one that has routed real deliveries, and I did not refactor it to share code with the server. It runs live deliveries and its original lives outside this repo. A public mirror is the wrong place to fork running code.
The test suite drives the server over stdio with the SDK's own client, because reading the source proves nothing about a protocol. It makes six malformed calls and then checks the server is still serving. See mcp/README.md for the three decisions worth naming.
skills/ and scheduled/
How the agent layer is organized: reusable skills with explicit trigger conditions, and scheduled routines that run against live business data. See each directory's README.
Architecture
┌─────────────────────────────┐
business systems │ Shopify · Xero · Square │
│ Notion · Gmail · Calendar │
└──────────────┬───────────────┘
│ MCP connectors
┌──────────────▼───────────────┐
agent layer │ skills (triggered) │
│ scheduled routines (cron) │
└──────────────┬───────────────┘
│ shell
┌──────────────▼───────────────┐
safety layer │ PreToolUse hooks │ ← this repo
│ ask / deny by permission │
└──────────────┬───────────────┘
│
┌──────────────▼───────────────┐
real world │ live storefront · deliveries │
└───────────────────────────────┘
Cloudflare Worker receives Shopify webhooks → logs to Notion → push alerts
kova-route (mcp/) is my own MCP server, exposing the delivery routing to the agent layer
See ARCHITECTURE.md for the full write-up, including the failure modes that shaped it.
What I'd want you to take from this
- I specify defensive infrastructure. The interesting decisions here are about what happens when something fails, not when it works.
- I test what I can't see. The three real bugs in these hooks were invisible to code review and obvious to a crafted payload.
- I build against live systems with real consequences — a bad merge publishes to a storefront that customers are looking at, and a bad route means ice cream melts.
- I document why, not just what. Every non-obvious decision in this repo carries its reasoning, because the next person to touch it is usually me, six weeks later, having forgotten.
Contact
Juan Turcios — Los Angeles juanernesto.com · kovakream.com