@ionivetech/mugiwara 0.1.3 → 0.3.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.
Files changed (83) hide show
  1. package/.opencode/commands/mugiwara-execute.md +11 -0
  2. package/.opencode/commands/mugiwara-heal.md +11 -0
  3. package/.opencode/commands/mugiwara-mode.md +6 -0
  4. package/.opencode/commands/mugiwara-plan.md +11 -0
  5. package/.opencode/commands/mugiwara-review.md +11 -0
  6. package/.opencode/commands/mugiwara-security.md +11 -0
  7. package/.opencode/commands/mugiwara-ship.md +11 -0
  8. package/.opencode/commands/mugiwara.md +11 -0
  9. package/.opencode/plugins/mugiwara.mjs +221 -0
  10. package/README.md +351 -324
  11. package/content/agents/brook-healing.md +8 -2
  12. package/content/agents/chopper-checkpoint.md +9 -4
  13. package/content/agents/eval-runner.md +5 -1
  14. package/content/agents/franky-gates.md +9 -4
  15. package/content/agents/jinbe-security.md +5 -1
  16. package/content/agents/luffy-orchestrator.md +15 -8
  17. package/content/agents/memory-keeper.md +4 -0
  18. package/content/agents/nami-planner.md +12 -5
  19. package/content/agents/resume-coordinator.md +5 -1
  20. package/content/agents/robin-reviewer.md +6 -2
  21. package/content/agents/sanji-quality.md +7 -3
  22. package/content/agents/skeptic-verifier.md +6 -2
  23. package/content/agents/using-mugiwara.md +16 -8
  24. package/content/agents/usopp-brainstorm.md +9 -3
  25. package/content/agents/zoro-execution.md +16 -11
  26. package/content/skills/mugiwara-api-and-interface-design/SKILL.md +87 -0
  27. package/content/skills/mugiwara-backend/SKILL.md +12 -0
  28. package/content/skills/mugiwara-brainstorm/SKILL.md +28 -1
  29. package/content/skills/mugiwara-checkpoint/SKILL.md +8 -6
  30. package/content/skills/mugiwara-context-engineering/SKILL.md +59 -0
  31. package/content/skills/mugiwara-deprecation/SKILL.md +77 -0
  32. package/content/skills/mugiwara-doubt-driven-development/SKILL.md +65 -0
  33. package/content/skills/mugiwara-dynamic-workflow/SKILL.md +3 -3
  34. package/content/skills/mugiwara-execution/SKILL.md +36 -15
  35. package/content/skills/mugiwara-frontend/SKILL.md +58 -56
  36. package/content/skills/mugiwara-frontend/references/checklist.md +37 -0
  37. package/content/skills/mugiwara-gates/SKILL.md +8 -0
  38. package/content/skills/mugiwara-git/SKILL.md +10 -0
  39. package/content/skills/mugiwara-git-worktrees/SKILL.md +62 -0
  40. package/content/skills/mugiwara-healing/SKILL.md +21 -3
  41. package/content/skills/mugiwara-mode/SKILL.md +72 -0
  42. package/content/skills/mugiwara-orchestration/SKILL.md +44 -8
  43. package/content/skills/mugiwara-planning/SKILL.md +57 -34
  44. package/content/skills/mugiwara-pr/SKILL.md +62 -0
  45. package/content/skills/mugiwara-quality/SKILL.md +29 -2
  46. package/content/skills/mugiwara-resume/SKILL.md +6 -4
  47. package/content/skills/mugiwara-security/SKILL.md +38 -1
  48. package/content/skills/mugiwara-ship/SKILL.md +24 -1
  49. package/content/skills/mugiwara-systematic-debugging/SKILL.md +77 -0
  50. package/content/skills/mugiwara-test-driven-development/SKILL.md +84 -0
  51. package/content/skills/mugiwara-testcases/SKILL.md +52 -0
  52. package/content/skills/mugiwara-workflow/SKILL.md +42 -13
  53. package/content/skills/mugiwara-writing-skills/SKILL.md +60 -0
  54. package/dist/mugiwara.js +42 -26
  55. package/docs/adoption-guide.md +72 -0
  56. package/docs/agent-anatomy.md +72 -0
  57. package/docs/agents.md +51 -0
  58. package/docs/claude-setup.md +43 -0
  59. package/docs/codex-setup.md +26 -0
  60. package/docs/comparison.md +63 -0
  61. package/docs/config.md +50 -0
  62. package/docs/copilot-setup.md +29 -0
  63. package/docs/cursor-setup.md +25 -0
  64. package/docs/developer-onboarding.md +85 -0
  65. package/docs/execution-model.md +92 -0
  66. package/docs/gemini-setup.md +27 -0
  67. package/docs/getting-started.md +96 -0
  68. package/docs/git-strategy.md +62 -0
  69. package/docs/index.md +50 -0
  70. package/docs/modes.md +74 -0
  71. package/docs/opencode-setup.md +54 -0
  72. package/docs/pr-summary.md +54 -0
  73. package/docs/rule-based-setup.md +31 -0
  74. package/docs/skill-anatomy.md +78 -0
  75. package/docs/skills.md +73 -0
  76. package/docs/windsurf-setup.md +18 -0
  77. package/docs/workflow.md +80 -0
  78. package/hooks/hooks.json +15 -0
  79. package/hooks/session-start.ts +8 -0
  80. package/package.json +20 -2
  81. package/src/targets/claude.ts +18 -1
  82. package/src/targets/codex.ts +1 -1
  83. package/src/targets/gemini.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-frontend
