@hopla/claude-setup 1.12.1 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +209 -144
  4. package/agents/system-reviewer.md +13 -0
  5. package/cli.js +301 -399
  6. package/commands/code-review-fix.md +1 -1
  7. package/commands/create-prd.md +1 -1
  8. package/commands/execute.md +27 -8
  9. package/commands/guide.md +14 -8
  10. package/commands/guides/ai-optimized-codebase.md +1 -1
  11. package/commands/guides/mcp-integration.md +3 -3
  12. package/commands/guides/remote-coding.md +3 -3
  13. package/commands/guides/review-checklist.md +5 -5
  14. package/commands/guides/scaling-beyond-engineering.md +6 -9
  15. package/commands/init-project.md +12 -10
  16. package/commands/plan-feature.md +18 -2
  17. package/commands/rca.md +9 -4
  18. package/commands/review-plan.md +2 -2
  19. package/commands/validate.md +2 -2
  20. package/global-rules.md +18 -50
  21. package/hooks/env-protect.js +39 -8
  22. package/hooks/hooks.json +1 -1
  23. package/hooks/session-prime.js +39 -12
  24. package/hooks/tsc-check.js +21 -10
  25. package/package.json +1 -1
  26. package/skills/brainstorm/SKILL.md +7 -2
  27. package/skills/code-review/SKILL.md +4 -2
  28. package/skills/debug/SKILL.md +8 -0
  29. package/skills/execution-report/SKILL.md +2 -2
  30. package/skills/git/commit.md +20 -3
  31. package/skills/git/flow-detection.md +68 -0
  32. package/skills/git/pr.md +46 -16
  33. package/skills/prime/SKILL.md +1 -1
  34. package/skills/subagent-execution/SKILL.md +1 -1
  35. package/skills/tdd/SKILL.md +1 -1
  36. package/skills/verify/SKILL.md +11 -1
  37. package/skills/worktree/SKILL.md +83 -38
  38. package/commands/end-to-end.md +0 -67
  39. package/commands/git-commit.md +0 -76
  40. package/commands/git-pr.md +0 -138
@@ -1,33 +1,44 @@
1
1
  #!/usr/bin/env node
2
- // PostToolUse hook: runs tsc --noEmit after file edits and feeds errors back to Claude
2
+ // PostToolUse hook: runs tsc --noEmit after file edits and feeds errors back to Claude.
3
+ // Prefers the project-local tsc (node_modules/.bin/tsc) over a global install so
4
+ // the hook reports real results even when the user does not have tsc on PATH.
3
5
 
4
6
  import { execSync } from "child_process";
5
7
  import fs from "fs";
6
8
  import path from "path";
7
9
 
10
+ function resolveTscCommand(cwd) {
11
+ const localBin = path.join(cwd, "node_modules", ".bin", "tsc");
12
+ if (fs.existsSync(localBin)) return `"${localBin}"`;
13
+ // Fall back to npx --no-install so we never trigger a network install;
14
+ // if tsc is not available anywhere, npx exits non-zero with a clear error.
15
+ return "npx --no-install tsc";
16
+ }
17
+
8
18
  async function main() {
19
+ // Drain stdin (hook contract) but we don't need the payload for tsc --noEmit
9
20
  const chunks = [];
10
- for await (const chunk of process.stdin) {
11
- chunks.push(chunk);
12
- }
21
+ for await (const chunk of process.stdin) chunks.push(chunk);
13
22
 
14
- // If no tsconfig.json in cwd, exit silently (non-TS project)
15
- const tsconfigPath = path.join(process.cwd(), "tsconfig.json");
23
+ const cwd = process.cwd();
24
+ const tsconfigPath = path.join(cwd, "tsconfig.json");
16
25
  if (!fs.existsSync(tsconfigPath)) {
26
+ // Not a TypeScript project — skip silently
17
27
  process.exit(0);
18
28
  }
19
29
 
20
- let result;
30
+ const tsc = resolveTscCommand(cwd);
31
+
21
32
  try {
22
- execSync("tsc --noEmit", { cwd: process.cwd(), stdio: "pipe" });
23
- // No errors — exit silently
33
+ execSync(`${tsc} --noEmit`, { cwd, stdio: "pipe" });
34
+ // Compile clean — exit silently
24
35
  process.exit(0);
25
36
  } catch (err) {
26
37
  const output = (err.stdout || "").toString() + (err.stderr || "").toString();
27
38
  if (output.trim()) {
28
39
  process.stdout.write("TypeScript errors detected:\n" + output + "\n");
29
40
  }
30
- // Exit 0: PostToolUse hooks cannot block, but stdout is fed back to Claude
41
+ // PostToolUse hooks cannot block; stdout is fed back to Claude
31
42
  process.exit(0);
32
43
  }
33
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hopla/claude-setup",
3
- "version": "1.12.1",
3
+ "version": "1.14.1",
4
4
  "description": "Hopla team agentic coding system for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -72,14 +72,14 @@ Conceptual design details
72
72
  - Anything still unclear
73
73
 
74
74
  ## Next Step
75
- Run `/hopla-plan-feature` to create the implementation plan from this design
75
+ Run `/hopla:plan-feature` to create the implementation plan from this design
76
76
  ```
77
77
 
78
78
  ### Step 6: Review Loop
79
79
  Present the design document for user review.
80
80
  - Accept feedback using the `<? ... >` comment syntax
81
81
  - Iterate until the user approves
82
- - Only then suggest: "Design approved! Ready to create the plan with `/hopla-plan-feature`?"
82
+ - Only then suggest: "Design approved! Ready to create the plan with `/hopla:plan-feature`?"
83
83
 
84
84
  ## Rules
85
85
  - Never skip to planning without design approval
@@ -87,3 +87,8 @@ Present the design document for user review.
87
87
  - Always ground proposals in the existing codebase (not abstract theory)
88
88
  - If the feature is trivial (< 30 minutes of work), skip the full process — just confirm approach and proceed
89
89
  - In planning mode (non-technical users): focus on product decisions, not technical details
90
+
91
+ ## Integration
92
+
93
+ - If the user hasn't defined requirements yet, suggest: "Before brainstorming, consider running `/hopla:create-prd` to define the product requirements. This gives us clearer constraints to design against."
94
+ - If the user is brainstorming a bug fix rather than a new feature, suggest: "This sounds like a bug rather than a new feature. Consider running the `debug` skill for systematic root cause analysis instead."
@@ -37,6 +37,7 @@ For each changed file, look for:
37
37
  - Stale closures — callbacks passed to imperative APIs (grids, charts, maps) that capture stale state instead of using refs or stable references
38
38
  - Unhandled promise rejections — `.then()` without `.catch()`, async calls without `try/catch` in non-void contexts
39
39
  - Side effects inside JSX render — mutations of arrays/objects inside `.map()` in JSX (breaks React strict mode, causes double-execution bugs)
40
+ - Stale dependency arrays — for every new `useState`/`useRef` variable introduced in the diff, verify it appears in the dependency arrays of `useEffect`, `useCallback`, or `useMemo` that reference it. Missing deps cause stale closures — this was the #1 React bug category across 28 implementations
40
41
 
41
42
  **2. Security Issues**
42
43
  - Exposed secrets or API keys
@@ -44,10 +45,11 @@ For each changed file, look for:
44
45
  - Missing input validation on API endpoints — required fields, format constraints (regex, length), payload size limits
45
46
  - Insecure data handling — raw user input in queries, responses exposing internal data or stack traces
46
47
  - XSS vulnerabilities (frontend)
48
+ - Multi-user authorization context — for multi-tenant apps, verify each endpoint filters by the correct context (e.g., active org vs personal org, admin vs viewer). Check that middleware/auth guards match the intended audience for each route
47
49
 
48
50
  **3. Performance Problems**
49
51
  - Unnecessary re-renders (React)
50
- - N+1 queries or redundant API calls
52
+ - N+1 queries — database queries or API calls inside loops (`for`, `.map`, `.forEach`), duplicate existence checks before mutations, sequential operations that could use `Promise.all()` or batch SQL. This was found in 5 of 13 recent implementations
51
53
  - Memory leaks
52
54
 
53
55
  **4. Code Quality**
@@ -94,4 +96,4 @@ If no issues found: "Code review passed. No technical issues detected."
94
96
  ## Next Step
95
97
 
96
98
  After the review, suggest:
97
- > "Code review saved to `.agents/code-reviews/[name].md`. If issues were found, run `/hopla-code-review-fix .agents/code-reviews/[name].md` to fix them. If the review passed clean, proceed to `/hopla-execution-report`."
99
+ > "Code review saved to `.agents/code-reviews/[name].md`. If issues were found, run `/hopla:code-review-fix .agents/code-reviews/[name].md` to fix them. If the review passed clean, proceed to the `execution-report` skill."
@@ -71,3 +71,11 @@ When the bug is fixed, briefly report:
71
71
  - **Fix**: What was changed and why
72
72
  - **Test**: What test verifies the fix
73
73
  - **Prevention**: How to prevent similar bugs (if applicable)
74
+
75
+ ## Escalation
76
+
77
+ If the 3-Strike Rule activates (3 fixes failed), suggest:
78
+ > "This bug may need deeper investigation. Run `/hopla:rca` to produce a structured Root Cause Analysis document with evidence, proposed fix, and prevention steps."
79
+
80
+ If the bug is fixed, suggest:
81
+ > "Bug fixed. Run `/hopla:validate` to verify no regressions, then the `git` skill (say "commit") to save the fix."
@@ -101,7 +101,7 @@ New gotchas, patterns, or conventions learned during this implementation that sh
101
101
 
102
102
  - **Pattern/Gotcha:** [description]
103
103
  - **Where it applies:** [what type of feature or context triggers this]
104
- - **Suggested documentation:** [which file should capture this: CLAUDE.md, `.agents/guides/review-checklist.md`, or a new guide]
104
+ - **Ready-to-paste CLAUDE.md entry:** [Write the EXACT text that should be added to the project's CLAUDE.md to prevent this gotcha in future features. Format it as a bullet point under the appropriate section. If it belongs in a guide instead, write the exact text for the guide. Do not write vague suggestions like "document this" — write the actual content so the system reviewer can apply it directly.]
105
105
 
106
106
  If nothing new was discovered, write "No new patterns discovered."
107
107
 
@@ -115,4 +115,4 @@ Based on this implementation, what should change for next time?
115
115
  ## Next Step
116
116
 
117
117
  After the report is saved, suggest:
118
- > "Execution report saved to `.agents/execution-reports/[name].md`. Run `/hopla-git-commit` to commit your changes."
118
+ > "Execution report saved to `.agents/execution-reports/[name].md`. Run the `git` skill (say "commit") to commit your changes."
@@ -20,7 +20,10 @@ git log --oneline -5
20
20
  - Identify what was added, modified, or deleted
21
21
  - Determine the appropriate commit type: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `style`
22
22
  - Identify the scope if relevant (e.g., `auth`, `api`, `ui`)
23
- - Check current branch confirm it follows Git Flow naming (`feature/`, `fix/`, `hotfix/`, `develop`, `dev`)
23
+ - Resolve branch context using `flow-detection.md` (same directory):
24
+ - Confirm the current branch is NOT a base branch (`main`/`master`/`develop`/`dev`) — if it is, warn the user before committing
25
+ - Confirm the branch prefix matches `feature/`, `fix/`, `hotfix/`, or `release/` — otherwise ask the user
26
+ - Detect whether you are inside a worktree (via `git rev-parse --git-dir` vs `--git-common-dir`) and report the location to the user for context
24
27
 
25
28
  ## Step 3: Stage Files
26
29
 
@@ -42,7 +45,18 @@ Present the proposed commit message to the user **before executing**:
42
45
 
43
46
  Wait for explicit approval before running `git commit`.
44
47
 
45
- ## Step 5: Execute Commit
48
+ ## Step 5: Version Bump (if configured)
49
+
50
+ Before committing, check the project's `CLAUDE.md` for a `## Versioning` section. If it exists:
51
+
52
+ 1. Read the versioning configuration (command, trigger, files)
53
+ 2. Check if the **trigger condition** matches (e.g., specific branches, always, etc.)
54
+ 3. If it matches, run the version bump command
55
+ 4. Stage the version files alongside the other changes
56
+
57
+ If no `## Versioning` section exists in the project's `CLAUDE.md`, skip this step entirely.
58
+
59
+ ## Step 6: Execute Commit
46
60
 
47
61
  Once approved, create the commit:
48
62
 
@@ -50,10 +64,13 @@ Once approved, create the commit:
50
64
  git commit -m "<type>(<scope>): <description>"
51
65
  ```
52
66
 
53
- ## Step 6: Push Reminder
67
+ ## Step 7: Push Reminder
54
68
 
55
69
  After committing, remind the user:
56
70
 
57
71
  > "Commit created locally. Do you want to push to `origin/<branch>`?"
58
72
 
59
73
  **Never push automatically** — wait for explicit confirmation.
74
+
75
+ If the user confirms the push (or if the branch was already pushed), suggest:
76
+ > "Ready to create a Pull Request? Run the `git` skill (say "create PR") to create one."
@@ -0,0 +1,68 @@
1
+ # Git Flow Detection — Shared Reference
2
+
3
+ > Shared by the `git` skill (`commit.md`, `pr.md`), the `worktree` skill, and the `execute` command. Keep the logic here and reference it from callers — do not duplicate.
4
+
5
+ ## Step 1: Detect the branching model
6
+
7
+ ```bash
8
+ git branch -r
9
+ ```
10
+
11
+ Resolve `$DEFAULT_BASE`:
12
+
13
+ - `origin/develop` exists → **Git Flow**, `$DEFAULT_BASE = develop`
14
+ - Else `origin/dev` exists → **Git Flow**, `$DEFAULT_BASE = dev`
15
+ - Else only `origin/main` / `origin/master` → **GitHub Flow**, `$DEFAULT_BASE = main` (or `master`)
16
+
17
+ ## Step 2: Map branch prefix → base branch
18
+
19
+ | Branch prefix | Base (Git Flow) | Base (GitHub Flow) |
20
+ |---|---|---|
21
+ | `feature/*` | `$DEFAULT_BASE` | `main` |
22
+ | `fix/*` | `$DEFAULT_BASE` | `main` |
23
+ | `hotfix/*` | `main` | `main` |
24
+ | `release/*` | `main` | N/A — ask the user |
25
+
26
+ **Edge cases:**
27
+
28
+ - Branch does not match a known prefix → ask the user which base to use
29
+ - Current branch is `main`/`master`/`develop`/`dev` → stop and warn; commits and PRs must come from a feature/fix/hotfix/release branch
30
+ - `hotfix/*` on a Git Flow project but base resolved to `develop` → **refuse** and correct to `main`
31
+
32
+ ## Step 3: Detect worktree context
33
+
34
+ ```bash
35
+ GIT_DIR=$(git rev-parse --git-dir)
36
+ GIT_COMMON_DIR=$(git rev-parse --git-common-dir)
37
+ ```
38
+
39
+ - `GIT_DIR` ≠ `GIT_COMMON_DIR` → you are **inside a worktree**
40
+ - Else you are in the **main repo**
41
+
42
+ List all active worktrees when useful for the user:
43
+
44
+ ```bash
45
+ git worktree list
46
+ ```
47
+
48
+ The main repo path is:
49
+
50
+ ```bash
51
+ MAIN_REPO=$(dirname "$(git rev-parse --git-common-dir)")
52
+ ```
53
+
54
+ ## Step 4: Verify the resolved base exists remotely
55
+
56
+ ```bash
57
+ git show-ref --verify --quiet refs/remotes/origin/$BASE || echo "missing"
58
+ ```
59
+
60
+ If missing, ask the user before proceeding.
61
+
62
+ ## Step 5: Standard warnings
63
+
64
+ Emit these to the user when applicable:
65
+
66
+ - On `main`/`develop`/`dev`: "You're on `$BRANCH` — this is a base branch. Commits and PRs should come from feature branches."
67
+ - Unknown prefix: "Branch `$BRANCH` does not match `feature/`, `fix/`, `hotfix/`, or `release/`. Which base branch should it target?"
68
+ - Hotfix from wrong base: "`hotfix/*` must branch from `main`, not `$DETECTED_BASE`. Refusing to proceed — recreate the branch from `main`."
package/skills/git/pr.md CHANGED
@@ -21,21 +21,16 @@ Read the following if they exist:
21
21
 
22
22
  **If the user specified a base branch**, use it.
23
23
 
24
- **Otherwise, infer from Git Flow branch naming:**
24
+ **Otherwise**, resolve it using `flow-detection.md` (same directory):
25
25
 
26
- | Current branch prefix | Base branch |
27
- |---|---|
28
- | `feature/*` | `develop` or `dev` |
29
- | `fix/*` | `develop` or `dev` |
30
- | `hotfix/*` | `main` |
31
- | `release/*` | `main` |
26
+ 1. Detect the branching model and `$DEFAULT_BASE` (Step 1 of flow-detection.md)
27
+ 2. Map the current branch prefix → base branch (Step 2 of flow-detection.md)
28
+ 3. Verify the resolved base exists remotely (Step 4 of flow-detection.md)
29
+ 4. Apply the standard warnings (Step 5 of flow-detection.md)
32
30
 
33
- To resolve `develop` vs `dev`: run `git branch -r` and look for `origin/develop` or `origin/dev`. Use whichever exists.
31
+ **Always show the resolved base branch in Step 5** so the user can catch mistakes before the PR is created.
34
32
 
35
- **Guard rails:**
36
- - If the current branch is `main`, `master`, `develop`, or `dev` → stop and warn: "You're on `[branch]` — PRs should come from feature branches."
37
- - If the branch name doesn't match any Git Flow prefix → ask the user: "I can't determine the base branch from `[branch]`. Should this PR target `develop` or `main`?"
38
- - **Always show the resolved base branch in Step 5** so the user can catch mistakes before the PR is created.
33
+ Also detect if you are inside a worktree (Step 3 of flow-detection.md) — this is needed for post-merge cleanup in Step 7.
39
34
 
40
35
  ## Step 3: Check Push Status
41
36
 
@@ -94,11 +89,44 @@ After creating, show the PR URL to the user.
94
89
 
95
90
  **Never merge automatically** — the PR is for human review.
96
91
 
92
+ After showing the PR URL, suggest:
93
+ > "PR created. To complete the cycle, run the `execution-report` skill (if not done yet) and `/hopla:system-review` after the PR is merged."
94
+
97
95
  ## Step 7: Post-Merge Cleanup
98
96
 
99
- After the user confirms the PR was approved and merged on GitHub, run the cleanup workflow based on the branch type:
97
+ After the user confirms the PR was approved and merged on GitHub, detect whether the branch lives in a worktree and run the appropriate cleanup.
98
+
99
+ ### Detect worktree
100
+
101
+ Apply Step 3 of `flow-detection.md`:
102
+
103
+ ```bash
104
+ GIT_DIR=$(git rev-parse --git-dir)
105
+ GIT_COMMON_DIR=$(git rev-parse --git-common-dir)
106
+ MAIN_REPO=$(dirname "$GIT_COMMON_DIR")
107
+ ```
108
+
109
+ If `GIT_DIR` ≠ `GIT_COMMON_DIR`, the branch is in a worktree — use **Path A**. Otherwise use **Path B**.
110
+
111
+ ### Path A — Cleanup from a worktree
112
+
113
+ Capture the worktree path before moving out:
114
+
115
+ ```bash
116
+ WORKTREE_PATH=$(git rev-parse --show-toplevel)
117
+ cd "$MAIN_REPO"
118
+
119
+ git checkout [base-branch]
120
+ git pull origin [base-branch]
121
+
122
+ git worktree remove "$WORKTREE_PATH"
123
+ git branch -d [merged-branch]
124
+ git push origin --delete [merged-branch] 2>/dev/null # skip if GitHub already deleted it
125
+ ```
100
126
 
101
- ### For all branch types:
127
+ If `git worktree remove` fails because the tree has uncommitted work, stop and ask the user — do **not** pass `--force` without explicit confirmation.
128
+
129
+ ### Path B — Cleanup from the main repo
102
130
 
103
131
  ```bash
104
132
  git checkout [base-branch]
@@ -107,7 +135,9 @@ git branch -d [merged-branch]
107
135
  git push origin --delete [merged-branch] 2>/dev/null # skip if GitHub already deleted it
108
136
  ```
109
137
 
110
- ### Additional steps for `hotfix/*` and `release/*`:
138
+ **Important:** When `dev` is merged to `main` via PR, do NOT pull `main` back into `dev` — `dev` already has all the commits. Only sync `main` → `dev` for hotfix/release branches (see below).
139
+
140
+ ### Additional steps for `hotfix/*` and `release/*`
111
141
 
112
142
  These branches were merged to `main` but `develop` also needs the changes:
113
143
 
@@ -127,4 +157,4 @@ git push origin v[version]
127
157
 
128
158
  Ask the user for the version number before tagging.
129
159
 
130
- **Always confirm each destructive action** (branch deletion, tag creation) before executing.
160
+ **Always confirm each destructive action** (branch deletion, worktree removal, tag creation) before executing.
@@ -54,7 +54,7 @@ If there are pending plans, list them clearly after the prose summary:
54
54
  ```
55
55
  Pending plans:
56
56
  - inventory-page.draft.md ← draft, not finalized yet
57
- - add-user-authentication.md ← ready to execute with /hopla-execute
57
+ - add-user-authentication.md ← ready to execute with /hopla:execute
58
58
  ```
59
59
 
60
60
  End with a sentence like: "All caught up — what are we working on today?"
@@ -63,7 +63,7 @@ Report your status as DONE, DONE_WITH_CONCERNS, NEEDS_CONTEXT, or BLOCKED.
63
63
  - Commit at phase boundaries (every 3-5 tasks)
64
64
  - Always validate before committing
65
65
 
66
- ## Integration with /hopla-execute
66
+ ## Integration with /hopla:execute
67
67
  This skill is an ALTERNATIVE to inline execution. Suggest it when:
68
68
  - The plan has 5+ tasks
69
69
  - The user expresses concern about quality in long sessions
@@ -44,7 +44,7 @@ description: "Test-driven development workflow using the RED-GREEN-REFACTOR cycl
44
44
  - Boilerplate with no logic
45
45
  - Legacy code without existing test infrastructure
46
46
 
47
- ## Integration with /hopla-execute
47
+ ## Integration with /hopla:execute
48
48
 
49
49
  When executing a plan with TDD:
50
50
  1. For each implementation task that has associated tests:
@@ -55,10 +55,20 @@ When completing a feature (not just a single file edit), run the full validation
55
55
  4. **Level 4**: Integration tests (if applicable)
56
56
  5. **Level 5**: Human review suggestion
57
57
 
58
- Reference `/hopla-validate` for project-specific validation commands.
58
+ Reference `/hopla:validate` for project-specific validation commands.
59
59
 
60
60
  ## Scope
61
61
 
62
62
  - **Applies to**: Any declaration of completion, whether mid-conversation or at end of task
63
63
  - **Does NOT apply to**: Intermediate progress updates ("I've finished editing file X, moving to file Y")
64
64
  - **Partial completion**: You may say "file X is updated" without full validation, but "the feature is complete" requires the full gate
65
+
66
+ ## Plan Execution Check
67
+
68
+ When verifying completion of a plan execution (not just a standalone task):
69
+
70
+ 1. **Divergences documented?** — Ask: "Were there any tasks added, skipped, or changed from the original plan?" If yes, verify they are documented in the completion report.
71
+ 2. **Unplanned files?** — Run `git diff --name-only` and compare against the plan's task list. Flag any files changed that aren't in any task.
72
+ 3. **All acceptance criteria met?** — Read the plan's acceptance criteria and verify each one has fresh evidence.
73
+
74
+ These checks prevent the common pattern where implementation is "done" but divergences are silently omitted from the report.
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  name: worktree
3
- description: "Git worktree management for isolated feature development. Use when starting a new feature that benefits from isolation, when the user says 'worktree', 'isolated branch', 'parallel development', or when implementing multiple features simultaneously. Do NOT use for quick fixes or single-file changes."
3
+ description: "Git worktree management for isolated feature development with Git Flow awareness. Use when starting a new feature that benefits from isolation, when the user says 'worktree', 'isolated branch', 'parallel development', or when implementing multiple features simultaneously. Do NOT use for quick fixes or single-file changes."
4
4
  ---
5
5
 
6
- # Git Worktrees for Isolated Development
6
+ # Git Worktrees Isolated Development with Git Flow
7
7
 
8
- ## What Are Worktrees?
9
- Git worktrees create separate working directories for different branches, sharing the same git history. Each worktree is an independent workspace.
8
+ > 🌐 **Language:** All user-facing output must match the user's language. Code, paths, and commands stay in English.
9
+
10
+ ## What are worktrees?
11
+
12
+ Git worktrees create separate working directories for different branches while sharing the same git history. Each worktree is an independent workspace.
13
+
14
+ ## When to use
10
15
 
11
- ## When to Use
12
16
  - Starting a feature that should be isolated from other work
13
17
  - Developing multiple features in parallel
14
18
  - Needing a clean baseline to test against
@@ -16,58 +20,99 @@ Git worktrees create separate working directories for different branches, sharin
16
20
 
17
21
  ## Setup Process
18
22
 
19
- ### Step 1: Choose Worktree Directory
23
+ ### Step 1: Identify branch type and resolve base branch
24
+
25
+ Ask the user (or infer from context) which type of branch to create:
26
+
27
+ | Prefix | Purpose | Base (Git Flow) | Base (GitHub Flow) |
28
+ |---|---|---|---|
29
+ | `feature/*` | New functionality | `develop` / `dev` | `main` |
30
+ | `fix/*` | Non-urgent bug fix | `develop` / `dev` | `main` |
31
+ | `hotfix/*` | Urgent production fix | `main` | `main` |
32
+ | `release/*` | Release candidate | `main` | N/A — ask user |
33
+
34
+ Use `../git/flow-detection.md` (Steps 1–2) to resolve the base branch from the prefix. Confirm it exists remotely (Step 4).
35
+
36
+ **Guard rails:**
37
+
38
+ - **Refuse** to create a `hotfix/*` worktree from `develop`/`dev`. Hotfixes must come from `main` — correct the base before proceeding.
39
+ - If the prefix is unknown, ask the user which base to use.
40
+ - Always show the resolved base to the user before executing `git worktree add`.
41
+
42
+ ### Step 2: Choose worktree directory
43
+
20
44
  Check in order:
45
+
21
46
  1. Existing `.worktrees/` or `worktrees/` directory
22
- 2. CLAUDE.md preference (if configured)
23
- 3. Ask the user
47
+ 2. `CLAUDE.md` preference (if configured)
48
+ 3. Ask the user (default: `worktrees/<kebab-name>`)
49
+
50
+ ### Step 3: Ensure the worktree directory is gitignored
24
51
 
25
- ### Step 2: Ensure Directory is Gitignored
26
52
  ```bash
27
- # Verify the worktree directory is in .gitignore
28
- grep -q "worktrees" .gitignore || echo "worktrees/" >> .gitignore
53
+ grep -q "^worktrees/" .gitignore 2>/dev/null || echo "worktrees/" >> .gitignore
29
54
  ```
30
55
 
31
- ### Step 3: Create Worktree
56
+ ### Step 4: Create the worktree from the correct base
57
+
58
+ Fetch first so the local base tracks the remote:
59
+
32
60
  ```bash
33
- # Create worktree with a new feature branch
34
- git worktree add worktrees/feature-name -b feature/feature-name
61
+ git fetch origin <base-branch>
62
+ git worktree add worktrees/<name> -b <prefix>/<name> origin/<base-branch>
35
63
  ```
36
64
 
37
- ### Step 4: Setup Project in Worktree
38
- Auto-detect and run setup:
39
- - **Node.js**: `npm install` or `yarn install`
40
- - **Python**: `pip install -r requirements.txt` or `poetry install`
41
- - **Rust**: `cargo build`
42
- - **Go**: `go mod download`
65
+ Examples:
43
66
 
44
- ### Step 5: Verify Clean Baseline
45
67
  ```bash
46
- cd worktrees/feature-name
47
- # Run tests to ensure baseline is green
48
- npm test # or equivalent
68
+ # Feature off develop
69
+ git worktree add worktrees/auth -b feature/auth origin/develop
70
+
71
+ # Hotfix off main
72
+ git worktree add worktrees/crash-fix -b hotfix/crash-fix origin/main
73
+
74
+ # Fix on GitHub Flow project
75
+ git worktree add worktrees/typo -b fix/typo origin/main
49
76
  ```
50
77
 
51
- If tests fail before any changes, STOP and report — the baseline is broken.
78
+ ### Step 5: Install project dependencies (if applicable)
79
+
80
+ Auto-detect from the project root — run only what matches:
81
+
82
+ - `package-lock.json` → `npm install`
83
+ - `yarn.lock` → `yarn install`
84
+ - `pnpm-lock.yaml` → `pnpm install`
85
+ - `requirements.txt` → `pip install -r requirements.txt`
86
+ - `pyproject.toml` with `poetry.lock` → `poetry install`
87
+ - `Cargo.toml` → `cargo build`
88
+ - `go.mod` → `go mod download`
89
+
90
+ If none match, skip.
91
+
92
+ ### Step 6: Verify clean baseline (optional)
93
+
94
+ If `CLAUDE.md` or `package.json` defines a test command, run it once inside the worktree to confirm the baseline is green. If no test command is defined, skip.
52
95
 
53
- ### Step 6: Work in the Worktree
54
- All work for this feature happens in `worktrees/feature-name/`.
96
+ If tests fail **before any changes**, STOP and report — the baseline is broken.
97
+
98
+ ### Step 7: Work in the worktree
99
+
100
+ All work for this branch happens in `worktrees/<name>/`. Use the `git` skill from inside the worktree directory for commits and PRs — it detects the worktree context automatically.
55
101
 
56
102
  ## Cleanup
57
103
 
58
- ### After Merge
59
- ```bash
60
- git worktree remove worktrees/feature-name
61
- git branch -d feature/feature-name
62
- ```
104
+ Post-merge cleanup is handled by the `git` skill — see `../git/pr.md` Step 7. It detects the worktree and runs `git worktree remove` automatically.
105
+
106
+ If the branch is **abandoned** before merge, confirm with the user and then:
63
107
 
64
- ### If Abandoned
65
108
  ```bash
66
- git worktree remove --force worktrees/feature-name
67
- git branch -D feature/feature-name
109
+ cd "$(dirname "$(git rev-parse --git-common-dir)")" # back to main repo
110
+ git worktree remove --force worktrees/<name>
111
+ git branch -D <prefix>/<name>
68
112
  ```
69
113
 
70
114
  ## Integration
71
- - Use with `/hopla-execute` for isolated feature implementation
72
- - Use with `/hopla-git-pr` for creating PRs from the worktree branch
73
- - Combine with parallel dispatch for multiple features simultaneously
115
+
116
+ - Combine with `/hopla:execute` run execution from inside the worktree
117
+ - Combine with the `git` skill commit and PR from inside the worktree; cleanup happens post-merge
118
+ - Combine with parallel dispatch — multiple worktrees active simultaneously
@@ -1,67 +0,0 @@
1
- # End-to-End Feature Implementation
2
-
3
- > Execute the complete PIV loop for a feature in one go: prime → brainstorm → plan → review → execute → validate → commit.
4
-
5
- > ⚠️ **Advanced**: Only use this command after you've proven each individual command works reliably. Build trust gradually.
6
-
7
- ## Input
8
- - `$ARGUMENTS`: Feature description or requirement
9
-
10
- ## Autonomy Levels
11
-
12
- This command represents **Level 3 autonomy**. Make sure you've mastered:
13
- - Level 1: Manual prompts (writing everything each time)
14
- - Level 2: Individual commands (/hopla-plan-feature, /hopla-execute, etc.)
15
- - Level 3: Command chaining (this command)
16
-
17
- ## Process
18
-
19
- ### Phase 1: Context Loading
20
- Load project context:
21
- - Read CLAUDE.md, README, package.json
22
- - Check git state (branch, status, pending plans)
23
- - Identify current development phase
24
-
25
- ### Phase 2: Brainstorm (if needed)
26
- If the feature is non-trivial (estimated > 1 hour):
27
- - Explore 2-3 approaches with trade-offs
28
- - Get user approval on approach
29
- - Save design doc to `.agents/specs/`
30
-
31
- If trivial: skip to Phase 3.
32
-
33
- ### Phase 3: Plan
34
- - Research codebase for related patterns
35
- - Generate structured implementation plan
36
- - Save to `.agents/plans/[feature-name].md`
37
-
38
- ### 🔒 GATE: Plan Review
39
- **STOP and present the plan to the user.**
40
- - Show executive summary
41
- - Wait for explicit approval before proceeding
42
- - If changes requested: iterate on the plan
43
-
44
- ### Phase 4: Execute
45
- - Create feature branch (`feature/[name]` from develop)
46
- - Execute all plan tasks sequentially
47
- - Validate after each phase boundary
48
-
49
- ### Phase 5: Validate
50
- - Run full validation pyramid (lint → types → tests → integration)
51
- - Run code review
52
- - Fix any critical/important issues found
53
-
54
- ### 🔒 GATE: Human Review
55
- **STOP and present results to the user.**
56
- - Show what was built, what was validated
57
- - Wait for approval before committing
58
-
59
- ### Phase 6: Commit & PR
60
- - Create conventional commit(s)
61
- - Suggest creating a PR if on a feature branch
62
-
63
- ## Rules
64
- - Never skip the human gates (plan review, final review)
65
- - If any phase fails, stop and report — don't push through
66
- - Each phase should feel like a natural conversation, not a script
67
- - Adapt: skip brainstorming for small features, skip PR for hotfixes