From 6f7e472f2076851941bd5a84f129d26782491e3d Mon Sep 17 00:00:00 2001 From: "k.hiro1818" Date: Sun, 3 May 2026 10:09:20 +0000 Subject: [PATCH 1/5] feat(devcontainer): introduce RTK and extract postCreateCommand to shell script Move postCreateCommand inline string to setup-devcontainer.sh for better readability and error handling. Install and initialize RTK in the script. Add gh CLI via devcontainer feature; add gh destructive commands to deny list. Co-Authored-By: Claude Sonnet 4.6 --- .claude/settings.json | 7 ++ .devcontainer/devcontainer-lock.json | 9 ++ .devcontainer/devcontainer.json | 6 +- .devcontainer/setup-devcontainer.sh | 15 +++ CONTRIBUTING.md | 1 + .../2026-05-03/introduce-rtk/plan.md | 93 +++++++++++++++++++ 6 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/devcontainer-lock.json create mode 100644 .devcontainer/setup-devcontainer.sh create mode 100644 docs/dev-notes/2026-05-03/introduce-rtk/plan.md diff --git a/.claude/settings.json b/.claude/settings.json index bc49141de..0edc5ffd2 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -12,6 +12,13 @@ "Bash(curl *)", "Bash(wget *)", "Bash(git push *)", + "Bash(gh pr merge *)", + "Bash(gh pr close *)", + "Bash(gh issue close *)", + "Bash(gh issue delete *)", + "Bash(gh release create *)", + "Bash(gh release delete *)", + "Bash(gh repo delete *)", "Bash(chmod 777 *)", "Read(**/.env)", "Read(**/.env.*)", diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 000000000..dc6fc6bfe --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "1.1.0", + "resolved": "ghcr.io/devcontainers/features/github-cli@sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671", + "integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671" + } + } +} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aa076add2..29df623a6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,9 @@ "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind,consistency=cached" ], // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, // // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ @@ -25,7 +27,7 @@ "initializeCommand": "mkdir -p ~/.claude", // // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "npm install -g @anthropic-ai/claude-code && (curl -fsSL https://cli.coderabbit.ai/install.sh | sh || echo 'CodeRabbit CLI installation failed, continuing...') && pnpm install", + "postCreateCommand": "bash .devcontainer/setup-devcontainer.sh", // // Configure tool-specific properties. "customizations": { diff --git a/.devcontainer/setup-devcontainer.sh b/.devcontainer/setup-devcontainer.sh new file mode 100644 index 000000000..eefb1cb69 --- /dev/null +++ b/.devcontainer/setup-devcontainer.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -euo pipefail + +# Install Claude Code CLI +npm install -g @anthropic-ai/claude-code + +# Install CodeRabbit CLI (continue if fails) +curl -fsSL https://cli.coderabbit.ai/install.sh | sh || echo 'CodeRabbit CLI installation failed, continuing...' + +# Install RTK — token optimization proxy for AI coding assistants (60-90% reduction) +curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh +rtk init -g --auto-patch + +# Install project dependencies +pnpm install diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 63c04f796..31068f5a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,7 @@ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) - AI コーディングアシスタント(VS Code 拡張: `anthropic.claude-code`) - [superpowers plugin](https://github.com/obra/superpowers) - `/writing-plans` スキルによる実装前の詳細計画生成 + - [RTK](https://github.com/rtk-ai/rtk) - AI コーディングアシスタント向けトークン最適化プロキシ(60–90% 削減) - [CodeRabbit](https://coderabbit.ai/) - AI コードレビュー - CodeRabbit CLI (`coderabbit review --plain`) — milestone 区切りでのローカルレビュー - CodeRabbit CI — PR 作成後の自動レビュー(最終品質ゲート) diff --git a/docs/dev-notes/2026-05-03/introduce-rtk/plan.md b/docs/dev-notes/2026-05-03/introduce-rtk/plan.md new file mode 100644 index 000000000..43f0d5625 --- /dev/null +++ b/docs/dev-notes/2026-05-03/introduce-rtk/plan.md @@ -0,0 +1,93 @@ +# RTK導入 & postCreateCommand のシェルスクリプト分離 + +## Context + +現在 `devcontainer.json` の `postCreateCommand` にインライン文字列でツールインストールを記述しており、コメントやエラーハンドリングが書きにくい。AtCoderClans PR #11994 を参考に、以下2点を実施する。 + +1. `postCreateCommand` をシェルスクリプト `.devcontainer/setup-devcontainer.sh` に分離 +2. RTK(Rust Token Killer)をそのスクリプト内でインストール・初期化 + +## 変更ファイル + +- `.devcontainer/devcontainer.json` — features に gh CLI 追加、postCreateCommand を1行に短縮 +- `.devcontainer/setup-devcontainer.sh` — 新規作成 +- `.claude/settings.json` — gh の不可逆操作を deny に追加 +- `CONTRIBUTING.md` — `### AI 支援ツール` セクションに RTK を追記 + +## 実装内容 + +### `.devcontainer/setup-devcontainer.sh`(新規) + +```bash +#!/bin/bash +set -euo pipefail + +# Install Claude Code CLI +npm install -g @anthropic-ai/claude-code + +# Install CodeRabbit CLI (continue if fails) +curl -fsSL https://cli.coderabbit.ai/install.sh | sh || echo 'CodeRabbit CLI installation failed, continuing...' + +# Install RTK — token optimization proxy for AI coding assistants (60-90% reduction) +curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh +rtk init -g --auto-patch + +# Install project dependencies +pnpm install +``` + +### `.devcontainer/devcontainer.json` + +`features` を追加(コメントアウト済みの行を置き換え)し、`postCreateCommand` を短縮: + +```json +"features": { + "ghcr.io/devcontainers/features/github-cli:1": {} +}, +"postCreateCommand": "bash .devcontainer/setup-devcontainer.sh", +``` + +> gh CLI はコンテナビルド時に root 権限で features が入れるため、`setup-devcontainer.sh`(node ユーザー)では不要。 + +## 設計上の判断 + +- `set -euo pipefail` で途中失敗を即停止(デバッグしやすい) +- CodeRabbit CLI は `|| echo ...` で失敗を許容(既存の挙動を維持) +- RTK インストール後 `rtk init -g --auto-patch` でグローバル Claude Code フックを自動パッチ + - `~/.claude` はボリュームマウントされるため、フック設定はコンテナ再作成後も永続する + +### `.claude/settings.json` — `permissions.deny` に追記 + +`git push` は既存で deny 済み。gh CLI の不可逆操作を追加する: + +```json +"Bash(gh pr merge *)", +"Bash(gh pr close *)", +"Bash(gh issue close *)", +"Bash(gh issue delete *)", +"Bash(gh release create *)", +"Bash(gh release delete *)", +"Bash(gh repo delete *)" +``` + +> `gh pr create` は可逆(close で取り消せる)のため deny 対象外。 + +### `CONTRIBUTING.md` — `### AI 支援ツール` セクション(71行目付近) + +```markdown +- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) - AI コーディングアシスタント(VS Code 拡張: `anthropic.claude-code`) + - [superpowers plugin](https://github.com/obra/superpowers) - `/writing-plans` スキルによる実装前の詳細計画生成 + - [RTK](https://github.com/rtk-ai/rtk) - AI コーディングアシスタント向けトークン最適化プロキシ(60–90% 削減) +``` + +## 検証 + +コンテナを再作成して以下を確認: + +```bash +which rtk # rtk が PATH にある +rtk --version # バージョンが表示される +rtk gain # トークン削減量が表示される +which gh # gh が PATH にある +gh --version # バージョンが表示される +``` From 38687e281ae31795f0b6ecc0e9017b893b53c622 Mon Sep 17 00:00:00 2001 From: "k.hiro1818" Date: Sun, 3 May 2026 12:05:16 +0000 Subject: [PATCH 2/5] feat(devcontainer): mount host .gitconfig into container Co-Authored-By: Claude Sonnet 4.6 --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 29df623a6..539a746eb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,8 @@ "dockerComposeFile": ["../compose.yaml"], "mounts": [ "source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,consistency=cached", - "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind,consistency=cached" + "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind,consistency=cached", + "source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached" ], // Features to add to the dev container. More info: https://containers.dev/features. "features": { From 43a7c7dc4161a5d4b4b1287e0935ca10921b281c Mon Sep 17 00:00:00 2001 From: "k.hiro1818" Date: Sun, 3 May 2026 12:06:51 +0000 Subject: [PATCH 3/5] docs: remove completed RTK introduction plan Co-Authored-By: Claude Sonnet 4.6 --- .../2026-05-03/introduce-rtk/plan.md | 93 ------------------- 1 file changed, 93 deletions(-) delete mode 100644 docs/dev-notes/2026-05-03/introduce-rtk/plan.md diff --git a/docs/dev-notes/2026-05-03/introduce-rtk/plan.md b/docs/dev-notes/2026-05-03/introduce-rtk/plan.md deleted file mode 100644 index 43f0d5625..000000000 --- a/docs/dev-notes/2026-05-03/introduce-rtk/plan.md +++ /dev/null @@ -1,93 +0,0 @@ -# RTK導入 & postCreateCommand のシェルスクリプト分離 - -## Context - -現在 `devcontainer.json` の `postCreateCommand` にインライン文字列でツールインストールを記述しており、コメントやエラーハンドリングが書きにくい。AtCoderClans PR #11994 を参考に、以下2点を実施する。 - -1. `postCreateCommand` をシェルスクリプト `.devcontainer/setup-devcontainer.sh` に分離 -2. RTK(Rust Token Killer)をそのスクリプト内でインストール・初期化 - -## 変更ファイル - -- `.devcontainer/devcontainer.json` — features に gh CLI 追加、postCreateCommand を1行に短縮 -- `.devcontainer/setup-devcontainer.sh` — 新規作成 -- `.claude/settings.json` — gh の不可逆操作を deny に追加 -- `CONTRIBUTING.md` — `### AI 支援ツール` セクションに RTK を追記 - -## 実装内容 - -### `.devcontainer/setup-devcontainer.sh`(新規) - -```bash -#!/bin/bash -set -euo pipefail - -# Install Claude Code CLI -npm install -g @anthropic-ai/claude-code - -# Install CodeRabbit CLI (continue if fails) -curl -fsSL https://cli.coderabbit.ai/install.sh | sh || echo 'CodeRabbit CLI installation failed, continuing...' - -# Install RTK — token optimization proxy for AI coding assistants (60-90% reduction) -curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh -rtk init -g --auto-patch - -# Install project dependencies -pnpm install -``` - -### `.devcontainer/devcontainer.json` - -`features` を追加(コメントアウト済みの行を置き換え)し、`postCreateCommand` を短縮: - -```json -"features": { - "ghcr.io/devcontainers/features/github-cli:1": {} -}, -"postCreateCommand": "bash .devcontainer/setup-devcontainer.sh", -``` - -> gh CLI はコンテナビルド時に root 権限で features が入れるため、`setup-devcontainer.sh`(node ユーザー)では不要。 - -## 設計上の判断 - -- `set -euo pipefail` で途中失敗を即停止(デバッグしやすい) -- CodeRabbit CLI は `|| echo ...` で失敗を許容(既存の挙動を維持) -- RTK インストール後 `rtk init -g --auto-patch` でグローバル Claude Code フックを自動パッチ - - `~/.claude` はボリュームマウントされるため、フック設定はコンテナ再作成後も永続する - -### `.claude/settings.json` — `permissions.deny` に追記 - -`git push` は既存で deny 済み。gh CLI の不可逆操作を追加する: - -```json -"Bash(gh pr merge *)", -"Bash(gh pr close *)", -"Bash(gh issue close *)", -"Bash(gh issue delete *)", -"Bash(gh release create *)", -"Bash(gh release delete *)", -"Bash(gh repo delete *)" -``` - -> `gh pr create` は可逆(close で取り消せる)のため deny 対象外。 - -### `CONTRIBUTING.md` — `### AI 支援ツール` セクション(71行目付近) - -```markdown -- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) - AI コーディングアシスタント(VS Code 拡張: `anthropic.claude-code`) - - [superpowers plugin](https://github.com/obra/superpowers) - `/writing-plans` スキルによる実装前の詳細計画生成 - - [RTK](https://github.com/rtk-ai/rtk) - AI コーディングアシスタント向けトークン最適化プロキシ(60–90% 削減) -``` - -## 検証 - -コンテナを再作成して以下を確認: - -```bash -which rtk # rtk が PATH にある -rtk --version # バージョンが表示される -rtk gain # トークン削減量が表示される -which gh # gh が PATH にある -gh --version # バージョンが表示される -``` From 62b0f37fad7476ff641b683bb529730c9011b479 Mon Sep 17 00:00:00 2001 From: "k.hiro1818" Date: Sun, 3 May 2026 12:09:54 +0000 Subject: [PATCH 4/5] chore(devcontainer): fix missing newline at end of lock file Co-Authored-By: Claude Sonnet 4.6 --- .devcontainer/devcontainer-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json index dc6fc6bfe..cdd61126b 100644 --- a/.devcontainer/devcontainer-lock.json +++ b/.devcontainer/devcontainer-lock.json @@ -6,4 +6,4 @@ "integrity": "sha256:d22f50b70ed75339b4eed1ba9ecde3a1791f90e88d37936517e3bace0bbad671" } } -} \ No newline at end of file +} From 9b614fd8efbbb608c94d6e947e530a1f0f0249f3 Mon Sep 17 00:00:00 2001 From: "k.hiro1818" Date: Sun, 3 May 2026 12:44:44 +0000 Subject: [PATCH 5/5] chore(devcontainer): make RTK install non-fatal and pre-create .gitconfig Co-Authored-By: Claude Sonnet 4.6 --- .devcontainer/devcontainer.json | 2 +- .devcontainer/setup-devcontainer.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 539a746eb..937ab0897 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -25,7 +25,7 @@ // "shutdownAction": "none", // // Use 'initializeCommand' to run commands before the container is created. - "initializeCommand": "mkdir -p ~/.claude", + "initializeCommand": "mkdir -p ~/.claude && touch ~/.gitconfig", // // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "bash .devcontainer/setup-devcontainer.sh", diff --git a/.devcontainer/setup-devcontainer.sh b/.devcontainer/setup-devcontainer.sh index eefb1cb69..4a4f1fd2d 100644 --- a/.devcontainer/setup-devcontainer.sh +++ b/.devcontainer/setup-devcontainer.sh @@ -8,8 +8,8 @@ npm install -g @anthropic-ai/claude-code curl -fsSL https://cli.coderabbit.ai/install.sh | sh || echo 'CodeRabbit CLI installation failed, continuing...' # Install RTK — token optimization proxy for AI coding assistants (60-90% reduction) -curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh -rtk init -g --auto-patch +curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh || echo 'RTK installation failed, continuing...' +rtk init -g --auto-patch || echo 'RTK init failed, continuing...' # Install project dependencies pnpm install