Skip to content

Commit 9981085

Browse files
committed
add claude code support
1 parent feb3641 commit 9981085

5 files changed

Lines changed: 47 additions & 20 deletions

File tree

‎README.md‎

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
> [!NOTE]
44
> This project is meant for people working on the Rust Project infrastructure.
55
6-
Run codex in a Linux VM using [lima](https://lima-vm.io/).
7-
Control it from [ChatGPT desktop](https://chatgpt.com/download/).
6+
Run Codex and Claude Code in a Linux VM using [lima](https://lima-vm.io/).
7+
Use either CLI over SSH, or control Codex from
8+
[ChatGPT desktop](https://chatgpt.com/download/).
89

910
The VM has read-only access to Cloud services like DataDog and Fastly.
1011
Credentials are read automatically from the Rust Foundation 1Password.
@@ -50,15 +51,22 @@ Credentials are read automatically from the Rust Foundation 1Password.
5051
you are experiencing issues, check the
5152
[authentication docs](./docs/authentication.md).
5253

53-
- Enable "Device code authorization for Codex" in
54+
- If using Codex, enable "Device code authorization for Codex" in
5455
[ChatGPT security settings](https://chatgpt.com/#settings/Security).
5556

56-
- Login to Codex, Datadog and Fastly from the guest:
57+
- Login to Codex, Claude Code, Datadog and Fastly from the guest:
5758

5859
```sh
5960
just login
6061
```
6162

63+
For Claude Code, open the URL printed in the terminal in your host's browser
64+
and paste the returned login code into the terminal when prompted. See the
65+
[Claude Code SSH login instructions](https://code.claude.com/docs/en/troubleshoot-install#oauth-login-fails-in-wsl2-ssh-or-containers).
66+
67+
To use only one coding agent, run `just login-codex` or `just login-claude`,
68+
followed by `just login-datadog login-fastly`.
69+
6270
### 3. Set up projects
6371
6472
The host directory `~/buddy` is mounted inside the VM at `$HOME/work`.
@@ -86,7 +94,12 @@ Place your projects in the host directory:
8694
ssh lima-buddy
8795
```
8896
89-
- (Optional) Launch the `codex` command inside the VM to start the Codex TUI.
97+
- Launch `codex` or `claude` inside the VM from your project directory:
98+
99+
```sh
100+
cd ~/work/<project>
101+
claude
102+
```
90103
91104
See the [Lima SSH documentation](https://lima-vm.io/docs/usage/ssh/) for more details.
92105
@@ -112,6 +125,10 @@ for more details.
112125
113126
- Check the [justfile](./justfile) for other available commands.
114127
128+
- Run `just upgrade` to update the guest and both coding agents. This also
129+
installs Claude Code in an existing VM. New VMs install it automatically
130+
using the [native installer](https://code.claude.com/docs/en/installation).
131+
115132
- Run commands in the VM:
116133
117134
```sh
@@ -134,14 +151,14 @@ for more details.
134151
135152
The template explicitly sets `user.passwordlessSudo: true`, which is
136153
[Lima's default for Linux guests](https://lima-vm.io/docs/config/sudo/).
137-
This gives Codex unrestricted root access inside the guest, but does not grant
138-
root access on the host. The VM boundary and the resources exposed to the VM,
139-
such as the writable `$HOME/work` mount, remain the main security boundary.
154+
This gives Codex and Claude Code unrestricted root access inside the guest, but
155+
does not grant root access on the host. The VM boundary and the resources exposed
156+
to the VM, such as the writable `$HOME/work` mount, remain the main security boundary.
140157

141158
Enabling passwordless sudo has this advantage:
142159

143-
- Codex and other automation can install packages, update the guest, and fix
144-
system configuration without waiting for a password prompt.
160+
- Codex, Claude Code, and other automation can install packages, update the guest,
161+
and fix system configuration without waiting for a password prompt.
145162

146163
It also has these disadvantages:
147164

@@ -154,10 +171,10 @@ It also has these disadvantages:
154171

155172
## FAQ
156173

157-
> Why not running Codex directly on the host?
174+
> Why not run Codex or Claude Code directly on the host?
158175

159-
Auditing all commands that codex wants to run is not productive. Instead, by
160-
running it in an isolated VM, you can run codex in yolo mode.
176+
Auditing all commands that coding agents want to run is not productive. Running
177+
them in an isolated VM lets you give them full permissions inside the guest.
161178

162179
> Why not using one VM per project?
163180

@@ -174,10 +191,10 @@ Lima provides:
174191
- It's an open source [CNCF project](https://www.cncf.io/projects/lima/), while Docker Desktop is a proprietary product.
175192
- The Docker Desktop feature [Enhanced Container Isolation](https://docs.docker.com/enterprise/security/hardened-desktop/enhanced-container-isolation/), which "prevents malicious containers from compromising the host system" is restricted to Docker Business.
176193
177-
> I don't want to run codex with full privileges, I think it is dangerous!
194+
> I don't want to run coding agents with full privileges, I think it is dangerous!
178195

179-
Nobody forces you to run codex with full privileges. You can still run it in the
180-
`buddy` VM for improved security _and_ customize its permissions.
196+
Nobody forces you to run Codex or Claude Code with full privileges. You can still
197+
run either in the `buddy` VM for improved security _and_ customize its permissions.
181198

182199
## License
183200

‎buddy.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ssh:
1616
forwardAgent: false
1717
loadDotSSHPubKeys: false
1818

19-
# Codex can elevate to root inside the VM
19+
# Codex and Claude Code can elevate to root inside the VM
2020
# without receiving or storing the guest user's password.
2121
user:
2222
passwordlessSudo: true

‎justfile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ delete: stop
2929
delete-file path:
3030
limactl shell "{{ vm }}" bash -lc 'rm -f "{{ path }}"'
3131

32-
login: login-codex login-datadog login-fastly
32+
login: login-codex login-claude login-datadog login-fastly
3333

3434
login-codex:
3535
limactl shell "{{ vm }}" bash -lc 'codex login --device-auth'
3636

37+
login-claude:
38+
limactl shell "{{ vm }}" bash -lc 'claude auth login'
39+
3740
login-datadog:
3841
cargo run --quiet -- login-datadog "{{ vm }}"
3942

@@ -54,9 +57,11 @@ logout-fastly: (delete-file (config_dir / "fastly.env"))
5457
# a full upgrade would make startup slower, less predictable, and could install kernel updates requiring another reboot.
5558
upgrade:
5659
limactl shell "{{ vm }}" sudo apt-get update
60+
limactl shell "{{ vm }}" sudo apt-get install -y socat
5761
limactl shell "{{ vm }}" sudo apt-get upgrade
5862
limactl shell "{{ vm }}" bash -lc 'brew update && brew upgrade --yes'
5963
limactl shell "{{ vm }}" bash -lc 'curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh'
64+
limactl shell "{{ vm }}" bash -o pipefail -lc 'curl -fsSL https://claude.ai/install.sh | bash'
6065
# stop the old running app-server and start it again using the newly installed binary.
6166
limactl shell "{{ vm }}" bash -lc \
6267
'pkill -x codex || true; exec codex app-server daemon bootstrap'

‎provision/system.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ set -Eeuo pipefail
33

44
apt-get update
55

6-
# Codex uses bubblewrap for its Linux sandbox. This is needed if you want to run codex withot full access.
6+
# Codex and Claude Code use bubblewrap for their Linux sandboxes.
7+
# Claude Code also uses socat to proxy sandbox network traffic.
78
apt-get install -y \
89
build-essential \
910
bubblewrap \
@@ -20,6 +21,7 @@ apt-get install -y \
2021
python3-venv \
2122
ripgrep \
2223
rsync \
24+
socat \
2325
unzip \
2426
zip
2527

‎provision/user.sh‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ brew install fastly/tap/fastly
3535
# Install or update codex
3636
curl -fsSL https://chatgpt.com/codex/install.sh | sh
3737

38-
# The Codex installer adds ~/.local/bin to .bashrc
38+
# Install or update Claude Code
39+
curl -fsSL https://claude.ai/install.sh | bash
40+
41+
# Make both native CLIs available to login shells, including SSH sessions.
3942
append_line_if_missing "export PATH=\"\$HOME/.local/bin:\$PATH\"" "$HOME/.profile"

0 commit comments

Comments
 (0)