walid@portfolio:~/lab/agentic-backend$
cd../lab
01ideaSep 2026

The agentic backend

Every agent demo you have seen is a front end — this is the three layers underneath it

A build guide for the part nobody records: the workspace agents run in, the files that tell them what the business is, and the access that lets them act without letting them send. Four layers, four paste-able prompts, and a build order that deliberately leaves the infrastructure until month two.

AgentsClaude CodeMCPSupabaseArchitectureSupersetSuperset repoSupabaseVercelInngestRailwayResend
i
The demo problem

Every flashy agent demo has the same shape — a screen recording, a voiceover, one chat window doing one job while someone narrates over it. That is a front end. It works because exactly one thing is happening and a human is driving. A system is what is left when nobody is narrating: five agents running while you are on a call, each one knowing what the business is before it touches anything.

The shape of it

Three things, and you need all three

Get these right and you can walk away from the machine. Miss one and what you have is a demo.

01·WORKSPACE

Somewhere the agents actually run

Side by side, without stepping on each other. Two agents in two tabs editing the same folder will overwrite each other and leave it in a state neither of them can explain.

02·BRAIN

Files that describe the business

What you sell, who buys, how each job gets done — read before the agent touches anything. An agent with no context is a stranger on day one, every day.

03·ACCESS

Hands, and the gate on them

Tool calls, APIs, the CRM, the inbox — plus the rule that means nothing ships until you have looked at it. Most people build the hands and forget the gate, then wonder why they cannot leave the room.

At a glance

The stack, and the order it gets built in

Bottom-up, not top-down. The front end — the map, the dashboard, the thing that looks impressive — is the last layer, because it does no work.
Before the tools

Two rules that decide whether any of it survives

The brain comes before the agents. Every hour spent writing files saves ten hours of re-explaining.Any agent, same files. The best model changes every month and the business does not — build so that swapping one agent for another is a dropdown, not a rebuild.
Layer 1

The workspace

Why a chat window fails: one agent, one tab, one job at a time. While it works, you wait. While you review, it waits. Neither of you is busy. Open a second tab and the two agents edit the same files and overwrite each other.

The fix is boring — every agent gets its own copy of the project and its own branch. In git that is a worktree. You can set them up by hand, but then you spend more time managing worktrees than running agents, which is how this dies quietly.

What a workspace runner has to do

Superset is the free desktop app built around exactly this — source-available, bring your own subscriptions and keys. The requirements matter more than the brand; anything meeting them works.

One workspace per task — describe a job, get an isolated worktree on a fresh branch with the agent already in it.Any agent. Claude Code, Codex, Kimi, OpenCode, Gemini CLI, Copilot, Cursor Agent. If it runs in a terminal it should run here.One sidebar showing which agents are working, which are blocked, and which are waiting on you.Built-in diff review — see every change, comment, edit, then merge or throw it away.Automations, so an agent can sit on a schedule: overnight triage, weekly reporting, anything recurring.A CLI and a tool server, so everything is scriptable and an agent can spin up other agents.

Install

macOS is the primary target. Linux is experimental, Windows is not supported yet — on Windows use WSL with plain git worktrees and terminal tabs. You need git. That is the whole dependency list.

terminal1 lines
brew install superset-sh/tap/superset
Day one

Your first workspace

1

Point it at the project folder

The folder your brain files live in. It detects the git repository automatically — if the folder is not a repo yet, run git init inside it first.

2

New workspace, one specific sentence

“Rewrite the client onboarding process file from the notes in inbox/onboarding-call.md” beats “improve onboarding”. The specificity is what makes the diff reviewable later.

3

Pick the agent

Claude Code for anything touching many files or needing judgement. Codex for tight, well-specified jobs. A cheaper model when the task is low-stakes.

4

Watch it, or do not

This is the point. Open a second workspace. Then a third. The whole value is in not waiting.

5

Read the diff, not the file

If it only touched what you asked for, merge. If it touched something you did not expect, that is the thing to look at.

Setup scripts

Dependency installs and environment copying go in setup.sh, so every new workspace comes up identical instead of half working.

.superset/config.json4 lines
{
  "setup": ["./.superset/setup.sh"],
  "teardown": ["./.superset/teardown.sh"]
}
i
The any-agent rule

