Inspiration
Tamagotchis lived in your pocket and died in a drawer. They never knew it was raining, that you had a bad day, or that there was a can of Irn-Bru on the desk. We wanted a pet that notices your world, and Scotland gave us the perfect creature: the wild haggis, which (as every Scottish child is told) has longer legs on one side so it can only run one way round a hill.
Haggis-gotchi is a wee folklore pet that hatches from an egg on your phone, lives for about six weeks, feels your real weather, and is buried in the mother's kirkyard when it goes to the glen. The Frankenstein part: a cloud "mother" page, a phone-first web app, a server-side care engine, real weather, image recognition and push notifications, stitched into one creature that is never copied, only moved.
What it does
A Scottish folklore pet that hatches on your phone, feels your real weather, and grows up over six weeks. Who it's for: anyone who misses their Tamagotchi, and Scots near and far who'd like a wee bit of home on their phone. Why it matters: a gentle reason to check in each day and notice the world outside, plus an open-source example of building spec-first with Kiro: the specs, property tests and honest incident records are all in the repo for other builders to learn from.
- Claim an egg on your phone (no app store: it installs from the browser). Answer a few questions; they write a birth story and choose one of six Scots temperaments, from Douce (gentle) to Fair Wud (completely wild). Twenty seconds later it hatches, with its own film.
- Care for it: feed, cuddle, walk, treat, clean up, put to bed, play Haggis Run (guess which way it runs round the hill), and tell it off, fairly or unfairly, when it gets up to mischief.
- It feels your weather. Three times a day the real forecast for your rough area (about 11 km, never your exact location) changes its mood. Douce loves rain, Skeigh hides from thunder, Fair Wud lives for storms, and every haggis loves the haar.
- Photo Treat: snap tablet, shortbread, heather, tartan, bagpipes or Irn-Bru and Amazon Rekognition checks it. Every bar fills. Show it anything else and it tells you what it thinks.
- It grows up through Baby, Child, Teen, Adult and Old age, with new art and films at each stage, life-stage rules (teens refuse cuddles in public, old knees prefer gentle walks), and seasonal costumes (Halloween, St Andrew's Day, Christmas, Burns Night, Easter).
- Who they are is theirs to decide. If the carer opts in, at Teen the Haggling may tell them who they are: still a laddie or lassie, trans, non-binary (they/them) or not sure yet. It is random on purpose and every answer scores the same. The carer's only job is to support them.
- It keeps a diary. Every night Google Gemini writes a page in the Haggling's own voice from what really happened: the weather in your town, the care it got, its life stage, the season. On a stormy day it's all about the storm. Every page ever is kept in an ornate scrapbook book, with tabs by week.
- Show it anything. Photograph something that isn't a treat and it reacts in character ("A dog! Wee Yin is up the curtains"). Only the object labels go to the AI, never the photo, never people.
- A second game: a daily Scottish folklore riddle (kelpies, selkies, the Callanish Stones...), written and fact-checked by hand (we tried AI riddles; one mixed up two legends), the same for everyone, one guess a day.
- It reminds you (push notifications) at meal times and bedtime, with a quiet-nights setting.
- Life ends. After about six weeks it goes to the glen: an epitaph written from how it was treated, a stone in the mother's graveyard, and an optional wee ghost.
- The mother page (desktop) shows the brood, a live public scrapbook ("Fred just fed Harry · 2 min ago") and a painted kirkyard. Each Haggling can have a public share card.
How we built it
Built in Kiro IDE, spec first. Every feature went requirements (EARS) → design → tasks → code,
and the commits name the spec and task. There are 17 specs in .kiro/specs.
- One care engine, everywhere.
packages/care-engineis pure TypeScript. The same rules run on the phone, in Supabase Edge Functions (Deno) and in tests. A Haggling decays continuously, for example $$\text{hunger}(t) = \max!\big(0,\; h_0 - 9\,t\,w\,s\big)$$ where $t$ is awake hours, $w$ the temperament factor (1.15 for the wild ones) and $s$ the life-stage factor. Life XP only ever rises, and levels follow D&D-style thresholds: level 2 at 100, then 300, 600, 1000, and $+500$ after that. - Stack: React + Vite PWA on Cloudflare Pages (with a Pages Function for share-card previews), Supabase Postgres with row-level security, Edge Functions and pg_cron (reminders every 15 minutes, weather three times a day, lifecycle every 5 minutes), Supabase Vault for secrets, Web Push (VAPID), Resend for email, Cloudflare Turnstile, Open-Meteo, Amazon Rekognition, and Google Gemini (Gemini 3.5 Flash-Lite, paid tier) for the diary and photo reactions, after Amazon Bedrock gave our account zero tokens (see Challenges). Every AI line is checked by our own rules and has a written fallback, so the game never depends on the AI.
- Steering keeps Kiro on our rules: Scottish folklore voice, security, tech choices, how to write instructions for a non-specialist owner, and property-based tests on every feature.
- Hooks: a secret guard blocks key-shaped strings before they are written; a domain-language guard keeps the Scottish care voice (and keeps crypto-speak out); a schema reminder runs after every migration; and a hook keeps property tests in step whenever a spec's requirements change.
- MCP: we wrote our own
haggis-weatherMCP server, so Kiro could ask "what would a Radge Haggling feel on a hot day?" while designing, and used the AWS documentation MCP server to build the Rekognition integration. - Property-based testing: Kiro turned the EARS requirements into 62 fast-check properties (hundreds of random Hagglings, care sequences, names and time zones each). Tests run in GitHub CI and inside the Cloudflare build, so a broken rule cannot be deployed.
- Parallel Kiro sessions: a second Kiro session built the 3D graveyard in its own git worktree, from a written handover, while the main session carried on.
Challenges we ran into
- Too fiddly, so we pivoted. The first design hatched the egg on a desktop and moved it to the phone with three codes and two emails. The first real test showed nobody would do that several times a day. Halfway through, we went phone-first: one sign-in code, install from the browser, and a "home device" so a Haggling is never copied, only moved. The pivot is written up in the repo.
- A setup guide that cost two hours. Supabase changed its default table grants on 30 Oct 2026.
A Kiro-written setup guide didn't know, and two guessed fixes failed. We wrote an incident
record and a new steering file (
owner-instructions.md): check the provider's changelog first, run read-only checks before asking a human, one action per step, say what you should see. It has not happened again. - Bars that froze while you watched. Example tests passed for days. Property tests found that the phone's 30-second re-check rounded each tiny drop back to zero, so with the app open the bars never moved, while hunger and mess penalties hit every 30 seconds instead of every hour. The same suite found that the server judged "missed breakfast" in UTC, not the carer's time zone.
- Amazon Bedrock gave us zero tokens. We built the AI diary, photo reactions and riddles on Amazon
Nova (Bedrock). Our new AWS account turned out to have a daily token quota of 0, marked "not
adjustable"; every call returned "Too many tokens per day" (14 calls, 0 successful). The quota AWS
Support suggested was not adjustable either, an AI helper closed the first case, and when a person
finally looked, AWS declined because the account was new, advising us to "use 90%" of a limit of zero.
A second reply acknowledged the hackathon deadline, then said only that the request "may take some time".
We moved the AI words to Google Gemini instead, which meant making the game 18+ (Gemini's terms). Because every AI feature has a written fallback, players never saw a failure. The full record is
in
docs/INCIDENT-2026-11-23-aws-bedrock-quota.md. - Recognising a can of Irn-Bru. Rekognition often can't read the sideways logo. Testing real photos showed it reads the slogan "ORIGINAL AND BEST" at 98-100% in any orientation, so the rule is "slogan + a drink container".
- Getting identity right. We took advice and changed the wording until it said what we meant: "Your Haggling decides. Every answer is welcome."
Accomplishments that we're proud of
- It's a real product: live at haggisgotchi.com, installable, with push notifications, a privacy notice, account deletion, security headers and a bot check.
- 184 automated tests, 62 of them property-based, written from the specs. They found 11 real problems that example tests missed, and every one is fixed.
- Original art for six temperaments across five life stages: 36 short films (hatching, playing and one for each stage), ghosts, and 30 seasonal costumes.
- A pet that respects you: rough location only, photos never stored, public pages off by default, and an identity moment designed to be kind.
- An honest build record in the repo: what came before Kiro, the pivot, the incident, and the test findings.
What we learned
- Specs pay off most when they are honest. Rewriting the early specs to match the real code, with tasks ticked only when they were true, made every later feature faster.
- Property tests find a different kind of bug. Unit tests check the examples you thought of; properties check the rule. Our worst bug only appeared when time passed in many small steps.
- Steering is how you teach Kiro from your mistakes. One bad afternoon became a rule that changed every guide after it.
- Fiddly kills a toy. Test the whole flow on a real phone early.
What's next for Haggis-gotchi
- Costumes and unlocks for every life stage (hats, backdrops, a "Chieftain o' the Puddin-race" badge).
- More Photo Treats that work outside Scotland (anything tartan, a cup of tea, rain on a window).
- Idle animation, so the portrait breathes and blinks.
- A Raspberry Pi "hearth": a second body for the same Haggling on your desk.
- Gaelic and Scots language options.
Built With
- amazon-rekognition
- amazon-web-services
- cloudflare-pages
- cloudflare-turnstile
- deno
- fast-check
- ffmpeg
- github-actions
- google-gemini
- kiro
- model-context-protocol
- node.js
- open-meteo
- pg-cron
- postgresql
- pwa
- react
- resend
- service-workers
- supabase
- supabase-edge-functions
- typescript
- vite
- web-audio-api
- web-push