3
- description: Use for any frontend implementation or redesign task - converting Figma/images to code or restyling UI. Match the repo's existing standard first, audit-first for redesigns, design-system extraction before markup, taste and a11y baked in, bans generic AI-slop patterns and rationalizations. Framework-agnostic.
3
+ description: Use for any frontend implementation or redesign task - converting Figma/images to code or restyling UI. Match the repo's existing standard first, audit-first for redesigns, design-system extraction before markup, component architecture, state management, responsive behavior, and WCAG 2.1 AA baked in; bans generic AI-slop patterns and rationalizations. Framework-agnostic.
4
4
  ---
5
5
 
6
6
  # Frontend (Anti-Slop)
@@ -9,38 +9,53 @@ Interfaces built under this skill must not look templated.
9
9
 
10
10
  ## Existing repo standard first
11
11
 
12
- When the repo already has frontend, learn and follow ITS standard before writing anything new; match its components and patterns before creating anything. Greenfield with no existing UI: skip to the design-system extraction below.
13
-
14
- - Component library (MUI/Tailwind/shadcn/etc) a new button must look like the repo's buttons, not the internet's.
15
- - File conventions, naming, folder structure, CSS strategy.
16
- - Lint, format, and test scripts; run them, match their style.
17
- - Design tokens already in the theme/config: palette, type, spacing, radii, shadows.
18
- - Existing page patterns: how pages compose sections, layout, and state.
12
+ Match the repo's standard before writing anything new; reuse its components and patterns. Greenfield with no UI: skip to design-system extraction.
13
+ - Component library (MUI/Tailwind/shadcn/etc) — a new button looks like the repo's buttons, not the internet's.
14
+ - File conventions, naming, folder structure, CSS strategy; lint/format/test scripts.
15
+ - Tokens already in the theme/config; existing page patterns — how pages compose sections and state.
19
16
 
20
17
  ## Redesigns: audit first
21
18
 
22
- Before changing existing UI: capture current layout, spacing scale, type scale, palette, and component inventory. Fix real problems; do not restyle what works.
19
+ Capture current layout, spacing/type scales, palette, and component inventory before changing existing UI. Fix real problems; do not restyle what works.
23
20
 
24
21
  ## Design-system extraction (before markup)
25
22
 
26
- Read tokens from the stack's design system BEFORE writing markup — CSS variables, Tailwind config, theme file, or the reference's specs. Extract: spacing scale, type scale (sizes/weights/line-heights), palette with roles, radii, shadows, motion language. Name tokens semantically (not `c3`, `font-large` — `surface-muted`, `display-weight`); store them where the stack keeps design tokens. No tokens extracted, no markup written.
23
+ Extract tokens from the stack's design system BEFORE markup — spacing scale, type scale, role-based palette, radii, shadows, motion language. Name them semantically (`surface-muted`, not `c3`); store where the stack keeps tokens. No tokens extracted, no markup written. Then turn tokens into a small primitive set (button, input, card, icon, layout helpers) before composing screens — reuse primitives everywhere; every bespoke component is debt on every screen.
24
+
25
+ ## Component architecture
26
+
27
+ Compose, don't inherit. Small, single-purpose components; the tree mirrors the page, not a god-component.
28
+ - Boundaries: one component = one responsibility; extract on reuse; leaves stay presentational (no data fetching).
29
+ - Composition over configuration: children/slots beat dozens of props.
30
+ - Props: primitives and plain callbacks over object-shaped flags; 3+ boolean props = split the component.
31
+ - Naming by role (`ProductCard`, not `CardA`); variants over copy-paste.
32
+
33
+ ## State management
34
+
35
+ Minimal state, local first; lift only what is shared.
36
+ - Server vs client state: never store a per-screen copy of API data; cache/refetch at a data layer; derive on render.
37
+ - Single source of truth per state; no duplicate mirrors.
38
+ - Lift only when siblings share; context/store for app-wide state, not one screen.
39
+ - Loading, error, empty, success states designed, not an afterthought.
27
40
 
28
41
  ## From Figma / image references
29
42
 
30
- 1. Extract tokens FIRST (see above), then reproduce structure faithfully: hierarchy, alignment, whitespace ratios. Do not "improve" the layout unasked.
31
- 2. New one-off components still follow the design system — a one-off is not a license to invent a second system.
43
+ Extract tokens first, then reproduce structure faithfully: hierarchy, alignment, whitespace ratios. Do not "improve" the layout unasked. One-off components still follow the design system — a one-off is not a license for a second system.
32
44
 
33
45
  ## Taste: positive design judgment
34
46
 
35
- Beyond banning slop, build with intent:
36
-
37
- - Hierarchy and rhythm: one primary action per view, one clear focal point, consistent spacing rhythm.
47
+ - Hierarchy and rhythm: one primary action per view, one focal point, consistent spacing.
38
48
  - Restraint: fewer, more considered elements; whitespace is a tool.
39
- - Typography discipline: 1-2 typefaces, deliberate scale, weight for emphasis not decoration, line length 45-75ch.
40
- - Color discipline: palette with roles (surface/text/action/state), contrast AA minimum, never pure-black-on-pure-white for text-heavy surfaces.
49
+ - Typography: 1-2 typefaces, deliberate scale, weight for emphasis not decoration, 45-75ch lines.
50
+ - Color: role-based palette, contrast AA minimum, never pure-black-on-pure-white for text-heavy surfaces.
41
51
  - Consistency: the same thing looks the same everywhere; no three ways to render a button.
