DEV Community

Cover image for One Open Source Project a Day (No. 185): Coder — Self-Hosted Cloud Dev Environments, Now Also a Safe Workshop for AI Agents
WonderLab
WonderLab

Posted on

One Open Source Project a Day (No. 185): Coder — Self-Hosted Cloud Dev Environments, Now Also a Safe Workshop for AI Agents

Introduction

"Give every developer a consistent, isolated, disposable dev machine — now give every AI agent the same kind of workshop."

This is the 185th article in the "One Open Source Project a Day" series. Today's project is Coder.

"It works on my machine" is a classic problem every team has hit — a new hire spends three days configuring an environment, a dependency won't install after an OS upgrade, or the local dev box simply doesn't have enough resources to run a large project. Cloud Development Environments (CDEs) answer this problem: move the dev environment to the cloud, define it declaratively with Terraform, and make it consistent, reproducible, and disposable on demand.

But Coder has picked up a second layer of meaning in recent years. As AI coding agents (Claude Code, Codex, Cursor, and others) start executing tasks autonomously, a new question shows up: where does the agent actually run? Where does its API key live? Who can see what it did?

Coder's answer: run agents on the same isolated, auditable infrastructure as human developers. The agent's reasoning loop runs on the control plane, and no LLM credentials ever sit inside the workspace — this is a security boundary designed for AI agents from the start, not a bolt-on fix.

14.9k Stars, AGPL-3.0, built in Go.

What You Will Learn

  • How Coder uses Terraform to define cloud development environments
  • The WireGuard-tunnel network architecture connecting workspaces
  • Four ways to run AI agents: Coder Agents, Agent Relay, Agents in the IDE, and Agents in workspace templates
  • How the AI Gateway centralizes model governance, cost tracking, and auditing
  • How Coder's positioning differs from traditional CDEs like GitHub Codespaces and Gitpod

Prerequisites

  • Basic understanding of Terraform (Infrastructure as Code)
  • Familiarity with basic Docker/Kubernetes operations
  • Optional: familiarity with AI agent tool-calling and MCP concepts

Project Background

What It Is

Coder's official positioning is "Self-Hosted Cloud Development Environments and AI Agents." The GitHub description is even more direct: "Secure environments for developers and their agents."

That line captures Coder's current dual identity: a traditional cloud development environment platform, and a secure runtime foundation for AI agents.