Claude Code reads CLAUDE.md when it starts. Codex and most others read AGENTS.md. Keep one as the real file and make the other a copy, so every agent you launch reads the same brain. This is the part the demos never show, and it is the difference between swapping models being a dropdown and being a rebuild.

Layer 2

The brain

The workspace is the easy part. The brain is what separates a system that runs from five random chatbots.

Plain text, in a folder, on your machine. Four brain files, one folder per department, one file per job — that is the whole thing. A mature version runs to seven departments and 137 job files, but it starts with one department and six files.

The file structure

company/18 lines
company/
  CLAUDE.md          ← the entry file: who we are, how we work, hard rules
  AGENTS.md          ← copy of CLAUDE.md for non-Claude agents
  brain/
    company.md       ← what the business is, who runs it, how it makes money
    offer.md         ← what you sell, pricing logic, what you never do
    customers.md     ← who buys, why, what they say, what they object to
    voice.md         ← how you write and talk, with real examples
  departments/
    sales/
      first-touch-email.md
      call-prep.md
      proposal.md
    operations/
      client-onboarding.md
      weekly-status-report.md
  memory/            ← what the agents learned, written by the agents
  inbox/             ← raw material you drop in: transcripts, notes, screenshots

What goes in the entry file

CLAUDE.md is not a config file, it is a briefing — the first thing every agent reads. Prompt 1 below writes yours from an interview.

Who you are and what the business does, in ten lines.The stack and the defaults — what you build with, what you never use.The hard rules: never send an email, never touch the database directly, never invent a client fact.Where everything lives, by path: client context in brain/customers.md, job files in departments/.How to write: the voice rules and the banned words.

The job file — seven sections, every time

The sections are fixed so any agent can pick up any job without being told the format.

departments/operations/client-onboarding.md25 lines
# Client onboarding

## Purpose
Get a signed client from "paid" to "first deliverable in hand" in 5 days.

## Trigger
Payment received (Stripe webhook, or you say "they paid").

## Inputs
Signed agreement, kickoff call transcript in inbox/, the proposal.

## Steps
1. Create the client folder from the template.
2. Draft the welcome email from voice.md. Save as a draft, do not send.
3. Build the access checklist from the proposal scope.
4. ...

## Output
Client folder, welcome email draft, access checklist, kickoff calendar hold.

## Done when
All four outputs exist and you have approved the email.

## Edge cases
No transcript yet: draft from the proposal and flag "check me".

Memory, and where to start

The brain is not static. Give the agents a memory/ folder and a rule in the entry file: when you learn something durable — a client preference, a correction I gave you, a thing that broke — write it down as one file with one fact. Claude Code does this natively; for other agents the rule in the entry file does the same job. Six weeks in, the agents know things about the business you have forgotten you told them.

Do not encode the whole company. Pick the department where the hours actually go — for most businesses that is outreach or delivery — write its four brain files and its six most repeated jobs, and run that. The second department takes a third of the time, because the brain files already exist.

Layer 3

Access — hands, and the gate

MCP is the standard way to give an agent a tool. A server wraps something you already use — Gmail, the calendar, the CRM, Notion, Slack, Postgres, GitHub — and exposes it as actions the agent can call: read the inbox, create a draft, search the CRM, insert a row.

Most SaaS tools now ship an official server or a hosted connector. Search “[tool] MCP server” and take the official one over a community fork every time.

Wire them once, inherit everywhere

At the root of the project, so every workspace picks them up without per-agent setup.

.mcp.json14 lines
{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": ["-y", "@supabase/mcp-server-supabase@latest", "--project-ref=YOUR_PROJECT_REF"],
      "env": { "SUPABASE_ACCESS_TOKEN": "${SUPABASE_ACCESS_TOKEN}" }
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" }
    }
  }
}
!
Keys

Every key lives in a .env that is in .gitignore. Never in a file the agent reads as context, never in a job file, never in a prompt — the agent gets the key at runtime through the tool config, not by reading it. If a key ever shows up in a diff, rotate it that day.

The gate

Three layers, all of them cheap

This is the half that lets you leave the room.

01·DRAFTS ONLY

Agents create drafts, humans press send

One sentence in the entry file. Emails become drafts. Posts go to the calendar as “Drafted”. Proposals are files, not attachments already on their way. Nothing external leaves the machine without a human click.

02·THE DIFF

Every file change is reviewed before it merges

This is the review step for everything that is not an email. Read the diff, not the file — the diff is short and the file is not, which is the only reason this scales.

03·HOOKS

A script that runs before any tool call

Block anything that looks like a send. Exit code 2 stops the call and shows the agent why, so it does the sensible thing and saves a draft instead. Extend the matcher to anything else irreversible: payments, deletes, publishing.

The hook that means nothing sends without you

.claude/settings.json10 lines
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "mcp__.*__(send_message|send_email|reply|forward)",
        "hooks": [{ "type": "command", "command": "echo 'BLOCKED: drafts only. You press send.' >&2; exit 2" }]
      }
    ]
  }
}
The ladder

Read, then draft, then almost never act

Start every new tool at Read. Promote it to Draft once its output is consistently right. Act is the rung almost nothing needs to climb to.

The permission ladder

LevelThe agent canExamplesWho signs off
ReadLook, search, summariseInbox, CRM, calendar, docsNobody — it is read-only
DraftCreate something that is not live yetEmail drafts, proposal files, calendar holds, CRM notesYou, before it goes out
ActChange the worldSend, pay, publish, deleteYou, every time, via a hook or a manual step
Layer 4

Infrastructure — and why it waits

Everything above runs on a laptop with files, and that is enough for weeks. You need infrastructure the day one of three things becomes true: two people need the same data, something has to run while the laptop is closed, or you want a URL.

Supabase — Postgres with auth and an API — is where anything exact lives: deals, tasks, contacts, invoices, what was sent to whom and when. Files are for context: qualitative and slow-changing. The database is for state: exact and changing hourly. Agents read it through the Supabase tool server and write through the same server or your app’s API. Turn on row-level security from day one even solo, because the habit costs nothing and it means an agent with the wrong key still cannot see everything. Keep the schema in a file the agents can read (db/schema.sql), so they write correct queries instead of guessing column names.

Vercel deploys anything with a URL — the dashboard, the client portal, the internal tool that shows what the agents did today. The agents write to Supabase, Vercel renders what is in Supabase, you look at it on your phone. The agents never touch Vercel directly: it is the window, not the engine.

The things that run without you

Scheduled jobs — Inngest runs functions on a schedule or on an event (a new row, a webhook), with retries and a log you can read. This is what replaces the no-code automation platforms: the same triggers, written in plain code the agents can maintain.Long-running workers — Railway for anything needing more than a few minutes: a Python service, a scraper, a queue worker.Transactional email — Resend for the mail your app sends, as distinct from the drafts the agents write for you. One API, good deliverability, no marketing bloat.

When you need what

Nobody needs all of this on day one. The people who build it all first never get to the part where agents do work.

StageWhat you haveWhat to add
Week 1Superset plus brain files on the laptopNothing. Run the first department
Week 3Agents producing real output dailyMCP servers for inbox, calendar, CRM. Hooks
Month 2Exact data that files cannot holdSupabase, a schema file, row-level security
Month 3You want to see it, or a client doesA Vercel front end reading from Supabase
When it hurtsSomething has to run while you sleepInngest for schedules, Railway for workers
The payoff

Your first parallel run

Most people find the ceiling at five to seven agents before reviewing becomes the bottleneck. That is not a limit on the tool — it is a sign the job files need to be clearer.

1

Split the week

Pull out three to five jobs that do not touch the same files. Jobs that would fight over one file run in sequence, not in parallel.

2

One workspace each

One specific sentence per workspace, pick the agent, and every one of them reads the same brain.

3

Dispatch and detach

Start all of them, then go do something else. Check back when the sidebar chimes, not every minute.

4

Review each diff on its own

Merge the good ones. Send the others back with one line of feedback in the same workspace, still isolated from everything else.

5

Write the lesson down

Anything you corrected twice goes into memory/ or the job file, so next week’s run does not make it again.

Prompt 1

Write my entry file

Run it in Claude Code inside the project folder. It interviews you, then writes CLAUDE.md and copies it to AGENTS.md.