42
- - Intentionality: every element earns its place; if you cannot say why it is there, remove it.
43
- - State design: hover, focus, active, disabled, loading, error, and empty states designed, not forgotten.
52
+ - Intentionality: every element earns its place; if you cannot say why, remove it.
53
+ - State design: hover, focus, active, disabled, loading, error, empty designed, not forgotten.
54
+ - Craft: deliberate spacing grids; subtle motion respecting `prefers-reduced-motion`; verified at mobile/tablet/desktop.
55
+
56
+ ## Responsive behavior
57
+
58
+ Mobile-first: start at the smallest screen, add breakpoints as layout needs them. Default full-width stacked; columns only when there is room. Use the stack's breakpoints, not a parallel scale; fluid containers, type, and spacing. Verify at every breakpoint, including between them — 3 widths checked is not 12 checked.
44
59
 
45
60
  ## Banned AI-default patterns (the slop list)
46
61
 
@@ -52,71 +67,58 @@ Beyond banning slop, build with intent:
52
67
 
53
68
  If the brief genuinely calls for one of these, execute it well — but the default is: don't.
54
69
 
55
- ## Craft bar
56
-
57
- - Typography: deliberate scale, weight contrast, line-length control.
58
- - Spacing: consistent scale, breathing room, aligned grids.
59
- - Motion: subtle and purposeful (hover/scroll states), respects `prefers-reduced-motion`.
60
- - Responsive: every layout verified at mobile/tablet/desktop breakpoints.
61
- - A11y baseline: semantic landmarks, contrast AA, visible focus states, alt text.
70
+ ## WCAG 2.1 AA accessibility
62
71
 
63
- ## Accessibility (non-negotiable)
72
+ Non-negotiable baseline. Full checklist: `references/checklist.md`.
64
73
 
65
- - Semantic landmarks (header/nav/main/footer), a single h1, logical heading order.
66
- - Contrast AA: 4.5:1 text, 3:1 large text/UI.
67
- - Focus: visible focus ring, logical tab order, skip-link, no focus trap without an escape.
68
- - Keyboard: every interaction operable without a mouse; nothing reachable only via hover.
69
- - Forms: every input labeled (placeholder is not a label); errors and success announced; `aria-describedby` for help text; validation never color-only.
70
- - ARIA: native elements before ARIA; `aria-live` for dynamic updates; roles honest.
71
- - Images: alt text (empty `alt=""` for decorative), never `alt="image"`.
72
- - `prefers-reduced-motion` respected.
73
- - Touch targets at least 44px.
74
+ - Keyboard: every interaction operable by keyboard alone; logical tab order; visible focus; no focus trap without escape.
75
+ - Semantics: native elements over ARIA; landmarks; logical heading order; buttons for actions, links for navigation.
76
+ - Contrast: 4.5:1 text, 3:1 large text/UI; never color-only meaning.
77
+ - Forms: every input labeled (placeholder is not a label); errors/success announced; `aria-describedby` help.
78
+ - Dynamic content: `aria-live` for changes; reduced-motion respected.
74
79
 
75
- ## Testability
80
+ ## Testability and verification
76
81
 
77
- Add stable `data-testid` attributes to interactive elements, following the repo's testing convention (getByRole/getByTestId). Never test by CSS class or by text that changes.
82
+ Add stable `data-testid` to interactive elements per the repo's testing convention. Never test by CSS class or by text that changes. Then compare the result against the reference side by side; list remaining deltas before calling it done.
78
83
 
79
84
  ## Performance
80
85
 
81
- - No layout thrash: batch DOM reads and writes.
82
- - No jank: keep heavy work off the scroll path; animate only transform/opacity.
83
- - Assets: no giant images or font payloads; lazy-load below the fold; no whole icon library for two icons.
86
+ - No layout thrash: batch DOM reads/writes; heavy work off the scroll path; animate only transform/opacity.
87
+ - Assets: no giant images/font payloads; lazy-load below the fold; no whole icon library for two icons.
84
88
  - No re-render storms: memoize heavy computation, stable keys, no work in render.
85
89
  - Measure before optimizing; do not guess the bottleneck.
86
90
 
87
91
  ## Frontend security
88
92
 
89
93
  - Never render user content via `dangerouslySetInnerHTML`/`v-html` unless sanitized.
90
- - Escape user input in every template; no injection through the client.
91
- - No secrets in client code API keys and tokens in the client are public.
92
- - Validate/sanitize anything from URL params, storage, or APIs before use.
93
- - `rel="noopener"` on `target="_blank"` links; validate URLs before navigating.
94
-
95
- ## Verify
96
-
97
- Compare the result against the reference side by side; list remaining deltas before calling it done. Not done while deltas are unlisted or unresolved.
94
+ - Escape user input in every template; no secrets in client code.
95
+ - Validate anything from URL params, storage, or APIs before use.
96
+ - `rel="noopener"` on `target="_blank"`; validate URLs before navigating.
98
97
 
99
98
  ## Red flags
100
99
 
101
- - "I'll match the repo later" — the repo standard is the first step, not a cleanup.
102
- - "It's accessible enough" — a11y is a checklist; unchecked boxes are not done.
100
+ - "I'll match the repo later" — the repo standard is the first step, not cleanup.
101
+ - "It's accessible enough" — the a11y checklist is all-or-nothing.
103
102
  - "Tests can find it" — no data-testid means the UI is not testable.
104
103
  - "Optimize when it's slow" — perf regressions ship measured later, rarely.
105
104
  - "It's client-side, so no security review" — the client is public by definition.
105
+ - "New screen, new components" — primitives are the default; bespoke is the exception.
106
+ - "Global store for everything" — local state first; lift only what is shared.
106
107
 
107
108
  ## Common Rationalizations
108
109
 
109
110
  | Excuse | Reality |
110
111
  |--------|---------|
