← All posts
Autonomous agentsClaude Agent SDKSelf-hostingAI Integration

An autonomous engineer your team actually owns

Devin and Cursor's background agents are impressive — and they're someone else's cloud, metered per task, holding your code. Here's the full architecture for building the same capability self-hosted: the loop, the data model, the six-phase plan, and the hardening that makes it safe for a real team.

Assign a task in plain English. An agent reads the repo, writes a plan, makes the changes, runs the tests, fixes what breaks, reviews its own diff, and opens a pull request for you. That’s the promise of Devin and of Cursor’s background agents — and it’s real, it works, and it’s genuinely useful.

It’s also somebody else’s cloud. Your source code is cloned onto their machines, the work is metered per task, and the agent’s behavior is a black box you configure but don’t control. For a lot of teams that trade is fine. For teams with private codebases, a fixed budget, and opinions about how their code gets written, it isn’t.

So we build the same capability a different way: self-hosted, on your infrastructure, on a Claude subscription you already pay for. This is the complete architecture behind the one we run internally, called Origin — and it’s more buildable than it looks.

The realization: most of it is plumbing you already have

An autonomous engineer sounds like a moonshot. It isn’t — it’s an orchestration layer over parts that already exist and are boring in the best way. Here’s the whole system on one page:

flowchart LR
  U["Team member"] -->|"assign · or label an issue"| O["Origin surface"]
  O --> ORC["Orchestrator"]
  ORC --> BR["Agent SDK executor"]
  BR --> WS["Isolated repo worktree"]
  WS -->|"push branch + PR"| GH["GitHub"]
  ORC -->|"repo test suite"| TST["Tests"]
  ORC -->|"verify the diff"| RV["Auto-review"]
  BR -.->|"plan · tool · diff · test · pr events"| O
  GH -.->|"issue label / PR comment"| ORC

Look at what each box actually is:

The agent supplies the judgment; everything around it — where it runs, what it’s allowed to touch, when a human signs off — is ordinary software you control. When we mapped our own build, roughly 70% was infrastructure we already ran:

CapabilityStatusWhat it is
Autonomous executor (shell · edit · git · web · MCP)HaveClaude Agent SDK
Clone → branch → commit → push → PRHavea shell wrapper
GitHub identity, per user (OAuth)Havegh + token
Run the repo’s test suiteHavethe repo’s own command
Claim-verifying PR reviewHavea reviewer agent
Live streaming of the agent’s workHaveSDK event stream
Kill switch & approval gateHavestop flag + gate
Run state machine & event logNewtwo DB tables
Isolated workspace + limits + queueNewworker + worktrees
The plan→build→test→review→PR loopNewthe orchestrator
The surface (board · session · diff)Newthe UI

The new work is a run record, an orchestration loop, and a UI. That’s the whole delta.

The loop that makes it trustworthy

A single agent call that “does the thing” is a demo. A colleague you’d let near a real repo is a state machine with checkpoints:

flowchart LR
  Q([task]) --> P[Plan]
  P -->|"⚑ approve plan"| B[Build]
  B --> T[Test]
  T -->|fail| B
  T -->|pass| R[Review]
  R --> S[Ship]
  S -->|"⚑ approve push"| PR([Pull request])
  1. Plan — reads the repo, breaks the goal into a checklist with acceptance criteria.
  2. Build — edits files in an isolated worktree with a shell, editor and git — streaming every step.
  3. Test — runs the repo’s suite. On failure, feeds the output back and fixes — up to N loops.
  4. Review — runs a claim-verifying reviewer over its own diff before it asks you.
  5. Ship — pushes the branch, opens an idempotent PR with a summary. It never merges to main.

Two of those stages carry an optional human gate — approve the plan before any code is written, approve before anything is pushed. The default posture is the important design decision:

Origin is a colleague who opens pull requests, not a bot with commit access to main.

Autonomy without handing over the keys.

The build, in six phases

We ship this the way we ship anything — in dependency order, where each stage is independently useful. The first two phases are the MVP (assign a task → it opens a PR); the safety phase is the bar for real team use.

PhaseWhat it deliversEffort
P0 Data model & surfaceRun record, event log, an empty board wired to real endpoints≈ 1–2 days
P1 Repo executionClone → the agent edits in the repo → push branch → open a PR≈ 2–3 days
P2 The loop & gatesPlan → test-fix → review, plan/push approval, steering, blocked-needs-input≈ 3–4 days
P3 Live session UIBoard + plan, streaming activity, diff, tests, PR≈ 3–5 days
P4 HardeningIsolation, secrets, guardrails, budget, audit, concurrency≈ 1–2 weeks
P5 Team integrationIssue-label & PR-comment triggers, per-project config, team skills≈ 3–5 days

What “production-ready” actually means

The gap between an impressive demo and something a team uses every day is entirely in the boring safety work — and it’s the part worth paying attention to:

ControlWhat it does
IsolationEach run gets its own workspace under an unprivileged user, in CPU/memory/time limits
Scoped secretsThe launcher’s git token is injected into that run only — never persisted or logged
GuardrailsWork-branch only, no force-push, no destructive shell, a path allowlist
Secret-leak scanThe diff is scanned for keys before any push; .env never rides along
Hard budgetA per-run token/dollar cap that stops at the ceiling, cost streaming live
Human gatesPlan- and push-approval, configurable per project; PR-only by default
Audit trailEvery shell command, tool call and git op logged immutably

None of that is glamorous. All of it is the difference between a party trick and something you’d point at your revenue-generating codebase.

Why own it

Running it yourself buys three things the hosted products can’t: your code never leaves your machines; the cost is your existing subscription instead of a per-task meter that scales with usage exactly when you want to use it most; and the agent works to your standards — your conventions, your review checklist, your definition of done — because you wrote the harness.

It plugs into the rest of your stack, too. Label an issue and a run spawns itself. A pull-request comment kicks off a fix. The same agents, budgets and knowledge base your team already uses are right there.

An autonomous engineer isn’t a product you have to buy. It’s an orchestration layer over tools you can run — and owning it is very much the point.


This is the approach we build for teams: autonomous engineering on your own infrastructure, wired into the tools you already run. If that’s a fit for how your team ships, start a project.

Want something like this built for your team?

Get a quote →