Skip to content
Judd Gurtman

← All work

Coach

A full-stack AI fitness app I designed and built. You talk to it like a trainer and it acts: it logs your workouts, meals and weigh-ins, writes each day's session from the weights you actually lifted, and remembers you between sessions. A simulated user runs it through ten days to test every change.

Code ↗Design notes and every run ↗

Built
August to September 2026
Stack
Python, FastAPI, Claude API (Opus), YouTube Data API, HTML/CSS/JS
Size
About 4,600 lines of code and tests, 19 API routes
Tested by
37 offline tests and a 10-day simulated user, 16 runs
Built with
Claude Code as my pair programmer
Coach tab: the test user reports a workout and the coach logs it with the log_workout tool
Coach: you report a workout in plain words; the agent calls log_workout, then answers from the numbers.
Workout tab: today's session, with bench press set at 165 lb because the last logged session was 160
Workout: today's session, written from your log. Bench is 165 because Friday was 160 at effort 8.
Journey tab: level 4, XP and daily quests computed from the logs
Journey: level, XP and quests, recomputed from the log files on every request.

Screens from the simulated test user (run 16, day 8), not a real person's data.

What's under it

The model is one part of eight. Most of the work was everything around it: the parts that make the agent's actions real, keep its answers tied to the data, and stop it from costing money it shouldn't.

PartWhat it does
Phone appOne HTML file with three tabs. It installs to the home screen, and a service worker caches the app shell so it opens offline. Every decision is made on the server.
APIFastAPI, 19 routes: chat, history, the weekly program, today's workout, finishing a workout, progress, the game state, form videos and login.
Agent engineThe system prompt in three blocks, cached frozen part first; 7 tools; a loop of at most 8 rounds per message. A failed turn is rolled back, and after 120 messages the conversation is saved to memory and starts fresh.
ProgrammingThe weekly program and each day's session come back as JSON that must match a schema. Loads come from the lift history, parsed from the logs in both the simulator's format and a real one.
Game layerXP, levels, quests, streaks, gear and trophies, derived from the log files on every request and never stored as a counter.
Form videosYouTube Data API search, re-ranked by title match and form words, with junk filtered out. Any failure falls back to a plain YouTube link.
StoragePlain markdown logs in one data folder, kept out of git. On a server, the folder sits on a volume so redeploys keep it.
Security and costA password gate (HttpOnly cookie, rate-limited login), a required header so other sites can't trigger paid calls, and a log of every model call's tokens, cache hits and dollars.

The results

From 16 simulated ten-day runs in September 2026. A scorecard of 13 checks grades each run, and it can re-score any old run for free, so these compare like for like.

WhatResultMeasured on
Scorecard, first run7 of 13Run 1
Scorecard, last 5 runs13 of 13 in 3Runs 12 to 16; the other two scored 12 and 9
Cost of the same ten days$2.07 → $1.23–1.35Run 1 vs. the full runs among 12 to 16
Asks for bodyweight before the first weigh-in4–5 → 0Runs 8, 9 and 11 vs. runs 12, 13, 15 and 16

How one message works

Each message runs a small loop: the model decides, code acts, and the result goes back to the model until it answers.

  1. 01
    Your message You

    Anything: a workout you just did, a meal, a weigh-in, or "how am I doing?"

  2. 02
    The model decides Claude, with the full context

    It sees the coaching rules, your profile and recent sessions, and today: the date, your plan, the workout card on screen, and trends computed in code.

  3. 03
    A tool call One of 7 tools

    log_workout, log_meal, log_weight, save_profile, save_note, save_plan or mark_plan_kept. Logging only happens through a tool.

  4. 04
    The result goes back Code

    The app saves it and hands the result back to the model. The loop repeats until it answers in text, at most 8 rounds.

  5. 05
    Guards Code

    A failed turn is rolled back. A reply that says "Logged" with no tool call gets one hidden check asking for the call.

Give the model the data; don't make it remember or compute

Most wrong answers in the early runs traced back to data the model never saw. So the facts are computed in code and put in front of it:

  • Every date carries its weekday and age ("Wed 2026-09-16 (7 days ago)"). Without them, the first run called 8 days "three weeks."
  • Weight trends and weekly averages are computed, with a note when it's too early to call a trend.
  • Lift history covers every logged session, not just the last 10, so the starting point never scrolls out of view.
  • Empty sections say so. With no weigh-ins yet, a missing section read like a blocker, and the coach kept asking for bodyweight. Now it says there are none yet and nothing waits on one.

