From software-engineering
Orchestrates git worktree workflow for features: creates isolated worktree/branch from staged changes or issue number, lints/tests/commits, creates MR. Supports --skip flags and modes.
npx claudepluginhub sgaunet/claude-plugins --plugin software-engineering[context | #issue-number] [--skip-branch] [--skip-issue] [--skip-mr] [--squash] [--msg "text"] [--dry-run] [--force] [--worktree-path <path>]# Feature Flow Worktree Command Orchestrate a complete git workflow using **worktrees** for feature development. Creates a parallel working directory instead of switching branches, keeping your current branch untouched. Two modes: 1. **Staged Changes Mode** (default): Analyze staged changes → worktree + branch → create issue → commit (in worktree) 2. **Issue Mode** (`#<number>`): Retrieve issue → worktree + branch → implement → lint → test → verify → commit → merge (all in worktree) Use `feature-flow-w` instead of `feature-flow` when you want to work on multiple features simultaneously w...
/create-worktreeCreates isolated git worktree for GitHub issue or PR number. Switches to existing if present, checks out feature branch from default, optionally copies .env files.
/worktreeManages git worktrees: lists all (default), shows status, reviews changes, merges to main, or discards feature worktrees.
/worktree-startCreates Git worktree for parallel development from branch or new one, auto-prefixes by type (feature/fix/refactor), detects project domain (Next.js/Nuxt/Vite/Python/Go/Rust), adds Claude Code .gitignore safeguards.
Share bugs, ideas, or general feedback.
Orchestrate a complete git workflow using worktrees for feature development. Creates a parallel working directory instead of switching branches, keeping your current branch untouched. Two modes:
#<number>): Retrieve issue → worktree + branch → implement → lint → test → verify → commit → merge (all in worktree)Use feature-flow-w instead of feature-flow when you want to work on multiple features simultaneously without leaving your current branch.
Route based on $argument: first positional argument matching #<number> or bare <number> → Issue Mode; otherwise → Staged Changes Mode.
Issue Mode examples: /feature-flow-w #42, /feature-flow-w 42 --squash
Staged Mode examples: /feature-flow-w, /feature-flow-w add user auth, /feature-flow-w --skip-issue
Before creating any worktree, compute the target path:
--worktree-path <path> (or -w <path>) provided → use that path (resolve to absolute if relative)<repo-parent>/<repo-name>-<sanitized-branch> where / in branch name becomes -
/home/user/my-project, branch feat/add-auth → /home/user/my-project-feat-add-authStore <worktree-path> and <original-path> (result of pwd) for use throughout all phases.
Execute parallel git commands: git status and git diff --staged
Detect Repository Host: Use the detect-repo-host skill to identify the hosting service (GitHub or GitLab) and extract owner/repo details.
Analysis steps:
Analyze staged changes:
feat, test+fixes → fix, docs only → docs, structural → refactor, build/config → choresrc/api/ → api, internal/auth/ → auth)Generate proposed branch name:
<type>/<scope>-<description> (kebab-case, 2-4 words)feat/api-user-profile, fix/auth-jwt-validation, docs/readme-updateError handling:
detect-repo-host skill provides detailed error messagesParse flags: --skip-branch or -b → skip this phase (no worktree created, behaves like original feature-flow).
If not skipped:
git rev-parse --abbrev-ref HEAD<path> with branch <name>?" with options: "Yes, create worktree", "Use different name", "Skip worktree creation"Worktree creation sequence (staged changes transfer):
git diff --staged > /tmp/feature-flow-w-staged-$(date +%s).patchgit reset HEADgit worktree add <path> -b <branch-name>cd <path> && git apply <patch-file> && git add .rm <patch-file>git worktree listError handling:
<path>-v2 or ask for alternativegit worktree remove <path>), re-stage original changes (git stash pop or re-apply patch), display error, suggest manual resolution<name>-v2 or ask for alternative.gitmodules detected → Run git submodule update --init --recursive in new worktreeParse flags: --skip-issue or -i → skip this phase.
If not skipped:
List available labels (same pattern as /create-issue command):
gh label list --repo <owner>/<repo>glab label listGenerate issue content following /create-issue conventions:
feat→enhancement, fix→bug, docs→documentation, etc.), validate against available labelsDisplay preview, ask confirmation: "Create issue with this content?" → "Yes, create issue" / "Skip issue creation"
Create issue if approved:
gh issue create --repo <owner>/<repo> --title "<title>" --body "<body>" --label "<label1>" --label "<label2>"glab issue create --title "<title>" --description "<body>" --label "<label1>" --label "<label2>"Error handling:
gh/glab CLI not installed → Skip issue creation, warn, continue to commitAll git commands execute in worktree directory (if created): prefix with cd <worktree-path> &&.
Generate conventional commit message following /commit command format (see commit.md for full spec):
Refs #<issue-number> or Closes #<N> for fixesDisplay preview, ask confirmation: "Commit with this message?" → "Yes, commit now" / "Edit message" / "Cancel workflow"
Execute: cd <worktree-path> && git commit -m "<message>", verify with cd <worktree-path> && git log -1 --oneline.
Error handling:
Display workflow summary showing:
<worktree-path>cd <worktree-path>cd <original-path>git worktree remove <worktree-path> && git branch -d <branch-name>Detect Repository Host: Use the detect-repo-host skill.
Get current branch: git rev-parse --abbrev-ref HEAD
Fetch issue details:
gh issue view <number> --repo <owner>/<repo> --json title,body,labelsglab issue view <number>Extract: Title (→ branch name, commit, MR title), Body (→ implementation spec), Labels (→ type detection)
Error handling:
gh/glab CLI not installed → Abort: "Cannot retrieve issue. Install gh (GitHub) or glab (GitLab) CLI first."Parse flags: --skip-branch or -b → skip this phase.
If not skipped:
Derive branch type from labels:
| Label contains | Type |
|---|---|
| bug, bugfix, fix | fix |
| enhancement, feature | feat |
| documentation, docs | docs |
| refactor | refactor |
| test | test |
| ci, ci-cd | ci |
| performance | perf |
| (no match) | feat |
Generate branch name: <type>/<scope>-issue-<N> (scope from issue title, kebab-case)
Compute worktree path (see Worktree Path Computation above)
Ask confirmation via AskUserQuestion: "Create worktree at <path> with branch <name>?" → handle response same as Phase 2.
Create worktree: git worktree add <path> -b <branch-name>
If .gitmodules detected: cd <path> && git submodule update --init --recursive
Verify: git worktree list
Error handling:
<path>-v2 or ask for alternative<name>-v2 or ask for alternativeAll file operations target the worktree directory.
Use the run-lint skill with working_directory set to <worktree-path>. If lint fails, ask user whether to continue.
Use the run-tests skill with working_directory set to <worktree-path>. If tests fail, ask user whether to continue.
All commands run in worktree directory.
cd <worktree-path> && git diff --stat summaryAll git commands run in worktree directory.
cd <worktree-path> && git add <files from Phase I-3> (only created/modified files)Closes #<N>cd <worktree-path> && git commit -m "<message>", verify with cd <worktree-path> && git log -1 --onelineError handling: Pre-commit hook fails → abort with recovery steps; commit fails → abort.
On successful commit: Immediately proceed to Phase I-8.
Parse flags: --skip-mr → skip this phase.
Build command: cd <worktree-path> && auto-mr [--squash] [--msg "<message>"]
--squash: if -s flag was passed--msg: default <type>(<scope>): <issue-title> (Closes #<N>), override with user's --msgExecute: Run auto-mr from worktree → on success display MR/PR URL → on failure warn and show manual push instructions.
Display summary showing:
<worktree-path>cd <worktree-path>cd <original-path>git worktree remove <worktree-path> && git branch -d <branch-name>Both modes:
| Flag | Short | Effect |
|---|---|---|
--skip-branch | -b | Skip worktree/branch creation, stay on current branch |
--worktree-path <path> | -w <path> | Override default worktree directory location |
--dry-run | -n | Preview mode: show what would be done without executing |
--force | -f | Skip all confirmation prompts, auto-approve all phases |
Staged changes mode only:
| Flag | Short | Effect |
|---|---|---|
--skip-issue | -i | Skip issue creation |
Issue mode only:
| Flag | Short | Effect |
|---|---|---|
--squash | -s | Pass --squash to auto-mr |
--msg "text" | -m "text" | Custom MR message for auto-mr |
--skip-mr | none | Skip auto-mr phase (I-8) |
Flag parsing: Split $argument by spaces. Tokens starting with -- or - are flags. #<number> or bare <number> as first positional → Issue Mode. Remaining non-flag text → context for branch/commit description. --worktree-path / -w consumes the next token as its value.
Dry run (--dry-run): Executes discovery/retrieval phases, displays all proposed actions (worktree path, branch, issue, commit, implementation plan, lint/test commands), but does NOT execute any mutations. Ends with "Dry run complete. No changes made."
Force mode (--force): Skips all AskUserQuestion calls, auto-approves all phases. Still displays progress and aborts on errors.
feature-flow-w vs feature-flow| Use case | Command |
|---|---|
| Work on multiple features in parallel | feature-flow-w |
| Keep current branch untouched | feature-flow-w |
| Simple single-feature workflow | feature-flow |
| Branch switching is acceptable | feature-flow |
| CI running on current branch, need to start new work | feature-flow-w |
Works with /create-issue (same CLI logic), /commit (same conventional format), and /analyze-pr (compatible output).
# Stage files, create worktree → branch + issue + commit
git add api/user.go api/user_test.go
/feature-flow-w
# Custom worktree location
git add api/user.go
/feature-flow-w --worktree-path ~/worktrees/user-feature
# Skip issue creation for trivial changes
git add docs/README.md
/feature-flow-w --skip-issue
# Preview without executing
git add database/schema.sql
/feature-flow-w --dry-run
# Minimal workflow: commit only (no worktree, no issue)
git add config.yml
/feature-flow-w --skip-branch --skip-issue
# Full workflow from issue (creates worktree)
/feature-flow-w #42
# With squash merge
/feature-flow-w #42 --squash
# Custom worktree path
/feature-flow-w #42 --worktree-path ../my-project-issue-42
# Implement and commit only, no MR
/feature-flow-w #42 --skip-mr
# Auto-approve everything
/feature-flow-w #42 --force --squash
| # | Error | Message / Action |
|---|---|---|
| 1 | No staged changes | "No staged changes found. Stage files with 'git add ' first." |
| 2 | Not a git repository | "Not a git repository. Initialize with 'git init' first." |
| 3 | Branch already exists | Suggest <name>-v2 or ask for alternative |
| 4 | Worktree directory already exists | Suggest <path>-v2 or ask for alternative |
| 5 | Branch checked out in another worktree | Display the other worktree path, ask for different branch name |
| 6 | Patch apply fails | Remove worktree, display error, suggest manual resolution |
| 7 | Pre-commit hook fails | Display hook output, abort, suggest fixing and retrying |
| 8 | gh/glab CLI not found (issue) | Skip issue creation, warn, continue to commit |
| 9 | Invalid labels | Remove invalid labels silently, warn user |
| 10 | Issue creation fails | Log error, continue to commit without issue reference |
| 11 | Commit fails | Display git error, abort |
| 12 | .gitmodules detected | Run git submodule update --init --recursive in new worktree |
| # | Error | Message / Action |
|---|---|---|
| 13 | Issue not found | "Issue #N not found in <owner/repo>." Abort. |
| 14 | gh/glab CLI not found (retrieval) | "Cannot retrieve issue. Install gh or glab CLI first." Abort. |
| 15 | Worktree directory already exists | Suggest <path>-v2 or ask for alternative |
| 16 | Branch checked out in another worktree | Display the other worktree path, ask for different branch name |
| 17 | Lint failure | Display errors, attempt auto-fix, ask user to continue or abort |
| 18 | Test failure | Display output, attempt fix (max 2 retries), ask user |
| 19 | auto-mr not installed | Warn, show manual push: git push -u origin <branch-name> |
| 20 | auto-mr fails | Show error, provide manual push command and MR URL |
| 21 | .gitmodules detected | Run git submodule update --init --recursive in new worktree |
--dry-run first to preview either mode--skip-issue for trivial changes (staged mode)/feature-flow-w add OAuth2 integration--worktree-path when the default path is too long or you prefer a specific location--skip-mr to commit without creating a merge request (issue mode)git worktree remove <path> && git branch -d <branch>git worktree list/feature-flow-w → work in worktree → /commit → /analyze-pr