Skip to content
Merged
Changes from 1 commit
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
104 changes: 79 additions & 25 deletions .claude/commands/setup-new-repo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Setup new repository with DevContainer, CI/CD, and development tools from config template
allowed-tools: Read, Write, Edit, Bash(git:*), Bash(gh:*), Bash(npm:*), Bash(mkdir:*), Bash(cp:*), Bash(ls:*), Bash(cat:*), Bash(test:*), Task, Glob, Grep
argument-hint: '<TARGET_DIR> [--minimal] [--no-devcontainer] [--license MIT|Apache-2.0] [--no-install]'
argument-hint: '<TARGET_DIR> [--minimal] [--no-devcontainer] [--no-codespaces] [--license MIT|Apache-2.0] [--no-install]'
---

# New Repository Setup Command
Expand All @@ -13,11 +13,12 @@ argument-hint: '<TARGET_DIR> [--minimal] [--no-devcontainer] [--license MIT|Apac
以下をセットアップします:

1. **Git初期化** - リポジトリの初期化
2. **DevContainer** - `.devcontainer/` と `.vscode/` 設定
2. **DevContainer** - `.devcontainer/` と `.vscode/` 設定(Codespaces 対応含む)
3. **Git設定** - commitlint, `.gitignore`
4. **GitHub Actions** - CI workflow, Issue/PRテンプレート
5. **開発ツール** - ESLint, Prettier, Jest, Husky
6. **ドキュメント** - README.md, CLAUDE.md, SECURITY.md
7. **Codespaces シークレット** - リポジトリへのシークレット紐付け

## Step 1: Parse Arguments

Expand All @@ -26,6 +27,7 @@ argument-hint: '<TARGET_DIR> [--minimal] [--no-devcontainer] [--license MIT|Apac
- `TARGET_DIR`: 新規リポジトリのパス(必須)
- `--minimal`: GitHub Actionsをスキップ
- `--no-devcontainer`: DevContainer設定をスキップ
- `--no-codespaces`: Codespacesシークレット紐付けをスキップ
- `--license TYPE`: ライセンス種別(デフォルト: MIT)
Comment on lines +30 to 31

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

--no-codespaces meaning is inconsistent.

Line 30 says it only skips secret binding, Step 5 says both devcontainers are always created, and the PR objectives say Codespaces settings/secrets are skipped. Please align the flag behavior and docs (either skip Codespaces devcontainer + secrets, or only skip secrets).

✅ Suggested wording fix (if skipping Codespaces devcontainer + secrets)
-- `--no-codespaces`: Codespacesシークレット紐付けをスキップ
+- `--no-codespaces`: Codespaces用 devcontainer 生成とシークレット紐付けをスキップ
@@
-DevContainer設定をプロジェクトに合わせて新規作成する。ローカル用と Codespaces 用の2つを作成する。
+DevContainer設定をプロジェクトに合わせて新規作成する。`--no-codespaces` 以外ではローカル用と Codespaces 用の2つを作成する。

Also applies to: 61-67, 103-138, 324-328, 395-401

🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md around lines 30 - 31, The
`--no-codespaces` flag description is inconsistent across the doc: decide
whether it skips both Codespaces devcontainer and secret binding or only secret
binding, then make all references consistent; update the `--no-codespaces`
bullet (current line ~30), the Step 5 description, the PR objectives section,
and all other occurrences (around lines noted) so the wording uniformly states
the chosen behavior, and ensure examples/usage and any mentions of Codespaces
settings/secrets use the exact same phrasing; search for `--no-codespaces` and
reconcile the docs to a single authoritative sentence describing what the flag
does.

- `--no-install`: npm install をスキップ

Expand Down Expand Up @@ -56,21 +58,75 @@ cd TARGET_DIR
git init
```

## Step 5: Copy DevContainer Configuration (unless --no-devcontainer)
## Step 5: Create DevContainer Configuration (unless --no-devcontainer)

```bash
# .devcontainer をコピー
cp -r CONFIG_REPO/.devcontainer TARGET_DIR/
DevContainer設定をプロジェクトに合わせて新規作成する。configリポジトリからコピーせず、プロジェクト固有の設定を生成する。

### 5.1 `.devcontainer/devcontainer.json` を作成

以下をすべて含める(Codespaces 対応がデフォルト):

