← 教程列表
实战📊 中级🛠 AI赚钱

2. `finishing-a-development-branch/SKILL.md` — Add Step 1.5 + cleanup guard (~20 lines)

📅 2026/6/14 15:43:48⏱ 约 5 分钟阅读👁 9 阅读

**Step 1.5: Detect Environment** (after Step 1 "Verify Tests", before Step 2 "Determine Base Branch") Run the detection commands. Three paths: - **Path A** skips Steps 2 and 3 entirely (no base branch or options needed). - **Paths B and C** proceed through Step 2 (Determine Base Branch) and Step 3 (Present Options) as normal. **Path A — Externally managed worktree + detached HEAD** (`GIT_DIR != GIT_COMMON` AND `BRANCH` empty): First, ensure all work is staged and committed (`git add` + `git commit`). The Codex App's finishing controls operate on committed work. Then present this to the user (do NOT present the 4-option menu): ``` Implementation complete. All tests passing. Current HEAD: This workspace is externally managed (detached HEAD). I cannot create branches, push, or open PRs from here. ⚠ These commits are on a detached HEAD. If you do not create a branch, they may be lost when this workspace is cleaned up. If your host application provides these controls: - "Create branch" — to name a branch, then commit/push/PR - "Hand off to local" — to move changes to your local checkout Suggested branch name: Suggested commit message: ``` Branch name derivation: use the ticket ID if available (e.g., `pri-823/codex-compat`), otherwise slugify the first 5 words of the plan title, otherwise omit the suggestion. Avoid including sensitive content (vulnerability descriptions, customer names) in branch names. Skip to Step 5 (cleanup is a no-op for externally managed worktrees). **Path B — Externally managed worktree + named branch** (`GIT_DIR != GIT_COMMON` AND `BRANCH` exists): Present the 4-option menu as normal. (The Step 5 cleanup guard will re-detect the externally managed state independently.) **Path C — Normal environment** (`GIT_DIR == GIT_COMMON`): Present the 4-option menu as today (unchanged). **Step 5 cleanup guard:** Re-run the `GIT_DIR` vs `GIT_COMMON` detection at cleanup time (do not rely on earlier skill output — the finishing skill may run in a different session). If `GIT_DIR != GIT_COMMON`, skip `git worktree remove` — the host environment owns this workspace. Otherwise, check and remove as today. Note: the existing Step 5 text says "For Options 1, 2, 4" but the Quick Reference table and Common Mistakes section say "Options 1 & 4 only." The new guard is added before this existing logic and does not change which options trigger cleanup. **Everything else unchanged:** Options 1-4 logic, Quick Reference, Common Mistakes, Red Flags.

← 返回教程列表 AI8899 · 内容仅供学习参考