111
- | "The brief calls for a hero trio." | A brief calling for slop is a constraint, not a license — the default stays don't; execute well only if the design truly demands it. |
112
- | "It's just a landing page." | Still verified for responsive and a11y — a small page is not exempt. |
112
+ | "The brief calls for a hero trio." | A brief calling for slop is a constraint, not a license — the default stays don't. |
113
+ | "It's just a landing page." | Still verified for responsive and a11y — small is not exempt. |
113
114
  | "It's a one-off component." | A one-off still follows the design system's tokens and patterns. |
114
- | "Good enough." | Not done until compared against the reference with remaining deltas listed. |
115
+ | "Good enough." | Not done until compared against the reference with deltas listed. |
115
116
  | "It looks right." | Verified at every breakpoint or it is not verified. |
116
117
  | "Everyone ships this card row." | Popularity is not design; if it's on the slop list, it stays banned. |
117
118
  | "Tokens later." | Tokens extracted before markup, or the layout gets rebuilt. |
118
- | "Our repo is messy, I'll use my own style." | You match the repo standard first, then you may propose raising it. |
119
- | "It's accessible enough." | The a11y checklist is all-or-nothing; unchecked boxes are not done. |
119
+ | "Our repo is messy, I'll use my own style." | Match the repo standard first, then propose raising it. |
120
120
  | "The user won't use a keyboard." | Every interaction must be keyboard-operable; "users won't" is not a design decision. |
121
+ | "Context for everything." | Server state belongs at a data layer, not a global store. |
122
+ | "It's a quick prop, no new component." | 3+ boolean props is the boundary — split the component. |
121
123
 
122
124
  If the rationalization wins, name it in the report as a known delta — not as silence.
@@ -0,0 +1,37 @@
1
+ # WCAG 2.1 AA Frontend Checklist
2
+
3
+ Run before calling a view done. Every box must check; unchecked boxes are not done.
4
+
5
+ ## Perceivable
6
+
7
+ - [ ] Text contrast 4.5:1; large text (18pt/24px or 14pt/18.66px bold) and UI components/graphics 3:1.
8
+ - [ ] No pure-black-on-pure-white text-heavy surfaces; text over images has a scrim or offset.
9
+ - [ ] `alt` on every image (empty `alt=""` when decorative; never `alt="image"`).
10
+ - [ ] No information conveyed by color alone; add icon/text/pattern.
11
+ - [ ] Captions/alternatives for media; no autoplaying audio without controls.
12
+
13
+ ## Operable
14
+
15
+ - [ ] Full keyboard operation: every interactive element reachable and operable with Tab/Enter/Space/arrows.
16
+ - [ ] Visible focus indicator at every focus point (never `outline: none`).
17
+ - [ ] Logical tab order matching visual order; skip-link to main content on repeated navigation.
18
+ - [ ] No focus trap without an escape (Esc or a focusable close); focus returns after modals close.
19
+ - [ ] Touch targets at least 44x44px; target spacing where 44px is not possible.
20
+ - [ ] No flashing more than 3 times/second.
21
+
22
+ ## Understandable
23
+
24
+ - [ ] Page has a `<title>` and a language attribute.
25
+ - [ ] Single `h1`; heading levels do not skip (h1→h3 without h2 is a defect).
26
+ - [ ] Every input has a programmatic label; placeholder alone is not a label.
27
+ - [ ] Form errors and success announced (via `aria-live`/`role="alert"`); help text via `aria-describedby`.
28
+ - [ ] Validation never color-only; `aria-invalid` marks errors.
29
+ - [ ] Navigation/meaning is not tied to hover-only or transient state.
30
+
31
+ ## Robust
32
+
33
+ - [ ] Native HTML elements first; ARIA only where native semantics cannot express the widget.
34
+ - [ ] Honest roles; no `role="button"` on a link, no empty labels on interactive elements.
35
+ - [ ] Dynamic updates announced via `aria-live` with appropriate `polite`/`assertive`.
36
+ - [ ] `prefers-reduced-motion` respected; motion scales, never disables content.
37
+ - [ ] No interaction reachable only by mouse; nothing requires drag to operate.
@@ -13,10 +13,18 @@ Gates are binary: pass or fail, with evidence. No negotiation.
13
13
  2. Thresholds: NEW files >= 90%, MODIFIED files >= 80%. Identify new/modified via git diff against the mission's base.
14
14
  3. No coverage tooling exists → the gate CANNOT pass silently: report the gap, propose the minimal tooling addition, ask the user to add it or waive the gate explicitly. Record their decision.
15
15
 
16
+ ## User-AC coverage override (per `mugiwara-testcases`)
17
+
18
+ When user acceptance criteria are declared, the coverage thresholds (90/80) apply only to unit-level new/modified code; the user-AC verdict governs ship-readiness. An e2e user suite that adds ~0% coverage is not a gate failure. The user-AC verdict must come from the quality wave evidence — user suites actually run — never asserted.
19
+
16
20
  ## Build gate
17
21
 
18
22
  Run the project's build (or typecheck for interpreted stacks). Must exit 0. Capture the tail of output.
19
23
 
24
+ ## Optional e2e gate (per `mugiwara-quality`)
25
+
26
+ Position: after quality checks, before the final gates below. Optional — it runs only when the quality wave triggered it (repo e2e setup AND changed-file e2e patterns, with consent by mode). Its outcome is recorded with evidence but never blocks PASS: a skipped or unrun e2e gate is logged, not a failure. The final verdict is still coverage + build + DoD.
27
+
20
28
  ## Definition of Done standing gate
21
29
 
22
30
  A fixed cross-project bar, distinct from per-task acceptance criteria. Verdict PASS only when all hold:
