Download chips/openroad_flow_scripts/docs/user/ClaudeCode.md from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 8.44 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/docs/user/ClaudeCode.md
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/openroad_flow_scripts/docs/user/ClaudeCode.md
-
curl -L -o ClaudeCode.md https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/docs/user/ClaudeCode.md
Running Claude Code in Docker
The claude.sh script runs Claude Code
inside a Docker container with --dangerously-skip-permissions. The container
provides a sandboxed environment where Claude Code has full shell access but
cannot affect the host system beyond the mounted repository.
The container supports:
- Building and testing OpenROAD with CMake and Bazel
- Running ORFS flows (Makefile-based RTL-GDSII)
- All file changes reflected on the host via volume mount
Prerequisites
- Docker installed on your machine
- Claude Code credentials (run
claudeon the host once to authenticate, or setANTHROPIC_API_KEYin your environment)
Quick start
./claude.sh
On first run the Docker image is built automatically. Credentials from
~/.claude/ are mounted into the container. The ORFS environment (env.sh)
is sourced automatically so tools are on PATH without any manual setup.
Usage
./claude.sh [OPTIONS] [-- CLAUDE_ARGS...]
Options
| Option | Description |
|---|---|
--build |
Force rebuild the Docker image |
--shell |
Start a bash shell instead of Claude Code |
--image NAME |
Override Docker image (default: openroad/flow-claude:latest) |
--name NAME |
Override container name (default: claude-orfs) |
-h, --help |
Show help |
Arguments after -- are passed directly to claude.
Examples
# Interactive Claude Code session
./claude.sh
# Pass a prompt to Claude Code
./claude.sh -- -p "fix the failing test in openroad/drt"
# Interactive bash shell (for manual builds)
./claude.sh --shell
# Force rebuild the image after updates
./claude.sh --build
# Run a parallel session
CONTAINER_NAME=claude-2 ./claude.sh
Building and testing inside the container
When using --shell, tools are already on PATH:
# CMake build
./build_openroad.sh --local --no_init -t $(nproc)
# Bazel build
cd tools/OpenROAD && bazel build //...
# Run an ORFS flow
cd flow && make DESIGN_CONFIG=./designs/nangate45/gcd/config.mk
Claude Code can run these same commands autonomously during an interactive session.
What persists across runs
The container is removed on exit (--rm), but the following host directories
are mounted so their contents survive:
| Host path | Container path | Content |
|---|---|---|
| Repository root | /workspace |
All source and build artifacts |
~/.claude/ |
~/.claude/ |
Credentials, settings, conversation history |
~/.cache/bazel-claude/ |
~/.cache/bazel/ |
Bazel external dependencies |
~/.gitconfig |
~/.gitconfig |
Git identity (read-only) |
Worktree and main .git (worktree only) |
Host paths, or paths under /tmp/claude-worktree if they overlap a container mount |
Git refs, objects, hooks, config |
$SSH_AUTH_SOCK |
forwarded | SSH agent for git over SSH |
Environment variables
All environment variables are optional. They are passed into the container when set on the host.
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY |
API key (alternative to stored credentials) |
ANTHROPIC_MODEL |
Model override |
CLAUDE_IMAGE |
Docker image override (same as --image) |
CONTAINER_NAME |
Container name override (same as --name) |
BAZEL_CACHE_DIR |
Host path for Bazel cache (default: ~/.cache/bazel-claude) |
CLAUDE_CODE_USE_BEDROCK |
Use AWS Bedrock |
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION |
AWS credentials for Bedrock |
How it works
The setup consists of three files:
docker/Dockerfile.claude
Extends the openroad/flow-ubuntu26.04-dev base image (which has all
OpenROAD build dependencies) with:
- Java 21 and Bazelisk (for Bazel 8.x builds)
- Node.js 22 LTS and Claude Code CLI
- VS Code CLI, sudo, and other convenience tools
No source code is copied into the image. Everything comes from the volume mount.
docker/claude-entrypoint.sh
Handles UID/GID mapping so files created inside the container have the correct ownership on the host. The entrypoint:
- Reuses the account with the host UID if that UID already exists in the container. Otherwise, it creates an account with the host UID/GID.
- Sources
env.shto set up tool paths, from the start directory if it has one, else from/workspace - Drops privileges via
setprivbefore running the command
The mapped user's account record and HOME both use /home/claude-user.
This keeps the settings and cache mounts visible when the base image already has an account with the host UID.
Run the entrypoint regression check in disposable containers:
bash docker/test-claude-entrypoint.sh
With Podman:
CONTAINER_ENGINE=podman bash docker/test-claude-entrypoint.sh
The check covers an existing UID and a new UID.
It verifies that the launched command can read and write fixture settings through HOME.
It also checks that the account's recorded home matches HOME.
It also checks that the user can create ~/.cache/bazelisk beside the mounted Bazel cache.
claude.sh
Wrapper script that assembles the docker run command with the correct
volume mounts, environment variables, and entrypoint arguments.
When you run claude.sh from the top of a git worktree, it also mounts the worktree and the main checkout's .git directory at their host paths.
The shell starts in the worktree's host path.
The worktree's .git file and the .git files of its submodules point to these paths, so git works in the container.
The entrypoint sources env.sh from there, so OPENROAD, FLOW_HOME and PATH use the host path too.
Rebuild the image with ./claude.sh --build to get this entrypoint.
The worktree is also at /workspace.
Use the start path for Git commands in submodules when /workspace is an alias for the worktree.
If a host path would overlap /workspace or /home/claude-user, the wrapper adds /tmp/claude-worktree before both host paths.
It starts Claude Code or the shell at the resulting worktree path and uses a temporary Git pointer there.
Submodules in a relocated worktree use the relative Git links that Git creates during normal initialization.
A worktree at exactly /workspace can use the existing checkout mount if its Git data is outside the reserved paths.
The paths of the other worktrees do not exist in the container, so git sees them as stale.
The wrapper sets gc.worktreePruneExpire=never in the container, so git gc keeps their records.
git gc still removes the record of a worktree that has no index file.
Do not run git worktree prune or git worktree repair in the container: they change the records of the other worktrees.
The start directory is part of some keys and caches.
Claude Code stores the history of a worktree session under its start path, so changing that path changes which sessions can resume.
Bazel uses a new output base, and a CMake build directory that you configured under /workspace must be configured again.
Check the mounts with a stub docker command, without a container engine:
bash docker/test-claude-sh.sh
The Claude Docker CI workflow also runs docker/test-claude-worktree-paths.sh on a disposable Linux runner.
It checks Git in the launched shell, including the initialized submodule and writes to the original checkout.
Security model
Claude Code runs with --dangerously-skip-permissions inside the
container, meaning it can execute any shell command without confirmation.
The Docker container provides the isolation:
- File access is limited to the mounted repository.
From a git worktree, this includes the main checkout's
.gitdirectory, with the refs and objects of all its worktrees. It also holds git hooks and config, which run on the host at the next git command, so code in the container can run code on the host. - No access to host system packages, services, or other projects
- No access to host network services bound to localhost
docker kill claude-orfsstops everything instantly
:::{Warning} The container has network access (required for the Anthropic API and Bazel dependency fetching). Claude Code could in principle make outbound network requests. If this is a concern, use Docker network policies to restrict egress to only the Anthropic API endpoints. :::