claude-code·8 min read·

Claude Agent SDK for UK indie hackers: build your own programmatic AI coder in 2026

Claude Code is brilliant when you sit in front of it. But what if you want an agent that runs without you? The Claude Agent SDK is the same engine, exposed as a library. Here is how a UK indie hacker uses it to build their own schedulers, scrapers, and ops bots in a weekend.

Claude Agent SDK for UK indie hackers: build your own programmatic AI coder in 2026

Most UK indie hackers meet Claude Code the same way: they install the CLI, type claude in a project folder, and start chatting. That is fine. That is, for the first month, plenty. The problem comes the first time you think, "I want this thing to run on its own."

A scheduler that does the boring half of your morning at 7am. A scraper that quietly turns ten Companies House filings into a one-pager every Friday. An ops bot that sits in your codebase and reacts to a webhook. The interactive Claude Code CLI was never going to do those jobs — you would have to be in front of it. The thing that does those jobs is the Claude Agent SDK, and as of late 2025 and early 2026 it is a public, first-class library. This post is the UK builder's tour: what it is, how to install it, a 40-line agent you can run today, and the weekend build idea that justifies the whole afternoon.

What the Claude Agent SDK actually is

The Claude Agent SDK is the library that powers Claude Code. The CLI you have been using is a thin wrapper around it. When you install the SDK, you are getting the same agent loop, the same tool-use machinery, the same MCP integration, the same subagent model, the same memory primitives — but exposed as a library you can call from your own code.

It matters because the alternative — the raw Anthropic API — gives you a chat completion. One prompt in, one response out. If you want the model to read a file, edit it, run a shell command, call another tool, or hand off to a subagent, you have to write that loop yourself. People have done it. It is hundreds of lines of careful glue and a year of bugs.

The Agent SDK is that glue, written by the people who built Claude Code, kept current with Claude Code, and supported by Anthropic. A UK indie hacker building their first agent should not be writing an agent loop in 2026. They should be using this one.

Two packages, same engine. TypeScript / Node: @anthropic-ai/claude-agent-sdk on npm. Python: claude-agent-sdk on PyPI. Pick whichever matches the rest of your stack. If you are already on Next.js, Vercel, and Supabase, TypeScript is the path of least resistance. If you are doing pandas, Jupyter, or scraping, Python.

A 40-line hello-world agent

Enough preamble. Here is the smallest useful agent: it reads a file and writes a summary to another file. TypeScript first.

mkdir morning-agent && cd morning-agent
npm init -y
npm install @anthropic-ai/claude-agent-sdk

Set your API key as an environment variable. On a UK Windows PC in PowerShell:

$env:ANTHROPIC_API_KEY = "sk-ant-..."

Or on macOS / Linux:

export ANTHROPIC_API_KEY="sk-ant-..."

Now agent.ts:

import { query } from "@anthropic-ai/claude-agent-sdk";

async function main() {
  const prompt = `
    Read the file ./notes/today.md.
    Summarise it in three bullet points.
    Write the summary to ./notes/today-summary.md.
    Reply with just "done" when finished.
  `;

  const response = query({
    prompt,
    options: {
      model: "claude-opus-4-7",
      cwd: process.cwd(),
      allowedTools: ["Read", "Write"],
      maxTurns: 6,
    },
  });

  for await (const message of response) {
    if (message.type === "assistant") {
      console.log(message.message.content);
    }
  }
}

main();

Run it with npx tsx agent.ts. The agent will read your file, write a summary, and tell you it is done. You have an agent.

The Python version is the same shape:

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
    options = ClaudeAgentOptions(
        model="claude-opus-4-7",
        allowed_tools=["Read", "Write"],
        max_turns=6,
    )
    prompt = (
        "Read ./notes/today.md, summarise in three bullets, "
        "write to ./notes/today-summary.md, reply 'done'."
    )
    async for message in query(prompt=prompt, options=options):
        if message.type == "assistant":
            print(message.content)

asyncio.run(main())

Forty lines, give or take. You now own a programmatic AI coder you can wire into anything that runs Python or Node.

Adding a custom tool

The real unlock is not the file edits. It is custom tools — your own functions, exposed to the agent, that it can call mid-loop. Here is a TypeScript example that gives the agent a lookupCompany tool backed by the (free, UK) Companies House API.

import { query, tool } from "@anthropic-ai/claude-agent-sdk";

const lookupCompany = tool({
  name: "lookup_company",
  description: "Look up a UK company by number on Companies House.",
  inputSchema: {
    type: "object",
    properties: {
      companyNumber: { type: "string" },
    },
    required: ["companyNumber"],
  },
  async run({ companyNumber }) {
    const res = await fetch(
      `https://api.company-information.service.gov.uk/company/${companyNumber}`,
      {
        headers: {
          Authorization:
            "Basic " + Buffer.from(process.env.CH_KEY + ":").toString("base64"),
        },
      }
    );
    return await res.json();
  },
});