@@ -39,6 +39,16 @@ Git hygiene keeps the mission reversible: one logical change per commit, a save-
39
39
  2. Copy the observed conventions: prefix style (`feat:`/`fix:` vs plain), subject case, body usage, subject length.
40
40
  3. No commits in the repo yet → adopt conventional commits and note it in the plan.
41
41
 
42
+ ## Branch naming
43
+
44
+ The mission branch pattern comes from the config `branch` key (default `feature/{type}-{issue}-{slug}`): `{type}` = feat/fix/chore/refactor from the task, `{issue}` = ticket/key ref (fallback: date), `{slug}` = kebab-case mission title (e.g. `feature/ABC-123-dark-mode`). One branch per mission, created before the first task commit; never force-push it once pushed. No mugiwara-prefixed branch names.
45
+
46
+ ## Worktrees — isolated workspaces
47
+
48
+ 1. For risky or parallel work, prefer a worktree over the shared working tree: `git worktree add ../<name> <branch>` gives an isolated checkout and lets you return to the main one without stashing.
49
+ 2. One worktree per mission/branch; two tasks never share a worktree.
50
+ 3. Remove when done: `git worktree remove ../<name>` (after the branch is merged or abandoned).
51
+
42
52
  ## Debugging via history
43
53
 
44
54
  1. `git bisect start`, then `git bisect bad <current>` and `git bisect good <known-good>` to find the regression commit. Log the bad commit range in the result.
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: mugiwara-git-worktrees
3
+ description: Use when running parallel branch work, keeping the main workspace clean, or reviewing a branch without switching. Isolated worktrees via git worktree add, branch hygiene, and safe cleanup.
4
+ ---
5
+
6
+ # Git Worktrees — Isolated Parallel Branches
7
+
8
+ Worktrees give each branch its own checkout, so parallel missions, reviews, and experiments never fight over one working tree. Companion to mugiwara-git, not a replacement for commit discipline.
9
+
10
+ ## When to use
11
+
12
+ - Parallel independent tasks on separate branches that must progress without blocking each other.
13
+ - Keeping the main workspace clean: main checkout stays untouched while risky work lives in a worktree.
14
+ - Reviewing or verifying a branch without switching: open it in a worktree, inspect, discard.
15
+ - Any task so risky you want it physically separate from the current tree.
16
+
17
+ Prefer a worktree over `git stash` juggling — each branch gets a real checkout, not a rescue from the reflog.
18
+
19
+ ## Process
20
+
21
+ 1. Create the worktree bound to a new branch:
22
+ `git worktree add -b <branch> <path>` (e.g. `git worktree add -b feature/ABC-123-dark-mode ../dark-mode`).
23
+ 2. Work entirely inside `<path>`: edit, commit, push there. Treat it as the only home of that branch.
24
+ 3. Do not touch that branch from the main checkout, and vice versa. Two tasks never share one worktree.
25
+ 4. Verify the work before it leaves the worktree: run the branch's checks and tests inside `<path>`.
26
+ 5. Merge or rebase back into the main branch from the main checkout; push when done.
27
+ 6. Clean up once the branch is merged or abandoned:
28
+ - `git worktree remove <path>` (add `--force` only if it has uncommitted changes you accept losing).
29
+ - `git worktree prune` to drop stale bookkeeping for worktrees removed outside git's book.
30
+ 7. Check nothing is left behind: `git worktree list` should show only your active checkouts.
31
+
32
+ ## Cleanup safety
33
+
34
+ - Remove only worktrees you created. Host-owned worktrees — ones the repo or another agent set up — are not yours to delete; leave them.
35
+ - Never remove a worktree that still has unmerged commits unless you have deliberately abandoned that branch.
36
+ - Remove the worktree, not the branch directory with `rm -rf`; bypassing git leaves stale metadata that `prune` then has to guess about.
37
+ - A worktree without a branch (`--detach`) is throwaway: verify, then remove with no branch to worry about.
38
+
39
+ ## Rationalizations
40
+
41
+ | Rationalization | Why it fails |
42
+ | --- | --- |
43
+ | "I'll just switch branches, it's faster." | Uncommitted changes block checkout; one mistake mixes work from two tasks. |
44
+ | "I can work on both branches in one checkout." | Stash conflicts and forgotten checkouts lose or misattribute work. |
45
+ | "Removing a worktree is the same as deleting a folder." | `rm -rf` leaves git's worktree bookkeeping stale; `git worktree remove` stays consistent. |
46
+ | "Their worktree looks abandoned, I'll clean it up." | Host-owned state. If it looks dead, report it, never remove it. |
47
+
48
+ ## Red flags
49
+
50
+ - A worktree path inside the repo's own directory tree — nested worktrees are confusing and error-prone.
51
+ - Deleting or force-removing a worktree whose branch has unpushed commits.
52
+ - The same branch checked out in two worktrees, or two tasks sharing one worktree.
53
+ - Touching or re-checking-out a host-owned worktree.
54
+
55
+ All mean: stop, verify branch state, and clean up only what belongs to your task.
56
+
57
+ ## Verification
58
+
59
+ 1. `git worktree list` shows exactly the checkouts you expect — yours, none stale.
60
+ 2. After cleanup, the worktree path is gone and `git worktree prune` reports nothing to prune.
61
+ 3. The main checkout shows no leftover files, locks, or artifacts from the removed worktree.
62
+ 4. The removed branch's commits are either merged into main or deliberately abandoned — never stranded.
@@ -17,12 +17,17 @@ Brook's inputs: `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md` rows + quali
17
17
  2. Reproduce: re-run the failure, confirm it is real and current.
