mcpField
S
skill-finish-branch

skill-finish-branch

github.com/nyldn開発4.3k56 回インストール今日更新
リポジトリ

skill-finish-branch について

Codex 向けに調整された、テストやレビューを経て開発ブランチを完了するスキルです。バージョンと変更履歴の更新、PR 作成やマージの選択肢を示し、確認を伴うクリーンアップを行います。

主な機能

  1. 01出荷前にプロジェクトのテストを実行
  2. 02複数プロバイダーでブランチ差分をレビュー
  3. 03バージョンと変更履歴の更新を選択可能
  4. 04出荷方法を4つ提示
  5. 05作業破棄の前に確認を要求

活用シーン

  1. 01テスト済みブランチでプルリクエストを準備
  2. 02ブランチをマージするか保持するか選択
  3. 03完了した作業ブランチを安全に破棄

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/nyldn/claude-octopus --skill skill-finish-branch

インストール後、Claude Code で/skill-finish-branchを入力して読み込まれたか確認します。

同梱ファイルagents/openai.yaml

詳細

ホスト:Codex CLI — このスキルは Claude Code 向けに設計され、Codex 用に調整されています。 相互参照コマンドでは、/octo:* スラッシュコマンドではなく、Codex でインストール済みのスキル名を使用します。 アクティブな Codex シェルとサブエージェントツールを使用してください。現在のセッションで利用可能になっていないプロバイダー、モデル、ホストのサブエージェントが使えると主張してはいけません。 ホストツールに相当するものについては、skills/blocks/codex-host-adapter.md を参照してください。

実行契約(必須 — 省略不可)

この生成された Codex スキルでは、元のスキルの強制ワークフロー契約が維持されています。

禁止事項:

  • このスキルで実行が求められているワークフローコマンドを、要約、模擬実行、または省略してはいけません。
  • 実際のファイルまたはコマンド出力を確認せずに、プロバイダーの出力や検証成果物が存在すると主張してはいけません。
  • 必須のプロバイダー、コマンド、またはホスト機能を利用できない場合、何も伝えずに作業を続けてはいけません。利用できない依存関係を報告し、サポートされている代替手段を使用してください。

開発ブランチを完了する

最初の出力行は必ず次のとおりにしてください: 🐙 **CLAUDE OCTOPUS ACTIVATED** - Branch Completion

概要

完全なリリースパイプライン:テスト → マルチプロバイダーレビュー → バージョン更新 → 変更履歴 → コミット → プッシュ → PR。

基本原則: テストを検証 → 差分をレビュー → バージョンを更新 → 変更履歴を更新 → 選択肢を提示 → 選択を実行 → クリーンアップ。

プロセス

ステップ 1:テストの合格を確認する

何よりも先に、テストの合格を確認してください:

# Detect and run project's test suite
if [[ -f "package.json" ]]; then npm test
elif [[ -f "pytest.ini" ]] || [[ -f "pyproject.toml" ]]; then pytest
elif [[ -f "Cargo.toml" ]]; then cargo test
elif [[ -f "go.mod" ]]; then go test ./...
elif [[ -f "Makefile" ]] && grep -q '^test:' Makefile; then make test
fi

テストが失敗した場合: 停止してください。失敗内容を表示してください。先へ進んではいけません。

テストが合格した場合: ステップ 2 に進んでください。

ステップ 2:マルチプロバイダー差分レビュー

リリース前に、変更内容を簡易マルチプロバイダーレビューにかけてください。 これにより、PR レビュアーに届く前に問題を検出できます。

# Get the diff summary
DIFF_STAT=$(git diff --stat $(git merge-base HEAD main)..HEAD)
DIFF_FILES=$(git diff --name-only $(git merge-base HEAD main)..HEAD)

簡易レビューは必ず実行してください。これは自動で行うものであり、省略できません:

# Quick review via orchestrate.sh (uses available providers)
${HOME}/.claude-octopus/plugin/scripts/orchestrate.sh spawn reviewer "Review this diff for bugs, security issues, and code quality problems. Be concise — only flag real issues, not style preferences.