prompt-1-entry-file.txt15 lines
I'm setting up a folder that AI agents will read before doing any work
for my business. Interview me, one question at a time, then write CLAUDE.md.

Cover, in this order:
1. Who I am and what the business does (10 lines max)
2. The tools we use and the ones we never use
3. Hard rules: things an agent must never do without me
   (assume: never send an email, never delete, never invent a fact
   about a client, never quote a price I haven't given you)
4. Where things live: brain/, departments/, memory/, inbox/
5. How we write: voice rules, banned words, examples

Keep it under 150 lines. Plain language, no headers deeper than ##.
When done, copy the file to AGENTS.md so other agents read the same thing.
Ask the first question now.
Prompt 2

Split this week into agent tasks

prompt-2-split-the-week.txt12 lines
Here is everything I need done this week: [paste your list]

Split it into 3 to 5 tasks for parallel agents. Rules:
- No two tasks touch the same files. If they would, merge them or sequence them.
- Each task is one sentence an agent can start on without asking me anything.
- Name the files each task will read and the files it will create or change.
- Say which agent you'd use for each (Claude Code for judgement and
  multi-file work, Codex for tight specs, a cheaper model for low-stakes)
  and why.
- Flag anything on the list that's actually a "send" and can't be delegated.

Output as a table: task, agent, reads, writes, done when.
Prompt 3

Wire a tool and set the gate

prompt-3-wire-a-tool.txt9 lines
I want my agents to have access to [tool, e.g. Gmail]. Do this:
1. Find the official MCP server for it and give me the exact .mcp.json entry.
2. Tell me which environment variables it needs and where to get them.
3. List every action the server exposes and sort them into Read / Draft / Act.
4. Write the PreToolUse hook that blocks every Act-level action, with the
   exact matcher string, and add it to .claude/settings.json.
5. Add one line to CLAUDE.md that says what this tool is for and that
   drafts are the ceiling.
Do not run anything. Show me the changes first.
Prompt 4

Design the database from my job files

prompt-4-design-the-schema.txt12 lines
Read every file in departments/ and brain/. Then design a Postgres schema
that holds the exact state these jobs produce and consume:
deals, contacts, tasks, invoices, whatever the files actually reference.

Rules:
- Only tables the job files need. No speculative ones.
- Every table gets created_at, updated_at, and row-level security on.
- Write it as db/schema.sql with a comment above each table saying
  which job files read or write it.
- Then write db/README.md: one paragraph per table in plain English,
  so an agent can pick the right table without reading SQL.
Show me the schema before applying anything.

The front end comes last

The map, the tree, the dashboards — all of it sits on top of this. The map is a picture of the files in departments/. The dashboard is a view of what is in the database. Neither of them does any work.

Build the front end when there is something worth looking at. Then shape it however you want, because the backend does not care what is on top of it.

The honest part

What this actually costs

01·TIME

The brain takes longer than you think

Writing the four brain files properly is an afternoon. Writing six good job files is a week of noticing what you actually do. It is the whole value and there is no shortcut.

02·ATTENTION

Review is the real cost

Five agents produce five diffs. If the job files are vague, every diff needs work. The fix is upstream — tighter files, not faster reading.

03·PLATFORM

The tooling is macOS-first

Linux is experimental and Windows is not there yet. The workflow still works with git worktrees and terminal tabs, it is just more manual.

04·CHURN

Models will change under you

That is the entire point of the any-agent rule. What you own is the files, and the files outlive whichever model is best this month.

05·ORDER

Do not build the infrastructure first

The database and the deploy host are month-two problems. Most people never reach month two, because they spent month one on infrastructure.

Before you call it built

Checklist

Superset installed, project folder is a git repo.CLAUDE.md written from the interview, copied to AGENTS.md.Four brain files: company, offer, customers, voice.One department, six job files, seven sections each.A memory/ folder, with the write-it-down rule in the entry file..mcp.json with your first two tools, keys in .env, .env in .gitignore.Drafts-only rule in the entry file, PreToolUse hook blocking sends.First parallel run done: three tasks, three workspaces, three diffs reviewed.Every correction written back into a job file or memory/.Supabase, Vercel, Inngest: not yet — and you know when.
next →
Fifty sites, and the seven you will actually use
← all experiments