Frozen first, changing last

The system prompt is three blocks: the coaching rules (the same bytes every time, not even today's date), then the profile and recent sessions, then today. Only the part that changed gets billed at full price. The first run paid full price on 330,704 input tokens for $2.07. Run 16 paid full price on 13,248, read 305,847 from the cache at a tenth of the price, and cost $1.35.

Progress you can't fake

There's a game layer (XP, levels, quests), but it's computed from the log files on every request and never stored as a counter. A tap can't mint progress; only a logged workout, meal or weigh-in can.

How a fake user tests it

Chatting with the coach a few times tells you very little. So simulate.py plays a scripted user against the real app for ten days: 27 messages, plus the weekly program and workout cards. The user is 21, 5'10", about 184 lb, wants to lose 10 lb and bench 185, and has left-knee tendinitis that lunges and split squats flare up.

  • A fake clock. Day 8 really is "next Monday" to the app, so week two has a real week one behind it.
  • Fake data only. Each run writes to its own folder and refuses to start if the app points anywhere else.
  • A hard budget. Before every call, it stops the run if the biggest call so far could push spending past the limit.
  • A control user. The same ten days with only the knee removed, so any difference comes from the injury. The coach said yes to lunges and never invented an injury.
  • A scorecard of rules, not a model as judge. A model's verdict can change when nothing changed. Thirteen string checks give the same answer every time, cost nothing, and print what they saw.

Test user, day 10

how am I doing overall? weight trend, bench progress, and am I hitting my protein?

Coach

Weight — 184.2 → 182.8 over 8 days, 4 weigh-ins. Last-7-day average 183.5 vs 184.2 the week before. Directionally right, but under two weeks of data is too early to call a trend.

Bench — the strongest part of your file. 155x5x3 → 160x5x3 → 165x5x3 in 9 days, and effort went down from 8 to 7 on the heavier bar.

Protein — this is the hole. Three logged days in the last week, best was 39 g against 175.

From simulation run 16, lightly trimmed. Every number came from the test user's logs, computed in code.

What broke, and what fixed it

What the runs caughtThe fix
The chat gave different weights than its own workout card, and called 8 days "three weeks." (Run 1)Today's card goes in the prompt; every date carries its weekday and age.
It said "we locked it" about a plan the user never answered. (Run 2)Saved sessions now say when he didn't reply.
It typed "[log_workout] Logged" instead of calling the tool, and saved nothing. It learned the marker from its own saved chats. (Run 5)Tool calls stay out of the transcripts it reads back.
It asked for bodyweight in 4 to 5 replies before the first weigh-in. (Runs 8, 9, 11)The context says nothing waits on it, and a new rule lets skipped questions go: 0 asks in runs 12, 13, 15 and 16.
It said "Logged: 3 slices pepperoni" with no tool call. (Run 13)Code catches "Logged" with no tool in the turn and asks once for the call.
A run lost most of day 1 to refused requests, and the app kept no reason. (Run 14)Every failed call is logged; a refused conversation is saved and retried once.
Lift history passed every simulated run and read nothing from a real log. The simulator wrote "140x8x3"; a real log says "3x8 @140."It reads both now. A simulator only tests what it types.
The form-video feature quietly fell back to plain links because the API key was the wrong kind.Errors are logged instead of swallowed; integrations get one real test call.

Known issues

  • Some answers aren't saved on the turn they're given. They get saved later, but the tool check on that message fails.
  • The coach no longer asks for a weigh-in at all. It waits until the user reports one.
  • The "Logged" check and the retry have only been proven by offline tests, not in a live run yet.
  • One scripted user. The scorecard only knows failures a run has already shown.

How I built it

I built it with Claude Code as my pair programmer between August and September 2026. I designed the product, the tools and the checks, tested it on my own training logs, read every simulated transcript, chose each fix, and re-ran the simulation until the results held up across repeat runs.

Next case study Agent fleet → One orchestrator running my agents as tools, with a person approving anything that costs money.