$(git diff $(git merge-base HEAD main)..HEAD | head -500)"

重大な問題が見つかった場合: 問題を提示し、修正するか、そのままリリースするかを尋ねてください。 問題がない場合: ステップ 3 に進んでください。✓ Review clean — no issues found と簡潔に表示してください。

ステップ 3:ベースブランチとバージョンを決定する
# Identify the base branch
BASE_BRANCH=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
[[ -z "$BASE_BRANCH" ]] && BASE_BRANCH="main"

# Check for VERSION file
VERSION_FILE=""
for f in VERSION version.txt package.json; do
  [[ -f "$f" ]] && VERSION_FILE="$f" && break
done
ステップ 4:バージョン更新と変更履歴(任意)

VERSION ファイルまたは package.json がある場合は、バージョン更新を提案してください:

AskUserQuestion({
  questions: [{
    question: "Version bump?",
    header: "Version",
    multiSelect: false,
    options: [
      {label: "Patch (Recommended)", description: "Bug fixes, minor changes (1.2.3 → 1.2.4)"},
      {label: "Minor", description: "New features, backward compatible (1.2.3 → 1.3.0)"},
      {label: "Major", description: "Breaking changes (1.2.3 → 2.0.0)"},
      {label: "Skip", description: "Don't bump version"}
    ]
  }]
})

バージョンを更新する場合: バージョンファイルを更新し、差分を要約した項目を変更履歴の先頭に追加してください:

# Generate changelog entry from commits
COMMITS=$(git log --oneline $(git merge-base HEAD $BASE_BRANCH)..HEAD)
# Prepend to CHANGELOG.md if it exists
ステップ 5:選択肢を提示する

次の 4 つの選択肢を、そのまま提示してください:

✅ Ship ready. Tests passing. Review clean. What would you like to do?

1. **Create PR** (Recommended) - Push and create a Pull Request for review
2. **Merge locally** - Merge back to <base-branch> on this machine
3. **Keep as-is** - Leave the branch, I'll handle it later
4. **Discard** - Delete this work permanently

Which option? (1-4)

選択肢は簡潔にしてください。 求められない限り、説明を追加してはいけません。

ステップ 4:選択した項目を実行する
オプション 1:ローカルでマージする
# Get current branch name
FEATURE_BRANCH=$(git branch --show-current)
BASE_BRANCH="main"  # or detected base

# Switch to base branch
git checkout $BASE_BRANCH

# Pull latest
git pull origin $BASE_BRANCH

# Merge feature branch
git merge $FEATURE_BRANCH

# Verify tests on merged result
npm test  # or appropriate test command

# If tests pass, delete feature branch
git branch -d $FEATURE_BRANCH

報告内容:

✅ Merged $FEATURE_BRANCH into $BASE_BRANCH
✅ Tests pass on merged result
✅ Feature branch deleted

Ready to push when you want: git push origin $BASE_BRANCH
オプション 2:PR を作成する
# Get branch info
FEATURE_BRANCH=$(git branch --show-current)

# Push branch
git push -u origin $FEATURE_BRANCH

# Create PR with a validated description file
REPO_SLUG=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
PR_TITLE=${PR_TITLE:?Complete PR_TITLE before creating the pull request}
CHANGE_SUMMARY=${CHANGE_SUMMARY:?Complete CHANGE_SUMMARY before creating the pull request}
CHANGE_REASON=${CHANGE_REASON:?Complete CHANGE_REASON before creating the pull request}
PR_BODY=$(cat <<EOF
## Summary
- ${CHANGE_SUMMARY}
- ${CHANGE_REASON}

## Test Plan
- [x] Unit tests pass
- [x] Manual verification done
- [ ] Code review needed
EOF
)
if ! "${CLAUDE_PLUGIN_ROOT:-${HOME}/.claude-octopus/plugin}/scripts/safe-gh-comment.sh" \
    --repo "$REPO_SLUG" pr-create "$PR_TITLE" "$FEATURE_BRANCH" - <<< "$PR_BODY"; then
  echo "GitHub write state is unknown; check for an existing pull request before retrying:" >&2
  gh pr list --repo "$REPO_SLUG" --head "$FEATURE_BRANCH" --state all --json number,state,url || true
  return 1 2>/dev/null || exit 1
fi

報告内容:

✅ Branch pushed to origin/$FEATURE_BRANCH
✅ PR created: https://github.com/owner/repo/pull/123

Branch preserved for review process.
オプション 3:現状を維持する
✅ Keeping branch $FEATURE_BRANCH as-is.

Current state:
- Branch: $FEATURE_BRANCH
- Commits ahead of $BASE_BRANCH: N
- Tests: Passing

When ready, you can:
- Merge: git checkout main && git merge $FEATURE_BRANCH
- PR: git push -u origin $FEATURE_BRANCH && gh pr create
- Discard: git branch -D $FEATURE_BRANCH

クリーンアップは一切行わないでください。

オプション 4:破棄する

必ず先に確認してください:

⚠️ This will PERMANENTLY delete:
- Branch: $FEATURE_BRANCH
- All commits:
  - abc1234 feat: add user validation
  - def5678 fix: handle edge case
  - ghi9012 test: add integration tests

Type 'discard' to confirm, or anything else to cancel.

完全一致の確認応答 discard を待ってください。

確認された場合:

# Switch to base branch first
git checkout $BASE_BRANCH

# Force delete the feature branch
git branch -D $FEATURE_BRANCH

# If remote exists, delete it too (with confirmation)
git push origin --delete $FEATURE_BRANCH 2>/dev/null || true

報告内容:

✅ Branch $FEATURE_BRANCH deleted locally
✅ Remote branch deleted (if existed)

Work has been permanently discarded.
ステップ 5:クリーンアップ(ワークツリーを使用している場合)

オプション 1、2、4 の場合: ワークツリー内にいるか確認し、クリーンアップしてください:

# Check if current directory is a worktree
if git worktree list | grep -q "$(pwd)"; then
  # Get worktree path
  WORKTREE_PATH=$(pwd)
  
  # Switch to main worktree
  cd $(git worktree list | head -1 | awk '{print $(1)}')
  
  # Remove the worktree
  git worktree remove "$WORKTREE_PATH"
  
  echo "✅ Worktree cleaned up"
fi

オプション 3 の場合: ワークツリーはそのまま残してください。

クイックリファレンス

オプションマージプッシュブランチを保持クリーンアップ
1. ローカルでマージ✓-削除✓
2. PR を作成-✓保持-
3. 現状を維持--保持-
4. 破棄--削除✓

Claude Octopus との連携

Octopus ワークフローの完了後、このスキルを使用してください:

# After tangle (develop) phase completes successfully
# After ink (deliver) phase validates the work

# User says: "I'm done, create a PR"
# → Invoke finishing-branch skill
# → Verify tests
# → Present options
# → Execute Option 2 (Create PR)
Octopus 検証を使用する場合
# Run octopus validation before finishing
${HOME}/.claude-octopus/plugin/scripts/orchestrate.sh ink "Validate before merge"

# If validation passes, proceed with finishing-branch

危険な行為 — 絶対にしないこと

操作危険な理由
テストせずにマージする動作しないコードをリリースすることになります
破棄時の確認を省略する作業が永久に失われます
許可なく強制プッシュする履歴が破壊されます
リモートブランチを黙って削除する共同作業者に影響します
テストが失敗した状態で続行するmain ブランチが壊れます

よくある間違い

間違い修正方法
テスト前に選択肢を提示する必ず最初にテストを確認してください
尋ねずに自動でマージする4 つの選択肢を提示し、ユーザーに選んでもらってください
確認せずに削除する入力による discard の確認を必須にしてください
「現状を維持する」を選んだのにワークツリーをクリーンアップするクリーンアップはオプション 1、2、4 の場合に限ってください

The Bottom Line

Finishing branch → Tests verified AND user chose option
Otherwise → Not complete

Verify tests. Present options. Execute safely. Clean up appropriately.

コメント