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
2 changes: 0 additions & 2 deletions .claude/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,6 @@ npm run update:all -- --skip-libs --skip-claude # Actions のみ
| --------------------------- | ------------------------- | --------------------------------------- |
| `setup-claude.sh` | DevContainer postCreate | Claude Code CLI の初期設定 |
| `setup-claude-build.sh` | DevContainer Dockerfile | ビルド時の Claude Code セットアップ |
| `setup-env.sh` | DevContainer postCreate | 環境変数のセットアップ |
| `setup-mcp.sh` | DevContainer postCreate | MCP 設定のセットアップ |
| `setup-lsp.sh` | DevContainer postCreate | LSP サーバーのセットアップ |
| `install-npm-globals.sh` | DevContainer postCreate | グローバル npm パッケージのインストール |
| `install-skills.sh` | DevContainer postStart | Claude スキルのインストール |
Expand Down
4 changes: 2 additions & 2 deletions .claude/commands/devcontainer-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ cat .claude-plugin/plugin.json | jq '.lspServers | keys'

```bash
# 環境変数を再生成
bash script/setup-env.sh
bash script/setup-mcp.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env

# DevContainerを完全に再ビルド
# VS Code: "Dev Containers: Rebuild Container"
Expand Down
23 changes: 8 additions & 15 deletions .claude/devcontainer-recommendations.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ Claude CodeでMCPサーバーを利用する場合、`.mcp.json`の配置とマ
#### `.mcp.json`の生成方法

```bash
# postCreateCommandで自動生成(推奨)
bash script/setup-mcp.sh
# .mcp.json はリポジトリに直接コミットされています
# カスタマイズが必要な場合はリポジトリの .mcp.json を直接編集してください
```

`setup-mcp.sh`は以下を実行:

- `credentials/mcp.env`から環境変数を読み込み
- `.mcp.json.template`から`.mcp.json`を生成
- ワークスペースルート(`/workspaces/<project>/.mcp.json`)に配置

#### MCP設定例(`.mcp.json`)

```json
Expand Down Expand Up @@ -131,7 +125,7 @@ bash script/setup-mcp.sh

```json
{
"postCreateCommand": "bash script/setup-env.sh && bash script/setup-mcp.sh && /usr/local/bin/setup-claude.sh"
"postCreateCommand": "/usr/local/bin/setup-claude.sh"
}
```

Expand All @@ -147,7 +141,7 @@ bash script/setup-mcp.sh
"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"
],
"postCreateCommand": "bash script/setup-env.sh && bash script/setup-mcp.sh && /usr/local/bin/setup-claude.sh",
"postCreateCommand": "/usr/local/bin/setup-claude.sh",
"runArgs": ["--env-file=${localEnv:HOME}/.devcontainer.env"]
}
```
Expand Down Expand Up @@ -751,7 +745,7 @@ NODE_ENV=development

2. **Claude Code認証エラー**
- `ANTHROPIC_API_KEY`の値を確認
- 1Passwordから最新のAPIキーを取得: `OP_ACCOUNT=your.1password.com bash script/setup-env.sh`
- 1Passwordから最新のAPIキーを取得: `OP_ACCOUNT=your.1password.com bash script/credentials.sh fetch && cp credentials/devcontainer.env ~/.devcontainer.env`
- 環境変数が正しく読み込まれているか確認: `echo $ANTHROPIC_API_KEY`

3. **`.codex`や`.claude`の設定が反映されない**
Expand Down Expand Up @@ -779,10 +773,9 @@ NODE_ENV=development
ls -la /workspaces/<project>/.mcp.json
ls -la ~/.claude/.mcp.json
```
- `.mcp.json`が生成されない場合:
- `credentials/mcp.env`が存在するか確認
- `script/setup-env.sh`を先に実行
- 手動で実行: `bash script/setup-mcp.sh`
- `.mcp.json`が存在しない場合:
- リポジトリの`.mcp.json`を確認(直接コミットされています)
- カスタマイズが必要な場合はリポジトリの`.mcp.json`を直接編集
- 環境変数が展開されているか確認:
```bash
cat .mcp.json | grep '\${'
Expand Down
72 changes: 31 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ config/
│ ├── security-credential-scan.sh
│ ├── setup-claude-build.sh
│ ├── setup-claude.sh
│ ├── setup-env.sh
│ ├── setup-file-length-check.sh
│ ├── setup-lsp.sh
│ ├── setup-mcp.sh
│ ├── setup-scheduled-agents.sh # Scheduled remote agents セットアップ
│ ├── setup-team-protection.sh
│ ├── update-agents-md.sh # AGENTS.md 自動生成セクション更新
Expand Down Expand Up @@ -481,15 +479,17 @@ git config --global user.signingkey ~/.ssh/id_ed25519.pub
For multiple 1Password accounts:

```bash
OP_ACCOUNT=my.1password.com bash script/setup-env.sh
bash script/setup-mcp.sh
OP_ACCOUNT=my.1password.com bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env
chmod 600 ~/.devcontainer.env
```

For single account:

```bash
bash script/setup-env.sh
bash script/setup-mcp.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env
chmod 600 ~/.devcontainer.env
```

This creates `~/.devcontainer.env` which is **required** for DevContainer startup.
Expand All @@ -511,9 +511,9 @@ git config --global user.signingkey ~/.ssh/id_ed25519.pub

The automated setup creates:

- `~/.devcontainer.env` - DevContainer environment variables (600 permissions)
- `credentials/devcontainer.env` - DevContainer environment variables (600 permissions)
- `credentials/mcp.env` - MCP environment variables (600 permissions)
- `.mcp.json` - MCP configuration file (600 permissions)
- `~/.devcontainer.env` - Installed from `credentials/devcontainer.env` (must be copied manually)

All generated files are automatically excluded from Git via `.gitignore`.

Expand Down Expand Up @@ -816,19 +816,18 @@ Use the automated setup scripts to generate environment files from 1Password:

```bash
# For multiple 1Password accounts
OP_ACCOUNT=my.1password.com bash script/setup-env.sh
bash script/setup-mcp.sh
OP_ACCOUNT=my.1password.com bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env

# For single account
bash script/setup-env.sh
bash script/setup-mcp.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env
```

This automatically creates:

- `~/.devcontainer.env` - DevContainer environment variables
- `credentials/devcontainer.env` - DevContainer environment variables
- `credentials/mcp.env` - MCP environment variables
- `.mcp.json` - MCP configuration file

All files are set with 600 permissions and excluded from Git.

Expand All @@ -852,7 +851,7 @@ If you need to customize `.mcp.json`:
chmod 600 .mcp.json
```

#### When to Run Setup Scripts
#### When to Regenerate Credentials

The environment variable setup is required at specific times:

Expand All @@ -861,42 +860,32 @@ The environment variable setup is required at specific times:
Before using DevContainer for the first time, run on your **host machine**:

```bash
OP_ACCOUNT=my.1password.com bash script/setup-env.sh
OP_ACCOUNT=my.1password.com bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env
```

This creates `~/.devcontainer.env` which is required for DevContainer startup via `runArgs`.
This creates `~/.devcontainer.env` which is required for DevContainer startup.

**2. DevContainer Startup (Automatic)**
**2. Credential Updates (Manual)**

When DevContainer starts, `postCreateCommand` automatically runs:

- `setup-env.sh` - Regenerates environment files inside container
- `setup-mcp.sh` - Generates `.mcp.json` from template

**3. Credential Updates (Manual)**

Re-run setup scripts when:
Re-run when:

- API keys are rotated in 1Password
- New credentials are added to templates
- Environment variables need to be refreshed

```bash
# On host machine
OP_ACCOUNT=my.1password.com bash script/setup-env.sh

# Inside DevContainer (or rebuild container)
bash script/setup-env.sh
bash script/setup-mcp.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env
```

**4. Template Updates (Manual)**
**3. Template Updates (Manual)**

After modifying `credentials/templates/*.env.template`, regenerate:

```bash
bash script/setup-env.sh
bash script/setup-mcp.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env
```

#### How It Works
Expand Down Expand Up @@ -930,15 +919,16 @@ make version-dry-run
#### Credential Management

```bash
# Automated setup (recommended)
bash script/setup-env.sh # Generate environment variables from 1Password
bash script/setup-mcp.sh # Generate MCP configuration
# Fetch credentials from 1Password
bash script/credentials.sh fetch

# For multiple 1Password accounts
OP_ACCOUNT=my.1password.com bash script/setup-env.sh
OP_ACCOUNT=my.1password.com bash script/credentials.sh fetch

# Install DevContainer environment file
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env

# Legacy method
make credentials # Fetch credentials from 1Password
# Other credential management
make clean-credentials # Clean up credential files
make list-credentials # List available credential templates
```
Expand Down
35 changes: 7 additions & 28 deletions credentials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,14 @@ credentials/
3. **環境変数を自動セットアップ**

```bash
bash script/setup-env.sh
bash script/credentials.sh fetch
cp credentials/devcontainer.env ~/.devcontainer.env && chmod 600 ~/.devcontainer.env
```

このスクリプトは以下を自動生成します:
- `~/.devcontainer.env` - DevContainer 環境変数
- `credentials/devcontainer.env` - DevContainer 環境変数
- `credentials/mcp.env` - MCP 設定用環境変数

4. **MCP 設定を生成**

