Playbook
Taking over a codebase written by AI: a CTO's first week
Illustrative scenario. The team and numbers below are a composite example, not a real customer. The problem and the fix are real.
TL;DR
- Day 1: run it and list the five flows that make money.
- Day 2–3: map those flows and lock them with proof commands.
- Day 4–5: set rules for every agent and turn on checks before anyone ships.
A founder built an app with Cursor and ChatGPT, got paying users, and has now brought in a fractional CTO. The code works, mostly. There are no docs, few tests and patterns that change from file to file. Here's how a first week can go.
Day 1: run it, and find what earns money
Get it running locally and deployed from your machine. Then ask the founder one question: "Which five things would cost us customers if they broke tomorrow?" Typical answers: sign-up, sign-in, the core action, payments, one integration.
npx stet-cli init # detects the stack, locks the existing test suite if there is one
Day 2: map how those flows actually work
stet study "checkout"
stet study "sign-up"
Each study writes docs/flows/<topic>.md: the key files, routes, a diagram, covering tests and what protects the flow. Your own notes in the file are kept when you refresh it. For a deeper read, stet context --flow checkout packs the doc and its files for your AI chat.
Day 3: lock what works before changing anything
stet lock add "Sign-up creates an account" --cmd "npm test -- tests/signup"
stet lock add "Stripe checkout session is created" --cmd "npm test -- tests/checkout"
stet lock add "Public API routes" --snapshot "node scripts/print-routes.js"
Where there's no test, write the smallest one that proves the flow works today. A snapshot lock is a fast way to freeze outputs such as routes, exports or API shapes.
Day 4: one rulebook for every agent
Edit .stet/charter.md with what the product is, the stack and the rules you'd block a PR for. Log the decisions you've learned so far with stet decide. Stet keeps AGENTS.md and CLAUDE.md in sync, so the founder's Cursor and your Claude Code follow the same rules.
Day 5: turn on the checks
stet hook install # out-of-scope commits are blocked locally
stet ci # guard, check and PR format on every pull request
stet handoff # HANDOFF.md for the next person to join
From now on, every task starts with stet scope set and ends with stet scope done --commit. The founder keeps shipping with AI; the money paths can't break silently.
FAQ
How do I understand a codebase written by AI quickly?
Start from the flows that matter to the business, map each one (files, routes, tests) and write it down. stet study automates the map for a named flow.
What should I lock first in an inherited codebase?
The five flows that would cost customers if they broke: usually sign-up, sign-in, the core action, payments and one key integration.
Can the founder keep using Cursor after a CTO joins?
Yes, as long as every agent reads the same rules and every change is checked. A shared AGENTS.md and checks on each pull request make that safe.
Put guardrails on your AI coding agent
Stet is a free, open-source CLI and MCP server for Claude Code, Cursor, Codex and Copilot. It runs locally: no account, your code never leaves your machine.
npx stet-cli init · Install · Setup guide · GitHub