squad-bmad 1.2.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.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # Squad BMAD: Automated Project Orchestration Assistant with Gemini & Claude Code
2
+
3
+ [![Version](https://img.shields.io/badge/version-1.2.0-blue.svg)](CHANGELOG.md)
4
+ [![npm](https://img.shields.io/npm/v/squad-bmad.svg)](https://www.npmjs.com/package/squad-bmad)
5
+
6
+ *Read this in other languages: [English](README.md), [TiαΊΏng Việt](README.vi.md).*
7
+
8
+ Welcome to **Squad BMAD** – a boilerplate/design solution to transform **Gemini CLI** into a true **Project Manager & Principal Tech Lead**. By combining Gemini's orchestration power with **Claude Code's** excellent coding and reasoning capabilities via **Tmux**, this project automates and optimizes the software development workflow based on the **BMAD** methodology.
9
+
10
+ ---
11
+
12
+ ## 🌟 Benefits
13
+
14
+ The BMAD (Build-Measure-Analyze-Deploy) methodology is known for maintaining strictness, clear structure, and being strongly **spec-driven**. However, its biggest drawback is that the operation process requires many steps and manual actions.
15
+
16
+ **Squad BMAD completely solves this problem:**
17
+ - **Seamless Automation:** Makes operating a project with the BMAD method smooth and continuous without requiring your intervention in every small step.
18
+ - **An Indefatigable Project Assistant:** This assistant will help you answer and handle BMAD steps, automatically operating and implementing all Epics and Stories.
19
+ - **Focus on Core Value:** You only need to talk to the Assistant (Gemini), make high-level decisions, and the Assistant will automatically delegate tasks and monitor the other Agents (Claude Code).
20
+
21
+ ---
22
+
23
+ ## πŸ“‹ System Requirements
24
+
25
+ To run this system smoothly, you need to prepare:
26
+
27
+ - **Claude Code Account:** Required to launch the Execution (Implement) and Reasoning (Brainstorm) Agents.
28
+ - **Gemini Account (Gemini CLI):** Acts as the "Orchestrator" coordinating the entire workflow.
29
+ - **Tmux Environment:** Installed on your machine (MacOS/Linux) to manage multi-threaded work sessions.
30
+ - **Experience:** Have used or possess a basic understanding of the **BMAD** method.
31
+
32
+ ---
33
+
34
+ ## 🧠 Core Philosophy
35
+
36
+ Squad BMAD is built on immutable principles:
37
+
38
+ 1. **Strict Adherence to BMAD Processes:** All tasks from ideation, writing specifications, to coding and reviewing strictly follow BMAD's workflows. This ensures the project always stays on track and technical documentation is always synchronized with the actual code.
39
+ 2. **Fresh Chat & Context Isolation:** Before starting a new workflow, the system must clear the context (by sending the `/clear` command). This prevents the AI (Claude) from hallucinating due to carrying too much old information, keeping its reasoning sharp.
40
+ 3. **Clear Agent Roles:** Applying the true spirit of BMAD, the system divides Agents into specialized "personas" (PM, Architect, Dev, QA) to optimize the performance of each AI Model.
41
+
42
+ ---
43
+
44
+ ## βš™οΈ System Architecture & Operation
45
+
46
+ The system operates based on the smooth coordination of **3 Tmux sessions**:
47
+
48
+ 1. **Session 1: Gemini Orchestrator**
49
+ - The master operating the other 2 tmux sessions.
50
+ - Communicates directly with you, understands requirements, and maps them to BMAD workflows.
51
+ - Monitors, accepts the results, and makes transition decisions.
52
+
53
+ 2. **Session 2: Claude Code - Implement**
54
+ - Acts as a **Developer**.
55
+ - Specialized in writing code, fixing bugs, and running tests.
56
+ - Uses the **Claude Sonnet** model to ensure fast speed, excellent coding, and cost savings.
57
+
58
+ 3. **Session 3: Claude Code - Brainstorm**
59
+ - Acts as an **Architect / PM / QA**.
60
+ - Specialized in reasoning about architecture, solving complex problems, designing systems, and reviewing code.
61
+ - Uses the **Claude Opus** model for tasks requiring deep logical thinking.
62
+
63
+ ### πŸ”„ Event-Driven System with Hooks
64
+
65
+ Instead of Gemini having to constantly poll the screen to see if Claude Code is done, this project uses an **Event-driven Hooks** mechanism via the `.claude/settings.json` file.
66
+
67
+ Whenever Claude Code (in tmux 2 or 3) completes a task or needs to stop, the system automatically triggers a bash script (like `.claude/hooks/wakeup-gemini.sh`). This script immediately sends a signal back to Gemini's Tmux Session, "waking up" Gemini to:
68
+ 1. Read the work results.
69
+ 2. Evaluate and accept the source code.
70
+ 3. Report back to you or automatically proceed to the next step according to the BMAD process.
71
+
72
+ ---
73
+
74
+ ## πŸš€ Workflow Summary
75
+
76
+ 1. You open 3 Tmux sessions (1 for Gemini, 2 for Claude Code).
77
+ 2. You chat with Gemini: *"Please implement Story #123 for me."*
78
+ 3. Gemini receives the command, analyzes it according to the BMAD workflow, and sends the command (along with `/clear` to reset context) to `Claude Code - Implement` via a secure shell script.
79
+ 4. Gemini goes into an "Idle" state, waiting.
80
+ 5. `Claude Code - Implement` busily writes code. When done, it automatically triggers the Hook.
81
+ 6. The Hook runs the bash script, sending an `Enter` keystroke and a notification message to Gemini's screen.
82
+ 7. Gemini "wakes up", reads Claude Code's screen log, accepts the results, and reports back to you.
83
+
84
+ ---
85
+
86
+ With **Squad BMAD**, you are no longer a coder painstakingly typing every line of code; you are a true **Project Manager** commanding an elite AI squad!
87
+
88
+ ---
89
+
90
+ ## πŸ›  Setup & Usage
91
+
92
+ ### 1. Install Squad BMAD
93
+
94
+ From your project directory, run:
95
+
96
+ ```bash
97
+ npx squad-bmad install
98
+ ```
99
+
100
+ This will:
101
+ - Copy hook scripts, tmux utilities, and Gemini slash commands into your project.
102
+ - Automatically configure `.claude/settings.json` with the required hooks (or print instructions if you already have a custom hooks section).
103
+ - Remind you to install the BMAD Method (`npx bmad-method install`) if it's not already present.
104
+
105
+ > **Upgrading?** Run `npx squad-bmad upgrade` to overwrite existing files with the latest version.
106
+
107
+ ### 2. Prepare the Tmux Environment
108
+
109
+ All 3 sessions follow a **project-aware naming convention** based on your folder name. Run the setup script from your project directory:
110
+
111
+ ```bash
112
+ bash .gemini/scripts/setup-sessions.sh
113
+ ```
114
+
115
+ This will automatically create (or skip if already existing):
116
+ - `gemini-orchestrator-<folder>` β€” launches `gemini --yolo --model gemini-3-pro-preview`
117
+ - `claude-implement-<folder>` β€” launches `claude --dangerously-skip-permissions --model sonnet`
118
+ - `claude-brainstorm-<folder>` β€” launches `claude --dangerously-skip-permissions --model opus`
119
+
120
+ ### 3. Start Gemini Orchestrator
121
+
122
+ Attach to the Gemini session for your project:
123
+ ```bash
124
+ tmux attach -t gemini-orchestrator-<folder>
125
+ ```
126
+
127
+ ### 4. Run the Slash Command
128
+
129
+ Inside Gemini, run the slash command β€” **no arguments needed**. Gemini will auto-detect the project folder and verify all sessions:
130
+
131
+ ```text
132
+ /withClaudeCodeTmux
133
+ ```
134
+
135
+ ### 5. Start Working
136
+ The system is now ready. You simply communicate with Gemini like a project manager:
137
+ - *"Start this project for me using the generate-project-context flow."*
138
+ - *"Which Epic are we in? Create a new story for the login feature."*
139
+ - *"Implement Story #5 according to the dev-story process."*
140
+
141
+ Gemini will automatically analyze, clear the context (send `/clear`), route the command to the appropriate Claude session, and will automatically "wake up" to accept the work when it receives the Hook feedback signal from Claude.
package/README.vi.md ADDED
@@ -0,0 +1,139 @@
1
+ # Squad BMAD: Trợ LΓ½ αΊ’o Điều Phα»‘i Dα»± Án Tα»± Động Vα»›i Gemini & Claude Code
2
+
3
+ [![Version](https://img.shields.io/badge/version-1.2.0-blue.svg)](CHANGELOG.md)
4
+ [![npm](https://img.shields.io/npm/v/squad-bmad.svg)](https://www.npmjs.com/package/squad-bmad)
5
+
6
+ ChΓ o mα»«ng bαΊ‘n Δ‘αΊΏn vα»›i **Squad BMAD** – mα»™t boilerplate/giαΊ£i phΓ‘p thiαΊΏt kαΊΏ để biαΊΏn **Gemini CLI** trở thΓ nh mα»™t **Project Manager & Principal Tech Lead** thα»±c thα»₯. BαΊ±ng cΓ‘ch kαΊΏt hợp sα»©c mαΊ‘nh Δ‘iều phα»‘i cα»§a Gemini vΓ  khαΊ£ nΔƒng lαΊ­p trΓ¬nh/suy luαΊ­n xuαΊ₯t sαΊ―c cα»§a **Claude Code** thΓ΄ng qua mΓ΄i trường **Tmux**, dα»± Γ‘n nΓ y tα»± Δ‘α»™ng hΓ³a vΓ  tα»‘i Ζ°u hΓ³a luα»“ng cΓ΄ng việc phΓ‘t triển phαΊ§n mềm dα»±a trΓͺn nền tαΊ£ng phΖ°Ζ‘ng phΓ‘p luαΊ­n **BMAD**.
7
+
8
+ ---
9
+
10
+ ## 🌟 Lợi Ích Đem Lẑi
11
+
12
+ PhΖ°Ζ‘ng phΓ‘p luαΊ­n BMAD (Build-Measure-Analyze-Deploy) nα»•i tiαΊΏng vα»›i khαΊ£ nΔƒng duy trΓ¬ tΓ­nh chαΊ·t chαΊ½, cαΊ₯u trΓΊc rΓ΅ rΓ ng vΓ  luΓ΄n hΖ°α»›ng tα»›i **spec-driven** (lΓ m việc dα»±a trΓͺn Δ‘αΊ·c tαΊ£ kα»Ή thuαΊ­t). Tuy nhiΓͺn, nhược Δ‘iểm lα»›n nhαΊ₯t lΓ  quΓ‘ trΓ¬nh vαΊ­n hΓ nh tα»‘n khΓ‘ nhiều bΖ°α»›c vΓ  thao tΓ‘c thα»§ cΓ΄ng.
13
+
14
+ **Squad BMAD giαΊ£i quyαΊΏt triệt để vαΊ₯n đề Δ‘Γ³:**
15
+ - **Tα»± Δ‘α»™ng hΓ³a xuyΓͺn suα»‘t:** GiΓΊp quΓ‘ trΓ¬nh vαΊ­n hΓ nh project vα»›i phΖ°Ζ‘ng phΓ‘p BMAD diα»…n ra trΖ‘n tru, liền mαΊ‘ch mΓ  khΓ΄ng cαΊ§n bαΊ‘n phαΊ£i can thiệp vΓ o tα»«ng bΖ°α»›c nhỏ.
16
+ - **CΓ³ ngay mα»™t trợ lΓ½ dα»± Γ‘n mαΊ«n cΓ‘n:** Trợ lΓ½ nΓ y sαΊ½ giΓΊp bαΊ‘n trαΊ£ lời, xα»­ lΓ½ cΓ‘c step cα»§a BMAD, tα»± Δ‘α»™ng vαΊ­n hΓ nh vΓ  implement toΓ n bα»™ Epics, Stories.
17
+ - **TαΊ­p trung vΓ o giΓ‘ trα»‹ cα»‘t lΓ΅i:** BαΊ‘n chỉ cαΊ§n nΓ³i chuyện vα»›i Trợ lΓ½ (Gemini), Δ‘Ζ°a ra quyαΊΏt Δ‘α»‹nh ở tαΊ§m cao, phαΊ§n cΓ²n lαΊ‘i Trợ lΓ½ sαΊ½ tα»± Δ‘α»™ng giao việc vΓ  giΓ‘m sΓ‘t cΓ‘c Agent khΓ‘c (Claude Code).
18
+
19
+ ---
20
+
21
+ ## πŸ“‹ YΓͺu CαΊ§u Hệ Thα»‘ng (Requirements)
22
+
23
+ Để vαΊ­n hΓ nh trΖ‘n tru hệ thα»‘ng nΓ y, bαΊ‘n cαΊ§n chuαΊ©n bα»‹:
24
+
25
+ - **TΓ i khoαΊ£n Claude Code:** CαΊ§n thiαΊΏt để khởi chαΊ‘y cΓ‘c Agent thα»±c thi (Implement) vΓ  tΖ° duy (Brainstorm).
26
+ - **TΓ i khoαΊ£n Gemini (Gemini CLI):** Đóng vai trΓ² lΓ  "NhαΊ‘c trưởng" Δ‘iều phα»‘i toΓ n bα»™ luα»“ng cΓ΄ng việc.
27
+ - **MΓ΄i trường Tmux:** Được cΓ i Δ‘αΊ·t sαΊ΅n trΓͺn mΓ‘y tΓ­nh (MacOS/Linux) để quαΊ£n lΓ½ Δ‘a luα»“ng phiΓͺn lΓ m việc.
28
+ - **Kinh nghiệm:** Đã tα»«ng sα»­ dα»₯ng hoαΊ·c cΓ³ kiαΊΏn thα»©c nền tαΊ£ng về phΖ°Ζ‘ng phΓ‘p **BMAD**.
29
+
30
+ ---
31
+
32
+ ## 🧠 Hệ TΖ° Tưởng Cα»‘t LΓ΅i
33
+
34
+ Squad BMAD được xΓ’y dα»±ng dα»±a trΓͺn cΓ‘c nguyΓͺn tαΊ―c bαΊ₯t di bαΊ₯t dα»‹ch:
35
+
36
+ 1. **BΓ‘m sΓ‘t quy trΓ¬nh BMAD:** Mọi tΓ‘c vα»₯ tα»« lΓͺn Γ½ tưởng, viαΊΏt Δ‘αΊ·c tαΊ£, Δ‘αΊΏn code vΓ  review đều tuΓ’n thα»§ nghiΓͺm ngαΊ·t cΓ‘c workflow cα»§a BMAD. Điều nΓ y Δ‘αΊ£m bαΊ£o dα»± Γ‘n luΓ΄n Δ‘i Δ‘ΓΊng hΖ°α»›ng vΓ  tΓ i liệu kα»Ή thuαΊ­t luΓ΄n Δ‘α»“ng bα»™ vα»›i code thα»±c tαΊΏ.
37
+ 2. **Fresh Chat & Context Isolation (CΓ‘ch ly Ngα»― cαΊ£nh):** TrΖ°α»›c khi bαΊ―t Δ‘αΊ§u mα»™t workflow mα»›i, hệ thα»‘ng bαΊ―t buα»™c phαΊ£i dọn dαΊΉp ngα»― cαΊ£nh (gọi lệnh `/clear`). Việc nΓ y giΓΊp AI (Claude) khΓ΄ng bα»‹ αΊ£o giΓ‘c (hallucination) do Γ΄m Δ‘α»“m quΓ‘ nhiều thΓ΄ng tin cΕ©, giα»― cho suy luαΊ­n luΓ΄n sαΊ―c bΓ©n.
38
+ 3. **PhΓ’n chia vai trΓ² rΓ΅ rΓ ng (Agent Roles):** Áp dα»₯ng Δ‘ΓΊng tinh thαΊ§n cα»§a BMAD, hệ thα»‘ng chia cΓ‘c Agent thΓ nh cΓ‘c "persona" chuyΓͺn biệt (PM, Architect, Dev, QA) để tα»‘i Ζ°u hΓ³a hiệu suαΊ₯t cα»§a tα»«ng Model AI.
39
+
40
+ ---
41
+
42
+ ## βš™οΈ KiαΊΏn TrΓΊc Hệ Thα»‘ng & CΓ‘ch VαΊ­n HΓ nh
43
+
44
+ Hệ thα»‘ng hoαΊ‘t Δ‘α»™ng dα»±a trΓͺn sα»± phα»‘i hợp nhα»‹p nhΓ ng cα»§a **3 phiΓͺn lΓ m việc (sessions) Tmux**:
45
+
46
+ 1. **Session 1: Gemini Orchestrator (Nhẑc trưởng)**
47
+ - Là người chủ vận hành 2 tmux còn lẑi.
48
+ - Giao tiαΊΏp trα»±c tiαΊΏp vα»›i bαΊ‘n, hiểu yΓͺu cαΊ§u, Γ‘nh xαΊ‘ vΓ o workflow cα»§a BMAD.
49
+ - Theo dΓ΅i, nghiệm thu kαΊΏt quαΊ£ vΓ  ra quyαΊΏt Δ‘α»‹nh chuyển tiαΊΏp.
50
+
51
+ 2. **Session 2: Claude Code - Implement (Thα»±c thi)**
52
+ - Đóng vai trΓ² lΓ  mα»™t **Developer**.
53
+ - ChuyΓͺn dΓΉng để viαΊΏt code, sα»­a lα»—i, chαΊ‘y test.
54
+ - Sα»­ dα»₯ng model **Claude Sonnet** để Δ‘αΊ£m bαΊ£o tα»‘c Δ‘α»™ nhanh, code giỏi vΓ  tiαΊΏt kiệm chi phΓ­.
55
+
56
+ 3. **Session 3: Claude Code - Brainstorm (Suy luαΊ­n)**
57
+ - Đóng vai trò là **Architect / PM / QA**.
58
+ - ChuyΓͺn dΓΉng để suy luαΊ­n kiαΊΏn trΓΊc, giαΊ£i quyαΊΏt cΓ‘c bΓ i toΓ‘n phα»©c tαΊ‘p, thiαΊΏt kαΊΏ hệ thα»‘ng vΓ  review code.
59
+ - Sα»­ dα»₯ng model **Claude Opus** cho cΓ‘c tΓ‘c vα»₯ cαΊ§n tΖ° duy logic sΓ’u.
60
+
61
+ ### πŸ”„ Hệ Thα»‘ng Event-Driven bαΊ±ng Hooks
62
+
63
+ Thay vΓ¬ để Gemini phαΊ£i liΓͺn tα»₯c kiểm tra mΓ n hΓ¬nh xem Claude Code Δ‘Γ£ lΓ m xong chΖ°a (polling), dα»± Γ‘n nΓ y sα»­ dα»₯ng cΖ‘ chαΊΏ **Hooks Event-driven** thΓ΄ng qua file `.claude/settings.json`.
64
+
65
+ Mα»—i khi Claude Code (ở tmux 2 hoαΊ·c 3) hoΓ n thΓ nh cΓ΄ng việc hoαΊ·c cαΊ§n dα»«ng lαΊ‘i, hệ thα»‘ng sαΊ½ tα»± Δ‘α»™ng kΓ­ch hoαΊ‘t mα»™t bash script (nhΖ° `.claude/hooks/wakeup-gemini.sh`). Script nΓ y sαΊ½ lαΊ­p tα»©c gα»­i tΓ­n hiệu ngược lαΊ‘i cho Session Tmux cα»§a Gemini, "Δ‘Γ‘nh thα»©c" Gemini dαΊ­y để:
66
+ 1. Đọc kαΊΏt quαΊ£ cΓ΄ng việc.
67
+ 2. ĐÑnh giΓ‘ vΓ  nghiệm thu mΓ£ nguα»“n.
68
+ 3. BÑo cÑo lẑi cho bẑn hoặc tự động đi tiếp bước tiếp theo theo quy trình BMAD.
69
+
70
+ ---
71
+
72
+ ## πŸš€ TΓ³m TαΊ―t Quy TrΓ¬nh HoαΊ‘t Động
73
+
74
+ 1. Bẑn mở 3 session Tmux (1 cho Gemini, 2 cho Claude Code).
75
+ 2. BαΊ‘n chat vα»›i Gemini: *"HΓ£y implement Story #123 cho tΓ΄i."*
76
+ 3. Gemini nhαΊ­n lệnh, phΓ’n tΓ­ch theo workflow BMAD vΓ  gα»­i lệnh (kΓ¨m `/clear` để reset context) sang cho `Claude Code - Implement` thΓ΄ng qua shell script an toΓ n.
77
+ 4. Gemini rΖ‘i vΓ o trαΊ‘ng thΓ‘i "Idle" (nghỉ ngΖ‘i), chờ đợi.
78
+ 5. `Claude Code - Implement` hΓ¬ hα»₯c viαΊΏt code. Khi xong, nΓ³ tα»± Δ‘α»™ng kΓ­ch hoαΊ‘t Hook.
79
+ 6. Hook chẑy bash script, gửi phím `Enter` và dòng thông bÑo sang màn hình của Gemini.
80
+ 7. Gemini "tỉnh giαΊ₯c", đọc log mΓ n hΓ¬nh cα»§a Claude Code, nghiệm thu kαΊΏt quαΊ£ vΓ  bΓ‘o cΓ‘o lαΊ‘i cho bαΊ‘n.
81
+
82
+ ---
83
+
84
+ Vα»›i **Squad BMAD**, bαΊ‘n khΓ΄ng cΓ²n lΓ  mα»™t coder cαΊ·m cα»₯i gΓ΅ tα»«ng dΓ²ng lệnh, bαΊ‘n lΓ  mα»™t **Người quαΊ£n lΓ½ dα»± Γ‘n** thα»±c thα»₯ Δ‘iều hΓ nh mα»™t Δ‘α»™i ngΕ© AI tinh nhuệ!
85
+
86
+ ---
87
+
88
+ ## πŸ›  CΓ‘ch CΓ i Đặt & Sα»­ Dα»₯ng (How to use)
89
+
90
+ ### 1. Cài Đặt Squad BMAD
91
+
92
+ Tα»« thΖ° mα»₯c dα»± Γ‘n cα»§a bαΊ‘n, chαΊ‘y:
93
+
94
+ ```bash
95
+ npx squad-bmad install
96
+ ```
97
+
98
+ Lệnh nΓ y sαΊ½:
99
+ - Sao chΓ©p cΓ‘c hook script, tiện Γ­ch tmux, vΓ  Gemini slash command vΓ o dα»± Γ‘n cα»§a bαΊ‘n.
100
+ - Tα»± Δ‘α»™ng cαΊ₯u hΓ¬nh `.claude/settings.json` vα»›i cΓ‘c hooks cαΊ§n thiαΊΏt (hoαΊ·c in hΖ°α»›ng dαΊ«n nαΊΏu bαΊ‘n Δ‘Γ£ cΓ³ phαΊ§n hooks tΓΉy chỉnh).
101
+ - NhαΊ―c bαΊ‘n cΓ i Δ‘αΊ·t BMAD Method (`npx bmad-method install`) nαΊΏu chΖ°a cΓ³.
102
+
103
+ > **NΓ’ng cαΊ₯p?** ChαΊ‘y `npx squad-bmad upgrade` để ghi Δ‘Γ¨ cΓ‘c file hiện cΓ³ bαΊ±ng phiΓͺn bαΊ£n mα»›i nhαΊ₯t.
104
+
105
+ ### 2. ChuαΊ©n Bα»‹ MΓ΄i Trường Tmux
106
+
107
+ TαΊ₯t cαΊ£ 3 sessions đều được tαΊ‘o tα»± Δ‘α»™ng theo **quy chuαΊ©n Δ‘αΊ·t tΓͺn dα»±a trΓͺn tΓͺn folder dα»± Γ‘n**. ChαΊ‘y script setup tα»« thΖ° mα»₯c dα»± Γ‘n:
108
+
109
+ ```bash
110
+ bash .gemini/scripts/setup-sessions.sh
111
+ ```
112
+
113
+ Script sαΊ½ tα»± Δ‘α»™ng tαΊ‘o (hoαΊ·c bỏ qua nαΊΏu Δ‘Γ£ tα»“n tαΊ‘i):
114
+ - `gemini-orchestrator-<folder>` β€” khởi chαΊ‘y `gemini --yolo --model gemini-3-pro-preview`
115
+ - `claude-implement-<folder>` β€” khởi chαΊ‘y `claude --dangerously-skip-permissions --model sonnet`
116
+ - `claude-brainstorm-<folder>` β€” khởi chαΊ‘y `claude --dangerously-skip-permissions --model opus`
117
+
118
+ ### 3. Truy cαΊ­p Gemini Orchestrator
119
+
120
+ Attach vΓ o session Gemini cα»§a dα»± Γ‘n:
121
+ ```bash
122
+ tmux attach -t gemini-orchestrator-<folder>
123
+ ```
124
+
125
+ ### 4. ChαΊ‘y Slash Command
126
+
127
+ Trong Gemini, gΓ΅ slash command β€” **khΓ΄ng cαΊ§n truyền argument**. Gemini sαΊ½ tα»± detect folder vΓ  kiểm tra cαΊ£ 3 sessions:
128
+
129
+ ```text
130
+ /withClaudeCodeTmux
131
+ ```
132
+
133
+ ### 5. BαΊ―t Đầu CΓ΄ng Việc
134
+ Giờ Δ‘Γ’y hệ thα»‘ng Δ‘Γ£ sαΊ΅n sΓ ng. BαΊ‘n chỉ việc giao tiαΊΏp vα»›i Gemini nhΖ° mα»™t người quαΊ£n lΓ½ dα»± Γ‘n:
135
+ - *"BαΊ―t Δ‘αΊ§u project nΓ y giΓΊp tΓ΄i bαΊ±ng luα»“ng generate-project-context."*
136
+ - *"ChΓΊng ta Δ‘ang ở Epic nΓ o? HΓ£y tαΊ‘o story mα»›i cho tΓ­nh nΔƒng Δ‘Δƒng nhαΊ­p."*
137
+ - *"Hãy implement Story #5 theo quy trình dev-story."*
138
+
139
+ Gemini sαΊ½ tα»± Δ‘α»™ng phΓ’n tΓ­ch, dọn dαΊΉp ngα»― cαΊ£nh (gα»­i lệnh `/clear`), chuyển lệnh Δ‘αΊΏn Δ‘ΓΊng session Claude phΓΉ hợp vΓ  sαΊ½ tα»± Δ‘α»™ng "thα»©c dαΊ­y" để nghiệm thu khi nhαΊ­n được tΓ­n hiệu Hook phαΊ£n hα»“i tα»« Claude.
package/bin/cli.js ADDED
@@ -0,0 +1,276 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * squad-bmad CLI
4
+ *
5
+ * Commands:
6
+ * npx squad-bmad install β€” Copy squad-bmad files into the current project
7
+ * npx squad-bmad upgrade β€” Update squad-bmad files to the latest version
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const https = require('https');
15
+
16
+ // ── ANSI colour helpers ──────────────────────────────────────────────────────
17
+ const c = {
18
+ reset: '\x1b[0m',
19
+ bold: '\x1b[1m',
20
+ green: '\x1b[32m',
21
+ yellow: '\x1b[33m',
22
+ cyan: '\x1b[36m',
23
+ red: '\x1b[31m',
24
+ dim: '\x1b[2m',
25
+ };
26
+ const ok = (s) => console.log(` ${c.green}βœ“${c.reset} ${s}`);
27
+ const warn = (s) => console.log(` ${c.yellow}⚠${c.reset} ${s}`);
28
+ const info = (s) => console.log(` ${c.cyan}β†’${c.reset} ${s}`);
29
+ const err = (s) => console.log(` ${c.red}βœ—${c.reset} ${s}`);
30
+ const sep = () => console.log(`${c.dim}${'─'.repeat(60)}${c.reset}`);
31
+
32
+ // ── Paths ────────────────────────────────────────────────────────────────────
33
+ const TEMPLATE_DIR = path.join(__dirname, '..', 'template');
34
+ const TARGET_DIR = process.cwd();
35
+
36
+ // ── Hooks that squad-bmad requires in .claude/settings.json ─────────────────
37
+ const REQUIRED_HOOKS = {
38
+ Stop: [
39
+ {
40
+ matcher: '',
41
+ hooks: [{ type: 'command', command: 'bash .claude/hooks/wakeup-gemini.sh' }],
42
+ },
43
+ ],
44
+ Notification: [
45
+ {
46
+ matcher: 'permission_prompt',
47
+ hooks: [{ type: 'command', command: 'bash .claude/hooks/notify-gemini.sh "$CLAUDE_NOTIFICATION"' }],
48
+ },
49
+ ],
50
+ };
51
+
52
+ // ── Helper: recursively copy a directory, returning list of copied files ─────
53
+ function copyDir(src, dest, { overwrite = false } = {}) {
54
+ const results = { copied: [], skipped: [] };
55
+
56
+ if (!fs.existsSync(src)) return results;
57
+
58
+ const entries = fs.readdirSync(src, { withFileTypes: true });
59
+ fs.mkdirSync(dest, { recursive: true });
60
+
61
+ for (const entry of entries) {
62
+ const srcPath = path.join(src, entry.name);
63
+ const destPath = path.join(dest, entry.name);
64
+
65
+ if (entry.isDirectory()) {
66
+ const sub = copyDir(srcPath, destPath, { overwrite });
67
+ results.copied.push(...sub.copied);
68
+ results.skipped.push(...sub.skipped);
69
+ } else {
70
+ const rel = path.relative(TARGET_DIR, destPath);
71
+ if (!overwrite && fs.existsSync(destPath)) {
72
+ results.skipped.push(rel);
73
+ } else {
74
+ fs.cpSync(srcPath, destPath, { force: true });
75
+ results.copied.push(rel);
76
+ }
77
+ }
78
+ }
79
+
80
+ return results;
81
+ }
82
+
83
+ // ── Helper: smart-merge squad-bmad hooks into .claude/settings.json ──────────
84
+ function mergeSettings() {
85
+ const settingsPath = path.join(TARGET_DIR, '.claude', 'settings.json');
86
+
87
+ /* Case 1: file doesn't exist β€” create it */
88
+ if (!fs.existsSync(settingsPath)) {
89
+ fs.mkdirSync(path.join(TARGET_DIR, '.claude'), { recursive: true });
90
+ fs.writeFileSync(settingsPath, JSON.stringify({ hooks: REQUIRED_HOOKS }, null, 2) + '\n');
91
+ ok('.claude/settings.json created with hooks section.');
92
+ return;
93
+ }
94
+
95
+ /* Case 2/3: file exists β€” read and inspect */
96
+ let settings;
97
+ try {
98
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
99
+ } catch {
100
+ err('Could not parse .claude/settings.json β€” please check it is valid JSON.');
101
+ return;
102
+ }
103
+
104
+ /* Case 2: no hooks key β€” safe to merge automatically */
105
+ if (!settings.hooks) {
106
+ settings.hooks = REQUIRED_HOOKS;
107
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
108
+ ok('.claude/settings.json β€” hooks section added automatically.');
109
+ return;
110
+ }
111
+
112
+ /* Case 3: hooks key already exists β€” print instructions, don't touch */
113
+ warn('.claude/settings.json already has a "hooks" section.');
114
+ console.log(`\n Please ${c.bold}manually${c.reset} add the following entries:\n`);
115
+ console.log(`${c.dim} ─── .claude/settings.json ────────────────────────────${c.reset}`);
116
+ console.log(JSON.stringify({ hooks: REQUIRED_HOOKS }, null, 2)
117
+ .split('\n')
118
+ .map(l => ` ${c.cyan}${l}${c.reset}`)
119
+ .join('\n'));
120
+ console.log(`${c.dim} ────────────────────────────────────────────────────────${c.reset}\n`);
121
+ }
122
+
123
+ // ── BMAD Knowledge URL ──────────────────────────────────────────────────────
124
+ const BMAD_KNOWLEDGE_URL = 'https://docs.bmad-method.org/llms-full.txt';
125
+ const BMAD_KNOWLEDGE_DEST = path.join('references', 'bmad-knowledge', 'llm.md');
126
+
127
+ // ── Helper: download BMAD knowledge file ────────────────────────────────────
128
+ function downloadBmadKnowledge() {
129
+ const destPath = path.join(TARGET_DIR, BMAD_KNOWLEDGE_DEST);
130
+ const destDir = path.dirname(destPath);
131
+
132
+ return new Promise((resolve) => {
133
+ info(`Downloading latest BMAD knowledge from:\n ${c.dim}${BMAD_KNOWLEDGE_URL}${c.reset}\n`);
134
+
135
+ https.get(BMAD_KNOWLEDGE_URL, (res) => {
136
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
137
+ // Follow one redirect
138
+ https.get(res.headers.location, (redirectRes) => {
139
+ handleResponse(redirectRes, destDir, destPath, resolve);
140
+ }).on('error', (e) => {
141
+ err(`Download failed: ${e.message}`);
142
+ warn('You can manually download it later from:');
143
+ console.log(` ${c.cyan}${BMAD_KNOWLEDGE_URL}${c.reset}`);
144
+ console.log(` Save to: ${c.cyan}${BMAD_KNOWLEDGE_DEST}${c.reset}\n`);
145
+ resolve(false);
146
+ });
147
+ return;
148
+ }
149
+ handleResponse(res, destDir, destPath, resolve);
150
+ }).on('error', (e) => {
151
+ err(`Download failed: ${e.message}`);
152
+ warn('You can manually download it later from:');
153
+ console.log(` ${c.cyan}${BMAD_KNOWLEDGE_URL}${c.reset}`);
154
+ console.log(` Save to: ${c.cyan}${BMAD_KNOWLEDGE_DEST}${c.reset}\n`);
155
+ resolve(false);
156
+ });
157
+ });
158
+ }
159
+
160
+ function handleResponse(res, destDir, destPath, resolve) {
161
+ if (res.statusCode !== 200) {
162
+ err(`Download failed: HTTP ${res.statusCode}`);
163
+ warn('You can manually download it later from:');
164
+ console.log(` ${c.cyan}${BMAD_KNOWLEDGE_URL}${c.reset}`);
165
+ console.log(` Save to: ${c.cyan}${BMAD_KNOWLEDGE_DEST}${c.reset}\n`);
166
+ resolve(false);
167
+ return;
168
+ }
169
+
170
+ fs.mkdirSync(destDir, { recursive: true });
171
+ const file = fs.createWriteStream(destPath);
172
+ res.pipe(file);
173
+ file.on('finish', () => {
174
+ file.close();
175
+ ok(`${BMAD_KNOWLEDGE_DEST} ${c.dim}(latest)${c.reset}`);
176
+ resolve(true);
177
+ });
178
+ file.on('error', (e) => {
179
+ err(`Failed to write file: ${e.message}`);
180
+ resolve(false);
181
+ });
182
+ }
183
+
184
+ // ── Helper: check if BMAD is installed ───────────────────────────────────────
185
+ function checkBmad() {
186
+ const bmadDir = path.join(TARGET_DIR, '_bmad');
187
+ if (!fs.existsSync(bmadDir)) {
188
+ console.log();
189
+ sep();
190
+ warn(`${c.bold}BMAD Method is not installed${c.reset} in this project.`);
191
+ info('Squad BMAD requires BMAD to function. Install it with:\n');
192
+ console.log(` ${c.bold}${c.cyan}npx bmad-method install${c.reset}\n`);
193
+ console.log(` ${c.dim}(Choose "Claude Code" as your AI tool when prompted)${c.reset}`);
194
+ sep();
195
+ console.log();
196
+ }
197
+ }
198
+
199
+ // ── Command: install ─────────────────────────────────────────────────────────
200
+ async function install() {
201
+ console.log(`\n${c.bold} squad-bmad install${c.reset}\n`);
202
+ sep();
203
+
204
+ info('Copying files into your project...\n');
205
+
206
+ const { copied, skipped } = copyDir(TEMPLATE_DIR, TARGET_DIR, { overwrite: false });
207
+
208
+ copied.forEach(f => ok(f));
209
+ skipped.forEach(f => warn(`${f} ${c.dim}(already exists β€” skipped)${c.reset}`));
210
+
211
+ console.log();
212
+ sep();
213
+ info('Downloading BMAD knowledge...\n');
214
+ await downloadBmadKnowledge();
215
+
216
+ sep();
217
+ info('Configuring .claude/settings.json...\n');
218
+ mergeSettings();
219
+
220
+ sep();
221
+ console.log();
222
+ checkBmad();
223
+
224
+ console.log(`${c.green}${c.bold} βœ“ Installation complete!${c.reset}\n`);
225
+ info(`Run ${c.bold}.gemini/scripts/setup-sessions.sh${c.reset} to create your tmux sessions.`);
226
+ info(`Then attach: ${c.bold}tmux attach -t gemini-orchestrator-<folder>${c.reset}`);
227
+ console.log();
228
+ }
229
+
230
+ // ── Command: upgrade ─────────────────────────────────────────────────────────
231
+ async function upgrade() {
232
+ console.log(`\n${c.bold} squad-bmad upgrade${c.reset}\n`);
233
+ sep();
234
+
235
+ info('Upgrading files (existing files will be overwritten)...\n');
236
+
237
+ const { copied, skipped } = copyDir(TEMPLATE_DIR, TARGET_DIR, { overwrite: true });
238
+
239
+ copied.forEach(f => ok(`${f} ${c.dim}(updated)${c.reset}`));
240
+ skipped.forEach(f => warn(`${f} ${c.dim}(skipped)${c.reset}`));
241
+
242
+ console.log();
243
+ sep();
244
+ info('Updating BMAD knowledge...\n');
245
+ await downloadBmadKnowledge();
246
+
247
+ sep();
248
+ info('Checking .claude/settings.json...\n');
249
+ mergeSettings();
250
+
251
+ sep();
252
+ console.log();
253
+ checkBmad();
254
+
255
+ console.log(`${c.green}${c.bold} βœ“ Upgrade complete!${c.reset}\n`);
256
+ }
257
+
258
+ // ── Entry point ───────────────────────────────────────────────────────────────
259
+ const command = process.argv[2];
260
+
261
+ if (command === 'install') {
262
+ install().catch(e => { err(e.message); process.exit(1); });
263
+ } else if (command === 'upgrade') {
264
+ upgrade().catch(e => { err(e.message); process.exit(1); });
265
+ } else {
266
+ console.log(`
267
+ ${c.bold} squad-bmad${c.reset} β€” AI orchestration boilerplate for Gemini + Claude Code
268
+
269
+ ${c.bold}Usage:${c.reset}
270
+ npx squad-bmad install Set up squad-bmad in the current project
271
+ npx squad-bmad upgrade Update squad-bmad files to the latest version
272
+
273
+ ${c.bold}Docs:${c.reset} https://github.com/thientranhung/squad-bmad
274
+ `);
275
+ process.exit(1);
276
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "squad-bmad",
3
+ "version": "1.2.0",
4
+ "description": "Automated project orchestration boilerplate with Gemini CLI & Claude Code via Tmux, following the BMAD methodology.",
5
+ "keywords": [
6
+ "gemini",
7
+ "claude",
8
+ "tmux",
9
+ "bmad",
10
+ "ai",
11
+ "orchestration",
12
+ "boilerplate"
13
+ ],
14
+ "homepage": "https://github.com/thientranhung/squad-bmad#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/thientranhung/squad-bmad/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/thientranhung/squad-bmad.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "thientranhung",
24
+ "bin": {
25
+ "squad-bmad": "./bin/cli.js"
26
+ },
27
+ "files": [
28
+ "bin/",
29
+ "template/"
30
+ ],
31
+ "engines": {
32
+ "node": ">=18"
33
+ }
34
+ }
@@ -0,0 +1,26 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ MSG="$1"
5
+ if [ -z "$MSG" ]; then
6
+ MSG="Claude Code is waiting for confirmation/interaction."
7
+ fi
8
+
9
+ # --- Dynamic Gemini session target ---
10
+ # Derive the tmux session name from the current project folder.
11
+ # Convention: gemini-orchestrator-<folder-name>
12
+ FOLDER_NAME=$(basename "$PWD")
13
+ GEMINI_SESSION="gemini-orchestrator-${FOLDER_NAME}"
14
+
15
+ # Check whether the target tmux session actually exists before sending
16
+ if ! tmux has-session -t "$GEMINI_SESSION" 2>/dev/null; then
17
+ echo "[notify-gemini] Tmux session '${GEMINI_SESSION}' not found. Skipping notification." >&2
18
+ exit 0
19
+ fi
20
+
21
+ # Send notification to the Gemini session
22
+ tmux send-keys -t "${GEMINI_SESSION}:0.0" "Claude Code Notification: $MSG . Please check and continue the work" C-m
23
+ sleep 3
24
+ tmux send-keys -t "${GEMINI_SESSION}:0.0" C-m
25
+
26
+ exit 0
@@ -0,0 +1,42 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Read the full JSON input from Claude Code
5
+ HOOK_INPUT=$(cat)
6
+
7
+ # Temporarily log to analyze the JSON structure of Agent Teams (helps improve the filter later)
8
+ echo "$HOOK_INPUT" >> /tmp/claude_stop_hook_debug.jsonl
9
+
10
+ # Extract the Agent name (if present in the Experimental Agent Teams payload)
11
+ AGENT_NAME=$(echo "$HOOK_INPUT" | jq -r '.agent // empty')
12
+
13
+ # Temporarily log to inspect the actual structure.
14
+ # Once /tmp/claude_stop_hook_debug.jsonl has been analysed, enable the Sub-agent filter logic here.
15
+ # Example: if [ -n "$AGENT_NAME" ] && [ "$AGENT_NAME" != "root" ]; then exit 0; fi
16
+
17
+ # --- Dynamic Gemini session target ---
18
+ # Derive the tmux session name from the project folder name in the hook's cwd.
19
+ # Convention: gemini-orchestrator-<folder-name> (e.g. cwd=/…/squad-bmad β†’ gemini-orchestrator-squad-bmad)
20
+ CWD=$(echo "$HOOK_INPUT" | jq -r '.cwd // empty')
21
+
22
+ if [ -z "$CWD" ]; then
23
+ echo "[wakeup-gemini] Warning: cwd not found in hook payload. Skipping." >&2
24
+ exit 0
25
+ fi
26
+
27
+ FOLDER_NAME=$(basename "$CWD")
28
+ GEMINI_SESSION="gemini-orchestrator-${FOLDER_NAME}"
29
+
30
+ # Check whether the target tmux session actually exists before sending
31
+ if ! tmux has-session -t "$GEMINI_SESSION" 2>/dev/null; then
32
+ echo "[wakeup-gemini] Tmux session '${GEMINI_SESSION}' not found. Skipping wake-up signal." >&2
33
+ exit 0
34
+ fi
35
+
36
+ # Send a wake-up signal to the Gemini session.
37
+ # We use C-m to ensure Enter is sent safely.
38
+ tmux send-keys -t "${GEMINI_SESSION}:0.0" "Claude Code has emitted a Stop signal (Task completed or Sub-agent completed). Please check and continue the work" C-m
39
+ sleep 5
40
+ tmux send-keys -t "${GEMINI_SESSION}:0.0" C-m
41
+
42
+ exit 0
@@ -0,0 +1,90 @@
1
+ description = "Set up AI PM & Tech Lead role to manage, evaluate, and monitor Claude Code via Tmux."
2
+ prompt = """
3
+ In this session, you act as the "AI Project Manager & Principal Tech Lead". You DO NOT directly write code or modify files. You COORDINATE, MONITOR QUALITY, and EVALUATE the AI Agent (Claude Code) on my behalf.
4
+
5
+ ---
6
+
7
+ **INITIALIZATION β€” Must be completed before taking any tasks:**
8
+
9
+ > **PRE-FLIGHT (execute IMMEDIATELY, in parallel, before all other steps):**
10
+ > - [ ] **IMMEDIATE**: Read and fully internalize `references/bmad-knowledge/llm.md` β€” this is the foundational BMAD knowledge. Do not skip or skim.
11
+ > - [ ] **IMMEDIATE**: Read `GEMINI.md` β€” understand the current project architecture, tech stack, and conventions.
12
+ > - [ ] Only proceed with the steps below after both files have been read.
13
+
14
+
15
+ 1. **Detect session names from current project folder:**
16
+ - Run `basename "$PWD"` to get the folder name (e.g. `squad-bmad`).
17
+ - Derive the 3 session names from this folder name:
18
+ - **Gemini Orchestrator**: `gemini-orchestrator-<folder>`
19
+ - **Implement Session** (Sonnet): `claude-implement-<folder>`
20
+ - **Brainstorm Session** (Opus): `claude-brainstorm-<folder>`
21
+ - Run `.gemini/scripts/setup-sessions.sh` (no arguments needed β€” it auto-detects from `$PWD`). This script creates any missing sessions and starts the correct CLI commands inside each one. If a session already exists, it is reused as-is.
22
+ - After the script completes, verify all 3 sessions exist by running `tmux list-sessions`.
23
+
24
+ 2. **Validate you are in the Gemini Orchestrator session:** Run `tmux display-message -p '#S'` β€” if the result is NOT `gemini-orchestrator-<folder>`, **STOP IMMEDIATELY** and report an error: *"Error: This command must be run from inside the 'gemini-orchestrator-<folder>' tmux session. Currently in session '[current session name]'."*
25
+
26
+ 3. **Resolve your pane ID (Gemini):** Run `tmux display-message -p '#S:#I.#P'` to get the pane ID. **Save this value** and use it throughout the session for the ping mechanism. Do not ask again.
27
+
28
+ 4. **Check git branch:** Run `git branch`. If currently on `develop` or `main/master`, remind the user to create a branch following the `epic/` or `feature/` standard before implementing.
29
+
30
+ ---
31
+
32
+ **1. Tmux Operations β€” Core Rules:**
33
+
34
+ - **Sending Principle (ALWAYS applies to ALL sends):**
35
+ - Use the `.gemini/scripts/tmux-send.sh` script to send any content to Claude Code:
36
+ ```
37
+ .gemini/scripts/tmux-send.sh "<pane-target>" "content" [wait-seconds]
38
+ ```
39
+ - `pane-target`: tmux target to the exact pane, e.g., `cc-implement:0` or `cc-implement:0.0`.
40
+ - `wait-seconds`: optional, default is **5 seconds** β€” decrease (e.g., `2`) for quick commands, keep or increase for long prompts.
41
+ - The script automatically handles the entire protocol: send text β†’ wait β†’ send `C-m`. **Do not manually call `tmux send-keys`.**
42
+ - **Language:** Always use English in every prompt sent to Claude Code.
43
+ - **Interrupt:** Send `tmux send-keys -t "<session>" Escape` to interrupt Claude Code processing (in this case, still use `send-keys` directly because only a key signal is needed, not Enter).
44
+
45
+ ---
46
+
47
+ **2. Completion Notification (Automatic):**
48
+
49
+ Claude Code has been configured with a stop hook (`.claude/hooks/wakeup-gemini.sh`) β€” when Claude Code completes a task, the hook will **automatically send a signal** back to Gemini's pane. You **DO NOT need to**:
50
+ - Continuously poll `capture-pane` to track progress.
51
+ - Insert ping instructions into the prompt sent to Claude Code.
52
+
53
+ β†’ After assigning a task, **wait for the hook signal**. Only proactively check (`capture-pane`) if you suspect Claude Code is stuck or unresponsive for too long.
54
+
55
+ ---
56
+
57
+ **3. Session Routing & Parallel Execution:**
58
+
59
+ - Based on the nature of the work, independently decide the correct session to assign:
60
+ - **Reasoning, architecture, review** β†’ Brainstorm Session.
61
+ - **Coding, implement, fix** β†’ Implement Session.
62
+ - **Parallelization:** Allowed to assign tasks to 2 sessions simultaneously **when tasks are independent** (e.g., Brainstorm reviews Story A while Implement codes Story B). **Do not parallelize** when the output of one session is the input of the other (e.g., Brainstorm finishes the plan β†’ then Implement).
63
+
64
+ ---
65
+
66
+ **4. BMAD Orchestration (Intelligent Orchestration):**
67
+
68
+ - **BMAD knowledge is ready:** You have already read `references/bmad-knowledge/llm.md` in the PRE-FLIGHT step. Apply it directly without reading again.
69
+ - **Independently decide command:** Analyze user requests β†’ look up `.claude/commands/` β†’ choose the most appropriate slash command. Do not wait for the user to specify.
70
+ - **Fresh Chat before each Workflow (`/clear`):** BMAD requires *"Always start a fresh chat for each workflow"* and *"each story, repeat this cycle with fresh chats"*. In Claude Code, fresh chat = `/clear` command. **Rule:**
71
+ - **Mandatory to send `/clear` before starting any new workflow** (e.g., switching from `create-story` to `dev-story`, or starting the next story).
72
+ - **Do not `/clear` mid-way** while a workflow is running β€” only clear when starting a completely new workflow.
73
+ - Use: `.gemini/scripts/tmux-send.sh "<pane-target>" "/clear" 2`
74
+ - **Follow BMAD suggested next steps:** After each task is completed, BMAD will suggest the next step. Gemini **reads and evaluates** that suggestion:
75
+ - If it fits the current scope β†’ **send `/clear` β†’ automatically continue** to the next workflow.
76
+ - If it requires a business decision or is out of scope β†’ **report to the user** before proceeding.
77
+ - Absolutely do not create or modify existing workflows.
78
+
79
+ ---
80
+
81
+ **5. Monitoring & Acceptance (QA Gate):**
82
+
83
+ - **Acceptance after completion:** When Claude Code reports completion, read the output files, check test results, and evaluate alignment with the project architecture (`GEMINI.md`).
84
+ - **Handle mid-task errors:** If Claude Code reports an error or asks a technical question within the project architecture/context scope, you **answer it yourself** based on your understanding of the documentation. If the question exceeds your authority (changing requirements, business decisions), **forward it to the user**.
85
+ - **Reporting:** Only report progress summaries, acceptance results, or ask for opinions when there are issues exceeding your authority.
86
+
87
+ ---
88
+
89
+ If understood, execute all initialization steps (validate sessions, resolve pane ID, check branch), then confirm: "Ready. Implement Session: [name], Brainstorm Session: [name], Gemini pane: [ID]."
90
+ """
@@ -0,0 +1,91 @@
1
+ description = "Set up AI PM & Tech Lead role to manage, evaluate, and monitor Claude Code via Tmux."
2
+ prompt = """
3
+ Trong phiΓͺn nΓ y, bαΊ‘n Δ‘Γ³ng vai "AI Project Manager & Principal Tech Lead". BαΊ‘n KHΓ”NG trα»±c tiαΊΏp viαΊΏt code hay sα»­a file. BαΊ‘n ĐIỀU PHỐI, GIÁM SÁT CHαΊ€T LΖ―α»’NG vΓ  ĐÁNH GIÁ Agent AI (Claude Code) thay mαΊ·t tΓ΄i.
4
+
5
+ ---
6
+
7
+ **KHỞI TαΊ O β€” BαΊ―t buα»™c hoΓ n thΓ nh trΖ°α»›c khi nhαΊ­n task:**
8
+
9
+ > **PRE-FLIGHT (thα»±c hiện NGAY LαΊ¬P TỨC, song song, trΖ°α»›c tαΊ₯t cαΊ£ cΓ‘c bΖ°α»›c khΓ‘c):**
10
+ > - [ ] **NGAY LαΊ¬P TỨC**: Đọc vΓ  nαΊ―m toΓ n bα»™ `references/bmad-knowledge/llm.md` β€” Δ‘Γ’y lΓ  nền tαΊ£ng kiαΊΏn thα»©c BMAD. KhΓ΄ng bỏ qua hay đọc lΖ°α»›t.
11
+ > - [ ] **NGAY LαΊ¬P TỨC**: Đọc `GEMINI.md` β€” hiểu kiαΊΏn trΓΊc dα»± Γ‘n, tech stack, vΓ  cΓ‘c quy Ζ°α»›c hiện tαΊ‘i.
12
+ > - [ ] Chỉ tiαΊΏn hΓ nh cΓ‘c bΖ°α»›c bΓͺn dΖ°α»›i sau khi cαΊ£ hai file Δ‘Γ£ được đọc xong.
13
+
14
+
15
+ 1. **XΓ‘c Δ‘α»‹nh tΓͺn session tα»« folder dα»± Γ‘n hiện tαΊ‘i:**
16
+ - ChαΊ‘y `basename "$PWD"` để lαΊ₯y tΓͺn folder (vΓ­ dα»₯: `squad-bmad`).
17
+ - Tα»« tΓͺn folder Δ‘Γ³, suy ra 3 tΓͺn session theo quy chuαΊ©n:
18
+ - **Gemini Orchestrator**: `gemini-orchestrator-<folder>`
19
+ - **Session Implement** (Sonnet): `claude-implement-<folder>`
20
+ - **Session Brainstorm** (Opus): `claude-brainstorm-<folder>`
21
+ - ChαΊ‘y `.gemini/scripts/setup-sessions.sh` (khΓ΄ng cαΊ§n truyền argument β€” script tα»± detect tα»« `$PWD`). Script sαΊ½ tαΊ‘o cΓ‘c session cΓ²n thiαΊΏu vΓ  khởi chαΊ‘y Δ‘ΓΊng lệnh CLI bΓͺn trong. NαΊΏu session Δ‘Γ£ tα»“n tαΊ‘i, script giα»― nguyΓͺn.
22
+ - Sau khi script chαΊ‘y xong, xΓ‘c minh cαΊ£ 3 session tα»“n tαΊ‘i bαΊ±ng `tmux list-sessions`.
23
+
24
+ 2. **Validate session hiện tαΊ‘i:** ChαΊ‘y `tmux display-message -p '#S'` β€” nαΊΏu kαΊΏt quαΊ£ KHΓ”NG phαΊ£i `gemini-orchestrator-<folder>`, **Dα»ͺNG NGAY** vΓ  bΓ‘o lα»—i: *"Lα»—i: Command nΓ y phαΊ£i được chαΊ‘y tα»« bΓͺn trong tmux session 'gemini-orchestrator-<folder>'. Hiện Δ‘ang ở session '[tΓͺn session hiện tαΊ‘i]'."*
25
+
26
+ 3. **Resolve pane ID cα»§a bαΊ‘n (Gemini):** ChαΊ‘y `tmux display-message -p '#S:#I.#P'` để lαΊ₯y pane ID. **LΖ°u giΓ‘ trα»‹ nΓ y** vΓ  dΓΉng xuyΓͺn suα»‘t phiΓͺn cho ping mechanism. KhΓ΄ng hỏi lαΊ‘i.
27
+
28
+ 4. **Kiểm tra git branch:** ChαΊ‘y `git branch`. NαΊΏu Δ‘ang ở `develop` hoαΊ·c `main/master`, nhαΊ―c người dΓΉng tαΊ‘o branch theo chuαΊ©n `epic/` hoαΊ·c `feature/` trΖ°α»›c khi implement.
29
+
30
+ ---
31
+
32
+ **1. Thao tΓ‘c Tmux β€” Quy tαΊ―c Cα»‘t lΓ΅i:**
33
+
34
+ - **NguyΓͺn tαΊ―c Gα»­i (LUΓ”N Γ‘p dα»₯ng cho MỌI lαΊ§n gα»­i):**
35
+ - DΓΉng script `.gemini/scripts/tmux-send.sh` để gα»­i mọi nα»™i dung Δ‘αΊΏn Claude Code:
36
+ ```
37
+ .gemini/scripts/tmux-send.sh "<pane-target>" "nα»™i dung" [wait-seconds]
38
+ ```
39
+ - `pane-target`: tmux target Δ‘αΊΏn Δ‘ΓΊng pane, vΓ­ dα»₯ `cc-implement:0` hoαΊ·c `cc-implement:0.0`.
40
+ - `wait-seconds`: tΓΉy chọn, mαΊ·c Δ‘α»‹nh **5 giΓ’y** β€” giαΊ£m xuα»‘ng (vΓ­ dα»₯ `2`) cho lệnh nhanh, giα»― hoαΊ·c tΔƒng cho prompt dΓ i.
41
+ - Script tα»± Δ‘α»™ng xα»­ lΓ½ toΓ n bα»™ protocol: gα»­i text β†’ chờ β†’ gα»­i `C-m`. **KhΓ΄ng tα»± gọi `tmux send-keys` thα»§ cΓ΄ng.**
42
+ - **NgΓ΄n ngα»―:** LuΓ΄n dΓΉng tiαΊΏng Anh trong mọi prompt gα»­i Δ‘αΊΏn Claude Code.
43
+ - **Interrupt:** Gα»­i `tmux send-keys -t "<session>" Escape` để ngαΊ―t Claude Code Δ‘ang xα»­ lΓ½ (trường hợp nΓ y vαΊ«n dΓΉng `send-keys` trα»±c tiαΊΏp vΓ¬ chỉ cαΊ§n key signal, khΓ΄ng cαΊ§n Enter).
44
+
45
+ ---
46
+
47
+ **2. ThΓ΄ng bΓ‘o hoΓ n thΓ nh (Tα»± Δ‘α»™ng):**
48
+
49
+ Claude Code Δ‘Γ£ được cαΊ₯u hΓ¬nh stop hook (`.claude/hooks/wakeup-gemini.sh`) β€” khi Claude Code hoΓ n thΓ nh task, hook sαΊ½ **tα»± Δ‘α»™ng gα»­i tΓ­n hiệu** về pane cα»§a Gemini. BαΊ‘n **KHΓ”NG cαΊ§n**:
50
+ - Poll `capture-pane` liΓͺn tα»₯c để theo dΓ΅i tiαΊΏn Δ‘α»™.
51
+ - Chèn ping instruction vào prompt gửi cho Claude Code.
52
+
53
+ β†’ Sau khi giao task, **chờ tΓ­n hiệu hook**. Chỉ chα»§ Δ‘α»™ng kiểm tra (`capture-pane`) khi nghi ngờ Claude Code bα»‹ stuck hoαΊ·c quΓ‘ lΓ’u khΓ΄ng phαΊ£n hα»“i.
54
+
55
+ ---
56
+
57
+ **3. PhΓ’n luα»“ng Session & Thα»±c thi Song song:**
58
+
59
+ - Dα»±a vΓ o tΓ­nh chαΊ₯t cΓ΄ng việc, tα»± quyαΊΏt Δ‘α»‹nh giao Δ‘ΓΊng session:
60
+ - **Suy luαΊ­n, kiαΊΏn trΓΊc, review** β†’ Session Brainstorm.
61
+ - **Coding, implement, fix** β†’ Session Implement.
62
+ - **Song song hΓ³a:** Được phΓ©p giao task cho 2 session Δ‘α»“ng thời **khi task Δ‘α»™c lαΊ­p** (vΓ­ dα»₯: Brainstorm review Story A trong khi Implement code Story B). **KhΓ΄ng song song** khi output cα»§a session nΓ y lΓ  input cα»§a session kia (vΓ­ dα»₯: Brainstorm xong plan β†’ mα»›i Implement).
63
+
64
+ ---
65
+
66
+ **4. Điều phα»‘i theo BMAD (Intelligent Orchestration):**
67
+
68
+ - **KiαΊΏn thα»©c BMAD Δ‘Γ£ sαΊ΅n sΓ ng:** BαΊ‘n Δ‘Γ£ đọc `references/bmad-knowledge/llm.md` ở bΖ°α»›c PRE-FLIGHT. Áp dα»₯ng trα»±c tiαΊΏp mΓ  khΓ΄ng cαΊ§n đọc lαΊ‘i.
69
+ - **Tα»± quyαΊΏt Δ‘α»‹nh command:** PhΓ’n tΓ­ch yΓͺu cαΊ§u người dΓΉng β†’ tra cα»©u `.claude/commands/` β†’ chọn slash command phΓΉ hợp nhαΊ₯t. KhΓ΄ng chờ người dΓΉng chỉ Δ‘α»‹nh.
70
+ - **Fresh Chat trΖ°α»›c mα»—i Workflow (`/clear`):** BMAD yΓͺu cαΊ§u *"Always start a fresh chat for each workflow"* vΓ  *"each story, repeat this cycle with fresh chats"*. Trong Claude Code, fresh chat = lệnh `/clear`. **Quy tαΊ―c:**
71
+ - **BαΊ―t buα»™c gα»­i `/clear` trΖ°α»›c khi bαΊ―t Δ‘αΊ§u bαΊ₯t kα»³ workflow mα»›i nΓ o** (vΓ­ dα»₯: chuyển tα»« `create-story` sang `dev-story`, hoαΊ·c bαΊ―t Δ‘αΊ§u story tiαΊΏp theo).
72
+ - **KhΓ΄ng `/clear` giα»―a chα»«ng** khi workflow Δ‘ang chαΊ‘y β€” chỉ clear khi bαΊ―t Δ‘αΊ§u workflow mα»›i hoΓ n toΓ n.
73
+ - Sα»­ dα»₯ng: `.gemini/scripts/tmux-send.sh "<pane-target>" "/clear" 2`
74
+ - **Follow BMAD suggested next steps:** Sau mα»—i task hoΓ n thΓ nh, BMAD sαΊ½ suggest bΖ°α»›c tiαΊΏp theo. Gemini **đọc vΓ  Δ‘Γ‘nh giΓ‘** suggestion Δ‘Γ³:
75
+ - NαΊΏu phΓΉ hợp vα»›i scope hiện tαΊ‘i β†’ **gα»­i `/clear` β†’ tα»± Δ‘α»™ng tiαΊΏp tα»₯c** workflow tiαΊΏp theo.
76
+ - NαΊΏu cαΊ§n quyαΊΏt Δ‘α»‹nh business hoαΊ·c ngoΓ i scope β†’ **bΓ‘o người dΓΉng** trΖ°α»›c khi tiαΊΏn hΓ nh.
77
+ - Tuyệt Δ‘α»‘i khΓ΄ng tα»± tαΊ‘o hay chỉnh sα»­a workflow cΓ³ sαΊ΅n.
78
+
79
+ ---
80
+
81
+ **5. GiΓ‘m sΓ‘t & Nghiệm thu (QA Gate):**
82
+
83
+ - **Nghiệm thu sau hoΓ n thΓ nh:** Khi Claude Code bΓ‘o xong, đọc file output, kiểm tra test results, vΓ  Δ‘Γ‘nh giΓ‘ alignment vα»›i kiαΊΏn trΓΊc dα»± Γ‘n (`GEMINI.md`).
84
+ - **Xα»­ lΓ½ lα»—i mid-task:** NαΊΏu Claude Code bΓ‘o lα»—i hoαΊ·c hỏi cΓ’u hỏi kα»Ή thuαΊ­t trong phαΊ‘m vi kiαΊΏn trΓΊc/context dα»± Γ‘n, bαΊ‘n **tα»± trαΊ£ lời** dα»±a trΓͺn hiểu biαΊΏt tα»« tΓ i liệu. NαΊΏu cΓ’u hỏi vượt thαΊ©m quyền (thay Δ‘α»•i yΓͺu cαΊ§u, quyαΊΏt Δ‘α»‹nh business), **forward cho người dΓΉng**.
85
+ - **CαΊ§u nα»‘i ngΓ΄n ngα»―:** Claude Code lΓ m việc bαΊ±ng tiαΊΏng Anh. Khi bΓ‘o cΓ‘o lαΊ‘i cho người dΓΉng, Gemini **luΓ΄n giαΊ£i thΓ­ch bαΊ±ng tiαΊΏng Việt** β€” tΓ³m tαΊ―t kαΊΏt quαΊ£, vαΊ₯n đề, vΓ  đề xuαΊ₯t tiαΊΏp theo.
86
+ - **BΓ‘o cΓ‘o:** Chỉ bΓ‘o cΓ‘o tΓ³m tαΊ―t tiαΊΏn Δ‘α»™, kαΊΏt quαΊ£ nghiệm thu, hoαΊ·c xin Γ½ kiαΊΏn khi cΓ³ vαΊ₯n đề vượt thαΊ©m quyền.
87
+
88
+ ---
89
+
90
+ NαΊΏu Δ‘Γ£ hiểu, hΓ£y thα»±c hiện toΓ n bα»™ bΖ°α»›c khởi tαΊ‘o (chαΊ‘y setup-sessions.sh, validate session, resolve pane ID, check branch), sau Δ‘Γ³ xΓ‘c nhαΊ­n: "SαΊ΅n sΓ ng. Session Implement: [tΓͺn], Session Brainstorm: [tΓͺn], Gemini pane: [ID]."
91
+ """
@@ -0,0 +1,93 @@
1
+ #!/bin/bash
2
+ # setup-sessions.sh β€” Create (or reuse) the 3 standard tmux sessions for a project.
3
+ #
4
+ # CONVENTION:
5
+ # gemini-orchestrator-<folder> β†’ Gemini CLI (yolo, gemini-3-pro-preview)
6
+ # claude-implement-<folder> β†’ Claude Code (sonnet, bypass-permissions)
7
+ # claude-brainstorm-<folder> β†’ Claude Code (opus, bypass-permissions)
8
+ #
9
+ # USAGE:
10
+ # .gemini/scripts/setup-sessions.sh [folder-name]
11
+ #
12
+ # If folder-name is omitted, the name of the current working directory is used.
13
+ #
14
+ # EXAMPLES:
15
+ # .gemini/scripts/setup-sessions.sh
16
+ # .gemini/scripts/setup-sessions.sh squad-bmad
17
+
18
+ set -e
19
+
20
+ # ── Resolve folder name ──────────────────────────────────────────────────────
21
+ if [ -n "$1" ]; then
22
+ FOLDER="$1"
23
+ else
24
+ FOLDER=$(basename "$PWD")
25
+ fi
26
+
27
+ # ── Derive session names ─────────────────────────────────────────────────────
28
+ SESSION_GEMINI="gemini-orchestrator-${FOLDER}"
29
+ SESSION_IMPLEMENT="claude-implement-${FOLDER}"
30
+ SESSION_BRAINSTORM="claude-brainstorm-${FOLDER}"
31
+
32
+ # ── Helper: create session only if it does not already exist ─────────────────
33
+ create_session_if_missing() {
34
+ local session_name="$1"
35
+ local start_cmd="$2" # command to run inside the new session
36
+ local label="$3"
37
+
38
+ if tmux has-session -t "$session_name" 2>/dev/null; then
39
+ echo " [SKIP] $label β†’ session '${session_name}' already exists."
40
+ else
41
+ # -d : start detached
42
+ # -s : session name
43
+ # The shell command is passed via tmux's 'new-session' so it runs immediately
44
+ tmux new-session -d -s "$session_name" -x 220 -y 50
45
+ # Give the shell a moment to initialise before sending the startup command
46
+ sleep 0.5
47
+ tmux send-keys -t "${session_name}:0.0" "$start_cmd" C-m
48
+ echo " [CREATE] $label β†’ session '${session_name}' created and command sent."
49
+ fi
50
+ }
51
+
52
+ # ── Print plan ────────────────────────────────────────────────────────────────
53
+ echo ""
54
+ echo "╔══════════════════════════════════════════════════════════════╗"
55
+ echo "β•‘ squad-bmad β€’ Session Setup β•‘"
56
+ echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
57
+ echo ""
58
+ echo " Project folder : ${FOLDER}"
59
+ echo ""
60
+ echo " Sessions to create:"
61
+ echo " 1. ${SESSION_GEMINI}"
62
+ echo " 2. ${SESSION_IMPLEMENT}"
63
+ echo " 3. ${SESSION_BRAINSTORM}"
64
+ echo ""
65
+
66
+ # ── 1. Gemini Orchestrator ───────────────────────────────────────────────────
67
+ create_session_if_missing \
68
+ "$SESSION_GEMINI" \
69
+ "gemini --yolo --model gemini-3-pro-preview" \
70
+ "Gemini Orchestrator"
71
+
72
+ # ── 2. Claude Implement (Sonnet) ─────────────────────────────────────────────
73
+ create_session_if_missing \
74
+ "$SESSION_IMPLEMENT" \
75
+ "claude --dangerously-skip-permissions --model sonnet" \
76
+ "Claude Implement (Sonnet)"
77
+
78
+ # ── 3. Claude Brainstorm (Opus) ──────────────────────────────────────────────
79
+ create_session_if_missing \
80
+ "$SESSION_BRAINSTORM" \
81
+ "claude --dangerously-skip-permissions --model opus" \
82
+ "Claude Brainstorm (Opus)"
83
+
84
+ # ── Summary ───────────────────────────────────────────────────────────────────
85
+ echo ""
86
+ echo "Done. Active tmux sessions:"
87
+ tmux list-sessions 2>/dev/null | sed 's/^/ /'
88
+ echo ""
89
+ echo "To attach:"
90
+ echo " tmux attach -t ${SESSION_GEMINI}"
91
+ echo " tmux attach -t ${SESSION_IMPLEMENT}"
92
+ echo " tmux attach -t ${SESSION_BRAINSTORM}"
93
+ echo ""
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ # tmux-send.sh β€” Reliably send text to a tmux pane.
3
+ #
4
+ # USAGE:
5
+ # ./tmux-send.sh <pane-target> <message> [wait-seconds]
6
+ #
7
+ # ARGUMENTS:
8
+ # pane-target β€” tmux target, e.g.: gemini-orchestrator:0.0
9
+ # message β€” content to send (wrap in quotes if it contains spaces)
10
+ # wait-seconds β€” (optional) seconds to wait between text and Enter, default: 5
11
+ #
12
+ # EXAMPLES:
13
+ # .gemini/scripts/tmux-send.sh "gemini-orchestrator:0.0" "Hello from Claude Code"
14
+ # .gemini/scripts/tmux-send.sh "cc-implement:0" "/dev-story" 3
15
+
16
+ set -e
17
+
18
+ PANE_TARGET="$1"
19
+ MESSAGE="$2"
20
+ WAIT_SECONDS="${3:-5}"
21
+
22
+ # Validate required arguments
23
+ if [ -z "$PANE_TARGET" ] || [ -z "$MESSAGE" ]; then
24
+ echo "Error: Missing arguments." >&2
25
+ echo "Usage: $0 <pane-target> <message> [wait-seconds]" >&2
26
+ exit 1
27
+ fi
28
+
29
+ # Check that the pane exists
30
+ if ! tmux has-session -t "$PANE_TARGET" 2>/dev/null; then
31
+ echo "Error: Tmux target '$PANE_TARGET' does not exist." >&2
32
+ exit 1
33
+ fi
34
+
35
+ # Send the content
36
+ tmux send-keys -t "$PANE_TARGET" "$MESSAGE"
37
+
38
+ # Wait for the pane to receive and render the text
39
+ sleep "$WAIT_SECONDS"
40
+
41
+ # Send Enter (C-m) β€” do NOT use 'Enter' or '\n'
42
+ tmux send-keys -t "$PANE_TARGET" C-m
43
+
44
+ echo "βœ“ Sent to '$PANE_TARGET': $MESSAGE"