```bash
bash script/setup-mcp.sh
```

`.mcp.json` が自動生成されます。

## サポートされているMCPサーバー

このリポジトリは以下のMCP (Model Context Protocol) サーバーをサポートしています:
Expand Down Expand Up @@ -199,29 +192,15 @@ cp credentials/templates/devcontainer.env.template ~/.devcontainer.env
**解決策**:

1. スクリプトの実行権限確認: `ls -l script/setup-*.sh`
2. 手動実行でデバッグ: `bash -x script/setup-env.sh`

### .mcp.json が生成されない
2. 手動実行でデバッグ: `bash -x script/credentials.sh fetch`

**症状**: `envsubst: command not found`
### MCP設定を変更したい

**解決策**:

1. `envsubst` インストール:
```bash
brew install gettext
brew link --force gettext
```
2. `credentials/mcp.env` が正しく生成されているか確認:
```bash
cat credentials/mcp.env
```
`.mcp.json` はリポジトリに直接コミットされています。変更が必要な場合はリポジトリの `.mcp.json` を直接編集してください。

## 関連ファイル

- `.mcp.json.template`: MCP 設定テンプレート(環境変数参照)
- `script/setup-env.sh`: 環境変数自動セットアップスクリプト
- `script/setup-mcp.sh`: MCP 設定自動生成スクリプト
- `script/credentials.sh`: クレデンシャル取得スクリプト
- `.zsh/configs/pre/.env.secret.template`: シェル環境変数トークンのテンプレート
- `.claude/settings.local.json.template`: Claude Code ローカル設定のテンプレート
- `script/export.sh`: 設定エクスポートスクリプト(フィルタリング機能含む)
Expand Down
2 changes: 1 addition & 1 deletion docs/doppler-setup-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export DOPPLER_TOKEN=dp.pt.xxxxx

## 既存の 1Password 管理からの移行

このリポジトリでは `script/setup-env.sh` + 1Password CLI でシークレットを管理しているが、
このリポジトリでは `script/credentials.sh` + 1Password CLI でシークレットを管理しているが、
プロジェクトごとに Doppler に移行する場合の手順:

1. 1Password のシークレットを Doppler の `dev` config にインポート
Expand Down
12 changes: 0 additions & 12 deletions script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ Manage GitHub Codespaces secrets across multiple repositories.

**Claude command**: `/codespaces-secrets`

### setup-env.sh

Sets up environment variables for DevContainer from credential files.

**Usage**: `./script/setup-env.sh`

### setup-mcp.sh

Sets up MCP (Model Context Protocol) configuration for Claude Code.

**Usage**: `./script/setup-mcp.sh`

## Claude Code Development

### setup-claude.sh
Expand Down
2 changes: 0 additions & 2 deletions script/lib/agents-md-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# shellcheck disable=SC2034 # all variables are sourced and consumed externally

declare -A DOT_DIR_PURPOSE=(
[.agents]="AI agent skills and configurations"
[.codex]="Codex AI agent configuration"
[.context]="Shared intermediate artifacts (complexity reports etc.)"
[.cursor]="Cursor editor settings"
Expand Down Expand Up @@ -32,7 +31,6 @@ declare -A REG_DIR_PURPOSE=(
[dot]="Dotfiles (DevContainer .zshrc, peco)"
[eslint]="ESLint configuration and plugins"
[git]="Git hooks and configuration"
[next]="Next.js project templates"
[nix]="nix-darwin + home-manager (macOS environment)"
[npm]="npm global configuration and library management"
[script]="Utility shell scripts"
Expand Down
9 changes: 0 additions & 9 deletions script/lib/output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ log_info() { output::info "$@"; }
log_success() { output::success "$@"; }
log_warn() { output::warning "$@"; }

# errors:: namespace aliases (migrated from errors.sh)
errors::fatal() { output::fatal "$@"; }
errors::warn() { output::warning "$@"; }
errors::info() { output::info "$@"; }
errors::success() { output::success "$@"; }
errors::require_command() { output::require_command "$@"; }
errors::require_file() { output::require_file "$@"; }
errors::require_directory() { output::require_directory "$@"; }

# Bash-compatible short aliases
info() { output::info "$@"; }
success() { output::success "$@"; }
Comment on lines 119 to 120

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore errors aliases or remove their integration tests

This removal also breaks the Bats integration job: test/integration/lib_functions.bats still greps for errors::fatal, errors::warn, and errors::require_command, then sources script/lib/output.sh and calls errors::require_command, errors::info, and errors::success. Because .github/workflows/ci.yml runs that Bats suite, this commit will fail CI unless the aliases are retained or the tests are changed in the same commit.

Useful? React with 👍 / 👎.

Expand Down
Loading