Skip to content

feat: add /setup-new-repo command for bootstrapping new repositories - #399

Merged
keito4 merged 1 commit into
mainfrom
feat/add-setup-new-repo-command
Feb 2, 2026
Merged

feat: add /setup-new-repo command for bootstrapping new repositories#399
keito4 merged 1 commit into
mainfrom
feat/add-setup-new-repo-command

Conversation

@keito4

@keito4 keito4 commented Feb 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • 新しいリポジトリをセットアップするための /setup-new-repo コマンドを追加
  • DevContainer、CI/CD、開発ツール、ドキュメントを一括でセットアップ可能

Features

このコマンドで以下をセットアップ:

項目 内容
DevContainer .devcontainer/, .vscode/
Git設定 commitlint, .gitignore
GitHub Actions CI workflow, Issue/PRテンプレート
開発ツール ESLint, Prettier, Jest, Husky
ドキュメント README.md, CLAUDE.md, SECURITY.md

Usage

/setup-new-repo <TARGET_DIR> [--minimal] [--no-devcontainer] [--license MIT|Apache-2.0] [--no-install]

Options

オプション 説明
--minimal GitHub Actionsをスキップ
--no-devcontainer DevContainer設定をスキップ
--license TYPE ライセンス種別(デフォルト: MIT)
--no-install npm installをスキップ

Test plan

  • コマンドファイルが正しい形式で作成されていることを確認
  • /setup-new-repo /tmp/test-repo で新規リポジトリをセットアップできることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added comprehensive documentation for the repository bootstrap command, covering repository initialization, DevContainer and CI/CD configuration management, development tools setup, supported arguments and configuration options, dependency installation procedures, and step-by-step guidance for setting up new projects.

✏️ Tip: You can customize this high-level summary in your review settings.

Add a Claude command that sets up new repositories with:
- DevContainer configuration
- CI/CD workflows (GitHub Actions)
- Development tools (ESLint, Prettier, Jest, Husky)
- Git configuration (commitlint, .gitignore)
- Documentation templates (README, CLAUDE.md, SECURITY.md)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A new documentation file is added that comprehensively describes a command for bootstrapping new repositories. The guide details steps for argument parsing, directory validation, initializing Git, copying DevContainer and VSCode configurations, setting up CI/CD workflows, configuring development tools, generating documentation files, and installing dependencies.

Changes

Cohort / File(s) Summary
Repository Setup Command Documentation
.claude/commands/setup-new-repo.md
New documentation file (310 lines) defining a complete workflow for initializing repositories with DevContainer support, GitHub Actions CI/CD, development tooling (ESLint, Prettier, Jest), and scaffolded project files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hopping through the setup guide so neat,
New repos bloom from template feet,
DevContainers, workflows divine,
Documentation helps repos align,
Bootstrap magic, from start to the finish!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely describes the main change: adding a new /setup-new-repo command for bootstrapping repositories, which matches the file addition and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-setup-new-repo-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In @.claude/commands/setup-new-repo.md:
- Around line 230-233: Update the "9.3 SECURITY.md" step to include a concrete
SECURITY.md creation action: either paste a basic SECURITY.md template (e.g.,
reporting process, contact, PGP key, disclosure timeline) directly under the
"### 9.3 SECURITY.md" section or add a copy command that pulls the file from the
config repo (e.g., cp CONFIG_REPO/SECURITY.md TARGET_DIR/) and mention which
repo/path to use; ensure the section clearly shows the template content or the
exact copy command and destination so the step is actionable.
- Around line 52-58: The "Step 4: Initialize Git Repository" sequence uses "cd
TARGET_DIR" without ensuring the directory exists; update this step to create
the directory first by running "mkdir -p TARGET_DIR" (or equivalent) before "cd
TARGET_DIR" so the subsequent "git init" won't fail if the target directory is
missing; modify the block containing "cd TARGET_DIR" and "git init" to include
the directory creation command immediately above the cd command.
- Around line 287-294: The documentation references a non-existent shell script
path `/path/to/config/script/setup-new-repo.sh` which will confuse users; either
remove the "Alternative: Use Shell Script" section or update it to clearly mark
the script as a placeholder/planned feature (e.g., "script not yet available")
and remove the absolute placeholder path, ensuring references to
"setup-new-repo.sh" or the section header "Alternative: Use Shell Script" are
updated accordingly so readers aren’t misled.
- Around line 244-276: The fenced code block containing the "Repository Setup
Complete" banner is missing a language identifier; update that block to use a
plaintext language tag (e.g., add ```text) so the linter is satisfied and the
output is rendered clearly—locate the fenced block that wraps the banner text
and change its opening triple-backticks to include "text" (or "plaintext").
🧹 Nitpick comments (1)
.claude/commands/setup-new-repo.md (1)

180-223: Clarify placeholder substitution mechanism.

The README template includes placeholders like {project-name} (line 181) and {LICENSE} (line 221), but the documentation doesn't explain how these should be substituted with actual values. Consider adding a note about the substitution mechanism or providing example sed/awk commands to replace these placeholders.

Comment on lines +52 to +58
## Step 4: Initialize Git Repository

```bash
cd TARGET_DIR
git init
```

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

Add directory creation before cd TARGET_DIR.

The command sequence attempts to cd TARGET_DIR without ensuring the directory exists first. Step 2 mentions "Directory will be created" but Step 4 doesn't actually create it. If the target directory doesn't exist, the cd command will fail.

📁 Proposed fix to create directory first
+```bash
+mkdir -p TARGET_DIR
+```
+
 ```bash
 cd TARGET_DIR
 git init
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Step 4: Initialize Git Repository
```bash
cd TARGET_DIR
git init
```
## Step 4: Initialize Git Repository
🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md around lines 52 - 58, The "Step 4:
Initialize Git Repository" sequence uses "cd TARGET_DIR" without ensuring the
directory exists; update this step to create the directory first by running
"mkdir -p TARGET_DIR" (or equivalent) before "cd TARGET_DIR" so the subsequent
"git init" won't fail if the target directory is missing; modify the block
containing "cd TARGET_DIR" and "git init" to include the directory creation
command immediately above the cd command.

Comment on lines +230 to +233
### 9.3 SECURITY.md

セキュリティポリシーを作成。

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 | 🟡 Minor

Complete SECURITY.md creation step.

Step 9.3 mentions creating a security policy ("セキュリティポリシーを作成") but doesn't provide the content, template, or command to create it. This step is incomplete compared to the detailed instructions provided for README.md and other files.

📄 Suggestion to complete this step

Either provide the SECURITY.md template content inline (similar to the README.md template) or specify copying from the config repository:

cp CONFIG_REPO/SECURITY.md TARGET_DIR/

Or provide a basic template if one doesn't exist in the config repo.

🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md around lines 230 - 233, Update the "9.3
SECURITY.md" step to include a concrete SECURITY.md creation action: either
paste a basic SECURITY.md template (e.g., reporting process, contact, PGP key,
disclosure timeline) directly under the "### 9.3 SECURITY.md" section or add a
copy command that pulls the file from the config repo (e.g., cp
CONFIG_REPO/SECURITY.md TARGET_DIR/) and mention which repo/path to use; ensure
the section clearly shows the template content or the exact copy command and
destination so the step is actionable.

Comment on lines +244 to +276
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Repository Setup Complete
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📁 Target: {TARGET_DIR}

Files Created:
✅ .devcontainer/
✅ .vscode/
✅ .github/workflows/ci.yml
✅ .github/ISSUE_TEMPLATE/
✅ .github/PULL_REQUEST_TEMPLATE.md
✅ package.json
✅ eslint.config.mjs
✅ .prettierrc
✅ jest.config.js
✅ commitlint.config.js
✅ .gitignore
✅ README.md
✅ CLAUDE.md
✅ SECURITY.md

Next Steps:
1. cd {TARGET_DIR}
2. Update README.md with project details
3. Update package.json (name, description)
4. git add . && git commit -m "chore: initial setup"
5. gh repo create (optional)
6. git push -u origin main

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

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 | 🟡 Minor

Specify language for fenced code block.

The fenced code block lacks a language specification. While this is output text rather than executable code, specifying text or plaintext would satisfy the linter and improve clarity.

📝 Proposed fix
-```
+```text
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ✅ Repository Setup Complete
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)

[warning] 244-244: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md around lines 244 - 276, The fenced code
block containing the "Repository Setup Complete" banner is missing a language
identifier; update that block to use a plaintext language tag (e.g., add
```text) so the linter is satisfied and the output is rendered clearly—locate
the fenced block that wraps the banner text and change its opening
triple-backticks to include "text" (or "plaintext").

Comment on lines +287 to +294
## Alternative: Use Shell Script

シェルスクリプトを直接実行することも可能:

```bash
/path/to/config/script/setup-new-repo.sh TARGET_DIR [OPTIONS]
```

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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for setup-new-repo.sh in the repository
echo "=== Searching for setup-new-repo.sh ==="
fd -t f 'setup-new-repo\.sh' || echo "No matches found"

echo ""
echo "=== Searching for any script directory ==="
fd -t d 'script' || echo "No script directories found"

echo ""
echo "=== Checking the documentation file ==="
head -n 300 .claude/commands/setup-new-repo.md | tail -n 30

Repository: keito4/config

Length of output: 1132


Remove or clarify the non-existent shell script reference.

The shell script setup-new-repo.sh does not exist in the repository. The path /path/to/config/script/setup-new-repo.sh is a placeholder that will confuse users. Either remove this section or add a note that it describes a planned feature and is not yet available.

🤖 Prompt for AI Agents
In @.claude/commands/setup-new-repo.md around lines 287 - 294, The documentation
references a non-existent shell script path
`/path/to/config/script/setup-new-repo.sh` which will confuse users; either
remove the "Alternative: Use Shell Script" section or update it to clearly mark
the script as a placeholder/planned feature (e.g., "script not yet available")
and remove the absolute placeholder path, ensuring references to
"setup-new-repo.sh" or the section header "Alternative: Use Shell Script" are
updated accordingly so readers aren’t misled.

@claude

claude Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

PR Review: /setup-new-repo コマンド追加

全体評価

新規リポジトリのブートストラップを自動化する有用なコマンドです。全体的な構造は良好ですが、いくつかの改善点があります。


✅ 良い点

  1. 明確な構造: ステップバイステップのアプローチで、各段階が分かりやすい
  2. オプション設定: --minimal, --no-devcontainer など柔軟な設定が可能
  3. 包括的なセットアップ: DevContainer, CI/CD, 開発ツール、ドキュメントを網羅
  4. 視覚的なサマリー: 最終的な出力フォーマットが分かりやすい

🔴 Critical Issues

1. セキュリティ: コピー元パスの検証不足

場所: Step 3, 5, 6, 7, 8

問題点:

cp -r CONFIG_REPO/.devcontainer TARGET_DIR/
cp CONFIG_REPO/git/commitlint.config.js TARGET_DIR/

パス検証やエラーハンドリングが記載されていません。存在しないファイルをコピーしようとした際の動作が不明確です。

推奨対応:

# コピー前に存在確認
if [ -d "CONFIG_REPO/.devcontainer" ]; then
  cp -r CONFIG_REPO/.devcontainer TARGET_DIR/
else
  echo "Warning: .devcontainer not found, skipping..."
fi

2. ライセンス機能の未実装

場所: Step 1, Step 9

問題点:

  • --license TYPE オプションが定義されているが、実際に使用される箇所がない
  • README.md に {LICENSE} プレースホルダーがあるが、置換処理が記載されていない
  • SECURITY.md の生成が「セキュリティポリシーを作成」とだけ書かれており、具体的な実装がない

推奨対応:

### 9.3 LICENSE ファイル生成

ライセンスタイプに応じてLICENSEファイルを作成:

- MIT: MIT License テンプレートを使用
- Apache-2.0: Apache 2.0 License テンプレートを使用

また、README.md の {LICENSE} を実際のライセンス名に置換。

⚠️ Major Issues

3. package.json の依存バージョンが古い

場所: Step 8.1

問題点:

"@commitlint/cli": "^19.0.0",
"eslint": "^9.0.0",
"husky": "^9.0.0",

2026年2月時点では、これらのパッケージはより新しいバージョンがリリースされている可能性があります。

推奨対応:

  • 最新の安定版を指定
  • または npm install --save-dev @commitlint/cli@latest のように動的に最新版を取得

4. DevContainer イメージバージョンの不一致

場所: Step 5, DevContainer 設定内容

問題点:

  • ドキュメントに ghcr.io/keito4/config-base:latest と記載
  • しかし、CLAUDE.md では ghcr.io/keito4/config-base:1.48.0 を使用すると明記

推奨対応:

  • 固定バージョン (1.48.0 または最新の安定版) を使用
  • latest タグは予期しない変更を引き起こす可能性があるため非推奨

5. Git初期コミットのコミットメッセージが規約違反

場所: Step 11, Next Steps

問題点:

git commit -m "chore: initial setup"

CLAUDE.md に記載されている通り、chore タイプはリリースをトリガーしません。しかし、.codex/**, .devcontainer/codex*, package*.json などツール関連ファイルを含む場合は、リリース型 (feat, fix, etc.) が必要です。

推奨対応:

git commit -m "feat: initial repository setup with DevContainer and CI/CD"

⚡ Performance & Best Practices

6. npm install の重複実行リスク

場所: Step 10

問題点:

npm install
npx husky init

Husky の prepare スクリプトが package.json に含まれている (Step 8.1) ため、npm install 実行時に自動的に Husky が初期化されます。その後 npx husky init を実行すると重複する可能性があります。

推奨対応:

npm install
# Husky は prepare スクリプトで自動初期化されるため、追加の init は不要

7. エラーハンドリングの詳細化が必要

場所: Step 11 (Error Handling セクション)

問題点:
エラーハンドリングのセクションが抽象的で、具体的なエラーシナリオと対応方法が不足しています。

推奨対応:
各ステップで想定されるエラーを列挙:

  • ディレクトリ作成失敗 (権限不足)
  • npm install 失敗 (ネットワークエラー)
  • Git 初期化失敗 (既存の .git ディレクトリ)
  • ファイルコピー失敗 (存在しないソース)

📝 Documentation & Code Quality

8. コマンド実行の前提条件が不明確

問題点:

  • このコマンドを実行するディレクトリ (config リポジトリ内 or 外部) が不明
  • 必要な環境 (Node.js, Git, gh CLI のバージョン) が記載されていない

推奨対応:

## Prerequisites

このコマンドを実行する前に、以下が必要です:

- Node.js 22+ がインストール済み
- Git 2.40+ がインストール済み
- gh CLI (GitHub CLI) がインストール済み
- config リポジトリのローカルクローン

9. Step 2 の上書き確認が実装されていない

場所: Step 2

問題点:
「既存のリポジトリがある場合は警告を表示し、上書きの確認を取る」と記載されているが、具体的な実装方法が記載されていない。

推奨対応:
Claude Code コマンドでは AskUserQuestion ツールを使用して対話的に確認を取る必要があります。その手順を明記すべきです。

10. Related Commands との連携が不明確

場所: Related Commands セクション

問題点:
関連コマンドがリストされているが、実際にこのコマンド実行後にそれらを使うべきかどうかが不明確です。

推奨対応:

## Related Commands

新規リポジトリセットアップ後、必要に応じて以下のコマンドを実行:

| タイミング | コマンド | 説明 |
|----------|---------|------|
| セットアップ後すぐ | `/setup-team-protection` | ブランチ保護ルールの設定 (推奨) |
| CI/CD カスタマイズ時 | `/setup-ci` | CI/CD ワークフローの詳細設定 |
| DevContainer更新時 | `/config-base-sync-update` | DevContainerを最新に更新 |

🧪 Testing

11. テストプランが不完全

場所: PR本文の Test plan

問題点:

- [x] コマンドファイルが正しい形式で作成されていることを確認
- [ ] /setup-new-repo /tmp/test-repo で新規リポジトリをセットアップできることを確認

2つ目のテストが未完了のまま PR が作成されています。

推奨対応:
実際に /tmp/test-repo でコマンドを実行し、以下を検証してからマージ:

  • すべてのファイルが正しく作成されるか
  • npm install が成功するか
  • git commit が成功するか
  • 作成されたリポジトリで CI が正常に動作するか

💡 Enhancement Suggestions

12. テンプレート変数の置換処理

README.md で {project-name}{LICENSE} のようなプレースホルダーを使用していますが、これらを自動的に置換する処理が記載されていません。

推奨追加:

## Step 9.4: Replace Template Variables

以下の変数を実際の値に置換:

- `{project-name}`: TARGET_DIR のディレクトリ名から推測
- `{LICENSE}`: --license オプションの値 (デフォルト: MIT)

13. .gitignore の内容が不十分

場所: Step 6.2

問題点:
提示されている .gitignore は Node.js プロジェクト向けですが、以下が不足:

  • .claude/ 関連の設定ファイル (settings.local.json など)
  • .husky/_/ ディレクトリ
  • .cache/ ディレクトリ

推奨追加:

# Claude
.claude/settings.local.json
.claude/.tmp/

# Husky
.husky/_/

# Cache
.cache/
.eslintcache

📊 Summary

カテゴリ 件数
Critical 2
Major 4
Performance 2
Documentation 3
Testing 1
Enhancement 2

Next Steps

  1. 必須: Critical と Major の問題を修正
  2. 推奨: テストプランの2つ目の項目を完了
  3. 任意: Enhancement の提案を検討

全体的に有用なコマンドですが、上記の問題を解決することで、より堅牢で使いやすいツールになります。


.claude/commands/setup-new-repo.md:71
.claude/commands/setup-new-repo.md:156-162
.claude/commands/setup-new-repo.md:221
.claude/commands/setup-new-repo.md:271

@keito4
keito4 merged commit 9d84fc3 into main Feb 2, 2026
6 checks passed
@github-actions

github-actions Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.61.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant