@hopla/claude-setup 1.12.0 → 1.14.0

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.
@@ -29,6 +29,13 @@ Verify that the plan's documented assumptions still hold. **You are not re-audit
29
29
 
30
30
  See `.agents/guides/data-audit.md` for detailed criteria on what to check.
31
31
 
32
+ **Concrete verification:** For each table or API endpoint mentioned in the plan's tasks, run ONE verification command before writing code. Examples:
33
+ - Schema: `grep -n 'CREATE TABLE\|ALTER.*tablename' migrations/*.sql | tail -3`
34
+ - API route: Read the route file and confirm the endpoint signature
35
+ - Component: Read the component and confirm its props interface
36
+
37
+ If ANY assumption from the plan doesn't match current code, file a Blocker Report immediately. Do not proceed with tasks that depend on incorrect assumptions.
38
+
32
39
  If a discrepancy is found, stop immediately and file a Blocker Report below. You may continue with tasks that are not blocked by the discrepancy.
33
40
 
34
41
  #### Blocker Report
@@ -60,10 +67,12 @@ Do not proceed until the working tree is clean.
60
67
 
61
68
  ### Branch check
62
69
 
63
- Check that the current branch follows Git Flow:
64
- - **Never execute on `main` or `master`** — stop and warn the user
65
- - **If on `develop`/`dev`** — ask: "You're on `develop`. Should I create a feature branch first? (recommended: `feature/[plan-name]`)"
70
+ Check the current branch and determine the appropriate action:
66
71
  - **If on a `feature/`, `fix/`, or `hotfix/` branch** — proceed
72
+ - **If on `develop`/`dev`** — ask: "You're on `develop`. Should I create a feature branch first? (recommended: `feature/[plan-name]`)"
73
+ - **If on `main` or `master`** — check if `develop`/`dev` exists:
74
+ - If `develop`/`dev` exists: warn "You're on `main` but `develop` exists. Switch to `develop` first, or create a feature branch from `main` if this is a hotfix."
75
+ - If NO `develop`/`dev` exists (GitHub Flow project): ask "You're on `main` (no develop branch detected). Should I create a feature branch? (recommended: `feature/[plan-name]`)"
67
76
  - **If the plan specifies a base branch** (in `## Git Strategy`) — verify the current branch was created from that base. If not, warn the user:
68
77
  > "The plan specifies base branch `[X]` but the current branch was created from `[Y]`. This may cause the PR to target the wrong branch. Continue anyway?"
69
78
 
@@ -98,6 +107,7 @@ Work through each task in the plan sequentially. For each task:
98
107
  **Git strategy:**
99
108
  - **Plans with 1–7 tasks:** Do not commit after individual tasks. Keep all changes staged but uncommitted until the full plan passes validation (Step 5). This allows a clean revert if later tasks fail.
100
109
  - **Plans with 8+ tasks (or plans with `## Phase Boundaries`):** Commit at each phase boundary defined in the plan. Run Level 1–2 validation (lint + types) before each intermediate commit. Use commit message format: `feat(<scope>): <feature> — phase N of M`. This prevents losing work on large implementations if later phases fail.
110
+ For plans with 8+ tasks, the **first intermediate commit** should happen after the first 3-4 tasks pass validation — do not wait until a full phase boundary if one isn't defined. Losing work on large implementations was a recurring problem when commits were deferred too long.
101
111
 
102
112
  **Pause and report if, during implementation:**
103
113
  - A task is ambiguous or has multiple valid implementations
@@ -107,6 +117,15 @@ Work through each task in the plan sequentially. For each task:
107
117
 
108
118
  Do not improvise silently. When in doubt, stop and ask.
109
119
 
120
+ ### Destructive Command Guard
121
+
122
+ **NEVER** run destructive database or state commands during plan execution:
123
+ - `db:reset`, `db:push --force`, `DROP TABLE`, `DELETE FROM` without WHERE
124
+ - `rm -rf` on data directories
125
+ - `git reset --hard`, `git clean -fd`
126
+
127
+ If a migration fails or data needs to be reset, **stop and report to the user**. The cost of pausing is low; the cost of data loss is catastrophic. This rule exists because a `db:reset` during execution caused complete local data loss in a past implementation.
128
+
110
129
  ### Scope Guard
111
130
 
112
131
  If the user requests changes that are NOT in the plan during execution:
package/commands/guide.md CHANGED
@@ -1,3 +1,9 @@
1
+ ---
2
+ description: 4D Framework guide for non-technical users working with AI coding assistants
3
+ ---
4
+
5
+ > 🌐 **Language:** All user-facing output must match the user's language. Code, paths, and commands stay in English.
6
+
1
7
  # HOPLA Guide for Non-Technical Users
2
8
 
3
9
  > A guided framework for working effectively with your AI coding assistant.
@@ -427,18 +427,20 @@ Create the following directories (with `.gitkeep` where needed):
427
427
 
428
428
  ```
429
429
  .agents/
430
- ├── plans/ <- /hopla-plan-feature saves here (commit these)
431
- ├── guides/ <- on-demand reference guides (commit these)
432
- ├── execution-reports/ <- /hopla-execution-report saves here (do NOT commit)
433
- ├── code-reviews/ <- /hopla-code-review saves here (do NOT commit)
434
- └── system-reviews/ <- /hopla-system-review saves here (do NOT commit)
430
+ ├── plans/ <- /hopla-plan-feature saves here (commit)
431
+ ├── done/ <- /hopla-system-review archives completed plans here (commit)
432
+ │ └── backlog/ <- /hopla-execute Scope Guard defers ideas here (commit)
433
+ ├── specs/ <- brainstorm skill saves design docs here (commit)
434
+ ├── guides/ <- on-demand reference guides (commit)
435
+ ├── rca/ <- /hopla-rca saves root cause analysis docs here (commit)
436
+ ├── execution-reports/ <- /hopla-execution-report saves here (commit — needed for cross-session learning)
437
+ ├── system-reviews/ <- /hopla-system-review saves here (commit — needed for feedback loop)
438
+ └── code-reviews/ <- /hopla-code-review saves here (do NOT commit — ephemeral, consumed by code-review-fix)
435
439
  ```
436
440
 
437
441
  Add to `.gitignore` (create if it doesn't exist):
438
442
  ```
439
- .agents/execution-reports/
440
443
  .agents/code-reviews/
441
- .agents/system-reviews/
442
444
  ```
443
445
 
444
446
  ## Step 7: Create .claude/commands/ (optional but recommended)
@@ -28,6 +28,7 @@ Read the following to understand the project:
28
28
  3. `package.json` or `pyproject.toml` — stack, dependencies, scripts
29
29
  4. `.agents/guides/` — if this directory exists, read any guides relevant to the feature being planned (e.g. `@.agents/guides/api-guide.md` when planning an API endpoint)
30
30
  5. `MEMORY.md` (if it exists at project root or `~/.claude/`) — check for user preferences that affect this feature (UI patterns like modal vs inline, keyboard shortcuts, component conventions)
31
+ 6. `.agents/execution-reports/` — if this directory exists, scan recent reports (last 3-5) for technical patterns discovered and gotchas relevant to the feature being planned. These contain real-world learnings from previous implementations that prevent re-discovering known issues.
31
32
 
32
33
  Then run:
33
34
 
@@ -52,6 +53,15 @@ Use the Grep tool to find relevant files (pattern: relevant keyword, case-insens
52
53
 
53
54
  Read the key files in their entirety — not just the parts that seem relevant.
54
55
 
56
+ ### Assumption verification (required)
57
+
58
+ For each existing table, API endpoint, or component the plan will modify, verify the current state during planning — do not defer to execution:
59
+ - **Database/schema:** Read the most recent migration or schema definition. Confirm column names, types, and constraints match your assumptions.
60
+ - **API endpoints:** Read the actual route handler. Confirm the request/response shape matches your assumptions.
61
+ - **Components:** Read the component file. Confirm props, state, and data flow match your assumptions.
62
+
63
+ Document verified assumptions in the plan's **Context References** with the exact file and line number. This prevents the #1 cause of mid-implementation redesigns: plans that assumed a field name, type, or constraint that didn't match reality.
64
+
55
65
  ### Data audit (required for features that consume existing data)
56
66
 
57
67
  Follow the full checklist in `.agents/guides/data-audit.md`.
@@ -76,6 +86,10 @@ Based on research, define:
76
86
  - **User preferences check:** Before specifying UI architecture (modal vs. inline, page vs. panel, dialog vs. drawer), verify against MEMORY.md and conversation history for established preferences. In past implementations, plans that specified modals were rejected because the user preferred inline panels — this caused rework. When no preference exists, note it as a decision point for the user to confirm.
77
87
  - **Reuse context analysis:** When a new view reuses an existing component in a different context (e.g., a list component in a "history" view vs. an "active" view), the plan MUST list what's different about the new context's requirements: different columns, different data filters, different interactions, different toolbar layout. Missed context differences caused 40%+ of unplanned work in past implementations.
78
88
  - **Multi-phase plan guidance:** For features requiring 3+ phases, create an architectural plan (`backlog/NN-feature.md`) with schema, phase boundaries, and target architecture. When executing each phase, create a standalone plan (`phase-NX-description.md`) with full task-level detail following this template. The architectural plan is the spec; phase plans are the execution instructions. Each phase should have its own feature branch and PR.
89
+ - **API surface enumeration (security/access control plans):** When the plan modifies access control, authorization, or data visibility, enumerate ALL API surfaces that serve the same data — REST endpoints, WebSocket handlers, Durable Object methods, and any other data paths. Each surface must be updated consistently. In past implementations, updating only the WebSocket path while missing the parallel REST endpoint caused a security gap that was only caught by code review. Add a task for each surface, not just the primary one.
90
+ - **Role access matrix:** For features involving multiple user roles or multi-tenant access (admin, member, viewer, buyer, external user), define a matrix: what data does each role see? What endpoints does each role call? What filters apply per role? In past implementations, plans that didn't specify role-level access had authorization bugs discovered only during code review.
91
+ - **External integration buffer:** If the feature integrates an external API or third-party service, budget 2x the estimated time. Document: do we have working test credentials? Is the SDK tested in our runtime (Workers, Node, edge, etc.)? Are there known deprecations or version constraints? External integrations consistently took 2-3x longer than planned in past implementations.
92
+ - **UI iteration budget:** For features with significant UI (new pages, complex forms, interactive grids), note that UI specifications are provisional — expect 30-50% additional work for visual refinement based on user feedback. Specify what "good enough for v1" looks like vs. future polish. This prevents scope creep from being classified as plan failure.
79
93
 
80
94
  ## Phase 5: Generate the Plan
81
95
 
@@ -216,6 +230,8 @@ Before saving the draft, review the plan against these criteria:
216
230
  - [ ] **Time-box on risky tasks:** Any task involving unfamiliar libraries, heuristic parsing, or known-complex behavior (auto-sizing, animation, real-time sync) has a Time-box with a fallback strategy
217
231
  - [ ] **Plan size checked:** If >8 tasks, phase boundaries are defined with intermediate commit points. If >12 tasks, split justification is provided or phases are created.
218
232
  - [ ] **Likely follow-ups listed:** If the Out of Scope section has items, the Likely Follow-ups section is populated with naturally adjacent work the user may request
233
+ - [ ] **API surface enumeration (if security/access plan):** All parallel API surfaces (REST, WebSocket, DO) that serve the same data are listed with a task for each
234
+ - [ ] **N+1 query check:** For every task that writes database queries or API calls, verify: is any call inside a loop? Could it be batched? Are there duplicate existence checks before mutations? N+1 queries were found in 5 of 13 recent implementations.
219
235
 
220
236
  ## Phase 7: Save Draft and Enter Review Loop
221
237
 
package/commands/rca.md CHANGED
@@ -1,6 +1,11 @@
1
- # Root Cause Analysis
1
+ ---
2
+ description: Investigate a bug or issue and produce a structured RCA document
3
+ argument-hint: "<issue-description-or-github-url>"
4
+ ---
5
+
6
+ > 🌐 **Language:** All user-facing output must match the user's language. Code, paths, and commands stay in English.
2
7
 
3
- > Investigate a bug or issue and produce a structured RCA document.
8
+ # Root Cause Analysis
4
9
 
5
10
  > 💡 **Tip**: Use Extended Thinking mode for complex bugs with multiple possible causes.
6
11
 
package/global-rules.md CHANGED
@@ -24,6 +24,7 @@
24
24
  ## 3. Behavior & Autonomy
25
25
 
26
26
  **Always ask before:**
27
+
27
28
  - Running `git commit`
28
29
  - Running `git push`
29
30
  - Installing new dependencies (`npm install <pkg>`, `pip install <pkg>`, etc.)
@@ -31,59 +32,33 @@
31
32
  - Any destructive or hard-to-reverse operation
32
33
 
33
34
  **Proactively suggest commits** at logical save points:
35
+
34
36
  - After completing a feature or fix
35
37
  - Before starting a risky refactor
36
38
  - After passing all validation checks
37
39
  - Explain WHY it's a good moment to commit so the team understands
38
40
 
39
41
  **Never:**
42
+
40
43
  - Auto-commit or auto-push without explicit approval
41
44
  - Skip validation steps to save time
42
45
  - Add features, refactors, or improvements beyond what was asked
43
46
 
44
47
  ---
45
48
 
46
- ## 4. Git Workflow (Git Flow)
47
-
48
- ### Branch Strategy
49
- - `main` → production only, never commit directly
50
- - `develop` / `dev` active development branch
51
- - Feature branches: `feature/short-description`
52
- - Bug fix branches: `fix/short-description`
53
- - Hotfix branches: `hotfix/short-description`
54
-
55
- ### Commit Format — Conventional Commits
56
- ```
57
- <type>(<optional scope>): <short description>
58
-
59
- [optional body]
60
- ```
61
-
62
- **Types:**
63
- - `feat:` — new feature
64
- - `fix:` — bug fix
65
- - `refactor:` — code restructure without behavior change
66
- - `docs:` — documentation only
67
- - `test:` — adding or fixing tests
68
- - `chore:` — build, config, dependencies
69
- - `style:` — formatting, no logic change
70
-
71
- **Examples:**
72
- ```
73
- feat(auth): add JWT token validation
74
- fix(api): handle null response from products endpoint
75
- chore: update dependencies to latest versions
76
- ```
77
-
78
- ### When to Suggest a Commit
79
- Explain in plain language when suggesting a commit, adapting to the user's language, e.g.:
80
- > "This would be a good moment to commit — we finished feature X and all tests pass. Should we commit before continuing?"
49
+ ## 4. Git Workflow
50
+
51
+ Follow **Conventional Commits** (`type(scope): description`). Types: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `style`.
52
+
53
+ Branch strategy (GitHub Flow vs Git Flow) is **auto-detected** by the git skill based on whether `origin/develop` or `origin/dev` exists. See the git skill for full details.
54
+
55
+ When suggesting a commit, explain in plain language why it's a good moment, adapting to the user's language.
81
56
 
82
57
  ---
83
58
 
84
59
  ## 5. Code Quality
85
60
 
86
- - Validate before considering anything done (lint → types → tests)
61
+ - Validate before declaring done (lint → types → tests). The verify skill enforces this at completion.
87
62
  - Write tests alongside implementation, not after
88
63
  - Flag security issues immediately — never leave them for later
89
64
  - If the same validation failure repeats, signal it as a system improvement opportunity
@@ -93,11 +68,13 @@ Explain in plain language when suggesting a commit, adapting to the user's langu
93
68
  ## 📋 Context Management
94
69
 
95
70
  ### Three levels of CLAUDE.md
71
+
96
72
  - **Machine-level** (`~/.claude/CLAUDE.md`): These global rules — apply to all projects
97
73
  - **Project-level** (`CLAUDE.md` at repo root): Shared with team via git — project-specific rules
98
74
  - **Local-level** (`CLAUDE.local.md`): Personal overrides — NOT committed to git
99
75
 
100
76
  ### Context control
77
+
101
78
  - Use `@filename` to include specific files in context (works in chat and inside CLAUDE.md)
102
79
  - Use `/compact` between related tasks (preserves learned knowledge)
103
80
  - Use `/clear` between unrelated tasks (full reset)
@@ -116,19 +93,10 @@ Explain in plain language when suggesting a commit, adapting to the user's langu
116
93
 
117
94
  ---
118
95
 
119
- ## 🛠️ Available HOPLA Commands
96
+ ## 🛠️ HOPLA Skills
97
+
98
+ HOPLA skills are auto-triggered based on context — no slash command needed. The session-prime hook lists available skills at the start of each session.
99
+
120
100
  When a skill applies to your current task, you MUST use it. Check available skills before responding.
121
101
 
122
- ### Workflow: Plan → Implement → Validate
123
- 1. `/hopla-plan-feature` — Research codebase and create implementation plan
124
- 2. `/hopla-review-plan` — Review plan before execution
125
- 3. `/hopla-execute` — Execute plan with validation
126
- 4. `/hopla-validate` — Run full validation pyramid
127
- 5. `/hopla-git-commit` — Create conventional commit
128
- 6. `/hopla-git-pr` — Create GitHub PR
129
-
130
- ### Other commands
131
- - `/hopla-create-prd` — Create or update Product Requirements Document
132
- - `/hopla-init-project` — Initialize project with CLAUDE.md and .agents/ structure
133
- - `/hopla-code-review-fix` — Fix issues from code review report
134
- - `/hopla-system-review` — Analyze plan vs execution for process improvements
102
+ Use the `plan-feature` command to start the full Plan → Implement → Validate workflow.
@@ -13,6 +13,38 @@ function run(cmd) {
13
13
  }
14
14
  }
15
15
 
16
+ function discoverSkills() {
17
+ // Try plugin context first: ../skills/ relative to this script
18
+ const hookDir = import.meta.dirname;
19
+ const skillsDir = path.join(hookDir, "..", "skills");
20
+
21
+ if (!fs.existsSync(skillsDir)) {
22
+ return null;
23
+ }
24
+
25
+ const skills = [];
26
+ for (const entry of fs.readdirSync(skillsDir).sort()) {
27
+ const skillDir = path.join(skillsDir, entry);
28
+ if (!fs.statSync(skillDir).isDirectory()) continue;
29
+
30
+ const skillFile = path.join(skillDir, "SKILL.md");
31
+ if (!fs.existsSync(skillFile)) continue;
32
+
33
+ // Extract description from SKILL.md frontmatter
34
+ const content = fs.readFileSync(skillFile, "utf8");
35
+ const descMatch = content.match(/^description:\s*"?(.+?)"?\s*$/m);
36
+ if (descMatch) {
37
+ // Truncate to first sentence for brevity
38
+ const desc = descMatch[1].split(".")[0];
39
+ skills.push(`- ${entry}: ${desc}`);
40
+ } else {
41
+ skills.push(`- ${entry}`);
42
+ }
43
+ }
44
+
45
+ return skills.length > 0 ? skills : null;
46
+ }
47
+
16
48
  async function main() {
17
49
  const lines = [];
18
50
 
@@ -40,18 +72,13 @@ async function main() {
40
72
  lines.push(`Project rules (CLAUDE.md excerpt):\n${content}`);
41
73
  }
42
74
 
43
- // Available skills reminder
44
- lines.push(`📦 HOPLA Skills Available:
45
- - prime: Project orientation (trigger: "orient", "get context", "load project")
46
- - git: Git operations (trigger: "commit", "PR", "push")
47
- - code-review: Code review (trigger: "review code", "code review")
48
- - execution-report: Post-implementation docs (trigger: "generate report")
49
- - verify: Completion verification (trigger: any "done"/"listo"/"finished" claim)
50
- - brainstorm: Design exploration (trigger: "new feature", "brainstorm", "explore options")
51
- - debug: Systematic debugging (trigger: "bug", "error", "debug")
52
- - tdd: Test-driven development (trigger: implementing with tests)
53
-
54
- ⚠️ If a skill applies to the current task, you MUST use it.`);
75
+ // Auto-discover available skills
76
+ const skills = discoverSkills();
77
+ if (skills) {
78
+ lines.push(`📦 HOPLA Skills Available:\n${skills.join("\n")}\n\n⚠️ If a skill applies to the current task, you MUST use it.`);
79
+ } else {
80
+ lines.push(`📦 HOPLA skills are available. Check your session's skill list for details.\n\n⚠️ If a skill applies to the current task, you MUST use it.`);
81
+ }
55
82
 
56
83
  if (lines.length > 0) {
57
84
  process.stdout.write(lines.join("\n\n"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hopla/claude-setup",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Hopla team agentic coding system for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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**
@@ -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 `/hopla-git-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
 
@@ -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 `/hopla-git-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 `/hopla-execution-report` (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.
@@ -62,3 +62,13 @@ Reference `/hopla-validate` for project-specific validation commands.
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.