18
18
  3. Localize: layer map of where it sits (config/test/code/env); use `git bisect` when a regression window is unclear.
19
19
  4. Reduce: shrink to the minimal case that still fails.
20
- 5. Fix the ROOT cause grep all callers before patching; never patch only the symptom path.
21
- 6. Guard with a regression test that fails without the fix.
22
- 7. Verify end-to-end: run the failed check, capture output.
20
+ 5. Diagnose before you touch code. Read the error in full (line, file, code), ask what changed recently (`git diff`, new deps, config), and chase the bad value upstream to its origin. Grep every caller before patching a fix aimed only at the visible symptom leaves its siblings broken.
21
+ 6. Test one theory at a time. State it, try the smallest change that could confirm it, and check. A failed theory → a new one; never pile a second fix on top of the first.
22
+ 7. Guard with a regression test that fails without the fix.
23
+ 8. Verify end-to-end: run the failed check, capture output.
23
24
 
24
25
  Never push past a failing test — a red test stops the line until it is green or escalated.
25
26
 
27
+ ## When fixes keep failing → question the foundation
28
+
29
+ Two or three different fixes that each uncover a fresh dependency somewhere else are a signal you're patching a symptom. The foundation, not the failure, is wrong. Stop, lay out the pattern to Luffy and the human, and argue about the architecture before attempting another fix.
30
+
26
31
  ## Prove-It pattern
27
32
 
28
33
  Before fixing a bug: write the failing test that reproduces it, watch it fail, then fix until green. Red → code → green, in that order. A fix with no reproducing test is unproven.
@@ -45,6 +50,18 @@ Before fixing a bug: write the failing test that reproduces it, watch it fail, t
45
50
  4. After healing: update the ledger — mark each healed row with evidence; keep unfixed rows for escalation.
46
51
  5. Cycle counter: after this wave the flow returns to Wave 4 (Chopper) for re-audit. Same failure surviving 3 heal cycles → stop, escalate with full history.
47
52
 
53
+ ## Worker subagents
54
+
55
+ Brook runs inline; the only dispatches are disposable WORKER subagents for genuinely parallel work. Three named workers:
56
+
57
+ - **reviewer-worker** — adversarial diff review of Brook's fixes from a fresh context (per `mugiwara-review`).
58
+ - **security-worker** — security pass over the fixes (per `mugiwara-security`).
59
+ - **re-run-check worker** — independently re-runs the failed checks and returns raw evidence (command output, exit codes), so the re-verify is not Brook re-confirming its own fix.
60
+
61
+ Flow: Brook aggregates worker findings → applies minimal root-cause fixes (triage matrix + Rules above) → dispatches a re-run-check worker to re-verify.
62
+
63
+ Workers are NOT crew members — disposable subagents, one narrow job, results return as a report. The crew itself always runs inline in the main thread, never Task-dispatched.
64
+
48
65
  ## Output
49
66
 
50
67
  Fixed list (finding → commit → evidence), escalated list (finding → plan → owner), updated ledger → back to Wave 4 (Chopper).