Team and Background

  • Repository: coder/coder
  • Website: coder.com
  • License: AGPL-3.0 (enterprise features are covered by a separate license, see the repo's LICENSE.enterprise)
  • Primary languages: Go (backend) + TypeScript (frontend, in the site directory)

Project Stats

  • ⭐ GitHub Stars: 14,900+
  • 🍴 Forks: 1,500+
  • 👀 Watchers: 82
  • 📄 License: AGPL-3.0
  • 🌐 Website: coder.com

What It Does

The Problem It Solves

Traditional dev environment setup:
  New hire → install system deps → configure IDE → set up DB → get running
  ↑ Takes days, and "works on my machine" issues are common
  ↑ Local machine may lack the resources for large projects

Cloud development environments (Coder's approach):
  Terraform template defines the environment → developer clicks a button → consistent env in seconds
  ↑ Onboarding time drops from days to seconds
  ↑ Idle resources shut down automatically, saving cost
  ↑ Environments are fully consistent — no more "my machine" problem

The new problem in the AI agent era:
  You want Claude Code / Codex to run tasks autonomously
  → Where does it actually run? Locally? Inside the workspace?
  → Where does the API key live? Is exposing it to the workspace safe?
  → Who's tracking how many tokens the agent spent and what it did?

Coder's answer:
  The agent's reasoning loop runs on the control plane (on your own infrastructure)
  → No LLM credentials ever live inside the workspace
  → Every action is tied to a specific user identity — auditable by design
  → The AI Gateway centralizes authentication, cost, and policy
Enter fullscreen mode Exit fullscreen mode

Use Cases

  1. Standardized development environments for teams/enterprises

    • Replace "everyone configures their own machine" — new hires get a standardized workspace in seconds
  2. Cloud-based development for large projects

    • Offload compute-heavy work to the cloud when local hardware isn't enough; the local machine is just a lightweight client
  3. Hosting AI agent background tasks

    • Delegate long-running tasks to Claude Code, Codex, and other coding agents inside isolated workspaces without tying up the developer's local machine
  4. Enterprise-grade AI model governance

    • Scenarios that need to track team-wide token usage, which agents called which tools, and centrally manage API keys
  5. Environments with strict compliance and audit requirements

    • Industries like finance and healthcare that need complete operational audit logs for their dev environments

Quick Start

# Quick local trial
curl -L https://coder.com/install.sh | sh
coder server

# Production deployment (requires PostgreSQL 13+)
coder server --postgres-url <postgres-connection-string> --access-url <public-url>
Enter fullscreen mode Exit fullscreen mode

A Helm Chart is also available for Kubernetes deployment, suited to team-scale production use.

Core Features

1. Terraform-Defined Workspaces

Each workspace's underlying infrastructure is declared through a Terraform template, with support for:

Backend Description
AWS EC2 instances and other cloud resources
Kubernetes Pod-level workspaces
Docker Containerized workspaces, good for local/small-scale deployments
Other cloud platforms Extendable through the Terraform Provider ecosystem

The Template Builder offers a guided UI for common configurations, so you don't need to hand-write Terraform for everything.

2. WireGuard Secure Tunnels

Workspaces connect over WireGuard tunnels, keeping network traffic secure while supporting flexible topologies — direct SSH, IDE remote connections, or the web terminal.

3. Automatic Shutdown of Idle Resources

Workspaces automatically shut down their underlying compute resources when unused, starting them back up only on demand — a key cost control mechanism that avoids the classic "forgot to turn off the cloud VM" problem.

4. Four Ways to Run AI Agents

Method Best For
Coder Agents A built-in native AI coding agent whose reasoning loop runs on the control plane; the workspace can be fully network-isolated, ideal for long-running background tasks
Agent Relay Connects a cloud-hosted agent service (like Cursor Cloud Agents) to a self-hosted workspace — reasoning happens in the cloud, the workspace executes tool calls (early preview)
Agents in the IDE Integrates with IDE-native agents like Cursor, Devin Desktop, and Zed, working alongside a developer's existing workflow
Agents in workspace templates Template admins install terminal-based agents like Claude Code or Codex directly into workspace templates via Registry modules

An example of an agent baked into a template:

module "claude-code" {
  source   = "registry.coder.com/coder/claude-code/coder"
  version  = "~> 5.2"
  agent_id = coder_agent.main.id
}
Enter fullscreen mode Exit fullscreen mode

5. AI Gateway (Enterprise)

Centralized management of all AI model access:

  • Unified authentication: no need to configure API keys separately in every workspace
  • Audit trail: logs all prompts and tool calls
  • Policy enforcement: governs access to upstream LLM providers
  • Agent Firewall: process-level network and command policies that constrain what an agent can access and execute inside a workspace

6. Editor and Ecosystem Integrations

  • VS Code extension, JetBrains Toolbox plugin
  • Dev Containers support (@devcontainers/cli + Docker)
  • Envbuilder (an alternative for environments without Docker access)
  • Kubernetes log streaming, GitHub Actions integration

A Deeper Look

Why Running the Agent Loop on the Control Plane Matters

This is the most interesting architectural choice in Coder's AI agent design. Most AI coding tools follow this pattern:

Common architecture (agent runs inside the workspace/locally):
  Developer machine / workspace
  ├── AI agent process
  ├── LLM API key (in an env var/config file)
  └── Tool calls execute directly, locally

  Risk: if the workspace is compromised, the API key is exposed directly
  Risk: there's no unified audit point for everything the agent does
Enter fullscreen mode Exit fullscreen mode

Coder Agents takes a different approach:

Coder's architecture (agent reasoning runs on the control plane):
  Control plane (your infrastructure, not the workspace)
  ├── Agent reasoning loop
  ├── LLM API key (lives here, and only here)
  └── Decisions → dispatched to the workspace for execution

  Workspace
  ├── Only receives specific execution instructions
  ├── Never stores any credentials
  └── Execution results → reported back to the control plane

  Benefits:
  - A compromised workspace leaks no API key (it's simply not there)
  - Every tool call is tied to a user identity — auditable by design
  - Workspaces can be fully network-isolated and the agent still works
Enter fullscreen mode Exit fullscreen mode

The design essentially separates "brain" from "hands and feet" — reasoning happens in a controlled central environment, execution is distributed to isolated workspaces. For enterprise scenarios that need compliance audits, this architecture gives you a single, controllable audit point.

The Trade-offs Across Four Agent Modes

Coder doesn't push a single way to integrate AI agents — it offers four choices, each mapping to a different trust model and use case:

Ranked by trust level, highest to lowest:

1. Coder Agents (most controlled)
   Reasoning happens entirely on your infrastructure; credentials never leave the control plane
   Best for: enterprises with strict compliance needs requiring full audit trails

2. Agents in workspace templates (controlled + flexible)
   The agent itself runs inside the workspace, but the workspace is standardized and auditable
   Best for: teams that need to use specific tools like Claude Code or Codex

3. Agents in the IDE (developer autonomy)
   Follows the developer's own local IDE configuration; Coder just provides the underlying workspace
   Best for: letting developers use familiar tools while Coder handles the infrastructure

4. Agent Relay (trusting a third-party cloud service)
   Orchestration/reasoning happens on a third-party cloud, the workspace just executes
   Best for: teams that want cloud agent capabilities like Cursor Cloud, but need self-hosted execution
Enter fullscreen mode Exit fullscreen mode

The practical implication of this layered design: different teams have different trust boundaries for "what can the AI agent see, what can it do." Coder covers the entire spectrum — from "fully closed internal loop" to "bring in external cloud intelligence" — on the same underlying infrastructure.

How It Compares to Similar Cloud Development Environments

Dimension GitHub Codespaces Gitpod Coder
Deployment GitHub-hosted only Mostly cloud-hosted Fully self-hosted
Infrastructure definition Limited customization .gitpod.yml Terraform (full IaC)
Data sovereignty ❌ Lives on GitHub's cloud Partial ✅ Fully self-controlled
Native AI agent support Limited Limited ✅ Four modes
Model governance (AI Gateway) ✅ Enterprise
Backend flexibility Fixed Fixed Choose AWS/K8s/Docker
Open source Partially open ✅ AGPL-3.0

Coder's core differentiation: data sovereignty from full self-hosting + Terraform-level infrastructure flexibility + a security boundary purpose-built for AI agents. The trade-off is you have to operate the system yourself rather than getting "it just works" like Codespaces.


Project Links and Resources

Official Resources

Related Resources

  • Terraform — The foundation of Coder's template system, declarative infrastructure definition
  • Devcontainers — The containerized dev environment standard Coder supports
  • Model Context Protocol — The tool-calling standard relevant to Coder's agent ecosystem

Summary

Key Takeaways

  1. Terraform defines everything: workspace infrastructure is declared as IaC, freely choosing AWS/Kubernetes/Docker backends, fully reproducible
  2. WireGuard secure tunnels + automatic idle shutdown: network security and cost control together
  3. Four AI agent integration modes: from the fully controlled Coder Agents to the flexible Agents in the IDE, covering different trust boundaries
  4. Agent reasoning runs on the control plane: credentials never enter the workspace, auditable by design — a security architecture built for the AI agent era, not a feature bolted onto a traditional CDE
  5. The AI Gateway provides centralized governance: unified authentication, cost tracking, and policy enforcement — necessary infrastructure for enterprise-grade AI usage

Who This Is For

  • Teams that need a self-hosted cloud dev environment: don't want code and data on a third-party cloud, but still want Codespaces-level experience
  • Organizations running AI coding agents at scale: need to centrally manage API keys, track cost, and audit agent actions
  • Enterprises with strict compliance and audit requirements: finance, healthcare, and other industries that need complete operational logs
  • DevOps/platform teams: want to manage dev environment infrastructure uniformly with Terraform instead of everyone configuring their own

One-Line Verdict

Coder originally solved the old problem of "cloud development environments," but the security boundary it built for AI agents — reasoning on the control plane, credentials never in the workspace — may turn out to be its real value in this era.


Check out PrimeSkills — a curated marketplace of AI agents and skills that have been validated in real-world, enterprise-grade workflows. No fluff, just what actually works.

Find more useful knowledge and interesting products on my Homepage

Top comments (0)