feat: strengthen git workflow skill guidance

This commit is contained in:
alex
2026-03-11 11:27:40 +00:00
parent f7a1aac68b
commit 11340a36aa

View File

@@ -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/<feature-name> -b <branch-name>
```
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/<workstream-2> -b feat/<workstream-2>
- 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 `<branch-name>` 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 `<branch-name>` 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 <branch-name>`.
- After confirmation, remove the worktree and force-delete the unmerged branch with `git branch -D <branch-name>`; 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 <base-branch>
git merge <branch-name>
git worktree remove .worktrees/<feature-name>
git branch -d <branch-name> # optional cleanup
git branch -d <branch-name> # optional cleanup when fully merged
```
### Completing multiple worktrees (independent PRs):