The Indie Dev Playbook for Autonomous AI Side Projects
Building autonomous AI agents as a solo developer means making smart architectural choices upfront—this playbook gives you the specific patterns, database schemas, and API integrations that let you ship faster without burning out on infrastructure.
Architecture: Agent-Server Communication Pattern
Your AI agent needs a reliable message queue and state store. The proven indie pattern is a Next.js API route that acts as a broker between your Claude agent and Supabase. Each agent run gets a session ID; messages are stored as immutable logs; tool calls are queued and processed asynchronously.
This decoupling means you can restart agents mid-execution, replay conversations for debugging, and scale to multiple concurrent agents without rewriting core logic. Use Supabase's real-time subscriptions to push updates to your frontend—no polling.
export async function POST(req: Request) {
const { sessionId, messages, model } = await req.json();
const response = await anthropic.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 2048,
messages,
tools: AGENT_TOOLS,
});
await supabase
.from('agent_runs')
.insert({ session_id: sessionId, messages: response, status: 'pending' });
return Response.json(response);
}Tool Use: Keep Agents Scoped and Testable
Define your Claude tools narrowly. Instead of a generic 'database' tool, create fetch_user, update_user, list_tasks. This forces you to think through exactly what your agent can do and makes unit testing trivial—just mock the tool implementations.
Each tool should be a pure function that validates input, executes one operation, and returns structured output. Use TypeScript to enforce contracts. This prevents agents from accidentally cascading writes or getting into infinite loops.
Cost Control: Tokens, Batching, and Caching
Use Claude's prompt caching to reduce token spend on repeated context (system prompts, long instructions). For side projects, caching often cuts API costs by 40–60% after a few runs.
Batch non-urgent agent tasks. If your agent is generating reports or processing backlog items, queue them and run 5–10 together in a cron job rather than on-demand. Set reasonable max_tokens (2048–4096) and use stop sequences to prevent rambling.
State Management: What the Database Needs to Store
You need: session metadata (created_at, user_id, status), message history (role, content, tokens_used), tool calls (name, input, output, latency), and error logs. Start with Supabase's JSON column for message content—it's faster to iterate than strict schemas.
Index on (user_id, created_at) for your dashboard. Add a status enum (pending, running, completed, failed) so you can retry or audit failed runs. Don't over-normalize early; a single agents table with JSONB columns beats a dozen junction tables for a solo project.
Error Handling and Retry Logic
Claude's API is reliable, but your agent will fail—bad tool inputs, timeouts, rate limits. Build retry logic into your message loop: exponential backoff for rate limits, structured error recovery for tool failures.
Log every tool call's latency and error. After 10 failed runs, human review stops bleeding money. Use Supabase's pg_cron to auto-cleanup old sessions, and set up simple Slack alerts for agent errors that cross a threshold.
Frontend: Real-Time Visibility Without Polling
Use Supabase real-time subscriptions to watch agent_runs in real-time. Build a simple React component that streams tokens and tool calls as they happen. This gives users confidence the system is working and catches edge cases you'll miss in testing.
Display the full message history and tool outputs. When an agent gets stuck, you need visibility into exactly what it was thinking.
Open-source implementation
Everything in this article runs in pantheon — a production-ready Next.js + Supabase + Claude starter. Clone it, deploy to Vercel, run PM2. The dashboard auto-commits every agent edit and reverts itself if TypeScript breaks.
◈ Tools mentioned
- Supabase — open-source Firebase alt
- Vercel — zero-config Next.js hosting
- Anthropic — Claude API
- Claude — AI assistant by Anthropic
- Gumroad — sell digital products
Some links may pay us a referral if you sign up. Never affects the price you pay.
Get the full starter kit
Start with the Pantheon reference implementation at github.com/lewisallena17/pantheon to see these patterns in production code—then grab the full starter kit below to ship your first autonomous AI side project.