How I’ve used devcontainers to speed up my work 20x

I run Claude Code with --dangerously-skip-permissions most of the day now. Without the flag, the agent stops to ask before reading a file, before writing with Python or sed, before almost any command. With it, I hand over a task and scroll my Instagram feed while it works.

The flag has “dangerously” in its name for a reason, so I never run it on my own machine. I run it inside a devcontainer, where Claude works in a Docker image and can’t touch my computer or my data.

The catch is the setup. A useful devcontainer needs a firewall, GitHub access, database access, git worktrees, and a set of skills and hooks to keep the agent in line. Here is how I configured each one. I’ve also published a repository with the whole configuration, and you’ll find the link at the end of the post.

Why run Claude Code with skip permissions inside a devcontainer

Permission prompts are what make an agent slow. Each one waits for me, and I’m usually doing something else. Skipping them removes the waiting, but it also removes the safety net.

The devcontainer puts the safety net back at a different level. Claude can do whatever it wants inside the container, and the container decides what it can reach outside: which domains, which credentials, which branches.

claude --dangerously-skip-permissions

Configuring the devcontainer firewall for dependencies and ports

The firewall is the first thing to get right. Too strict and the agent can’t install anything; too open and the container stops protecting you.

My allowlist covers what the agent actually needs:

  • npm for Node dependencies and PyPI for Python
  • GitHub
  • Google, for the occasional search
  • Figma URLs, if you use the Figma MCP

I also open the ports the application uses, so Claude can run it inside the devcontainer while I test it from outside. This is very useful: I can click through the feature in my browser and give feedback without waiting for a PR.

Letting the agent open pull requests with a GitHub token

I created a GitHub token so the agent can open pull requests by itself. After I write the prompt and validate the plan, I sit and wait for the PR.

Read-only access to the dev database and AWS for investigation

The agent has read-only access to my dev database and to the AWS infrastructure, so it can check the real state of the data or the infrastructure instead of guessing from the code.

Some bugs only make sense with that context. A failed payment action can come from a missing field in the data. A container that misbehaves can be running a version that was never deployed. The code alone won’t tell you either of those.

Make sure the access is read-only. An agent running without permission prompts should never hold write credentials to anything that matters.

Running parallel Claude sessions with git worktrees

I configured git to create a new worktree every time I start on a new topic. Each worktree is an independent checkout of the same repository, so I can run several Claude sessions at once, each on its own branch.

git worktree add ../bazinga-backend-payment-retry -b feature/payment-retry

I don’t wait for one task to finish before starting the next. At this point the real question is who’s faster: me writing prompts, or Claude writing the code I asked for.

The skills, commands and hooks that keep the agent safe

All of this runs through a few skills, commands and hooks. Some are deterministic scripts, because some rules shouldn’t depend on the agent remembering them.

A git hook that blocks direct pushes to main and develop

This one is a plain script. It refuses any push to develop, main, hotfix and the other protected branches, so every change goes through a PR.

#!/usr/bin/env bash
protected='^(main|develop|hotfix.*)$'

while read -r local_ref local_sha remote_ref remote_sha; do
  branch="${remote_ref#refs/heads/}"
  if [[ "$branch" =~ $protected ]]; then
    echo "Direct push to $branch is blocked. Open a pull request." >&2
    exit 1
  fi
done

A create-PR skill for branch names and short descriptions

The create-PR skill tells the agent how to name the branch and how to write the commit title and description. I keep the description short, because nobody reads a long one.

What it must include:

  • the ticket number
  • a warning when the change impacts other projects
  • any required migration
  • any backward-compatibility issue

A code reviewer skill in a root repository

I keep an extra repository at the root folder of each project. Say the project is called “bazinga”. I have:

bazinga-root
bazinga-backend
bazinga-frontend
bazinga-terraform
bazinga-job-first

bazinga-root only holds a glossary, a README, the Claude markdown files and the devcontainer configuration.

The code reviewer checks that the changes aren’t overcomplicated and follow the naming conventions. It also checks that the existing unit tests still pass and stay simple, that new tests cover the new behavior, and that the documentation is up to date.

A feature implementation skill that starts in plan mode

This skill forces plan mode before any code is written. The agent asks about every case and edge case, then describes where the changes go, which projects they impact, and what existing code it will reuse.

A debug skill that writes the failing test first

The debug skill can reach the database when it needs to, through an SSH tunnel that isn’t always running. The agent has to ask me to start it. Same for cloud access: it gets read-only access to AWS (or GCP) only after I refresh the credentials. I decide when the agent touches those resources, not the agent.

Before changing any code, it writes unit tests that reproduce the incorrect behavior and runs them. That confirms the bug and narrows down where it lives. After the fix, those same tests must go green.

Scripts for git worktree creation and cleanup

Another deterministic script creates all the worktrees a task needs before any change starts. When I exit the devcontainer and close the Claude session, it removes and prunes them to free up space.

git worktree remove ../bazinga-backend-payment-retry
git worktree prune

How much faster an autonomous Claude Code setup burns your tokens

Expect your Claude token consumption to climb with this setup.

Before the devcontainer, I pinned the files Claude needed, sometimes down to the exact lines. Now the agent builds its own context. It reads the README and the Claude files again and again, and it runs a review on every change.

On my $20 subscription, I never went above 25% of my weekly usage before using devcontainers. Now I easily reach 90%.

Devcontainer sample repository with the full Claude Code configuration

The devcontainer, the firewall rules, the hooks and the skills described above are all in this repository: github.com/serlesen/devcontainers-sample


Discover more from The Dev World – Sergio Lema

Subscribe to get the latest posts sent to your email.


Comments

Leave a Reply