Skip to content

Claude Code

GitHub code

Claude Code CLI for AI-assisted development directly inside workspace containers.

Last tested on commit d43ad1c by @j3soon.

To enable Claude Code CLI, set the CLAUDE_CODE argument to YES in the compose.yaml file of your desired workspace (e.g., template_ws/docker/compose.yaml). After making these changes, rebuild the Docker image.

Notice - Subscription required: Claude Code is a third-party service that requires an active Anthropic account or subscription to use. This module only installs the CLI; you need an active subscription to use it.

Installation

The module automatically installs Claude Code CLI (latest version) using the official installer from https://claude.ai/install.sh.

Alternatively, if you want to install the Claude Code extension for your favorite IDE (e.g., Claude Code for VSCode), refer to the Claude Code IDE extension for more details instead. This module doesn't need to be enabled if you just want to use the IDE extension.

Usage

After building a workspace with Claude Code enabled, you can use the CLI inside the container:

# Start your workspace container
cd ~/ros2-essentials/template_ws/docker
docker compose up -d
docker exec -it ros2-template-ws bash

# Inside the container, verify Claude Code is installed
claude --version

# Run Claude Code CLI
claude

The first time you run Claude Code, you'll be prompted to authenticate with your Anthropic account.

If you want to run Claude Code CLI to run continuously without asking for permissions, make sure to comment out privileged: true in the compose.yaml file and restart the container. Then run:

claude --dangerously-skip-permissions

This is not as secure as the official container due to the lack of firewall protection. But it should be fine for most cases as it's inside a container.

Authentication

Claude Code caches login details locally at ~/.claude.json and ~/.claude/. The default compose.yaml mounts <git_root_dir>/.env.d/.claude to /home/user/.claude and <git_root_dir>/.env.d/.claude.json to /home/user/.claude.json so credentials can persist across containers.

References

For more discussions on AI coding assistants (such as Cursor etc.), please refer to issue #102.