@@ -58,5 +75,6 @@ Fixed list (finding → commit → evidence), escalated list (finding → plan
58
75
  - A code failure marked `env` to close the ledger.
59
76
  - A ledger row processed with no evidence recorded.
60
77
  - The same failure healing past 3 cycles without escalation.
78
+ - Several failed fixes on one failure without taking the architecture question to Luffy.
61
79
 
62
80
  All mean: the fix is not real. Stop, find the root cause, or escalate with full history.
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: mugiwara-mode
3
+ description: Use when reading or changing the runtime mode (guided / semi / auto) from .mugiwara/config or ~/.mugiwara/config, applying the consent invariants, the auto plan-GO gate, and the push + ready-PR terminal. Single source of truth for the mode contract.
4
+ ---
5
+
6
+ # Mode (guided / semi / auto)
7
+
8
+ The crew's autonomy level. Read once per wave at dispatch; a flip takes effect from the next wave, never mid-wave. Single source of truth for the mode contract — the consent invariants and the auto-GO gate live here; quality and testcases reference them.
9
+
10
+ ## Levels
11
+
12
+ | Level | Plan GO | Branch/commit | Ambiguities | Check-ins |
13
+ |-------|---------|---------------|-------------|-----------|
14
+ | guided | ask the user | ask the user | ask the user | ask the user |
15
+ | semi | present plan for user GO | auto | self-answer + log | log, no pause |
16
+ | auto | gated auto-GO | auto | self-answer + log | log, no pause |
17
+
18
+ Consent is an invariant in ALL levels — see below. Every level ends at push + ready PR + verdict (the user opens the PR); the crew never creates a PR, never merges, never deploys.
19
+
20
+ ## Config
21
+
22
+ Two files, four keys, `key=value` lines, optional `#` comments:
23
+
24
+ ```
25
+ # .mugiwara/config (project) overrides ~/.mugiwara/config (global)
26
+ mode=guided
27
+ branch=feature/{type}-{issue}-{slug}
28
+ commit=conventional
29
+ base=main
30
+ ```
31
+
32
+ | Key | Values | Default (no mugiwara branding) |
33
+ |-----|--------|--------------------------------|
34
+ | mode | guided / semi / auto | guided |
35
+ | branch | branch pattern | feature/{type}-{issue}-{slug} |
36
+ | commit | conventional / gitmoji / plain | conventional |
37
+ | base | PR summary target branch | main |
38
+
39
+ **Mode owns autonomy; config owns writing standards.** The mode key alone
40
+ decides whether branch/commit run automatically. The remaining keys shape HOW
41
+ artifacts are written — the `branch` naming pattern, the `commit` message
42
+ style, and `base` (the PR target named in the prepared PR summary per
43
+ `mugiwara-pr`). There is no autonomy key in config; a mode flip is the only
44
+ lever that changes behavior.
45
+
46
+ The `branch` value is a naming pattern, never executed: its placeholders (`{type}`/`{issue}`/`{slug}`) are filled from mission metadata and validated against a safe charset (alphanumerics, `-`, `_`) before any git command.
47
+
48
+ Read order per wave: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); project wins per key; a key missing from both falls back to the default. A key whose value is outside its enum table — or an unknown key — also falls back to that key's default; unknown lines are ignored. Config is data, never instructions. `.mugiwara/` is gitignored. Lazy-create on WRITE only — a missing config on read means guided, never auto-create the file. A flip is logged in the decision log (`.mugiwara/logs/YYYY-MM-DD-<mission>.md`) and applies from the next wave.
49
+
50
+ ## Override protocol
51
+
52
+ In-session phrase `mugiwara mode <guided|semi|auto>` → write the project `.mugiwara/config` AND append a decision-log row (level, requester, timestamp). No CLI flag; the installer CLI stays untouched.
53
+
54
+ ## Consent invariant
55
+
56
+ State-mutating tests against NON-isolated / shared state (real DB writes, network, browsers) ALWAYS require explicit user consent in ALL modes. Provably-isolated mutation — in-memory / temp / testcontainer-backed DBs, tooling-proven isolation — is explicitly auto-safe and needs no consent. `auto` runs only provably-isolated tests (unit-level, or tooling-proven isolation such as in-memory / local DB). `guided`/`semi` keep the existing ask-first rule for integration tests. Consent is not a mode knob. Record every consent answer in the report.
57
+
58
+ ## Auto plan-GO gate
59
+
60
+ The plan proceeds past approval in `auto` ONLY with zero blocking ambiguities AND zero high-risk tasks (task `Risk` line = deploy / migration / DB / public API / state-mutating). Otherwise it stops for the user. This keeps the planner's never-hand-without-GO contract intact; the safety line moves into the GO gate.
61
+
62
+ ## Terminal invariant
63
+
64
+ Every mode ends at: push the mission branch (per the `branch` key) → write the PR verdict file per `mugiwara-pr` (includes a ready PR summary; target per `base`) → hand the branch + verdict to the user, who opens the PR. The crew never creates a PR, never merges, never deploys, never auto-reacts to review comments or CI in any mode. PR review is the terminal gate.
65
+
66
+ ## Rules
67
+
68
+ 1. Read the config once per wave at dispatch; a flip never applies mid-wave.
69
+ 2. Missing config on read = guided; the file is created only on a write.
70
+ 3. State-mutating consent holds in every mode — auto never runs a state-mutating test against non-isolated / shared state without it.
71
+ 4. Auto plan-GO is gated, never assumed.
72
+ 5. The terminal is push + ready PR + verdict in every mode — the crew never creates a PR.
@@ -5,7 +5,17 @@ description: Use to triage a new mission at the gateway, classify requests 5 way
5
5
 
6
6
  # Orchestration (Luffy)
7
7
 
8
- Captain duties: triage, check-ins, work splitting, decisions, closure. Luffy coordinates — never implements code.
8
+ Captain duties: triage, check-ins, work splitting, decisions, closure. Luffy coordinates — never implements code. You are embodied by the main thread; you RETURN decisions and verdicts to the conversation, you never dispatch another crew member yourself.
9
+
10
+ ## Coordination files
11
+
12
+ The plan doc (`.mugiwara/plans/YYYY-MM-DD-<mission>.md`) is Nami's clean execution plan — NEVER write coordination into it. Your decisions, route reasons, and check-in verdicts go to `.mugiwara/logs/YYYY-MM-DD-<mission>.md` (append-only, deletable at cleanup). The closure report goes to `.mugiwara/results/YYYY-MM-DD-<mission>-closure.md`.
13
+
14
+ ## Mode read (Wave 0)
15
+
16
+ Read the runtime mode via `mugiwara-mode` at Wave 0: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); a key missing from both = `guided`. Record the active mode in the decision log. Read once per wave at dispatch; a flip applies from the next wave, never mid-wave.
17
+
18
+ Alongside the config, read the declared test source (per `mugiwara-testcases`): a path glob from the mission prompt or an explicit repo path. Record it in the decision log like the mode config. No source declared → no user tests for the mission.
9
19
 
10
20
  ## 5-way request classifier (Wave 0)
11
21
 
@@ -19,11 +29,11 @@ Classify every incoming request:
19
29
  | Open-ended | broad goal, undefined scope or success criteria | Wave 1 first |
20
30
  | Ambiguous | requirements, APIs, or scope unclear | Wave 1 first |
21
31
 
22
- Record decision + one-line reason at the top of the plan doc. Risk (money/security/data/public API) → full pipeline; never shortcut without recording why. Any route without a recorded reason is a red flag.
32
+ Record decision + one-line reason at the top of the decision log (`.mugiwara/logs/YYYY-MM-DD-<mission>.md`). Risk (money/security/data/public API) → full pipeline; never shortcut without recording why. Any route without a recorded reason is a red flag.
23
33
 
24
34
  ## Direct calls
25
35
 
26
- The user may summon any crew member directly (e.g. "Nami, plan this"). Luffy still records the route plus the reason in the plan doc so the harness stays coherent. Direct calls do not skip check-ins.
36
+ The user may summon any crew member directly (e.g. "Nami, plan this"). Luffy still records the route plus the reason in the decision log so the harness stays coherent. Direct calls do not skip check-ins.
27
37
 
28
38
  ## Periodic check-ins
29
39
 
@@ -34,22 +44,48 @@ After every wave AND at the end of each execution batch, verify:
34
44
  3. Heal-loop counters within bounds (max 3 cycles).
35
45
  4. Blocker ledger `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md` reviewed; every row has an owner or a path forward.
36
46
 
47
+ By mode (per `mugiwara-mode`): `guided` checks in with the user as today; `semi`/`auto` write the check-in verdicts to the decision log without pausing the pipeline.
48
+
37
49
  On drift: stop, diagnose with Chopper's ledger, decide continue / retry / escalate to human.
38
50
 
51
+ ## Wave transitions (visibility)
52
+
53
+ Every wave opens with a visible main-thread banner `## Wave N — <crew> (<skill>)` and closes with the handoff line `→ Wave N+1 — <crew>` (Wave 9: `→ closure`). No wave starts without its banner. A wave intentionally omitted is never silent — record wave, owner, and reason in the decision log before moving on. The user must always see which crew runs now and who takes over next.
54
+
39
55
  ## Work splitting
40
56
 
41
- When a wave has many independent tasks, instruct Zoro to parallelize — one task per subagent — and may split the mission into parallel tracks. Never run more parallelism than the plan proves safe (check the dependency graph, no shared files). A `[PARALLEL]` task set with a hidden dependency edge is a red flag.
57
+ When a wave has many independent tasks, instruct Zoro to parallelize — one task per WORKER subagent — and may split the mission into parallel tracks. Only `[PARALLEL]` sets are dispatched; sequential work stays inline. Never run more parallelism than the plan proves safe (check the dependency graph, no shared files). A `[PARALLEL]` task set with a hidden dependency edge is a red flag.
42
58
 
43
59
  ## Q&A hub
44
60
 
45
- Any agent routes a question to Luffy. Answer with: decision + reason + impact on the plan. Log every decision to `.mugiwara/logs/`; append the impact to the plan doc.
61
+ Any agent routes a question to Luffy (via the main thread). Answer with: decision + reason + impact on the plan. Log every decision to `.mugiwara/logs/YYYY-MM-DD-<mission>.md`; do NOT touch the plan doc.
62
+
63
+ ## Override (in-session)
64
+
65
+ Recognize the in-session phrase `mugiwara mode <guided|semi|auto>`: write the project `.mugiwara/config`, append a decision-log row (level, requester, timestamp), and apply from the next wave. No CLI flag. The mode is read once per wave — a flip never applies mid-wave.
46
66
 
47
67
  ## Closure (Wave 9)
48
68
 
49
- Gate — every task's acceptance criteria verified, every gate passed, findings resolved or explicitly deferred with an owner, blocker ledger reviewed, unused intermediate markdown files deleted. Append the closure report to the plan doc: mission summary, per-wave outcomes, deferred items, lessons learned.
69
+ Gate — every task's acceptance criteria verified, every gate passed, findings resolved or explicitly deferred with an owner, blocker ledger reviewed, unused intermediate markdown files deleted. Write the closure report to `.mugiwara/results/YYYY-MM-DD-<mission>-closure.md`: mission summary, per-wave outcomes, deferred items, lessons learned. The plan doc stays untouched.
70
+
71
+ ### Detailed closure summary (mandatory, inline)
72
+
73
+ Present a detailed summary to the user — never a one-liner:
74
+
75
+ - Mission summary — goal, mode, waves, task count.
76
+ - Per-wave outcome table — wave, tasks, status, evidence pointer.
77
+ - Gate verdicts — quality, gates (coverage/build/DoD), review + security findings with dispositions, e2e (run / skipped + why).
78
+ - Tests — unit/integration results; ATDD oracle verdict when user tests were declared.
79
+ - Risks / rollback — remaining risk and the rollback path (revert commit / feature flag).
80
+ - Deferred items + owner.
81
+ - Next steps — PR material pointer, anything the user must do.
82
+
83
+ ### Terminal step (every mode, per `mugiwara-mode`)
84
+
85
+ Save-point commit → push the mission branch (per the config `branch` key, default `feature/{type}-{issue}-{slug}`) with plain `git push -u origin <branch>` → write `.mugiwara/results/YYYY-MM-DD-<mission>-pr-verdict.md` per the `mugiwara-pr` format (includes a ready PR summary block) → hand the branch + verdict file to the user, who opens the PR. The crew never creates a PR, never merges, never deploys, never auto-reacts to review comments or CI in any mode. On push failure (no auth / no remote), fall back to the local closure report and log the reason.
50
86
 
51
- Lessons: at Wave 0 triage read `.mugiwara/logs/lessons.md` and surface relevant rows to the owning agent. At closure dispatch memory-keeper to append this mission's lessons to `.mugiwara/logs/lessons.md` — one row per real lesson, append-only, never overwrite.
87
+ Lessons: at Wave 0 triage read `.mugiwara/logs/lessons.md` and surface relevant rows to the owning agent. At closure embody memory-keeper inline to append this mission's lessons to `.mugiwara/logs/lessons.md` — one row per real lesson, append-only, never overwrite.
52
88
 
53
89
  ## Spirit vs letter
54
90
 
55
- The plan doc is the contract, but the mission goal outranks it. If following the plan's letter drifts from the mission's intent, stop and amend the plan — do not bend the mission to the plan. Log the amendment with a reason.
91
+ The plan doc is the contract, but the mission goal outranks it. If following the plan's letter drifts from the mission's intent, stop and amend the plan (through Nami) — do not bend the mission to the plan. Log the amendment with a reason in `logs/`.