Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .claude/commands/config-base-sync-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Read the reference configuration from this repository:

Extract recommended configuration based on `updateScope`:

- **all**: Update image, features, mounts, postCreateCommand, customizations, remoteEnv
- **all**: Update image, features, mounts, postCreateCommand, customizations
- **image-only**: Update only the image field
- **minimal**: Update image and features only

Expand All @@ -164,7 +164,6 @@ From `devcontainer-recommendations.md`, identify:

2. **Claude Code必須設定**:
- `.codex` mount (必須)
- `.claude` mount (必須)
- `postCreateCommand`に`/usr/local/bin/setup-claude.sh`を含める

3. **プロジェクトタイプ別Features**(現在のプロジェクトに基づいて判定):
Expand Down Expand Up @@ -220,14 +219,28 @@ Update `image` field to `ghcr.io/keito4/config-base:{target-version}`
**Claude Code必須mounts**を確認・追加:

- `.codex` mount
- `.claude` mount

**標準mounts**を確認・追加:

- `.cursor` mount
- `.gitconfig` mount
- `.config/gh` mount

**環境変数ファイル設定(推奨)**:

- `.devcontainer.env`ファイルのマウントを追加:
```json
"source=${localEnv:HOME}/.devcontainer.env,target=/home/vscode/.devcontainer.env,type=bind,consistency=cached"
```
- `containerEnv`に`CLAUDE_ENV_FILE`を追加:
```json
"containerEnv": {
"CLAUDE_ENV_FILE": "/home/vscode/.devcontainer.env"
}
```
- この設定により、`setup-claude.sh`実行時に環境変数ファイルが読み込まれる
- ユーザーは`~/.devcontainer.env`ファイルを作成して環境変数を設定

既存のユーザー追加mountsは保持。

### 7.4: Update postCreateCommand (if updateScope is "all")
Expand All @@ -242,7 +255,6 @@ Update `image` field to `ghcr.io/keito4/config-base:{target-version}`

### 7.5: Update Other Settings (if updateScope is "all")

- Update `remoteEnv` with recommended environment variables
- Update `customizations` with recommended VS Code settings

Use the Edit tool to make precise updates to the JSON file.
Expand Down Expand Up @@ -300,7 +312,6 @@ _注意: これらのfeaturesは自動削除されていません。必要に応
**追加されたMounts**:

- `.codex` (Claude Code必須)
- `.claude` (Claude Code必須)

### Commands Changes (if updateScope is "all")

Expand All @@ -310,7 +321,6 @@ _注意: これらのfeaturesは自動削除されていません。必要に応

### Other Changes (if updateScope is "all")

- Updated remoteEnv settings
- Updated VS Code customizations

## Step 10: Commit Changes
Expand All @@ -325,7 +335,7 @@ git commit -m "feat: Update config-base image to v{target-version}
- Sync configuration with latest recommended settings
- Add {count} new features based on project type detection
- Ensure Claude Code compatibility (mounts, postCreateCommand)
- Update features, mounts, and environment variables
- Update features and mounts

Features added: {list-of-added-features}

Expand Down Expand Up @@ -366,13 +376,14 @@ If `autoCreatePR` is true:
- ✨ **Preserved**: {preserved-features-list}

#### Configuration
- 📁 **Mounts**: Added Claude Code required mounts (`.codex`, `.claude`)
- 📁 **Mounts**: Added Claude Code required mounts (`.codex`)
- 🔧 **postCreateCommand**: Ensured `/usr/local/bin/setup-claude.sh` execution
- ⚙️ **Settings**: Synced remoteEnv and VS Code customizations
- ⚙️ **Settings**: Synced VS Code customizations
- 🔑 **containerEnv**: Added CLAUDE_ENV_FILE for environment configuration

### Claude Code Compatibility
This update ensures full Claude Code compatibility with:
- Required mounts for `.codex` and `.claude`
- Required mounts for `.codex`
- Automatic Claude CLI setup via `setup-claude.sh`
- Recommended features based on project type

Expand Down
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# Build arguments for Claude Code authentication
ARG CLAUDE_CODE_OAUTH_TOKEN

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG ANTHROPIC_API_KEY

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

# Install dependencies and Node.js using official binaries
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -56,11 +56,13 @@

RUN CLAUDE_CODE_VERSION=$(node -pe "require('/tmp/npm-global.json').dependencies['@anthropic-ai/claude-code'].version") \
&& CODEX_VERSION=$(node -pe "require('/tmp/npm-global.json').dependencies['@openai/codex'].version") \
&& VERCEL_VERSION=$(node -pe "require('/tmp/npm-global.json').dependencies['vercel'].version") \
&& npm install -g eslint \
typescript \
typescript-language-server \
@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION} \
@openai/codex@${CODEX_VERSION}
@openai/codex@${CODEX_VERSION} \
vercel@${VERCEL_VERSION}

USER vscode
RUN bash -lc "cargo install similarity-ts" || true \
Expand Down
13 changes: 5 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@
},
"ghcr.io/schlich/devcontainer-features/playwright:0": {}
},
"remoteEnv": {
"HOMEBREW_NO_AUTO_UPDATE": "1",
"SHELL": "/bin/bash",
"TMPDIR": "/home/vscode/.claude/tmp",
"ENABLE_LSP_TOOL": "1"
},
"overrideCommand": true,
"updateRemoteUserUID": false,
"initializeCommand": "mkdir -p ~/.claude ~/.cursor",
"containerEnv": {
"CLAUDE_ENV_FILE": "/home/vscode/.devcontainer.env"
},
"mounts": [
"source=${localEnv:HOME}/.claude,target=/home/vscode/.claude,type=bind,consistency=cached",
"source=${localEnv:HOME}/.devcontainer.env,target=/home/vscode/.devcontainer.env,type=bind,consistency=cached",
"source=${localEnv:HOME}/.cursor,target=/home/vscode/.cursor,type=bind,consistency=cached",
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
"source=${localEnv:HOME}/.config/gh,target=/home/vscode/.config/gh,type=bind,consistency=cached",
Expand All @@ -52,5 +49,5 @@
}
},
"postCreateCommand": "bash script/setup-env.sh && bash script/setup-mcp.sh && sudo chown -R vscode:vscode /workspaces/config && npm ci && npm run prepare && cp -r /tmp/.husky /workspaces/config/ && cp git/commitlint.config.js commitlint.config.js && bash script/sync-claude-commands.sh && bash script/setup-lsp.sh && /usr/local/bin/setup-claude.sh",
"runArgs": ["--env-file=${localEnv:HOME}/.devcontainer.env"]
"postStartCommand": "bash script/sync-claude-commands.sh"
}
7 changes: 7 additions & 0 deletions script/setup-claude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ main() {
log_info "Claude Code セットアップを開始します..."
log_info "環境: HOME=${HOME}"

# CLAUDE_ENV_FILE が設定されている場合、環境変数ファイルを読み込む
if [[ -n "${CLAUDE_ENV_FILE:-}" ]] && [[ -f "$CLAUDE_ENV_FILE" ]]; then
log_info "環境変数ファイルを読み込みます: ${CLAUDE_ENV_FILE}"
# shellcheck source=/dev/null
source "$CLAUDE_ENV_FILE"
fi

# 一時ディレクトリを作成(クロスデバイスリンクエラー対策)
mkdir -p "${CLAUDE_DIR}/tmp"
export TMPDIR="${CLAUDE_DIR}/tmp"
Expand Down
Loading