const response = query({
  prompt: "Look up company 12345678 and summarise it in two sentences.",
  options: {
    model: "claude-opus-4-7",
    tools: [lookupCompany],
    maxTurns: 4,
  },
});

The agent decides when to call lookup_company, what to pass it, and what to do with the result. You did not write a loop. You wrote a tool, handed it over, and the SDK did the rest. That is the whole point.

Plugging in an MCP server

If you have already explored Model Context Protocol — and if you read the MCP primer for UK indie hackers — you will be glad to hear MCP servers are a first-class citizen in the Agent SDK. You can point your agent at the same Supabase MCP, GitHub MCP, or filesystem MCP you already use in Claude Code.

const response = query({
  prompt: "List the five most recent rows in the leads table.",
  options: {
    model: "claude-opus-4-7",
    mcpServers: {
      supabase: {
        command: "npx",
        args: ["-y", "@supabase/mcp-server-supabase"],
        env: {
          SUPABASE_URL: process.env.SUPABASE_URL!,
          SUPABASE_SERVICE_ROLE_KEY: process.env.SUPABASE_SERVICE_ROLE_KEY!,
        },
      },
    },
    allowedTools: ["mcp__supabase__*"],
  },
});

The agent now has the entire Supabase MCP toolset available, including SQL queries, schema introspection, and row inserts, scoped to the project whose keys you handed in. Same pattern works for GitHub, filesystem, browser, Gmail, Linear — anything with a published MCP server.

UK builder angle: pricing, infra, and the side-hustle frame

The honest cost shape. The Agent SDK bills on your Anthropic API key, not your Claude Code Pro plan. Expect:

  • A small hello-world agent run: 2p to 10p.
  • A meaty agent with five tool calls and a 30k-token context: 30p to GBP 1.50.
  • A daily morning brief that runs every weekday for a month: roughly GBP 5 to GBP 20 at current Opus pricing, less on Sonnet.

For comparison, Claude Code Pro at GBP 20/mo is unmetered for interactive use but does not cover programmatic runs. If you are running a daemon overnight, you are on the API meter, full stop.

Where to host it. A UK indie hacker has three sensible options:

  • Local PC. If you have a desktop that stays on, Windows Task Scheduler or cron on macOS / Linux is the cheapest possible host. Zero infra spend. Caveat: only as reliable as your home electricity.
  • Railway or Fly.io worker. Around GBP 4 to GBP 10/mo for a small always-on Node or Python worker. Easy to deploy from a UK timezone, sensible logging, EU regions for GDPR comfort.
  • Vercel cron. Free tier covers daily runs. Caveat: 60-second execution limit on the Hobby plan, so split long agent runs into stages or upgrade.

The side-hustle frame: an Agent SDK agent is a tiny piece of always-on labour you own outright. It does not call in sick, does not need management, and runs in your timezone. The first one you build will feel like a toy. The third one will feel like a quiet co-founder.

What can go wrong, and how to plan for it

Runaway token spend. An agent in a tight loop with the wrong maxTurns can burn GBP 10 in a minute. Always set maxTurns (six is plenty for most jobs), log every run, and put a hard daily spend cap on your Anthropic key. The cap is in the Anthropic console, takes thirty seconds, and is non-negotiable for unattended agents.

Tool misuse. An agent given the Bash or shell tool can in principle delete files or hit production. The fix is scope: allowedTools should be the smallest list that does the job. A scraper does not need Bash. A summariser does not need Write outside one folder. Set cwd to a sandboxed project directory. Treat the agent like a junior contractor with a security badge.

Silent failure. An agent that runs at 7am and fails at 7:02am is invisible unless you log. Always pipe runs to a file with a timestamp, and have the agent email or Slack you on exception. A five-line try/catch that sends to a webhook is the cheapest insurance you will buy.

Model drift between runs. Pin the model. model: "claude-opus-4-7" (or whichever ID is current at the time of writing — check the Anthropic models page). Letting the SDK pick a default means a future upgrade can change behaviour overnight. Pinning gives you a stable build.

Rate limits and 529s. Anthropic will rate-limit you, especially in the first month on a new key. Wrap your query call in a retry with exponential backoff. The SDK does not retry automatically by design — you decide your own policy.

No observability. A headless agent is a black box unless you build one. The cheapest fix is to log every query call as a JSON row to a local file or a Supabase table: timestamp, prompt hash, tools used, tokens in, tokens out, exit status. Ten minutes of plumbing, and your agent goes from invisible to debuggable. After a fortnight you will have a dataset that tells you which prompts are expensive, which tools the agent leans on, and where you are paying for a --max-turns that is too generous.

The weekend build: a Companies House morning brief

Here is a concrete, shippable, UK-flavoured weekend project: a 7am agent that emails a sole-trader founder a one-pager of fresh Companies House filings for a watch-list of competitors.

The shape:

  1. A JSON file watchlist.json with ten competitor company numbers.
  2. An agent that loops through them, calls Companies House for recent filings, and writes a markdown brief.
  3. The agent then formats the brief as HTML and sends it via Resend (or the Gmail MCP server) to your inbox.
  4. A Vercel cron or a Windows Task Scheduler entry kicks it off at 06:55 every weekday.

Token budget: a watchlist of ten companies, three filings each, Sonnet model — roughly 2p to 6p per morning, GBP 0.40 to GBP 1.20 per month. Resend free tier covers the email. Total infrastructure cost: zero.

Friday afternoon, you will have an agent. Monday morning at 7am, before your second coffee, the brief lands. That is the moment the Agent SDK stops being abstract.

If you want a starting brief for the what — a UK opportunity that fits this exact shape — pick up this week's free report. Same data depth, same UK-first lens, ready to feed straight into your first weekend build.

Frequently asked

What is the Claude Agent SDK and how is it different from the raw Anthropic API?

The Claude Agent SDK is the official library that powers Claude Code itself. The raw API gives you a single chat completion. The Agent SDK gives you the full agent loop: tool use, file edits, shell commands, MCP servers, subagents, and memory. You write a few lines of code and you get an agent, not a chatbot.

Which package do I install for TypeScript or Python?

For Node and TypeScript the package is @anthropic-ai/claude-agent-sdk on npm. For Python it is claude-agent-sdk on PyPI. Both wrap the same underlying agent loop and accept the same prompts. Most UK indie hackers pick TypeScript if they are already on a Next.js stack and Python if they are doing data work.

Do I pay for the Claude Agent SDK with my Claude Code Pro subscription?

No. Claude Code Pro covers interactive use of the Claude Code CLI. The Agent SDK runs against the Anthropic API and bills per token on your API key. Budget around 30p to GBP 1.50 per substantial agent run while you are learning, then drop sharply once you cache the system prompt and tighten the loop.

Can I run an Agent SDK agent from a Windows PC or a Vercel cron job?

Yes. The SDK is a normal library. Anywhere you can run Node 20 or Python 3.10 you can run it: a UK developer's home PC, a Railway worker, a Vercel cron, a Hetzner box in Helsinki, a GitHub Action. The agent is just code, so deploy it wherever your other code lives.

Is the SDK safe to give file system or shell access?

It is as safe as you make it. The SDK exposes allowed tools, working directory, and permission modes so you can lock an agent down to a single folder or a curated tool list. For a weekend build, run it in a project subfolder with only the tools it needs, log everything, and never point it at your home directory.

Related reading

More UK-focused guides from the IdeaStack blog.

Deploy a headless Claude Code worker to Railway: a UK indie hacker guide for 2026

Deploy a headless Claude Code worker to Railway: a UK indie hacker guide for 2026

When the home PC is the wrong host - webhooks, public endpoints, multi-user triggers - Railway is the cleanest move for a UK indie hacker. Sterling billing, EU regions, a Dockerfile-or-Procfile worker. Here is the full walkthrough, including the storage and env gotchas.

Read more →

Error tracking for your live v1 (UK SaaS, Claude Code 2026)

Error tracking for your live v1 (UK SaaS, Claude Code 2026)

Your v1 is live, three founding members are using it, and the next outage is a question of when, not if. This is the right-sized observability layer for a brand-new UK SaaS: the three things actually worth watching, how to wire error tracking and a money-path alarm into a Next.js app with Claude Code in one session, source maps so a stack trace points at real code, a simple uptime ping, and the discipline to stop there instead of building enterprise monitoring for three customers.

Read more →

Your first feature build session after launch (UK SaaS, Claude Code 2026)

Your first feature build session after launch (UK SaaS, Claude Code 2026)

Your v1 is live and three founding members are using it. The feedback is rolling in faster than you can build. This is the UK indie hacker guide to your first feature build session after launch: how to read founding feedback for the one signal that matters, pick the single feature that removes the most friction, scope it to one Claude Code session, build and test it against the money path, and ship it the same day with a 'you asked for this' note that turns a paying founder into an evangelist.

Read more →

Ship your v1 to founding members (UK SaaS, Claude Code 2026)

Ship your v1 to founding members (UK SaaS, Claude Code 2026)

Scaffold done, auth and billing wired. Now you ship the v1 to the founding members who already paid. This is the UK indie hacker go-live checklist: the pre-launch checks that stop launch day going sideways, how to onboard three pre-paid founders by hand, the feedback loop that tells you what to build next, and the first iteration cadence that turns a founding cohort into retained, paying customers instead of three refunds.

Read more →

Supabase auth + Stripe billing for a UK SaaS (Claude Code, 2026)

Supabase auth + Stripe billing for a UK SaaS (Claude Code, 2026)

Your skeleton is live. Now your founding members need two things: a way to log in and a way to keep paying you. This is the UK indie hacker walkthrough for wiring Supabase auth and Stripe subscriptions with Claude Code - the auth flow, the subscription model, the one webhook that actually matters, and the UK-specific decision every US tutorial skips: do you take payments through Stripe directly and own your VAT, or go through a Merchant of Record like Paddle and hand the VAT headache away?

Read more →

The newsletter

One UK business idea, every Thursday

By Tim Bland. Free.