Skip to content

Integrated Claude/Codex in Dev Container - #136

Open
srinath-iyer wants to merge 5 commits into
mainfrom
integrated-cc-codex
Open

srinath-iyer wants to merge 5 commits into
mainfrom
integrated-cc-codex

Conversation

@srinath-iyer

@srinath-iyer srinath-iyer commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

These changes allow you to run Claude/Codex in a VSCode Dev Container.

Roughly, it adds the install commands for Claude/Codex CLI to Dockerfile. Additionally, the devcontainer.json config pulls in the local auth info for codex and claude (for linux/wsl, as MacOS stores auth in Keychain).

Usage:
claude or codex in the terminal, and then login if on MacOS for every rebuild; if Linux/WSL, auto-login.

Testing:
Tested on MacOS, and WSL, and Linux.

Future Work:
If MacOS re-login is a pain, we will find an alternative. For example, copying over the API key into .env. But for now this is a minor inconvenience.

@srinath-iyer

Copy link
Copy Markdown
Contributor Author

Note: The linter fails because of new rules added in July 2026 to Ruff. These are fixed in #130 but are not here as it's improper to include here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Authentication initialization and path handling issues remain, along with unnecessary privileged container access.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Claude Code and Codex CLI support to the VS Code Dev Container.

Changes:

  • Installs both CLIs in the Docker image.
  • Adds host authentication/configuration mounts.
  • Documents setup and platform-specific authentication.
File summaries
File Changes
SETUP.md Documents CLI usage and authentication behavior.
docker/Dockerfile Installs Claude Code and Codex.
docker-build.sh Creates host CLI configuration paths.
.devcontainer/devcontainer.json Adds authentication mounts and container settings.
Review details

Suppressed comments (4)

.devcontainer/devcontainer.json:11

  • initializeCommand invokes docker-build.sh skip-wsl, and that script exits at its WSL check before reaching the new mkdir/touch commands. A first-time WSL Dev Container therefore still has missing auth paths (and Docker may create .claude.json as a directory), contrary to this comment and the documented auto-mount behavior. Move path creation before the skip or create the paths in a WSL-safe initialization step.
    // docker-build.sh creates these paths on the host first if they don't already exist.

.devcontainer/devcontainer.json:15

  • This source expression concatenates HOME and USERPROFILE instead of selecting one. On Windows/WSL environments where both variables are present, it expands to an invalid path such as /home/userC:\Users\user/.claude, so the bind mounts do not expose the host credentials. Use a single normalized host-home variable or separate OS-specific mount configuration.
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude,target=/home/ubuntu/.claude,type=bind",
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude.json,target=/home/ubuntu/.claude.json,type=bind",
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.codex,target=/home/ubuntu/.codex,type=bind"

SETUP.md:196

  • The new setup note contains the typo fro; please correct it to for.
If you're using VS Code Dev Containers and already have Claude Code and/or the Codex CLI set up (logged in) on your host machine, the Dev Container automatically bind-mounts your host `~/.claude/`, `~/.claude.json`, and `~/.codex/` config/auth paths into the container. This means `claude`/`codex` are already logged in inside the container, and any changes (for example, updated settings or a new login) are shared between your host machine and the container. NOTE: This is only supported fro Linux/WSL. For MacOS, currently it is required to login every clean build.

docker-build.sh:58

  • When ~/.claude.json is absent, touch creates a zero-byte file. Since that file is then bind-mounted as Claude's JSON config, it is an existing but invalid configuration rather than an absent one and can make the CLI fail before login. Initialize it to {} only when absent, preserving any existing file.
touch ~/.claude.json
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .devcontainer/devcontainer.json Outdated
Comment thread docker-build.sh
Comment on lines +52 to +59
# Create Claude Code and Codex config/auth paths if they don't already exist
# The Dev Container bind-mounts these paths (see .devcontainer/devcontainer.json) so that a developer's existing
# Claude Code/Codex CLI login carries over into the container. Creating them here first ensures Docker mounts a
# file at ~/.claude.json (instead of creating an empty directory in its place, which is Docker's default
# behavior when bind-mounting a file path that doesn't exist yet)
mkdir -p ~/.claude
touch ~/.claude.json
mkdir -p ~/.codex
Comment thread SETUP.md Outdated
### Claude Code and Codex CLIs
The Claude Code and Codex CLIs are installed in the Dev Container, so you can run `claude` or `codex` in any integrated terminal.