# .vscode をコピー
cp -r CONFIG_REPO/.vscode TARGET_DIR/
```json
{
"name": "{project-name}",
"image": "ghcr.io/keito4/config-base:latest",
"features": {
// プロジェクトに必要な追加 features をここに記載
},
"remoteEnv": {
"TMPDIR": "/home/vscode/.claude/tmp"
},
"postCreateCommand": "npm install",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

--no-install is contradicted by postCreateCommand: "npm install".

Docs say --no-install skips installation, but the generated DevContainer will still run npm install. Clarify or conditionalize the template.

✅ Suggested doc fix: make postCreateCommand conditional
-  "postCreateCommand": "npm install",
+  "postCreateCommand": "{if not --no-install}npm install{else}echo \"skip npm install\"{end}",

Also applies to: 119-119, 316-322

🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md at line 79, The template currently always
injects the DevContainer setting postCreateCommand: "npm install" which
contradicts the documented --no-install flag; update the template and docs so
the postCreateCommand is either omitted or conditional based on the user's
choice (e.g., only add postCreateCommand when install is requested), and apply
the same change to the other occurrences of postCreateCommand in this file (the
other template blocks that add "postCreateCommand": "npm install"); also update
the explanatory text to state that the command will only be present when
installation is enabled.

"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-next"
// プロジェクトに応じた拡張機能を追加
],
"settings": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}
},
"codespaces": {
"openFiles": ["README.md"]
}
},
"secrets": {
"ANTHROPIC_API_KEY": {
"description": "Anthropic API key for Claude Code"
}
// プロジェクト固有のシークレットを追加
}
}
```

**重要**: `codespaces` カスタマイゼーションと `secrets` セクションは常にデフォルトで含める。

### 5.2 `.vscode/` 設定を作成

```bash
mkdir -p TARGET_DIR/.vscode
```

- `extensions.json`: 推奨拡張機能
- `settings.json`: エディタ設定(formatOnSave, ESLint, Prettier)

### DevContainer 設定内容

- `ghcr.io/keito4/config-base:latest` ベースイメージ
- Node.js 22+
- 推奨VS Code拡張機能
- Codespaces 対応(シークレット定義、openFiles)
- `postCreateCommand` による自動依存関係インストール

## Step 6: Setup Git Configuration

Expand Down Expand Up @@ -239,9 +295,10 @@ npm install
npx husky init
```

## Step 11: Add to Codespaces Secrets (Optional)
## Step 11: Add to Codespaces Secrets (Default)

GitHub Codespacesでリポジトリを使用する場合、シークレットの紐付けが必要です。
Codespaces でリポジトリを使用できるように、シークレットの紐付けをデフォルトで実行する。
`--no-codespaces` オプションが指定された場合のみスキップ。

### 11.1: Check if codespaces-secrets.sh is available

Expand All @@ -251,8 +308,6 @@ test -f CONFIG_REPO/script/codespaces-secrets.sh && echo "available" || echo "no

### 11.2: Add repository to Codespaces secrets

If available and user chooses to enable Codespaces:

```bash
# リポジトリをシークレット管理対象に追加
CONFIG_REPO/script/codespaces-secrets.sh repos add {owner}/{repo-name}
Expand All @@ -261,16 +316,14 @@ CONFIG_REPO/script/codespaces-secrets.sh repos add {owner}/{repo-name}
CONFIG_REPO/script/codespaces-secrets.sh sync

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 Run Codespaces sync only after remote repo exists

Step 11 now executes codespaces-secrets.sh repos add {owner}/{repo-name} and sync by default even though this workflow only initializes a local git repo in Step 4 and doesn’t prompt gh repo create until Step 12. In that common new-repo path, repos add can’t register a non-existent remote and cmd_sync in script/codespaces-secrets.sh fatals when no repos are configured, so /setup-new-repo can fail unless users manually opt out with --no-codespaces.

Useful? React with 👍 / 👎.

```

### 11.3: Display Codespaces reminder
### 11.3: Verify setup

```bash
# 紐付け状態を確認
CONFIG_REPO/script/codespaces-secrets.sh list
```
📦 Codespaces 設定のリマインダー

GitHub Codespacesでこのリポジトリを使用する場合:
1. シークレットを紐付け: ./script/codespaces-secrets.sh repos add {owner}/{repo-name}
2. 同期実行: ./script/codespaces-secrets.sh sync
3. 確認: ./script/codespaces-secrets.sh list
```
シークレットスクリプトが利用できない場合は、手動設定のガイドを表示する。

## Step 12: Generate Summary

Expand Down Expand Up @@ -313,12 +366,13 @@ Next Steps:

## Options Summary

| オプション | 説明 | デフォルト |
| ------------------- | -------------------------- | ---------- |
| `--minimal` | GitHub Actionsをスキップ | false |
| `--no-devcontainer` | DevContainer設定をスキップ | false |
| `--license TYPE` | ライセンス種別 | MIT |
| `--no-install` | npm installをスキップ | false |
| オプション | 説明 | デフォルト |
| ------------------- | -------------------------------------- | ---------- |
| `--minimal` | GitHub Actionsをスキップ | false |
| `--no-devcontainer` | DevContainer設定をスキップ | false |
| `--no-codespaces` | Codespacesシークレット紐付けをスキップ | false |
| `--license TYPE` | ライセンス種別 | MIT |
| `--no-install` | npm installをスキップ | false |

## Related Commands

Expand Down