{
    "url": "https://delaparra-services.nl/skills/finishing-a-development-branch",
    "locale": "en",
    "title": "Finishing a Development Branch | DeLaParra Services",
    "description": "Use when implementation is complete, all tests pass, and you need to decide how to integrate the work",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/finishing-a-development-branch",
        "nl": "https://delaparra-services.nl/nl/skills/finishing-a-development-branch"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/finishing-a-development-branch.csv",
        "md": "https://delaparra-services.nl/skills/finishing-a-development-branch.md",
        "json": "https://delaparra-services.nl/skills/finishing-a-development-branch.json",
        "zip": "https://delaparra-services.nl/skills/finishing-a-development-branch.zip",
        "pdf": "https://delaparra-services.nl/skills/finishing-a-development-branch.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch.csv",
            "encodingFormat": "text/csv",
            "name": "finishing-a-development-branch.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch.json",
            "encodingFormat": "application/json",
            "name": "finishing-a-development-branch.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch.md",
            "encodingFormat": "text/markdown",
            "name": "finishing-a-development-branch.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch.pdf",
            "encodingFormat": "application/pdf",
            "name": "finishing-a-development-branch.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch.zip",
            "encodingFormat": "application/zip",
            "name": "finishing-a-development-branch.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/finishing-a-development-branch/download",
            "encodingFormat": "application/zip",
            "name": "finishing-a-development-branch-files.zip"
        }
    ],
    "markdown": "# Finishing a Development Branch\n\n \n\nUse when implementation is complete, all tests pass, and you need to decide how to integrate the work\n\n \n\n**Licence** MIT\n\n \n\n**Source** obra/superpowers\n\n [Download zip](<https://delaparra-services.nl/skills/finishing-a-development-branch/download>)   \n\n# Finishing a Development Branch\n\n \n\n## Overview\n\n \n\n**Core principle:** Verify tests → Detect environment → Present options → Execute choice → Clean up.\n\n \n\n**Announce at start:** \"I'm using the finishing-a-development-branch skill to complete this work.\"\n\n \n\n## Step 1: Verify Tests\n\n \n\nRun the project's full test suite (` npm test ` / ` cargo test ` / ` pytest ` / ` go test ./... `).\n\n \n\n**If tests fail**, report the failures and stop — the menu comes after a green suite:\n\n \n\n```\nTests failing (<N> failures). Must fix before completing:\n\n[Show failures]\n```\n\n \n\n**If tests pass:** continue to Step 2.\n\n \n\n## Step 2: Detect Environment\n\n \n\n```\nGIT_DIR=$(cd \"$(git rev-parse --git-dir)\" 2>/dev/null && pwd -P)\nGIT_COMMON=$(cd \"$(git rev-parse --git-common-dir)\" 2>/dev/null && pwd -P)\n# Capture now, while still inside the workspace — Step 5 changes directory\n# before cleanup (Step 6) needs this value\nWORKTREE_PATH=$(git rev-parse --show-toplevel)\n```\n\n \n\nThis determines which menu to show and how cleanup works:\n\n    State Menu Cleanup     ` GIT_DIR == GIT_COMMON ` (normal repo) Standard 3 options No worktree to clean up   ` GIT_DIR != GIT_COMMON `, named branch Standard 3 options Provenance-based (see Step 6)   ` GIT_DIR != GIT_COMMON `, detached HEAD Reduced 2 options (no merge) Externally managed — leave in place    \n\n## Step 3: Determine Base Branch\n\n \n\nThe base branch is whatever this work forked from — usually named in the plan, the conversation, or the branch's upstream. If it is not already known, ask: \"This branch split from - is that correct?\" Confirm before merging: merging into the wrong base is expensive to undo.\n\n \n\n## Step 4: Present Options\n\n \n\n**Normal repo and named-branch worktree — present exactly these 3 options:**\n\n \n\n```\nImplementation complete. What would you like to do?\n\n1. Merge back to <base-branch> locally\n2. Push and create a Pull Request\n3. Keep the branch as-is (I'll handle it later)\n\nWhich option?\n```\n\n \n\n**Detached HEAD — present exactly these 2 options:**\n\n \n\n```\nImplementation complete. You're on a detached HEAD (externally managed workspace).\n\n1. Push as new branch and create a Pull Request\n2. Keep as-is (I'll handle it later)\n\nWhich option?\n```\n\n \n\nPresent the menu exactly as written — concise, with every option coming from the list above. Discarding the work happens only in response to your human partner explicitly asking for it (see \"If your human partner asks to discard the work\" below). Wait for their answer; the integration decision is theirs.\n\n \n\n## Step 5: Execute Choice\n\n \n\n### Option 1: Merge Locally\n\n \n\n```\n# Get main repo root for CWD safety\nMAIN_ROOT=$(git -C \"$(git rev-parse --git-common-dir)/..\" rev-parse --show-toplevel)\ncd \"$MAIN_ROOT\"\n\n# Merge first — verify success before removing anything\ngit checkout <base-branch>\ngit pull\ngit merge <feature-branch>\n\n# Verify tests on merged result\n<test command>\n```\n\n \n\nIf tests fail on the merged result: stop, leave the worktree and branch in place, and investigate — nothing has been pushed, so the merge is local and recoverable.\n\n \n\nOnce the merged result is green: clean up the worktree (Step 6), then delete the branch:\n\n \n\n```\ngit branch -d <feature-branch>\n```\n\n \n\n### Option 2: Push and Create PR\n\n \n\n```\ngit push -u origin <feature-branch>\n# From a detached HEAD, name the new branch on the remote:\n# git push origin HEAD:refs/heads/<new-branch>\n```\n\n \n\nThen create the pull/merge request against with the forge's tooling — its CLI if one is available, or the creation URL most forges print when you push — following the repo's PR template and conventions if present, and report the URL to your human partner.\n\n \n\nKeep the worktree — your human partner iterates on PR feedback there.\n\n \n\n### Option 3: Keep As-Is\n\n \n\nReport: \"Keeping branch . Worktree preserved at .\"\n\n \n\n### If your human partner asks to discard the work\n\n \n\nThis path exists only as a response to an explicit request to throw the work away. Confirm first:\n\n \n\n```\nThis will permanently delete:\n- Branch <name>\n- All commits: <commit-list>\n- Worktree at <path>\n\nType 'discard' to confirm.\n```\n\n \n\nWait for that exact confirmation. When it arrives:\n\n \n\n```\nMAIN_ROOT=$(git -C \"$(git rev-parse --git-common-dir)/..\" rev-parse --show-toplevel)\ncd \"$MAIN_ROOT\"\n```\n\n \n\nThen clean up the worktree (Step 6) and force-delete the branch:\n\n \n\n```\ngit branch -D <feature-branch>\n```\n\n \n\n## Step 6: Cleanup Workspace\n\n \n\n**Runs for Option 1 and confirmed discards.** Options 2 and 3 always preserve the worktree. Both callers have already changed directory to the main repo root — worktree removal must run from outside the worktree — and use the ` GIT_DIR `/` GIT_COMMON `/` WORKTREE_PATH ` values captured in Step 2, from before that directory change.\n\n \n\n**If ` GIT_DIR == GIT_COMMON `:** Normal repo, no worktree to clean up. Done.\n\n \n\n**If ` WORKTREE_PATH ` is under ` .worktrees/ ` or ` worktrees/ `:** Superpowers created this worktree — we own cleanup:\n\n \n\n```\ngit worktree remove \"$WORKTREE_PATH\"\ngit worktree prune  # Self-healing: clean up any stale registrations\n```\n\n \n\n**If removal is refused** (` contains modified or untracked files `): the worktree holds files that exist nowhere else — uncommitted plans, notes, or scratch work. Never ` --force ` on your own initiative. Show your human partner what is at stake and ask:\n\n \n\n```\ngit -C \"$WORKTREE_PATH\" status --porcelain -uall\n```\n\n \n\n```\nWorktree removal refused — these files were never committed:\n\n<file list>\n\n1. Commit them to <branch> before cleanup\n2. Move them into <main repo root>\n3. Delete them (unrecoverable)\n\nWhich?\n```\n\n \n\nCarry out the choice, then remove the worktree.\n\n \n\n**Otherwise:** The host environment owns this workspace — leave it in place. If your platform provides a workspace-exit tool, use it.\n\n \n\n## Quick Reference\n\n    Option Merge Push Keep Worktree Cleanup Branch     1. Merge locally yes - - yes   2. Create PR - yes yes -   3. Keep as-is - - yes -   Discard (explicit request only) - - - yes (force)    \n\n## Common Rationalizations\n\n    Excuse Reality     \"Tests passed earlier this session\" Run the suite on the tree you are about to integrate. A green run only proves the tree it ran on.   \"They obviously want it merged\" Integration is your human partner's decision. Present the menu and wait.   \"They seem done with this feature — I'll offer to discard it\" The menu is complete as written. Discard happens only when your human partner asks for it in so many words.   \"'Yeah, get rid of it' counts as confirmation\" Only the typed word ` discard ` authorizes deletion.   \"The PR is up, so the worktree is clutter now\" PR feedback gets fixed in that worktree. It stays until the work lands.   \"This other worktree looks stale — I'll clean it too\" Clean up only worktrees under ` .worktrees/ ` or ` worktrees/ `. Everything else belongs to the host.   \"Removal refused — ` --force ` is just finishing the cleanup\" The refusal means files exist only in that worktree. ` --force ` destroys them permanently. Show your human partner and ask.   \"The merged-result failure is probably flaky\" A failing merged result stops everything. Branch and worktree stay put while you investigate.   \"The base branch is obviously main\" Confirm the fork point or ask. Merging into the wrong base is expensive to undo.   \"The push was rejected — force-push will fix it\" A rejected push means the remote moved. Investigate; force-push only on your human partner's explicit request.\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md `\n\n \n\n## Related terms\n\n \n\n- [git bisect](<https://delaparra-services.nl/knowledge-hub/git-bisect>) \n- [git cherry-pick](<https://delaparra-services.nl/knowledge-hub/git-cherry-pick>) \n- [git clone](<https://delaparra-services.nl/knowledge-hub/git-clone>) \n- [git config](<https://delaparra-services.nl/knowledge-hub/git-config>) \n- [git fetch](<https://delaparra-services.nl/knowledge-hub/git-fetch>) \n- [git init](<https://delaparra-services.nl/knowledge-hub/git-init>) \n- [git merge](<https://delaparra-services.nl/knowledge-hub/git-merge>) \n- [git pull](<https://delaparra-services.nl/knowledge-hub/git-pull>) \n- [git push](<https://delaparra-services.nl/knowledge-hub/git-push>) \n- [git rebase](<https://delaparra-services.nl/knowledge-hub/git-rebase>) \n- [git remote](<https://delaparra-services.nl/knowledge-hub/git-remote>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/finishing-a-development-branch)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#webpage",
                "url": "https://delaparra-services.nl/skills/finishing-a-development-branch",
                "name": "Finishing a Development Branch | DeLaParra Services",
                "description": "Use when implementation is complete, all tests pass, and you need to decide how to integrate the work",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Finishing a Development Branch"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#skill",
                "url": "https://delaparra-services.nl/skills/finishing-a-development-branch",
                "name": "Finishing a Development Branch",
                "description": "Use when implementation is complete, all tests pass, and you need to decide how to integrate the work",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#dataset",
                "name": "Finishing a Development Branch",
                "description": "Use when implementation is complete, all tests pass, and you need to decide how to integrate the work",
                "url": "https://delaparra-services.nl/skills/finishing-a-development-branch",
                "identifier": "https://delaparra-services.nl/skills/finishing-a-development-branch#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/finishing-a-development-branch#skill"
                },
                "creditText": "obra/superpowers",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-28T15:33:12+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "finishing-a-development-branch-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/finishing-a-development-branch/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T15:33:12+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}