@kodevibe/harness 0.8.3

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.
@@ -0,0 +1,326 @@
1
+ # Bootstrap
2
+
3
+ ## Purpose
4
+
5
+ Onboard a new or existing project into Musher by filling **state files AND rules files** automatically.
6
+ Solves the cold-start problem: users don't know which `.md` files to fill or how.
7
+ One command does everything — no manual editing required.
8
+
9
+ ## When to Apply
10
+
11
+ - Right after running `musher init` on a new project
12
+ - When joining an existing project that has empty state files
13
+ - When state files are outdated and need a refresh
14
+ - When any agent reports "state files are empty"
15
+
16
+ ## Procedure
17
+
18
+ ### Phase 1: Project Discovery (read-only)
19
+
20
+ 1. **Scan project root** for configuration files:
21
+ - `package.json`, `tsconfig.json` → Node.js/TypeScript
22
+ - `go.mod`, `go.sum` → Go
23
+ - `requirements.txt`, `pyproject.toml`, `setup.py` → Python
24
+ - `pom.xml`, `build.gradle` → Java
25
+ - `Cargo.toml` → Rust
26
+ - `Gemfile` → Ruby
27
+ 2. **Scan directory structure**: List top-level directories and identify patterns
28
+ - `src/`, `lib/`, `app/` → source code
29
+ - `tests/`, `test/`, `__tests__/`, `spec/` → test directories
30
+ - `docs/` → documentation
31
+ 3. **Framework Coexistence Check** (경량 — 1회 list_dir만 사용):
32
+ 프로젝트 루트 `list_dir` 결과에서 아래 패턴과 매칭하여 존재 목록만 생성한다.
33
+ **⚠️ 내부 파일 스캔 금지** — 디렉토리 안의 파일을 읽거나 나열하지 않는다.
34
+
35
+ | 패턴 | 프레임워크 |
36
+ |------|:-----------|
37
+ | `.bmad-core/` | BMAD-METHOD |
38
+ | `.claude/` | Claude Code |
39
+ | `.cursor/` | Cursor |
40
+ | `.windsurf/` | Windsurf |
41
+ | `.gemini/` | Gemini |
42
+ | `.clinerules/` or `.cline/` | Cline |
43
+ | `.github/chatmodes/` | GitHub Chatmodes |
44
+ | `AGENTS.md` | Codex / OpenAI |
45
+ | `opencode.jsonc` | OpenCode |
46
+
47
+ > `.github/chatmodes/`는 `.github/` 하위이므로, `.github/` 존재 시 1회 추가 list_dir 허용.
48
+ > 감지된 프레임워크는 State file에 "공존 프레임워크: [목록]"으로 기록한다.
49
+
50
+ 4. **Scan for existing tests**: Find test files and map them to source modules
51
+ 5. **Scan imports/dependencies**: Trace module relationships from import statements
52
+
53
+ **Do NOT modify any code files in this phase.**
54
+
55
+ <!-- CREW_MODE_START -->
56
+ ### Phase 1.5: Crew Artifact Detection + Indexing
57
+
58
+ Check if external planning artifacts exist:
59
+ - `docs/crew/` directory — kode:crew output (requirements, analysis, design docs)
60
+ - `docs/PM/`, `docs/Analyst/`, `docs/ARB/` directories — kode:crew role-based output
61
+ - User-provided documents — requirements specs, wireframes, API designs
62
+ - User mentions "산출물", "PRD", "요구사항", "설계서" in their prompt
63
+
64
+ **If crew artifacts are found:**
65
+
66
+ 1. **Catalog all documents** with path, estimated role (Analyst/PM/ARB/unknown), and key contents
67
+ 2. **Check existing state**: If `docs/project-brief.md` already has a `## Crew Artifact Index` section with content:
68
+ - Ask user: "⚠️ 기존 crew 산출물이 이미 인덱싱되어 있습니다. 재인덱싱하겠습니까?" (user confirms or skips)
69
+ - If project-brief is empty (first crew sync) → proceed with full indexing
70
+ 3. **Lazy Read Protocol로 산출물 읽기** (⚠️ 전문 읽기 금지):
71
+
72
+ **Step A: 구조 스캔 (첫 50줄)**
73
+ - 각 산출물의 **첫 50줄만** 읽는다 (목차, 헤더, Executive Summary)
74
+ - 이 50줄에서 추출: 프로젝트 비전, 목표, 비목표, 기술 스택, FR/KPI/ARB 목록 존재 여부
75
+ - 문서 구조를 파악한다 (어떤 섹션이 몇 번째 줄에 있는지)
76
+ - 첫 50줄에 목차가 없으면 60줄까지 확장 허용
77
+
78
+ **Step B: 선택적 상세 읽기**
79
+ - State file 작성에 필요한 섹션만 추가로 읽는다:
80
+ - PRD → "Functional Requirements", "KPI", "Non-Functional Requirements" 섹션
81
+ - Architecture → "Tech Stack", "Module 구조" 섹션
82
+ - ARB Checklist → "Fail Items" 섹션만 (Pass 항목은 불필요)
83
+ - Product Brief → "Vision" + "Persona" 섹션
84
+ - **읽지 않는 섹션**: 배경, 시장 분석, 상세 설명, 참고 자료 등
85
+
86
+ > 효과: PRD 336줄 → ~130줄 (61% 감소), 4개 산출물 총합 885줄 → ~350줄 (60% 감소)
87
+
88
+ 4. **Create Artifact Index** in `docs/project-brief.md`:
89
+ - Add `## Crew Artifact Index` table with: Artifact name, Path, Role, key contents summary (one line each)
90
+ 5. **Extract Minimum** for quick reference (these go into the standard sections of project-brief.md):
91
+ - Vision: 1-2 sentences from product-brief
92
+ - Goals: KPI list from product-brief (measurable items only, not full descriptions)
93
+ - Non-Goals: Out-of-scope list from PRD or product-brief
94
+ - Key Technical Decisions: tech stack from architecture doc
95
+ 6. **Build Validation Tracker** in `docs/project-brief.md`:
96
+ - `### KPI Coverage`: extract KPI items from product-brief → create table with ID, KPI, Source, Story (empty), Status (⬜)
97
+ - `### ARB Fail Resolution`: extract Fail items from arb-checklist → create table with ID, Item, Severity (CRITICAL/HIGH), Story (empty), Status (⬜ Required)
98
+ - `### FR Coverage`: extract FR-NNN items from PRD → create table with FR, Description, Priority (P0/P1/P2), Stories (empty), Status (⬜)
99
+ 7. **Confirm with user**: "Crew 산출물 [N]개를 발견했습니다. Artifact Index와 Validation Tracker를 생성합니다. 맞나요?"
100
+ - If user says **yes** → proceed with Phase 3 using crew artifact data
101
+ - If user says **no** → skip Artifact Index/Tracker creation, proceed with regular Phase 2 interview (treat as 🟢 pipeline)
102
+ 8. **Skip most Phase 2 questions** — use artifact data instead. Only confirm implementation-specific decisions (test framework, specific library choices).
103
+ 9. Proceed to Phase 3 using extracted data
104
+
105
+ **Original crew documents are NEVER modified. Only the index and tracker are created.**
106
+
107
+ **Crew Artifact Path Detection** (bootstrap detects all patterns, priority order):
108
+ 1. Pattern C: User-provided paths (explicit in prompt) — highest priority, always authoritative
109
+ 2. Pattern B: `docs/crew/` (consolidated directory)
110
+ 3. Pattern A: `docs/PM/`, `docs/Analyst/`, `docs/ARB/` (kode:crew role-based directories)
111
+ 4. Pattern D: `docs/` files containing `prd`, `product-brief`, `architecture`, `checklist` keywords — lowest priority, fallback scan
112
+ - If multiple patterns match, use the highest priority source. Artifact Index records the actual discovered paths.
113
+
114
+ **If no crew artifacts:** Continue to Phase 2 (User Interview) normally.
115
+ <!-- CREW_MODE_END -->
116
+
117
+ ### Phase 2: User Interview (interactive)
118
+
119
+ Ask the user these questions (skip any already answered by Phase 1):
120
+
121
+ 1. "What does this project do? (one sentence)"
122
+ 2. "What are the top 3 goals of this project?"
123
+ 3. "What is explicitly OUT of scope? (non-goals)"
124
+ 4. "What architecture pattern are you using?" (show detected pattern if found)
125
+ 5. "Are there any type decisions or conventions the AI should know about?"
126
+ 6. "What is your test command?" (show detected command if found, e.g., `npm test`, `pytest`, `go test ./...`)
127
+
128
+ ### Phase 3: Fill State Files
129
+
130
+ Using data from Phase 1 + Phase 2, fill the following files:
131
+
132
+ **docs/project-brief.md**:
133
+ - Project Name → from package.json name, go.mod module, or user input
134
+ - Vision → from user answer #1
135
+ - Goals → from user answer #2
136
+ - Non-Goals → from user answer #3
137
+ <!-- CREW_MODE_START -->
138
+ - Crew Artifact Index → from Phase 1.5 (🟣 pipeline only — leave as template comment for 🟢 pipeline)
139
+ - Validation Tracker → from Phase 1.5 (🟣 pipeline only — leave as template comment for 🟢 pipeline)
140
+ <!-- CREW_MODE_END -->
141
+ - Key Technical Decisions → from Phase 1 scan + user answer #4, #5
142
+
143
+ **docs/features.md**:
144
+ - Add one row per detected module/feature area
145
+ - Status: `✅ done` for modules with passing tests, `🔧 active` for modules without tests
146
+ - Key Files: actual file paths from scan
147
+ - Test Files: actual test file paths from scan
148
+
149
+ **docs/dependency-map.md**:
150
+ - Add one row per module
151
+ - Layer: inferred from directory structure (domain/application/infrastructure/presentation)
152
+ - Depends On / Depended By: inferred from import scan
153
+
154
+ **docs/project-state.md**:
155
+ - Quick Summary: filled with current project state
156
+ - Sprint 1 stories: based on what bootstrap discovered
157
+ - Module Registry: summary from docs/dependency-map.md
158
+
159
+ **docs/failure-patterns.md**:
160
+ - Keep FP-001 through FP-004 as templates (Frequency: 0)
161
+ - No changes unless user reports known issues
162
+
163
+ ### Phase 3.5: Project Brief Auto-Configuration
164
+
165
+ Using language/framework detected in Phase 1 + user answers from Phase 2, enrich `docs/project-brief.md`:
166
+
167
+ 1. **Fill Key Technical Decisions** with detected tech stack:
168
+ - Language, framework, database (from Phase 1)
169
+ - Architecture pattern (from user answer #4)
170
+ - Type conventions (from user answer #5)
171
+ - Test command and mock location (from user answer #6)
172
+
173
+ 2. **Ask about coding conventions** for the detected language:
174
+ - "Any coding style conventions the AI should follow for [detected language]?" (e.g., enum vs union types, Pydantic vs dataclass, etc.)
175
+ - If the user provides conventions → write them to Key Technical Decisions
176
+ - If the user skips → do not inject any defaults
177
+
178
+ ### Phase 4: Verify
179
+
180
+ 1. Present a summary of all filled state files to the user
181
+ 2. Ask "Does this look correct? What should I change?"
182
+ 3. Apply corrections if any
183
+ 4. Report completion
184
+
185
+ <!-- TEAM_MODE_START -->
186
+ ## Team Mode: File Locations
187
+
188
+ In Team mode, state files are split between shared and personal directories:
189
+
190
+ ### Shared (docs/, git committed)
191
+ - `docs/project-brief.md` — project vision, goals, non-goals
192
+ - `docs/features.md` — feature registry
193
+ - `docs/dependency-map.md` — module dependency graph
194
+
195
+ ### Personal (.harness/, gitignored)
196
+ - `.harness/project-state.md` — current sprint/story progress
197
+ - `.harness/failure-patterns.md` — personal failure patterns
198
+ - `.harness/agent-memory/` — agent memory files
199
+
200
+ When filling state files in Phase 3, write to the correct directories based on this split.
201
+ After bootstrap completes, remind the user that shared files require `git pull` before editing (Pre-Pull Protocol).
202
+ <!-- TEAM_MODE_END -->
203
+
204
+ ## Output Format
205
+
206
+ ```
207
+ ## Bootstrap Complete
208
+
209
+ ### Project: [name]
210
+ ### Tech Stack: [detected stack]
211
+ ### Language: [detected language]
212
+ ### Modules Found: [count]
213
+ ### Features Mapped: [count]
214
+ ### Dependency Links: [count]
215
+
216
+ ### State Files Updated:
217
+ - [x]docs/project-brief.md — [summary]
218
+ - [x]docs/features.md — [N] features registered
219
+ - [x]docs/dependency-map.md — [N] modules, [N] dependencies
220
+ - [x]docs/project-state.md — Sprint 1 initialized
221
+ - [ ]docs/failure-patterns.md — templates only (no changes)
222
+
223
+ STATUS: DONE
224
+ ```
225
+
226
+ ### 🧭 Navigation — After Bootstrap
227
+
228
+ Bootstrap always leads to `planner`. Append this block after STATUS: DONE:
229
+
230
+ **If NO crew artifacts** (🟢 pipeline):
231
+ ```
232
+ ---
233
+ 🧭 Next Step
234
+ → Next: `planner` (슬래시 메뉴에서 선택하거나, 채팅에 아래 프롬프트 입력)
235
+ → Prompt: "[project]에 [첫 번째 기능]을 추가해줘"
236
+ → Why: State files are filled — now plan the first feature
237
+ → Pipeline: 🟢 Step 2/6
238
+ ---
239
+ ```
240
+
241
+ <!-- CREW_MODE_START -->
242
+ **If crew artifacts were used** (🟣 pipeline):
243
+ ```
244
+ ---
245
+ 🧭 Next Step
246
+ → Next: `planner` (슬래시 메뉴에서 선택하거나, 채팅에 아래 프롬프트 입력)
247
+ → Prompt: "crew 산출물을 기반으로 첫 번째 기능을 계획해줘"
248
+ → Why: Artifact Index + Validation Tracker created — planner will map FR→Stories
249
+ → Pipeline: 🟣 Step 2/6
250
+ ---
251
+ ```
252
+ <!-- CREW_MODE_END -->
253
+
254
+ ## Rules
255
+
256
+ - Never modify source code — this skill only writes to state files and rules files
257
+ - Always show the user what was discovered BEFORE writing files
258
+ - If the project has 0 source files, skip Phase 1 scan and go straight to Phase 2
259
+ - If a state file already has content, ask before overwriting
260
+ - Rules file TODO sections can be overwritten without asking (they are placeholders)
261
+ - Run this skill only once per project (or when explicitly requested for refresh)
262
+
263
+ ### Small Project Guidance
264
+
265
+ For projects with fewer than 3 modules (e.g., single-file scripts, small CLI tools):
266
+ - `docs/dependency-map.md` may have only 1-2 rows — this is normal, not a gap
267
+ - `feature-breakdown` Waves may collapse into a single Wave — skip Wave-level pacing
268
+ - Consider a simplified workflow: `bootstrap → planner → [code] → reviewer → learn` (skip sprint-manager for single-story projects)
269
+
270
+ ## Embedded Knowledge
271
+
272
+ ### Session Bootstrap Protocol
273
+ When starting a NEW session (not during bootstrap), read these files in order:
274
+ 1. `docs/project-state.md` — Quick Summary tells you where we left off
275
+ 2. `docs/features.md` — What features exist
276
+ 3. `docs/failure-patterns.md` — What mistakes to avoid
277
+ 4. `docs/project-brief.md` — Project vision and non-goals
278
+
279
+ ### Workflow Pipeline
280
+ - New feature: `planner → [code] → reviewer → sprint-manager → learn`
281
+ - Bug fix: `investigate → [fix] → test-integrity → reviewer → learn`
282
+ - Session lifecycle: `sprint-manager ("where are we?") → [work] → learn`
283
+
284
+ ### State File Size Limits
285
+ - docs/project-brief.md: Max 200 lines
286
+ - docs/project-state.md: Max 300 lines
287
+ - docs/failure-patterns.md: Max 50 patterns
288
+ - docs/dependency-map.md: Max 100 modules
289
+ - docs/features.md: Max 50 features
290
+ - docs/agent-memory/*.md: Max 100 lines each
291
+
292
+ ## Anti-patterns
293
+
294
+ | Anti-pattern | Correct Approach |
295
+ |---|---|
296
+ | Guess module boundaries | Scan actual directory structure and imports |
297
+ | Skip user interview | Phase 1 scan alone is insufficient — always confirm with user |
298
+ | Overwrite existing state files silently | Ask before overwriting non-empty files |
299
+ | Create perfect dependency map on first try | Start with what's detectable, refine over time |
300
+ | Leave rules file TODOs unfilled | Phase 3.5 fills Key Technical Decisions TODOs. Decision Log remains empty (filled later via `pivot` skill during project lifecycle) |
301
+ | Use TypeScript globs for non-TS projects | Detect language in Phase 1 and set correct globs |
302
+ | Only fill state files, skip rules | Bootstrap fills BOTH — state files AND rules files |
303
+
304
+ <!-- TEAM_MODE_START -->
305
+ ## Team Mode: Onboarding
306
+
307
+ When running bootstrap in Team mode:
308
+
309
+ ### New Project (first developer)
310
+ 1. Run `musher init --team` to create shared + personal state files
311
+ 2. Fill all state files via normal bootstrap procedure
312
+ 3. Commit shared files (docs/) to git
313
+ 4. Push to remote — teammates will clone this
314
+
315
+ ### Joining Developer (existing project)
316
+ 1. Clone the repository (shared docs/ already exist)
317
+ 2. Run `musher init --team` — only personal files (.harness/) are created; shared files are skipped
318
+ 3. **DO NOT re-run bootstrap interviews** — shared state is already filled by the first developer
319
+ 4. Review docs/project-brief.md to understand project goals
320
+ 5. Create your personal .harness/project-state.md with your current Story assignment
321
+
322
+ ### Rules
323
+ - **Never overwrite shared files** when joining an existing project
324
+ - Set your Owner name in docs/features.md and docs/dependency-map.md rows you create
325
+ - Personal state (.harness/) is yours alone — no coordination needed
326
+ <!-- TEAM_MODE_END -->
@@ -0,0 +1,141 @@
1
+ # Code Review PR
2
+
3
+ ## Purpose
4
+
5
+ Review an external Pull Request (PR) for quality, security, and direction alignment before merging.
6
+ Unlike the `reviewer` agent (which reviews your own changes pre-commit with full project context), this skill is for reviewing incoming PRs from teammates or external contributors. code-review-pr is a cold review — stricter on state file compliance because the reviewer has less context about the PR author's intent.
7
+
8
+ ## Invoked By
9
+
10
+ - **User** (direct) — when assigned as a PR reviewer or asked to review a branch
11
+ - Unlike `reviewer` agent (self-review before commit), this skill is for reviewing **incoming external PRs**
12
+
13
+ ## When to Apply
14
+
15
+ - When assigned as a PR reviewer
16
+ - When a teammate asks for a review of their branch
17
+ - When reviewing open-source contributions
18
+
19
+ ## Procedure
20
+
21
+ ### Step 1: Gather PR Context
22
+
23
+ 1. Read the PR title, description, and linked issues
24
+ 2. Run `git diff <base>...<branch>` (use the PR's base branch, per project-brief.md; default: main) to see all changes
25
+ 3. Run `git log --oneline <base>...<branch>` to understand commit history
26
+ 4. Count files changed: `git diff --stat <base>...<branch>`
27
+
28
+ ### Step 2: Direction Alignment
29
+
30
+ 1. Read `docs/project-brief.md` — Goals, Non-Goals, Decision Log
31
+ 2. Check: Does this PR serve a listed Goal?
32
+ 3. Check: Does this PR contradict a Non-Goal or Decision Log entry?
33
+ 4. If misaligned → comment on the PR with the concern before proceeding
34
+
35
+ ### Step 3: Scope Check
36
+
37
+ 1. Read `docs/project-state.md` — current Sprint and Stories
38
+ 2. Verify the PR changes only files within its stated scope
39
+ 3. Flag any out-of-scope modifications
40
+
41
+ ### Step 4: Code Quality
42
+
43
+ Run through these checks for each changed file:
44
+
45
+ - [ ] Architecture rules respected (no layer violations — check docs/dependency-map.md)
46
+ - [ ] No hardcoded credentials or API keys
47
+ - [ ] No `TODO` or `FIXME` without a linked issue
48
+ - [ ] Error handling is present where needed
49
+ - [ ] No overly complex functions (single responsibility)
50
+ - [ ] No duplicated logic that should be extracted to a shared module
51
+ - [ ] No circular imports (verify against docs/dependency-map.md)
52
+ - [ ] Naming conventions follow project standards (per project-brief.md → Key Technical Decisions)
53
+
54
+ ### Step 5: Test Coverage
55
+
56
+ - [ ] New features have corresponding tests
57
+ - [ ] Modified code has updated tests
58
+ - [ ] No `.only` or `.skip` left in test files
59
+ - [ ] Interface changes have synchronized mocks (Iron Law #1)
60
+
61
+ ### Step 6: State File Compliance
62
+
63
+ - [ ] New features registered in `docs/features.md` (Iron Law #7). If the PR is partial (only one layer of a feature), registration is optional — but must be registered when the feature-completing PR is merged.
64
+ - [ ] New modules registered in `docs/dependency-map.md` (Iron Law #6)
65
+ - [ ] `docs/project-state.md` Story Status updated
66
+
67
+ ### Step 7: Failure Pattern Cross-Check
68
+
69
+ 1. Read `docs/failure-patterns.md`
70
+ 2. Check if any active FP-NNN pattern applies to the PR changes
71
+ 3. If match found → comment with the pattern ID and prevention guidance
72
+
73
+ ## Output Format
74
+
75
+ ```
76
+ ## PR Review: [PR title]
77
+
78
+ ### Direction: ✅ Aligned / ⚠️ Concern / ❌ Misaligned
79
+ [details if not aligned]
80
+
81
+ ### Scope: ✅ Clean / ⚠️ Out-of-scope changes found
82
+ [list of out-of-scope files if any]
83
+
84
+ ### Code Quality: [N] issues found
85
+ - [issue 1]
86
+ - [issue 2]
87
+
88
+ ### Test Coverage: ✅ Sufficient / ⚠️ Gaps found
89
+ [list of gaps if any]
90
+
91
+ ### State Files: ✅ Updated / ⚠️ Missing updates
92
+ [list of missing updates if any]
93
+
94
+ ### Failure Patterns: [N] matches
95
+ - FP-NNN: [description]
96
+
97
+ ### Verdict: APPROVE / REQUEST_CHANGES / COMMENT
98
+ [summary recommendation]
99
+ ```
100
+
101
+ ### 🧭 Navigation — After PR Review
102
+
103
+ After PR review completes, always append a 🧭 block:
104
+
105
+ | PR Review Result | 🧭 Next Step |
106
+ |---|---|
107
+ | APPROVE | Merge & `deployment` — "리리즈 준비를 확인해줘" |
108
+ | REQUEST_CHANGES | [Fix] — "PR 지적사항을 수정하세요. 완료 후 다시 `code-review-pr` 호출" |
109
+ | Direction misaligned | `pivot` — "방향을 전환하고 state 파일을 업데이트해줘" |
110
+
111
+ Example 🧭 block for APPROVE:
112
+ ```
113
+ ---
114
+ 🧭 Next Step
115
+ → Next: `deployment`
116
+ → Prompt: "리리즈 준비를 확인해줘"
117
+ → Why: PR approved — validate deployment readiness
118
+ → Pipeline: 🟢/🔵 Step 5/6
119
+ ---
120
+ ```
121
+
122
+ ## Rules
123
+
124
+ - Do not modify the PR code directly — only review and comment
125
+ - Always check direction alignment FIRST — a well-written PR that goes the wrong direction is worse than a messy one that's aligned
126
+ - Be specific: reference file names, line numbers, and function names
127
+ - Suggest fixes, don't just point out problems
128
+
129
+ <!-- TEAM_MODE_START -->
130
+ ## Team Mode: Cross-Team PR Review
131
+
132
+ ### Owner-Aware Review
133
+ 1. Check `docs/dependency-map.md` Owner column for each file in the PR
134
+ 2. If the PR modifies modules owned by someone else → flag for that owner's review
135
+ 3. Only the module Owner (or designated authority per project-brief.md; default: team lead) can approve changes to their modules
136
+
137
+ ### Shared State Verification
138
+ - Verify the PR updates `docs/features.md` Owner column correctly
139
+ - Verify new modules in `docs/dependency-map.md` have an Owner assigned
140
+ - Check that the PR doesn't modify another developer's personal failure patterns
141
+ <!-- TEAM_MODE_END -->
@@ -0,0 +1,144 @@
1
+ # Deployment
2
+
3
+ ## Purpose
4
+
5
+ Pre-deployment validation checklist. Ensures all quality gates pass and state files are consistent before releasing or deploying.
6
+
7
+ ## When to Apply
8
+
9
+ - Before deploying to staging or production
10
+ - Before publishing a new npm/package version
11
+ - Before creating a release tag
12
+ - When the user says "ready to deploy" or "prepare release"
13
+
14
+ ## Procedure
15
+
16
+ ### Step 1: Version Check
17
+
18
+ 1. Read `package.json` (or equivalent manifest) — note current version
19
+ 2. Verify the version was bumped appropriately (Semantic Versioning):
20
+ - Bug fix → patch (0.0.x) — e.g., `v1.2.3 → v1.2.4`
21
+ - New feature (backward-compatible) → minor (0.x.0) — e.g., `v1.2.3 → v1.3.0`
22
+ - Breaking change → major (x.0.0) — e.g., `v1.2.3 → v2.0.0`
23
+ - If unsure, ask the designated authority (per project-brief.md)
24
+ 3. If version was not bumped → **warn and recommend bumping before deploy**
25
+
26
+ ### Step 2: Test Suite
27
+
28
+ 1. Run the project's test command (per project-brief.md → Key Technical Decisions; e.g., `npm test`, `pytest`, `go test ./...`)
29
+ 2. **All tests must pass.** If any fail → **BLOCKED, do not proceed**
30
+ 3. Report: total tests, passed, failed
31
+
32
+ ### Step 3: State File Consistency
33
+
34
+ Verify all state files are up to date:
35
+
36
+ - [ ] `docs/project-state.md` — Quick Summary reflects current state
37
+ - [ ] `docs/features.md` — All implemented features marked as `✅ done`
38
+ - [ ] `docs/dependency-map.md` — No orphaned modules
39
+ - [ ] `docs/failure-patterns.md` — No unresolved critical patterns
40
+ - [ ] `docs/project-brief.md` — Decision Log has entries for all major changes
41
+ - [ ] **Cross-check features ↔ stories**: All `done` stories should have their features marked `✅ done` in features.md
42
+
43
+ <!-- CREW_MODE_START -->
44
+ - [ ] **Validation Tracker FR Coverage**: All Functional Requirements (FR) have at least one mapped Story (`docs/project-brief.md` → Validation Tracker)
45
+ - [ ] **Validation Tracker ARB Fail Resolution**: All ARB Fail items resolved (✅) or explicitly deferred with rationale
46
+ - [ ] **KPI Coverage**: All KPIs addressed or deferred with documented reason
47
+ <!-- CREW_MODE_END -->
48
+
49
+ ### Step 4: Security Scan
50
+
51
+ 1. Run the `security-checklist` skill
52
+ 2. Verify no credentials, API keys, or `.env` files are staged
53
+ 3. Check for known vulnerable dependencies (if applicable)
54
+
55
+ ### Step 5: Git Status
56
+
57
+ 1. `git status` — working directory should be clean
58
+ 2. `git stash list` — verify no unintended stashes exist (if stashes are present, confirm they are intentional)
59
+ 3. `git log --oneline -5` — verify recent commits are meaningful
60
+ 3. Verify current branch is appropriate for deployment (the default branch or a release branch, per project-brief.md)
61
+
62
+ ### Step 6: Changelog / Release Notes
63
+
64
+ 1. Check if CHANGELOG.md or release notes exist
65
+ 2. If yes → verify they include entries for all changes since last release
66
+ 3. If no → generate a summary from `git log --oneline <last-tag>..HEAD`
67
+
68
+ ## Output Format
69
+
70
+ ```
71
+ ## Deployment Readiness: [project-name] v[version]
72
+
73
+ ### Pre-flight Checks:
74
+ - [x/✗] Version bumped: [version]
75
+ - [x/✗] Tests: [passed]/[total] passed
76
+ - [x/✗] State files consistent
77
+ - [x/✗] Security scan clean
78
+ - [x/✗] Git status clean
79
+ - [x/✗] Release notes prepared
80
+
81
+ ### Verdict: READY / NOT_READY
82
+ [blockers if not ready]
83
+
84
+ ### Deploy Command:
85
+ [Suggest based on project type detected in project-brief.md Key Technical Decisions:
86
+ npm: npm publish / npx changeset publish
87
+ Docker: docker build + docker push
88
+ GitHub: gh release create vX.Y.Z
89
+ Cloud: terraform apply / aws deploy]
90
+ ```
91
+
92
+ ### 🧭 Navigation — After Deployment Check
93
+
94
+ After deployment validation completes, always append a 🧭 block:
95
+
96
+ | Deployment Result | 🧭 Next Step |
97
+ |---|---|
98
+ | READY | [Deploy] — "배포 명령을 실행하세요" |
99
+ | NOT_READY (test failure) | [Fix] — "테스트 실패를 수정해줘. 완료 후 다시 `deployment` 호출" |
100
+ | NOT_READY (state files) | `learn` — "state 파일을 정리해줘" |
101
+ | NOT_READY (security) | `security-checklist` — "보안 이슈를 해결해줘" |
102
+
103
+ Example 🧭 block for READY:
104
+ ```
105
+ ---
106
+ 🧭 Next Step
107
+ → Next: [Deploy]
108
+ → Prompt: "배포 명령을 실행하세요"
109
+ → Why: All checks passed — safe to deploy
110
+ → Pipeline: 🟢/🔵 Step 5/6 → deploy
111
+ ---
112
+ ```
113
+
114
+ ## Rollback Procedure
115
+
116
+ If a deployment fails or a critical issue is found post-deploy:
117
+
118
+ 1. **Immediate**: Revert to the last known-good version
119
+ - npm: `npm unpublish <pkg>@<bad-version>` (within 72h) or publish a patch fix
120
+ - Docker: `docker tag <image>:<previous-tag> <image>:latest && docker push`
121
+ - GitHub: `gh release delete vX.Y.Z` + `git tag -d vX.Y.Z && git push --delete origin vX.Y.Z`
122
+ 2. **Record**: Add entry to `docs/failure-patterns.md` with deployment failure details
123
+ 3. **Re-validate**: Run `deployment` skill again on the rollback commit to confirm stability
124
+ 4. **Post-mortem**: Run `learn` skill to capture the incident for future sessions
125
+
126
+ ## Rules
127
+
128
+ - Never deploy with failing tests — no exceptions
129
+ - Never deploy with unstaged changes in the working directory
130
+ - Always verify version bump before deployment
131
+ - This skill is read-only — it validates but does not execute the deployment
132
+
133
+ <!-- TEAM_MODE_START -->
134
+ ## Team Mode: Pre-Deploy Coordination
135
+
136
+ ### Shared State Sync
137
+ 1. Run `git pull` on the default branch before starting deploy validation (per project-brief.md → Key Technical Decisions; default: main)
138
+ 2. Verify `docs/features.md` and `docs/dependency-map.md` are up to date with latest changes from all developers
139
+ 3. Check that no other developer has in-progress stories that depend on the current release
140
+
141
+ ### Owner Verification
142
+ - Verify all modified modules have their Owner's approval
143
+ - If deploying changes to modules owned by others, confirm they have reviewed and approved
144
+ <!-- TEAM_MODE_END -->