From f642f97e29a45f16bfbd3e80a0efe94374ff2827 Mon Sep 17 00:00:00 2001 From: "Oleg V. Kozlyuk" Date: Thu, 31 Jul 2025 09:35:10 +0200 Subject: [PATCH 1/3] Added claude-code-mounts feature --- .github/workflows/test.yaml | 1 + src/claude-code-mounts/README.md | 67 +++++++++++++++++++ .../devcontainer-feature.json | 52 ++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 src/claude-code-mounts/README.md create mode 100644 src/claude-code-mounts/devcontainer-feature.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 57c3de2..087f23f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,6 +14,7 @@ jobs: matrix: features: - claude-code + - claude-code-mounts baseImage: - debian:latest - ubuntu:latest diff --git a/src/claude-code-mounts/README.md b/src/claude-code-mounts/README.md new file mode 100644 index 0000000..a953124 --- /dev/null +++ b/src/claude-code-mounts/README.md @@ -0,0 +1,67 @@ + +# Claude Code CLI Mounts + +Mounts Claude Code configuration directories and files from the host into the devcontainer, enabling seamless access to your Claude Code settings, credentials, and customizations. + +## Example Usage + +```json +"features": { + "ghcr.io/anthropics/devcontainer-features/claude-code-mounts:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| + +## Customizations + +### VS Code Extensions + +- `anthropic.claude-code` + +## What This Feature Does + +This feature automatically mounts your Claude Code configuration from your host machine into the devcontainer, providing access to: + +- **Credentials** (`~/.claude/.credentials.json`) - Your authentication tokens +- **Settings** (`~/.claude/settings.json`) - Your Claude Code configuration +- **CLAUDE.md** (`~/.claude/CLAUDE.md`) - Your global project instructions +- **Agents** (`~/.claude/agents/`) - Custom agent configurations +- **Commands** (`~/.claude/commands/`) - Custom command definitions +- **Hooks** (`~/.claude/hooks/`) - Event-driven shell commands + +## Requirements + +This feature requires: + +1. The Claude Code CLI to be installed (use the `claude-code` feature) +2. Claude Code configuration files to exist on your host machine +3. HOME variable to be set - use "Edit user environment variables" in Windows + +## Recommended Configuration + +Use this feature together with the main Claude Code feature: + +```json +"features": { + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/anthropics/devcontainer-features/claude-code:1": {}, + "ghcr.io/anthropics/devcontainer-features/claude-code-mounts:1": {} +} +``` + +## Benefits + +- Maintain consistent Claude Code settings across all devcontainers +- No need to reconfigure credentials in each container +- Access to your custom agents, commands, and hooks +- Seamless development experience with persistent Claude Code configuration + + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/anthropics/devcontainer-features/blob/main/src/claude-code/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/claude-code-mounts/devcontainer-feature.json b/src/claude-code-mounts/devcontainer-feature.json new file mode 100644 index 0000000..5ec5918 --- /dev/null +++ b/src/claude-code-mounts/devcontainer-feature.json @@ -0,0 +1,52 @@ +{ + "name": "Claude Code CLI Mounts", + "id": "claude-code-mounts", + "version": "1.0.5", + "description": "Mounts the directories and files", + "options": {}, + "documentationURL": "https://github.com/anthropics/devcontainer-features/tree/main/src/claude-code", + "licenseURL": "https://github.com/anthropics/devcontainer-features/blob/main/LICENSE", + "customizations": { + "vscode": { + "extensions": [ + "anthropic.claude-code" + ] + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/node:1", + "ghcr.io/anthropics/devcontainer-features/claude-code:1" + ], + "mounts": [ + { + "source": "%USERPROFILE%/.claude/.credentials.json", + "target": "/home/vscode/.claude/.credentials.json", + "type": "bind" + }, + { + "source": "%USERPROFILE%/.claude/CLAUDE.md", + "target": "/home/vscode/.claude/CLAUDE.md", + "type": "bind" + }, + { + "source": "%USERPROFILE%/.claude/settings.json", + "target": "/home/vscode/.claude/settings.json", + "type": "bind" + }, + { + "source": "%USERPROFILE%/.claude/agents", + "target": "/home/vscode/.claude/agents", + "type": "bind" + }, + { + "source": "%USERPROFILE%/.claude/commands", + "target": "/home/vscode/.claude/commands", + "type": "bind" + }, + { + "source": "%USERPROFILE%/.claude/hooks", + "target": "/home/vscode/.claude/hooks", + "type": "bind" + }, + ] +} \ No newline at end of file From 14bd4e423fe5577089f2a147b9aaba4041c36ebd Mon Sep 17 00:00:00 2001 From: "Oleg V. Kozlyuk" Date: Thu, 31 Jul 2025 11:24:26 +0200 Subject: [PATCH 2/3] Various minor fixes --- src/claude-code-mounts/NOTES.md | 56 ++++++++++++++++ src/claude-code-mounts/README.md | 67 ------------------- .../devcontainer-feature.json | 44 ++---------- src/claude-code-mounts/install.sh | 7 ++ 4 files changed, 69 insertions(+), 105 deletions(-) create mode 100644 src/claude-code-mounts/NOTES.md delete mode 100644 src/claude-code-mounts/README.md create mode 100644 src/claude-code-mounts/install.sh diff --git a/src/claude-code-mounts/NOTES.md b/src/claude-code-mounts/NOTES.md new file mode 100644 index 0000000..89dda4b --- /dev/null +++ b/src/claude-code-mounts/NOTES.md @@ -0,0 +1,56 @@ +# Using Claude Code Mounts in devcontainers + +## Requirements + +This feature requires: + +1. The Claude Code CLI to be installed (use the `claude-code` feature first) +2. Claude Code configuration files to exist on your host machine at `~/.claude/` +3. HOME environment variable to be properly set on the host system + +Note: On Windows, ensure the HOME environment variable is set (e.g. using "Edit user environment variables" in the system settings). + +## Recommended configuration + +For most setups, we recommend using this feature together with the main Claude Code feature: + +```json +"features": { + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/anthropics/devcontainer-features/claude-code:1": {}, + "ghcr.io/anthropics/devcontainer-features/claude-code-mounts:1": {} +} +``` + +## What gets mounted + +This feature mounts the following Claude Code configuration files and directories from your host machine: + +- `~/.claude/CLAUDE.md` - Global project instructions (read-only) +- `~/.claude/settings.json` - Claude Code configuration (read-only) +- `~/.claude/agents/` - Custom agent configurations (read-only) +- `~/.claude/commands/` - Custom command definitions (read-only) +- `~/.claude/hooks/` - Event-driven shell commands (read-only) + +All mounts are read-only to prevent accidental modification from within the container. + +## Installation order + +This feature uses `installsAfter` to ensure it runs after: +1. Node.js feature (if used) +2. Claude Code feature + +This ensures the Claude Code CLI is available before mounting configuration files. + +## Troubleshooting + +### Errors when building the dev container + +- Ensure that mounted files and directories exist on host machine +- Check that the HOME environment variable is set correctly +- Ensure the devcontainer has been rebuilt after adding this feature + +### Permission issues + +- All mounts are read-only by design +- If you need to modify configuration, do so on the host machine and restart the container \ No newline at end of file diff --git a/src/claude-code-mounts/README.md b/src/claude-code-mounts/README.md deleted file mode 100644 index a953124..0000000 --- a/src/claude-code-mounts/README.md +++ /dev/null @@ -1,67 +0,0 @@ - -# Claude Code CLI Mounts - -Mounts Claude Code configuration directories and files from the host into the devcontainer, enabling seamless access to your Claude Code settings, credentials, and customizations. - -## Example Usage - -```json -"features": { - "ghcr.io/anthropics/devcontainer-features/claude-code-mounts:1": {} -} -``` - -## Options - -| Options Id | Description | Type | Default Value | -|-----|-----|-----|-----| - -## Customizations - -### VS Code Extensions - -- `anthropic.claude-code` - -## What This Feature Does - -This feature automatically mounts your Claude Code configuration from your host machine into the devcontainer, providing access to: - -- **Credentials** (`~/.claude/.credentials.json`) - Your authentication tokens -- **Settings** (`~/.claude/settings.json`) - Your Claude Code configuration -- **CLAUDE.md** (`~/.claude/CLAUDE.md`) - Your global project instructions -- **Agents** (`~/.claude/agents/`) - Custom agent configurations -- **Commands** (`~/.claude/commands/`) - Custom command definitions -- **Hooks** (`~/.claude/hooks/`) - Event-driven shell commands - -## Requirements - -This feature requires: - -1. The Claude Code CLI to be installed (use the `claude-code` feature) -2. Claude Code configuration files to exist on your host machine -3. HOME variable to be set - use "Edit user environment variables" in Windows - -## Recommended Configuration - -Use this feature together with the main Claude Code feature: - -```json -"features": { - "ghcr.io/devcontainers/features/node:1": {}, - "ghcr.io/anthropics/devcontainer-features/claude-code:1": {}, - "ghcr.io/anthropics/devcontainer-features/claude-code-mounts:1": {} -} -``` - -## Benefits - -- Maintain consistent Claude Code settings across all devcontainers -- No need to reconfigure credentials in each container -- Access to your custom agents, commands, and hooks -- Seamless development experience with persistent Claude Code configuration - - - ---- - -_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/anthropics/devcontainer-features/blob/main/src/claude-code/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/claude-code-mounts/devcontainer-feature.json b/src/claude-code-mounts/devcontainer-feature.json index 5ec5918..e11d596 100644 --- a/src/claude-code-mounts/devcontainer-feature.json +++ b/src/claude-code-mounts/devcontainer-feature.json @@ -2,51 +2,19 @@ "name": "Claude Code CLI Mounts", "id": "claude-code-mounts", "version": "1.0.5", - "description": "Mounts the directories and files", + "description": "Mounts the directories and files required for Claude Code", "options": {}, "documentationURL": "https://github.com/anthropics/devcontainer-features/tree/main/src/claude-code", "licenseURL": "https://github.com/anthropics/devcontainer-features/blob/main/LICENSE", - "customizations": { - "vscode": { - "extensions": [ - "anthropic.claude-code" - ] - } - }, "installsAfter": [ "ghcr.io/devcontainers/features/node:1", "ghcr.io/anthropics/devcontainer-features/claude-code:1" ], "mounts": [ - { - "source": "%USERPROFILE%/.claude/.credentials.json", - "target": "/home/vscode/.claude/.credentials.json", - "type": "bind" - }, - { - "source": "%USERPROFILE%/.claude/CLAUDE.md", - "target": "/home/vscode/.claude/CLAUDE.md", - "type": "bind" - }, - { - "source": "%USERPROFILE%/.claude/settings.json", - "target": "/home/vscode/.claude/settings.json", - "type": "bind" - }, - { - "source": "%USERPROFILE%/.claude/agents", - "target": "/home/vscode/.claude/agents", - "type": "bind" - }, - { - "source": "%USERPROFILE%/.claude/commands", - "target": "/home/vscode/.claude/commands", - "type": "bind" - }, - { - "source": "%USERPROFILE%/.claude/hooks", - "target": "/home/vscode/.claude/hooks", - "type": "bind" - }, + "source=${localEnv:HOME}/.claude/CLAUDE.md,target=/home/vscode/.claude/CLAUDE.md,type=bind,ro", + "source=${localEnv:HOME}/.claude/settings.json,target=/home/vscode/.claude/settings.json,type=bind,ro", + "source=${localEnv:HOME}/.claude/agents,target=/home/vscode/.claude/agents,type=bind,ro", + "source=${localEnv:HOME}/.claude/commands,target=/home/vscode/.claude/commands,type=bind,ro", + "source=${localEnv:HOME}/.claude/hooks,target=/home/vscode/.claude/hooks,type=bind,ro" ] } \ No newline at end of file diff --git a/src/claude-code-mounts/install.sh b/src/claude-code-mounts/install.sh new file mode 100644 index 0000000..085edd5 --- /dev/null +++ b/src/claude-code-mounts/install.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +echo "Activating feature 'claude-code-mounts'" + +mkdir -p $_REMOTE_USER_HOME/.claude +chown $_REMOTE_USER:$_REMOTE_USER $_REMOTE_USER_HOME/.claude From 2046b03569fefe96e58a716f3d86557494d67007 Mon Sep 17 00:00:00 2001 From: "Oleg V. Kozlyuk" Date: Thu, 31 Jul 2025 17:22:46 +0200 Subject: [PATCH 3/3] Added test prerequisites --- .github/workflows/test.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 087f23f..5e4c566 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: true strategy: + fail-fast: false matrix: features: - claude-code @@ -25,6 +26,15 @@ jobs: - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli + - name: "Create test prerequisites" + run: | + mkdir -p ~/.claude/agents + mkdir -p ~/.claude/commands + mkdir -p ~/.claude/hooks + touch ~/.claude/settings.json + touch ~/.claude/CLAUDE.md + + - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .