contribute について
git-town を使う開発者向けのコントリビューションワークフローです。フォークの確認からブランチ作成、プルリクエスト、マージまでを定め、ブランチ操作に git-town コマンドを必須とします。
主な機能
- 01フォーク設定と作業ツリーの確認
- 02git town sync による上流同期
- 03git town hack によるブランチ作成
- 04git town propose によるプルリクエスト作成
- 05承認済みリクエストの git town ship
- 06スタックブランチと競合の復旧
活用シーン
- 01設定済みフォークから貢献を始める
- 02既存ブランチからプルリクエストを作成する
- 03承認済みプルリクエストをマージする
- 04スタックした機能ブランチを管理する
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ terrylica/ cc-skills --skill contributeインストール後、Claude Code で/contributeを入力して読み込まれたか確認します。
同梱ファイルreferences/evolution-log.md
詳細
Git-Town のコントリビューションワークフロー — 必ずお読みください
このワークフローでは、git-town を使った一連のコントリビューションサイクルを案内します。
自己進化型スキル:このスキルは使用を通じて改善されます。手順が間違っている、パラメーターがずれている、または回避策が必要だった場合は、先送りせず、すぐにこのファイルを修正してください。実際に再現可能な問題がある場合にのみ更新してください。
⛔ ワークフローの遵守
必ず GIT-TOWN のコマンドを使用してください。生の GIT ブランチコマンドは禁止です。
| 手順 | ✅ 正しい | ❌ 禁止 |
|---|---|---|
| ブランチを作成 | git town hack | git checkout -b |
| ブランチを更新 | git town sync | git pull、git fetch、git merge |
| PR を作成 | git town propose | GitHub の UI から手動で作成 |
| PR をマージ | git town ship | git merge + git push |
フェーズ 0:事前確認 — 必須
手順 0.1:TodoWrite を作成
TodoWrite with todos:
- "[Contribute] Phase 0: Verify fork workflow is configured" | in_progress
- "[Contribute] Phase 0: Check workspace is clean" | pending
- "[Contribute] Phase 0: Sync with upstream" | pending
- "[Contribute] Phase 1: GATE - Confirm feature branch creation" | pending
- "[Contribute] Phase 1: Create feature branch with git town hack" | pending
- "[Contribute] Phase 2: Implement changes" | pending
- "[Contribute] Phase 2: Commit changes (raw git allowed here)" | pending
- "[Contribute] Phase 2: Sync branch before PR" | pending
- "[Contribute] Phase 3: GATE - Confirm PR creation" | pending
- "[Contribute] Phase 3: Create PR with git town propose" | pending
- "[Contribute] Phase 4: (Optional) Ship PR with git town ship" | pending
手順 0.2:フォークのワークフローが設定されていることを確認
/usr/bin/env bash << 'VERIFY_FORK_EOF'
echo "=== FORK WORKFLOW VERIFICATION ==="
# Check remotes
ORIGIN=$(git remote get-url origin 2>/dev/null)
UPSTREAM=$(git remote get-url upstream 2>/dev/null)
if [[ -z "$UPSTREAM" ]]; then
echo "❌ FATAL: upstream remote not configured"
echo "Run: /git-town-workflow:scion to configure"
exit 1
fi
echo "✅ origin: $ORIGIN"
echo "✅ upstream: $UPSTREAM"
# Check git-town config
SYNC_UPSTREAM=$(git config git-town.sync-upstream 2>/dev/null)
if [[ "$SYNC_UPSTREAM" != "true" ]]; then
echo "⚠️ WARNING: git-town.sync-upstream is not true"
echo "Run: git config git-town.sync-upstream true"
fi
# Check current branch
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
VERIFY_FORK_EOF
確認に失敗した場合:
AskUserQuestion with questions:
- question: "Fork workflow is not configured. Run fork setup first?"
header: "Setup Required"
options:
- label: "Yes, run /git-town-workflow:scion now"
description: "Configure fork workflow first"
- label: "No, abort"
description: "Cannot proceed without fork setup"
multiSelect: false
手順 0.3:ワークスペースがクリーンであることを確認
/usr/bin/env bash -c 'git status --porcelain'
ワークスペースに変更がある場合:
AskUserQuestion with questions:
- question: "Workspace has uncommitted changes. How to proceed?"
header: "Dirty Workspace"
options:
- label: "Stash changes (Recommended)"
description: "git stash, create branch, git stash pop"
- label: "Commit changes first"
description: "Create commit before new branch"
- label: "Discard changes"
description: "WARNING: Loses uncommitted work"
- label: "Abort"
description: "Handle manually"
multiSelect: false
手順 0.4:アップストリームと同期
機能ブランチを作成する前に、必ず同期してください:
git town sync
競合が発生した場合:
- 競合しているファイルを表示します
- ユーザーが解決するまで待ちます
git town continueを実行します
フェーズ 1:機能ブランチを作成
手順 1.1:ゲート — ブランチ作成を確認
AskUserQuestion with questions:
- question: "What is the feature branch name?"
header: "Branch Name"
options:
- label: "feat/{feature-name}"
description: "Standard feature branch"
- label: "fix/{bug-name}"
description: "Bug fix branch"
- label: "docs/{doc-name}"
description: "Documentation branch"
- label: "Enter custom name"
description: "I'll provide the full branch name"
multiSelect: false
手順 1.2:git-town でブランチを作成
⛔ git checkout -b は絶対に使用しないでください。必ず次を使用してください:
git town hack {branch-name}
このコマンドは次の処理を行います:
- origin と upstream からフェッチします
- 更新済みの main からブランチを作成します
- トラッキングを正しく設定します
- 親ブランチのチェーンを更新します
手順 1.3:ブランチが作成されたことを確認
/usr/bin/env bash << 'VERIFY_BRANCH_EOF'
BRANCH=$(git branch --show-current)
echo "Current branch: $BRANCH"
# Verify parent is main
git town branch
VERIFY_BRANCH_EOF
フェーズ 2:実装とコミット
手順 2.1:変更を実装
ここでユーザーが変更を実装します。
(このフェーズはユーザーまたは他のスキルが担当します)
手順 2.2:ステージングとコミット(生の git の使用可)
コミットには生の git を使用できます:
git add .
git commit -m "feat: description of change"
コミットメッセージの形式:
feat:- 新機能fix:- バグ修正docs:- ドキュメントrefactor:- コードのリファクタリングtest:- テストchore:- メンテナンス
手順 2.3:PR の前に同期
⛔ git pull または git push は絶対に使用しないでください。必ず次を使用してください:
git town sync
このコマンドは次の処理を行います:
- upstream/main から変更を取得します
- 機能ブランチをリベースまたはマージします
- origin(自分のフォーク)にプッシュします
競合が発生した場合:
AskUserQuestion with questions:
- question: "Sync encountered conflicts. What next?"
header: "Conflicts"
options:
- label: "I'll resolve conflicts manually"
description: "Fix conflicts, then run: git town continue"
- label: "Skip conflicting changes"
description: "Run: git town skip (may lose changes)"
- label: "Abort sync"
description: "Run: git town undo"
multiSelect: false
フェーズ 3:プルリクエストを作成
手順 3.1:ゲート — PR の作成を確認
AskUserQuestion with questions:
- question: "Ready to create a pull request to upstream?"
header: "Create PR"
options:
- label: "Yes, create PR to upstream"
description: "Run: git town propose"
- label: "No, keep working"
description: "Continue development, create PR later"
- label: "Create draft PR"
description: "Create PR but mark as draft"
multiSelect: false
手順 3.2:git-town で PR を作成
⛔ PR を手動で作成しないでください。必ず次を使用してください:
git town propose
このコマンドは次の処理を行います:
- 最新の変更を origin にプッシュします
- PR を作成するためにブラウザーを開きます
- 正しいアップストリームリポジトリをターゲットに設定します
- ブランチ情報を入力します
ドラフト PR の場合:
git town propose --draft
手順 3.3:PR が作成されたことを確認
/usr/bin/env bash -c 'gh pr view --json url,state,title'
フェーズ 4:Ship(PR の承認後)
手順 4.1:ゲート — Ship を確認
AskUserQuestion with questions:
- question: "Has your PR been approved and ready to merge?"
header: "Ship PR"
options:
- label: "Yes, ship it (merge to main)"
description: "Run: git town ship"
- label: "Not yet, PR is pending review"
description: "Wait for approval"
- label: "PR was merged via GitHub UI"
description: "Just cleanup local branches"
multiSelect: false
手順 4.2:git-town で Ship
⛔ 手動でマージしないでください。必ず次を使用してください:
git town ship
このコマンドは次の処理を行います:
- PR が承認されていることを確認します
- main にマージします
- 機能ブランチを削除します(ローカルとリモート)
- ローカルの main を更新します
手順 4.3:Ship 後のクリーンアップ
/usr/bin/env bash << 'CLEANUP_EOF'
echo "=== POST-SHIP STATUS ==="
# Show current branch
git branch --show-current
# Show recent commits on main
git log --oneline -5
# Verify feature branch deleted
git branch -a | grep -v "^*" | head -10
echo "✅ Ship complete"
CLEANUP_EOF
スタックブランチ(上級)
子ブランチの作成
機能を複数の小さな PR に分割する必要がある場合:
# On feature branch, create child
git town append child-feature
# Creates stack:
# main
# └── feature
# └── child-feature
スタック内の移動
git town up # Go to parent branch
git town down # Go to child branch
git town branch # Show full stack hierarchy
スタックの Ship
下から上へ Ship します:
git town ship feature # Ships feature first
git town ship child-feature # Then ship child
エラーからの復旧
最後の git-town コマンドを取り消す
git town undo
競合を解決した後に続行
git town continue
同期時に競合するブランチをスキップ
git town skip
git-town のステータスを確認
git town status
クイックリファレンス
┌─────────────────────────────────────────────────────────┐
│ GIT-TOWN CONTRIBUTION FLOW │
├─────────────────────────────────────────────────────────┤
│ │
│ 1. SYNC git town sync │
│ ↓ │
│ 2. BRANCH git town hack feature-name │
│ ↓ │
│ 3. COMMIT git add . && git commit -m "..." │
│ ↓ │
│ 4. SYNC git town sync │
│ ↓ │
│ 5. PR git town propose │
│ ↓ │
│ 6. SHIP git town ship (after approval) │
│ │
├─────────────────────────────────────────────────────────┤
│ ⚠️ FORBIDDEN: git checkout -b, git pull, git merge │
│ ✅ ALLOWED: git add, git commit, git log, git diff │
└─────────────────────────────────────────────────────────┘
引数
[feature-name]- 任意:新しい機能ブランチの名前--pr- PR 作成に進みます(ブランチはすでに存在します)--ship- Ship に進みます(PR はすでに承認されています)
例
# Start new contribution
/git-town-workflow:contribute feat/add-dark-mode
# Create PR for existing branch
/git-town-workflow:contribute --pr
# Ship after PR approved
/git-town-workflow:contribute --ship
トラブルシューティング
| 問題 | 原因 | 解決策 |
|---|---|---|
| 同期に失敗する | マージコンフリクト | コンフリクトを解決してから、git town sync を実行します |
| ブランチの親が間違っている | git-town の設定の不一致 | git town branch で階層を確認・修正します |
| 提案に失敗する | リモート追跡ブランチがない | 最初に git town sync を実行してプッシュします |
| 出荷がブロックされる | ブランチが main 上にない | 先に PR をマージするか、--ignore-parent を使用します |
| "Cannot ship" | 未コミットの変更 | 先に変更をコミットするか、スタッシュします |
| PR がすでに存在する | propose の再実行 | --pr フラグを使用して既存の PR を表示します |
実行後の振り返り
このスキルの実行が完了したら、タスクを終了する前に振り返ってください。
- 現在位置を確認します。 — 編集する前に、この SKILL.md の正式なパスを見つけます(このスキル名で Glob を実行します)。修正対象はこのファイルとその兄弟の references/ のみにしてください。他のドキュメントは対象にしないでください。
- 何が失敗しましたか? — 原因となった指示を修正します。再発する可能性がある場合は、アンチパターンとして追加します。
- 予想以上にうまくいったことは何ですか? — 推奨される実践方法として取り入れます。その理由も記録してください。
- 何が現状とずれていましたか? — スクリプト、参照、外部依存関係が現状と一致していない場合は、今すぐ修正します。
- 記録します。 — すべての変更について、きっかけ、修正内容、根拠を進化ログに記録します。
先送りしないでください。次回の実行では、ここに残した状態が引き継がれます。