How to Build a SaaS with Claude Code: A Founder's Workflow
Short answer: build it as a loop, not a prompt. Write a one-page spec. Give the agent a project memory file with your commands and rules. Plan each feature in plan mode, build it as one thin slice, let tests and type checks decide when it is done, read the diff, commit, clear the context, repeat. Buy the parts where a bug costs data or money (sign-in, payments, email delivery) and let the agent wire them up instead of inventing them.
The rest of this guide fills in that loop, with the Codex equivalent wherever the two tools differ.
Product facts on this page were checked against Anthropic's and OpenAI's documentation on 17 October 2026. Both tools change quickly. If the linked docs disagree with this page, trust the docs.
1. Write a one-page spec before the first prompt
An agent fills every gap you leave with a plausible default. A short spec turns those defaults into decisions you made. Keep it to one page and commit it to the repository, so every session can read it:
# SPEC.md
Who: freelance designers who invoice 5–20 clients a month
Job: send an invoice and know when it is paid
First paid feature: recurring invoices
Out of scope (v1): teams, multi-currency, mobile app
Data we store: client name + email, invoice lines, payment status
How we charge: $12/month after a 14-day trial
Done for v1: a stranger can sign up, send an invoice, get paidTwo lines do most of the work. "Out of scope" stops the agent from building the team-permissions system you never asked for. "Done for v1" gives you a finish line you can test against.
2. Pick a boring stack and buy the dangerous parts
Choose a stack the model has seen a lot of and that you can debug at 2 a.m.: one web framework, one Postgres database, one host. Then sort the work by two questions. What does a bug here cost? And does this part make your product different?
Cost of a bug ↑
Costly bug · low differentiation
Buy and configure
- Sign-in and sessions
- Payments and billing
- Email delivery
- Database backups
Costly bug · high differentiation
Agent builds, you review every line
- Who can see which record
- Data model and migrations
- Anything that computes money
Cheap bug · low differentiation
Take the defaults
- CSS framework and icons
- Analytics snippet
- Deploy config from a template
Cheap bug · high differentiation
Let the agent run
- Your core workflow UI
- Onboarding and empty states
- Internal admin screens
How much it sets your product apart →
The top-left box is where agent-written code hurts most. Sign-in, sessions, password resets, payments and email deliverability are solved problems with sharp edges. Use an established library or service and have the agent configure it. Payments have their own guide: Stripe vs Lemon Squeezy vs Paddle.
The top-right box is your data model and your who-can-see-what logic. Let the agent write it, and read every line.
3. Give the agent a project memory
Every session starts with an empty context. A memory file is how the agent learns your project before it touches anything.
- Claude Code loads
CLAUDE.mdat the start of every session:./CLAUDE.mdor./.claude/CLAUDE.mdfor the project,~/.claude/CLAUDE.mdfor your personal preferences, and a git-ignoredCLAUDE.local.mdfor private notes. Run/initand it drafts one from your codebase (Anthropic: how Claude remembers your project). - Codex reads
AGENTS.md. It walks from the project root down to your current directory, files closer to where you work override earlier ones, and it stops adding files at 32 KiB by default (OpenAI: custom instructions with AGENTS.md).
You don't need two files. Claude Code can import other files with @path, up to four hops deep, so a CLAUDE.md that contains only the line @AGENTS.md gives both agents the same instructions. Recent Claude Code versions also read AGENTS.md directly when a repository has no CLAUDE.md. ConfettiSaaS's own codebase uses the one-line import: the rules live in AGENTS.md, and CLAUDE.md points to it.
AGENTS.md
19 lines
- Marker 1
- What this is. One line of product context, so every session starts oriented.
- Marker 2
- Commands it may run. Exact commands, so the agent can check its own work instead of guessing.
- Marker 3
- A map. Where things live, so the first edit lands in the right file.
- Marker 4
- The few rules that matter. Memory is context, not enforcement. Back each of these with a deny rule or a hook.
- Marker 5
- Definition of done. What the agent must show before it says “done”.
AGENTS.md, and a one-line CLAUDE.md containing @AGENTS.md gives Claude Code the same rules. Keep it short; Anthropic suggests under 200 lines per file.Write the file for a smart newcomer, not for the model. Anthropic suggests keeping each file under 200 lines, because long files cost context and are followed less reliably. Also treat it as advice, not a lock. The docs say Claude treats memory "as context, not enforced configuration". Rules that must never break belong in permission rules or hooks (section 6).
4. Plan each feature, then build one thin slice
- 1
Plan
Plan mode: the agent reads code and proposes; it edits nothing.
- 2
Approve
Cut the plan down to one user-visible change. Then approve.
- 3
Build
The agent implements that slice: schema, logic, UI, test.
- 4
Verify
Gate
Tests, type check and lint run. Red sends it back to step 3.
- 5
Review
Gate
You read the diff, not the summary.
- 6
Commit
Commit, clear the context, start the next slice at step 1.
↺ After step 6, back to step 1 for the next slice
Shift+Tab in Claude Code; Codex gets the same effect from a read-only sandbox.Plan first. In Claude Code, start with claude --permission-mode plan, or press Shift+Tab until the status bar shows plan mode. Claude reads files and proposes a plan, and makes no edits until you approve (Anthropic: plan before editing). In Codex, a session started with --sandbox read-only gives you the same read-only pass (OpenAI: agent approvals and security).
Cut the plan down. A good slice is one change a user can see, end to end: the table, the server code, the screen and the test. "Recurring invoices" is a project. "A user can mark an invoice as monthly and see the next send date" is a slice.
Keep each session to one slice. Anthropic's best-practices page says it plainly: the context window fills fast, and performance degrades as it fills. Run /clear between unrelated tasks. If you've corrected the same mistake twice, start a clean session with a better prompt instead of trying a third correction (Anthropic: best practices).
Commit every green slice. Small commits keep each diff readable, and git revert becomes your undo button.
5. Make "done" mean "the checks pass"
The most useful line in Anthropic's guidance is to give the agent a check it can run: tests, a build, a linter, a screenshot to compare (Anthropic: give Claude a way to verify its work). In practice:
- Put the exact commands in the memory file, for example
pnpm test,pnpm typecheckandpnpm lint. - Ask for evidence, not a summary: "paste the test output".
- For bugs, have the failing test written first: "reproduce it in a test, then fix it".
- Run the same commands in CI on every push, so a check the agent skipped still runs.
For UI work, a screenshot is the check. If you let Claude drive Chrome for that and its debugging banner gets in the way, here's how to hide the "Claude started debugging this browser" banner.
For anything that must happen every time, use a hook instead of an instruction. A Claude Code PostToolUse hook with an Edit|Write matcher can run your formatter after every edit, and a PreToolUse hook can block an action outright (Anthropic: automate actions with hooks).
6. Set permissions and keep secrets out of reach
Claude Code has six permission modes: manual approval (default), acceptEdits, plan, auto, dontAsk and bypassPermissions. Shift+Tab cycles through manual, acceptEdits, plan and, where it's available, auto. dontAsk (for locked-down scripts) and bypassPermissions (which the docs reserve for isolated containers and VMs) are chosen when you start a session, with --permission-mode. On top of the mode, allow and deny rules in .claude/settings.json pre-approve or block specific tools, and deny rules apply in every mode (Anthropic: choose a permission mode, configure permissions). A starting point for a Node project:
{
"permissions": {
"allow": ["Bash(pnpm test *)", "Bash(pnpm typecheck)", "Bash(pnpm lint)"],
"deny": ["Read(./.env)", "Read(./.env.*)", "Bash(git push *)"]
}
}Codex sandboxes commands instead. In a version-controlled folder its default is workspace-write with on-request approvals, and that sandbox keeps network access off unless you enable it. Use --sandbox read-only for review sessions. The --dangerously-bypass-approvals-and-sandbox flag turns both protections off (OpenAI: agent approvals and security).
With either tool: use test keys only, never paste a live credential into the chat, and keep .env both in .gitignore and behind a deny rule.
7. Run a security pass before you take money
Agent-written code tends to fail in the same few places. Before your first paying customer, walk this list, ideally in a fresh session whose only job is review:
- Every route checks who the user is and whether they own the record they asked for.
- Payment status comes from verified webhooks, never from the success redirect. Stripe's docs require signature verification and warn that the same event can arrive more than once (Stripe: receive events in your webhook endpoint).
- Input is validated on the server, not only in the form.
- Sign-in, sign-up, password reset and anything that sends email are rate-limited.
- Secrets live in environment variables. None are in the repository, the client bundle or the logs.
- Dependencies are pinned by a committed lockfile, and your package manager's audit is clean or each finding is explained.
- A database backup has been restored at least once.
Then read the diff of the whole branch yourself. Review is the one step you can't delegate.
8. Charge, ship, launch
- Payments. Decide who is the seller of record before you wire up a checkout. Stripe vs Lemon Squeezy vs Paddle compares fees and tax handling with worked numbers.
- Deploy. One host, environment variables set there, a health-check URL, and the same CI checks gating every deploy.
- Launch. A launch is a sequence, not a day. Product Hunt alternatives lists the platforms with their real rules and costs, plus a plan from two weeks before launch to a month after.
Claude Code or Codex?
The workflow above is the same with either tool. These are the differences that matter for the loop:
| What you need | Claude Code | Codex |
|---|---|---|
| Project memory | CLAUDE.md, which can import AGENTS.md | AGENTS.md |
| Read-only planning | Plan mode (Shift+Tab) | --sandbox read-only |
| Guardrails | Permission modes, allow and deny rules, hooks | Sandbox modes, approval policies |
| Add an MCP server | claude mcp add --transport http NAME URL | codex mcp add NAME --url URL |
| Access | Claude Pro, Max, Team or Enterprise, or a Console account | ChatGPT Free, Go, Plus, Pro, Business, Edu or Enterprise, or an API key |
Pick the one you already pay for. Plans and usage limits change often, so check Claude's pricing and OpenAI's Codex pricing before you commit.
Sources
All retrieved 17 October 2026.
- Anthropic, How Claude remembers your project
- Anthropic, Common workflows
- Anthropic, Best practices for Claude Code
- Anthropic, Choose a permission mode
- Anthropic, Configure permissions
- Anthropic, Automate actions with hooks
- Anthropic, Authentication
- Anthropic, Connect Claude Code to tools via MCP
- OpenAI, Custom instructions with AGENTS.md
- OpenAI, Agent approvals and security
- OpenAI, MCP in Codex
- OpenAI, Codex pricing
- Stripe, Receive Stripe events in your webhook endpoint
