diff --git a/.config/opencode/skills/git-workflow/SKILL.md b/.config/opencode/skills/git-workflow/SKILL.md index e064125..b7404e5 100644 --- a/.config/opencode/skills/git-workflow/SKILL.md +++ b/.config/opencode/skills/git-workflow/SKILL.md @@ -33,9 +33,17 @@ permalink: opencode-config/skills/git-workflow/skill ### Creating a worktree for a new feature: ```bash # From project root +mkdir -p .worktrees +git check-ignore -q .worktrees || { printf "Add .worktrees/ to .gitignore before continuing.\n"; exit 1; } git worktree add .worktrees/ -b ``` +Before starting feature implementation in the new worktree: +- Verify `.worktrees/` is the project-local location and ignored by git before creating or reusing worktrees. +- Run project-declared setup/config scripts if the worktree needs dependencies or generated files. +- Run a baseline verification (project-declared check/test/lint scripts) to confirm the branch is clean before making changes. +- If baseline verification fails, stop and diagnose the environment or branch state before coding. + ### Creating multiple worktrees for independent workstreams: ```bash # From project root — create all worktrees upfront @@ -48,13 +56,29 @@ git worktree add .worktrees/ -b feat/ - Example: `workdir="/path/to/project/.worktrees/my-feature"` for all bash commands. - **Each coder invocation must target a specific worktree** — never mix worktrees in one coder dispatch. -### Completing a worktree: +### After implementation and tests pass: choose one finish path + +1. **Merge locally** + - Merge `` into your tracked/current base branch, then remove the feature worktree. + - If the branch is fully integrated and no longer needed, delete it. +2. **Push and open PR** + - Push `` and create a PR to the base branch using the GitHub PR procedure below. + - Keep the worktree until review/merge is complete, then remove the worktree and delete the merged branch. +3. **Keep branch/worktree for later** + - Leave branch and worktree in place when work is paused or awaiting input. + - Record the next step and expected resume point so cleanup is not forgotten. +4. **Discard work (destructive)** + - Only for work you explicitly want to throw away. + - Require typed confirmation before running destructive commands: `Type exactly: DISCARD `. + - After confirmation, remove the worktree and force-delete the unmerged branch with `git branch -D `; this cannot be undone from git alone once commits are unreachable. + +### Example local-merge cleanup flow: ```bash -# From main working tree -git checkout main +# From the primary working tree +git checkout git merge git worktree remove .worktrees/ -git branch -d # optional cleanup +git branch -d # optional cleanup when fully merged ``` ### Completing multiple worktrees (independent PRs):