If you're using VS Code Dev Containers and already have Claude Code and/or the Codex CLI set up (logged in) on your host machine, the Dev Container automatically bind-mounts your host `~/.claude/`, `~/.claude.json`, and `~/.codex/` config/auth paths into the container. This means `claude`/`codex` are already logged in inside the container, and any changes (for example, updated settings or a new login) are shared between your host machine and the container. NOTE: This is only supported fro Linux/WSL. For MacOS, currently it is required to login every clean build.
Comment thread docker/Dockerfile
Comment on lines +138 to +142
ENV NVM_DIR=/home/ubuntu/.nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install --lts=Jod \
&& npm install -g @anthropic-ai/claude-code @openai/codex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems valid

nathanaelren
nathanaelren previously approved these changes Sep 17, 2026

@nathanaelren nathanaelren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big Saag

Comment thread docker-build.sh Outdated
Comment on lines +52 to +56
# Create Claude Code and Codex config/auth paths if they don't already exist
# The Dev Container bind-mounts these paths (see .devcontainer/devcontainer.json) so that a developer's existing
# Claude Code/Codex CLI login carries over into the container. Creating them here first ensures Docker mounts a
# file at ~/.claude.json (instead of creating an empty directory in its place, which is Docker's default
# behavior when bind-mounting a file path that doesn't exist yet)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cut AI slop

Comment thread .devcontainer/devcontainer.json Outdated
Comment thread docker/Dockerfile
Comment on lines +133 to +137
# Install the Claude Code and Codex CLIs
# These are installed here (rather than relying on a host install) so that they run natively regardless of the
# host machine's OS/architecture. The Dev Container bind-mounts each developer's host ~/.claude, ~/.claude.json,
# and ~/.codex config/auth paths (see .devcontainer/devcontainer.json), so these CLIs are already logged in if the
# developer has Claude Code and/or the Codex CLI set up on their host machine

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cut AI slop

@nathanaelren

Copy link
Copy Markdown
Contributor

🟡 Changes recommended

Authentication initialization and path handling issues remain, along with unnecessary privileged container access.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Claude Code and Codex CLI support to the VS Code Dev Container.

Changes:

  • Installs both CLIs in the Docker image.
  • Adds host authentication/configuration mounts.
  • Documents setup and platform-specific authentication.
File summaries

| File | Changes |

|---|---|

| SETUP.md | Documents CLI usage and authentication behavior. |

| docker/Dockerfile | Installs Claude Code and Codex. |

| docker-build.sh | Creates host CLI configuration paths. |

| .devcontainer/devcontainer.json | Adds authentication mounts and container settings. |

Review details

Suppressed comments (4)

.devcontainer/devcontainer.json:11

  • initializeCommand invokes docker-build.sh skip-wsl, and that script exits at its WSL check before reaching the new mkdir/touch commands. A first-time WSL Dev Container therefore still has missing auth paths (and Docker may create .claude.json as a directory), contrary to this comment and the documented auto-mount behavior. Move path creation before the skip or create the paths in a WSL-safe initialization step.
    // docker-build.sh creates these paths on the host first if they don't already exist.

.devcontainer/devcontainer.json:15

  • This source expression concatenates HOME and USERPROFILE instead of selecting one. On Windows/WSL environments where both variables are present, it expands to an invalid path such as /home/userC:\Users\user/.claude, so the bind mounts do not expose the host credentials. Use a single normalized host-home variable or separate OS-specific mount configuration.
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude,target=/home/ubuntu/.claude,type=bind",
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.claude.json,target=/home/ubuntu/.claude.json,type=bind",
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.codex,target=/home/ubuntu/.codex,type=bind"

SETUP.md:196

  • The new setup note contains the typo fro; please correct it to for.
If you're using VS Code Dev Containers and already have Claude Code and/or the Codex CLI set up (logged in) on your host machine, the Dev Container automatically bind-mounts your host `~/.claude/`, `~/.claude.json`, and `~/.codex/` config/auth paths into the container. This means `claude`/`codex` are already logged in inside the container, and any changes (for example, updated settings or a new login) are shared between your host machine and the container. NOTE: This is only supported fro Linux/WSL. For MacOS, currently it is required to login every clean build.

docker-build.sh:58

  • When ~/.claude.json is absent, touch creates a zero-byte file. Since that file is then bind-mounted as Claude's JSON config, it is an existing but invalid configuration rather than an absent one and can make the CLI fail before login. Initialize it to {} only when absent, preserving any existing file.
touch ~/.claude.json
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Alright bro

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants