-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add /setup-new-repo command for bootstrapping new repositories #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,310 @@ | ||
| --- | ||
| 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]' | ||
| --- | ||
|
|
||
| # New Repository Setup Command | ||
|
|
||
| 新しいリポジトリにDevContainer、CI/CD、開発ツールをセットアップします。 | ||
|
|
||
| ## Overview | ||
|
|
||
| 以下をセットアップします: | ||
|
|
||
| 1. **Git初期化** - リポジトリの初期化 | ||
| 2. **DevContainer** - `.devcontainer/` と `.vscode/` 設定 | ||
| 3. **Git設定** - commitlint, `.gitignore` | ||
| 4. **GitHub Actions** - CI workflow, Issue/PRテンプレート | ||
| 5. **開発ツール** - ESLint, Prettier, Jest, Husky | ||
| 6. **ドキュメント** - README.md, CLAUDE.md, SECURITY.md | ||
|
|
||
| ## Step 1: Parse Arguments | ||
|
|
||
| 引数から設定を読み取る: | ||
|
|
||
| - `TARGET_DIR`: 新規リポジトリのパス(必須) | ||
| - `--minimal`: GitHub Actionsをスキップ | ||
| - `--no-devcontainer`: DevContainer設定をスキップ | ||
| - `--license TYPE`: ライセンス種別(デフォルト: MIT) | ||
| - `--no-install`: npm install をスキップ | ||
|
|
||
| ## Step 2: Validate Target Directory | ||
|
|
||
| ターゲットディレクトリを確認: | ||
|
|
||
| ```bash | ||
| # ディレクトリが存在するか確認 | ||
| ls -la TARGET_DIR 2>/dev/null || echo "Directory will be created" | ||
| ``` | ||
|
|
||
| 既存のリポジトリがある場合は警告を表示し、上書きの確認を取る。 | ||
|
|
||
| ## Step 3: Get Config Repository Path | ||
|
|
||
| このconfigリポジトリのパスを取得: | ||
|
|
||
| ```bash | ||
| # 現在のリポジトリパスを確認 | ||
| git rev-parse --show-toplevel | ||
| ``` | ||
|
|
||
| ## Step 4: Initialize Git Repository | ||
|
|
||
| ```bash | ||
| cd TARGET_DIR | ||
| git init | ||
| ``` | ||
|
|
||
| ## Step 5: Copy DevContainer Configuration (unless --no-devcontainer) | ||
|
|
||
| ```bash | ||
| # .devcontainer をコピー | ||
| cp -r CONFIG_REPO/.devcontainer TARGET_DIR/ | ||
|
|
||
| # .vscode をコピー | ||
| cp -r CONFIG_REPO/.vscode TARGET_DIR/ | ||
| ``` | ||
|
|
||
| ### DevContainer 設定内容 | ||
|
|
||
| - `ghcr.io/keito4/config-base:latest` ベースイメージ | ||
| - Node.js 22+ | ||
| - 推奨VS Code拡張機能 | ||
|
|
||
| ## Step 6: Setup Git Configuration | ||
|
|
||
| ### 6.1 Commitlint設定 | ||
|
|
||
| ```bash | ||
| cp CONFIG_REPO/git/commitlint.config.js TARGET_DIR/ | ||
| ``` | ||
|
|
||
| ### 6.2 .gitignore作成 | ||
|
|
||
| 以下の内容で `.gitignore` を作成: | ||
|
|
||
| ```gitignore | ||
| # Dependencies | ||
| node_modules/ | ||
| .pnp | ||
| .pnp.js | ||
|
|
||
| # Testing | ||
| coverage/ | ||
| *.lcov | ||
|
|
||
| # Production | ||
| build/ | ||
| dist/ | ||
| *.tgz | ||
|
|
||
| # Misc | ||
| .DS_Store | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
|
|
||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .vscode/settings.local.json | ||
|
|
||
| # OS | ||
| Thumbs.db | ||
| ``` | ||
|
|
||
| ## Step 7: Copy GitHub Actions (unless --minimal) | ||
|
|
||
| ```bash | ||
| mkdir -p TARGET_DIR/.github/workflows | ||
| cp CONFIG_REPO/.github/workflows/ci.yml TARGET_DIR/.github/workflows/ | ||
|
|
||
| mkdir -p TARGET_DIR/.github/ISSUE_TEMPLATE | ||
| cp -r CONFIG_REPO/.github/ISSUE_TEMPLATE/* TARGET_DIR/.github/ISSUE_TEMPLATE/ | ||
|
|
||
| cp CONFIG_REPO/.github/PULL_REQUEST_TEMPLATE.md TARGET_DIR/.github/ | ||
| ``` | ||
|
|
||
| ## Step 8: Setup Development Tools | ||
|
|
||
| ### 8.1 package.json 作成 | ||
|
|
||
| ```json | ||
| { | ||
| "name": "new-project", | ||
| "version": "1.0.0", | ||
| "description": "New project bootstrapped from config repository", | ||
| "scripts": { | ||
| "lint": "eslint . --ext .js,.ts,.tsx", | ||
| "lint:fix": "npm run lint -- --fix", | ||
| "format": "prettier --write .", | ||
| "format:check": "prettier --check .", | ||
| "test": "jest", | ||
| "test:watch": "jest --watch", | ||
| "test:coverage": "jest --coverage", | ||
| "prepare": "husky" | ||
| }, | ||
| "devDependencies": { | ||
| "@commitlint/cli": "^19.0.0", | ||
| "@commitlint/config-conventional": "^19.0.0", | ||
| "eslint": "^9.0.0", | ||
| "husky": "^9.0.0", | ||
| "jest": "^29.0.0", | ||
| "prettier": "^3.0.0" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 8.2 設定ファイルをコピー | ||
|
|
||
| ```bash | ||
| cp CONFIG_REPO/eslint.config.mjs TARGET_DIR/ | ||
| cp CONFIG_REPO/.prettierrc TARGET_DIR/ | ||
| cp CONFIG_REPO/jest.config.js TARGET_DIR/ | ||
| ``` | ||
|
|
||
| ## Step 9: Create Documentation | ||
|
|
||
| ### 9.1 README.md | ||
|
|
||
| プロジェクト名を含むREADMEを作成: | ||
|
|
||
| ```markdown | ||
| # {project-name} | ||
|
|
||
| <!-- TODO: Add project description --> | ||
|
|
||
| ## Features | ||
|
|
||
| <!-- TODO: List key features --> | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js 22+ | ||
| - npm or pnpm | ||
|
|
||
| ### Installation | ||
|
|
||
| \`\`\`bash | ||
| npm install | ||
| \`\`\` | ||
|
|
||
| ### Development | ||
|
|
||
| \`\`\`bash | ||
| npm run dev | ||
| \`\`\` | ||
|
|
||
| ### Testing | ||
|
|
||
| \`\`\`bash | ||
| npm test | ||
| npm run test:coverage | ||
| \`\`\` | ||
|
|
||
| ## Contributing | ||
|
|
||
| Please read [CLAUDE.md](./CLAUDE.md) for development guidelines. | ||
|
|
||
| ## License | ||
|
|
||
| This project is licensed under the {LICENSE} License. | ||
| ``` | ||
|
|
||
| ### 9.2 CLAUDE.md | ||
|
|
||
| ```bash | ||
| cp CONFIG_REPO/.claude/CLAUDE.md TARGET_DIR/ | ||
| ``` | ||
|
|
||
| ### 9.3 SECURITY.md | ||
|
|
||
| セキュリティポリシーを作成。 | ||
|
|
||
|
Comment on lines
+230
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 stepEither 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 |
||
| ## Step 10: Install Dependencies (unless --no-install) | ||
|
|
||
| ```bash | ||
| cd TARGET_DIR | ||
| npm install | ||
| npx husky init | ||
| ``` | ||
|
|
||
| ## Step 11: Generate Summary | ||
|
|
||
| ``` | ||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
| ✅ 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 | ||
|
|
||
| ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
| ``` | ||
|
Comment on lines
+244
to
+276
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for fenced code block. The fenced code block lacks a language specification. While this is output text rather than executable code, specifying 📝 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 |
||
|
|
||
| ## Options Summary | ||
|
|
||
| | オプション | 説明 | デフォルト | | ||
| | ------------------- | -------------------------- | ---------- | | ||
| | `--minimal` | GitHub Actionsをスキップ | false | | ||
| | `--no-devcontainer` | DevContainer設定をスキップ | false | | ||
| | `--license TYPE` | ライセンス種別 | MIT | | ||
| | `--no-install` | npm installをスキップ | false | | ||
|
|
||
| ## Alternative: Use Shell Script | ||
|
|
||
| シェルスクリプトを直接実行することも可能: | ||
|
|
||
| ```bash | ||
| /path/to/config/script/setup-new-repo.sh TARGET_DIR [OPTIONS] | ||
| ``` | ||
|
|
||
|
Comment on lines
+287
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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 30Repository: keito4/config Length of output: 1132 Remove or clarify the non-existent shell script reference. The shell script 🤖 Prompt for AI Agents |
||
| ## Related Commands | ||
|
|
||
| | コマンド | 説明 | | ||
| | -------------------------- | ------------------------------ | | ||
| | `/setup-ci` | CI/CDワークフローの詳細設定 | | ||
| | `/setup-husky` | Husky + lint-staged の詳細設定 | | ||
| | `/setup-team-protection` | ブランチ保護ルールの設定 | | ||
| | `/config-base-sync-update` | DevContainerを最新に更新 | | ||
|
|
||
| ## Error Handling | ||
|
|
||
| エラー発生時: | ||
|
|
||
| 1. 具体的なエラー内容を報告 | ||
| 2. 手動での修正方法を提案 | ||
| 3. 部分的な成功でも適用可能な変更は適用 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add directory creation before
cd TARGET_DIR.The command sequence attempts to
cd TARGET_DIRwithout 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, thecdcommand will fail.📁 Proposed fix to create directory first
📝 Committable suggestion
🤖 Prompt for AI Agents