@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,308 @@
1
+ # Learn
2
+
3
+ ## Purpose
4
+
5
+ Capture lessons from the current session before ending.
6
+ Updates docs/failure-patterns.md with new patterns and refreshes docs/project-state.md Quick Summary.
7
+ This is Musher's memory mechanism — without it, the same mistakes repeat across sessions.
8
+
9
+ ## Invoked By
10
+
11
+ - **User** (direct) — "세션 마무리해줘", "오늘 배운 것 기록해줘"
12
+ - **reviewer** (pass, all done) → learn — 모든 Story 완료 시
13
+ - **reviewer** (STATE-AUDIT) → learn — state 파일 정리 후 세션 종료
14
+ - Final step in ALL pipelines (🟢/🔵/🔴/🟡)
15
+
16
+ ## When to Apply
17
+
18
+ - Before ending a chat session (recommended as the LAST skill invoked, **once per session**)
19
+ - After a debugging session where a non-obvious fix was found
20
+ - After a review revealed a repeated mistake
21
+ - When the user explicitly asks to record a lesson
22
+
23
+ > **Timing**: Invoke this skill **once at session end**, not after each individual skill. It aggregates the entire session's work into state files.
24
+
25
+ ## Procedure
26
+
27
+ ### Step 1: Review Session Activity
28
+
29
+ 1. Scan recent git changes: `git log --oneline -10` and `git diff --stat HEAD~3`
30
+ 2. Identify what was accomplished in this session
31
+ 3. Identify any errors, failures, or unexpected issues that occurred
32
+
33
+ **Edge Case: Zero-Change Session**
34
+ If `git diff --stat` shows no changes and `git log` shows no new commits this session:
35
+ - Report: "📝 Quiet session — status checks only, no code changes."
36
+ - Skip Step 3 (Failure Pattern Detection) — no code changes means no new failure patterns
37
+ - Skip Step 5 (features.md update) and Step 5.5 (dependency-map.md verify) — nothing changed
38
+ - Still execute Step 4 (Quick Summary update) and Step 6 (Agent Memory) if an agent was used
39
+ - Still execute Step 2 (Direction Drift Check) — discussion-only drift is possible
40
+
41
+ ### Step 2: Direction Drift Check
42
+
43
+ Before recording failures, verify that the session's work stayed aligned with project direction:
44
+
45
+ 1. Read `docs/project-brief.md` — focus on **Goals**, **Non-Goals**, and **Decision Log**
46
+ 2. Compare this session's changes (from Step 1) against the brief:
47
+ - Did any change serve a Non-Goal? → Flag as potential direction drift
48
+ - Did any change contradict a Decision Log entry? → Flag as decision reversal
49
+ - Did the user explicitly change direction during this session? → Note for pivot recommendation
50
+ 3. **If drift detected**:
51
+ - Add a warning to the Step 7 Report: `⚠️ Direction drift: [description of misalignment]`
52
+ - Recommend: "Consider running `pivot` skill to formally update project direction. You can run it AFTER this learn session completes."
53
+ - Do NOT block — the learn skill always completes
54
+ 4. **If no drift**: Proceed silently (no output for this step)
55
+
56
+ <!-- CREW_MODE_START -->
57
+ #### Step 2.5: Validation Tracker Update (🟣 Pipeline only) ⚠️ MANDATORY
58
+
59
+ > **⛔ Completion Gate**: Step 2.5를 완료해야 Step 3 이후를 진행할 수 있습니다. Validation Tracker가 존재하면 반드시 갱신 후 다음 단계로 진행하세요.
60
+
61
+ If `docs/project-brief.md` contains a `## Validation Tracker` section with data:
62
+
63
+ 1. **Update KPI Coverage status**:
64
+ - Stories completed this session → if they map to a KPI → update Status (⬜→🟡 or 🟡→✅)
65
+ 2. **Update FR Coverage status**:
66
+ - Stories completed this session → if they have `[FR-NNN]` prefix → update Status (⬜→🟡 or 🟡→✅)
67
+ 3. **Update ARB Fail Resolution status**:
68
+ - Stories completed this session → if they have `[ARB-FAIL]` prefix and reviewer passed compliance check → update Status (⬜→🟡 or 🟡→✅)
69
+ 4. **Check for Validation Drift**:
70
+ - Did this session produce Stories/code that don't map to any FR or KPI? → warn
71
+ - Are there KPIs/FRs with no Stories after 2+ sprints? → warn as "⚠️ Unplanned KPI/FR risk"
72
+ - Include warnings in Step 7 Report
73
+ 5. **Self-check**: Validation Tracker의 KPI/FR/ARB 상태가 이 세션의 완료 Story를 정확히 반영하는지 확인. 미갱신 항목이 있으면 즉시 갱신 후 다음 단계로 진행.
74
+
75
+ > ⛔ Validation Tracker 갱신 없이 Step 3으로 진행하지 마세요. 이 단계를 건너뛰면 FR/KPI Coverage가 실제 진행 상황과 불일치합니다.
76
+
77
+ If no Validation Tracker → skip this step entirely.
78
+ <!-- CREW_MODE_END -->
79
+
80
+ ### Step 3: Failure Pattern Detection ⚠️ MANDATORY
81
+
82
+ For each issue/error that occurred in this session:
83
+
84
+ 1. Read `docs/failure-patterns.md`
85
+ 2. Check if this matches an existing pattern (FP-NNN):
86
+ - **If match found AND already incremented by `investigate` in this session**: Skip — do not double-count. Check `docs/project-state.md` Recent Changes for investigate entries from this session to determine if a pattern was already recorded.
87
+ - **If match found AND NOT already incremented this session**: Increment the Frequency counter, add the Sprint/Story to "Occurred"
88
+ - **If new pattern**: Assign next FP-NNN number, create a new entry using this format:
89
+
90
+ ```markdown
91
+ ## FP-NNN: [Short description]
92
+
93
+ - **Occurred**: S[sprint]-[story]
94
+ - **Frequency**: 1
95
+ - **Cause**: [What went wrong and why]
96
+ - **Prevention**: [Specific check to prevent recurrence]
97
+ - **Applied in**: [Which skills/agents/rules should enforce this]
98
+ - **Status**: Active
99
+ ```
100
+
101
+ 3. If the failure relates to a specific skill or agent, note it for that skill's checklist
102
+
103
+ > **Self-check**: Step 3 완료 시 `docs/failure-patterns.md`에 최소 하나의 FP 항목이 있어야 합니다 (이 세션에서 실패가 없었으면 기존 항목 확인만).
104
+
105
+ ### Step 4: Update docs/project-state.md ⚠️ MANDATORY
106
+
107
+ 1. Update **Quick Summary** (3 lines):
108
+ - Line 1: What was accomplished in this session
109
+ - Line 2: What is currently in progress
110
+ - Line 3: What should be done next
111
+
112
+ > **Self-check**: Quick Summary가 정확히 3줄인지 확인. 3줄 초과 시 축약, 미달 시 보충.
113
+
114
+ 2. Update **Story Status** table if any stories changed
115
+ 3. **MANDATORY** — Add to **Recent Changes** section with date and summary. Recent Changes가 비어있으면 반드시 추가:
116
+ ```
117
+ - [YYYY-MM-DD] S{N}-{M}: {what was done} (STATUS: DONE)
118
+ ```
119
+
120
+ ### Step 5: Update docs/features.md (if applicable)
121
+
122
+ 1. If new features were added → add row to Feature List
123
+ 2. If existing features were modified → update Key Files and Test Files columns
124
+ 3. If features were completed → update Status to `✅ done`
125
+
126
+ ### Step 5.5: Verify docs/dependency-map.md (mandatory)
127
+
128
+ 1. Check if any new modules were created in this session (scan `git diff --stat` for new directories)
129
+ 2. Check if any module interfaces changed
130
+ 3. For each finding:
131
+ - New module without dependency-map entry → **add it now**
132
+ - Interface change without Interface Change Log entry → **add it now**
133
+ 4. Cross-reference `docs/features.md` Key Files against `docs/dependency-map.md` modules — flag orphaned modules
134
+
135
+ > **Self-check**: `docs/dependency-map.md`에 이 세션에서 새로 추가한 모듈이 모두 등록되었는지 확인. 누락 시 즉시 추가.
136
+
137
+ ### Step 5.6: Resolve STATE-AUDIT Flags (if applicable)
138
+
139
+ If the `reviewer` agent was run in this session and produced `[STATE-AUDIT]` flags:
140
+ 1. Review each flagged item
141
+ 2. Apply the recommended state file update
142
+ 3. If the flag was already resolved during the session, skip it
143
+
144
+ ### Step 5.65: Auto-Commit State Files ⚠️ MANDATORY
145
+
146
+ State file 변경사항을 커밋합니다. Learn 실행 결과가 커밋되지 않으면 다음 세션에서 유실됩니다.
147
+
148
+ 1. Stage state files: `git add docs/project-state.md docs/failure-patterns.md docs/features.md docs/dependency-map.md docs/agent-memory/`
149
+ 2. Commit: `git commit -m "learn: session lessons captured"`
150
+ 3. If commit fails (nothing to commit), skip — state files were already committed
151
+
152
+ > **Self-check**: `git status`에 docs/ 아래 unstaged 파일이 없어야 합니다.
153
+
154
+ ### Step 5.7: Git Push Check (session end)
155
+
156
+ Before ending the session, check for unpushed commits:
157
+
158
+ 1. Run `git log --oneline @{u}..HEAD 2>/dev/null || echo "no upstream"` to find unpushed commits
159
+ 2. **If unpushed commits exist**:
160
+ - List the commits: `git log --oneline @{u}..HEAD`
161
+ - Solo mode: Recommend push — `git push origin {branch}`
162
+ - Team mode: **Strongly recommend** push — unpushed work is invisible to teammates
163
+ - Warn: "⚠️ {N}개의 커밋이 push되지 않았습니다. 작업물을 원격에 백업하세요."
164
+ 3. **If no upstream configured** (`no upstream`):
165
+ - Check if remote exists: `git remote -v`
166
+ - If remote exists: Suggest `git push -u origin {branch}` (first push)
167
+ - If no remote: Note "원격 저장소가 설정되지 않았습니다. 팀 협업 시 remote 설정이 필요합니다."
168
+ 4. **If all commits are pushed**: Skip (no output)
169
+
170
+ ### Step 6: Update Agent Memory (if applicable)
171
+
172
+ If an agent (reviewer, planner, sprint-manager, architect) was used in this session, update its memory file in `docs/agent-memory/`:
173
+
174
+ 1. Read `docs/agent-memory/{agent-name}.md`
175
+ 2. **Auto-initialize if needed**: If the file only contains `<!-- Example entries` placeholder comments and no real data:
176
+ - Replace the placeholder block with actual entries from this session
177
+ - Initialize statistics counters with real values
178
+ - If real entries already exist alongside placeholders, APPEND new entries and remove only the placeholder comments. Do not overwrite existing real data.
179
+ - **When does initialization happen?**: On the FIRST session where the agent is used AND learn is invoked. If an agent is never used, its memory stays as a placeholder indefinitely — this is expected.
180
+ - Example transformation:
181
+ ```
182
+ Before: <!-- Example entries (replace with real findings after first review):
183
+ After: - [S1-1] Mock sync missed for UserService interface change
184
+ ```
185
+ 3. **Append session learnings** to the appropriate section:
186
+ - **reviewer.md**: Add review patterns found, update statistics (total reviews +1, auto-fixes, escalations)
187
+ - **planner.md**: Record estimation accuracy (planned vs actual), note architecture discoveries
188
+ - **sprint-manager.md**: Update velocity (stories done/planned), record any scope drift incidents
189
+ - **architect.md**: Record design decisions made, module boundary insights, anti-patterns observed
190
+ 4. Keep entries concise — one line per learning, prefixed with `[S{sprint}-{story}]`
191
+ 5. Prune entries older than 5 sprints to stay within the 100-line limit
192
+ 6. If no agent was used in this session, skip this step
193
+
194
+ ### Step 7: Report
195
+
196
+ Present a summary of all updates made.
197
+
198
+ ## Output Format
199
+
200
+ ```
201
+ ## Session Learn Complete
202
+
203
+ ### Lessons Captured:
204
+ - [FP-NNN] (new/updated): [description]
205
+
206
+ ### State Files Updated:
207
+ - [x] docs/project-state.md — Quick Summary refreshed
208
+ - [x] docs/failure-patterns.md — [N] patterns added/updated
209
+ - [x] docs/features.md — [N] features updated (if applicable)
210
+ - [x] docs/dependency-map.md — [N] modules verified/added (if applicable)
211
+ - [x] docs/agent-memory/{name}.md — [N] agents updated (if applicable)
212
+
213
+ ### Git Status:
214
+ - Unpushed commits: [N] — `git push origin {branch}` 실행 권장
215
+ (or: All commits pushed ✅)
216
+
217
+ ### Next Session Should:
218
+ 1. [recommended first action]
219
+ 2. [next priority]
220
+
221
+ STATUS: DONE
222
+ ```
223
+
224
+ ### 🧭 Navigation — After Learn
225
+
226
+ Learn is the final skill in every pipeline. Append the appropriate 🧭 block:
227
+
228
+ ```
229
+ ---
230
+ 🧭 Next Step
231
+ → 🏁 Session End
232
+ → Prompt: "다음 세션 시작 시 `sprint-manager`를 호출하세요"
233
+ → Why: Session lessons captured — state files are up to date
234
+ → Pipeline:
235
+ 🟢/🔵: Step 6/6 (complete)
236
+ 🔴: Step 4/4 (complete)
237
+ ---
238
+ ```
239
+
240
+ <!-- CREW_MODE_START -->
241
+ If crew artifacts were used this session (🟣 pipeline), also append:
242
+ ```
243
+ → Note: 다음 세션에서 crew 산출물이 업데이트되었다면, `bootstrap`부터 다시 시작하세요
244
+ ```
245
+ <!-- CREW_MODE_END -->
246
+
247
+ ## Rules
248
+
249
+ - Never invent patterns that didn't actually occur — record only real failures
250
+ - Keep failure pattern descriptions concise (1-2 sentences for Cause and Prevention)
251
+ - If no failures occurred, skip Step 2 and just update state files
252
+ - Do not modify source code — this skill only updates state files
253
+ - Quick Summary must be exactly 3 lines — concise enough for the next session to scan instantly
254
+
255
+ ## Enforced Rules
256
+
257
+ - **Session Handoff**: Before ending a session, docs/project-state.md Quick Summary MUST be updated. Never leave the project in an undocumented state.
258
+ - **State File Size Limits**: Keep state files compact for LLM context windows:
259
+ - docs/project-brief.md: Max 200 lines
260
+ - docs/project-state.md: Max 300 lines (archive completed sprints)
261
+ - docs/failure-patterns.md: Max 50 patterns (remove resolved entries)
262
+ - docs/dependency-map.md: Max 100 modules
263
+ - docs/features.md: Max 50 features
264
+ - docs/agent-memory/*.md: Max 100 lines each
265
+ - .harness/ personal files: same limits as shared files
266
+
267
+ ## Anti-patterns
268
+
269
+ | Anti-pattern | Correct Approach |
270
+ |---|---|
271
+ | Record theoretical risks as failure patterns | Only record failures that actually happened |
272
+ | Write vague descriptions ("something broke") | Be specific: file name, error message, root cause |
273
+ | Skip this skill because "nothing went wrong" | Still update Quick Summary and Story Status |
274
+ | Update docs/failure-patterns.md but not docs/project-state.md | Always update both — they serve different purposes |
275
+
276
+ <!-- TEAM_MODE_START -->
277
+ ## Team Mode: Session Wrap-up
278
+
279
+ ### Pre-Pull (mandatory before any shared file edit)
280
+ 1. Run `git pull` on the default branch before updating docs/features.md or docs/dependency-map.md (per project-brief.md → Key Technical Decisions; default: main)
281
+ 2. If merge conflicts occur, follow the **Merge Conflict SOP** below
282
+
283
+ ### Merge Conflict SOP
284
+
285
+ When `git pull` causes merge conflicts in shared state files:
286
+
287
+ 1. **Identify conflict files**: `git diff --name-only --diff-filter=U`
288
+ 2. **Resolution strategy by file type**:
289
+ | File | Strategy |
290
+ |------|----------|
291
+ | `docs/features.md` | Keep BOTH entries (merge=union should handle; if not, manually keep all rows) |
292
+ | `docs/dependency-map.md` | Keep BOTH entries (merge=union should handle; if not, manually keep all rows) |
293
+ | `docs/project-brief.md` | Resolve based on team's pivot authority (per project-brief.md; default: prefer REMOTE) |
294
+ | `docs/failure-patterns.md` | Keep BOTH entries, deduplicate by FP-NNN number |
295
+ 3. **After resolving**: `git add <resolved-files> && git commit`
296
+ 4. **Verify**: Re-read the resolved file and confirm no data was lost
297
+ 5. **If unsure**: Do NOT force-resolve. Ask the designated authority (per project-brief.md; default: team lead) or the Owner of the conflicting rows.
298
+
299
+ ### Owner-Scoped Updates
300
+ - **docs/features.md**: only update rows where Owner = you
301
+ - **docs/dependency-map.md**: only update rows where Owner = you; if adding a new module, append at the bottom
302
+ - **Personal files** (.harness/project-state.md, .harness/failure-patterns.md, .harness/agent-memory/): update freely — no coordination needed
303
+
304
+ ### Failure Pattern Promotion
305
+ If a personal failure pattern (FP-NNN in .harness/failure-patterns.md) is likely to affect other developers:
306
+ 1. Discuss with the team (Slack, PR comment, etc.)
307
+ 2. If agreed, add it to a shared location (team wiki, PR description) so others can add it to their personal .harness/failure-patterns.md
308
+ <!-- TEAM_MODE_END -->
@@ -0,0 +1,171 @@
1
+ # Pivot
2
+
3
+ ## Purpose
4
+
5
+ When a project direction changes — technology swap, scope expansion/reduction, architecture shift — this skill propagates the change across ALL state files consistently.
6
+ Without this, direction changes create silent inconsistencies:docs/project-brief.md says "GraphQL" but docs/dependency-map.md still references REST modules.
7
+
8
+ ## Invoked By
9
+
10
+ - **User** (direct) — "방향을 바꾸자", "GraphQL로 변경해줘"
11
+ - **planner** (direction change detected) → BLOCK → pivot required before planning proceeds
12
+
13
+ ## When to Apply
14
+
15
+ - Technology change: "Switch from REST to GraphQL", "Replace PostgreSQL with MongoDB"
16
+ - Scope change: "Add real-time features", "Remove mobile support", "Downscope to MVP"
17
+ - Architecture shift: "Move from monolith to microservices", "Switch from SSR to SPA"
18
+ - Goal change: "Pivot from B2C to B2B", "Change target users"
19
+ - Any time the user says "let's change direction", "pivot", "switch to", "drop [feature area]"
20
+
21
+ ## Procedure
22
+
23
+ ### Step 1: Capture the Change
24
+
25
+ 1. Ask the user to describe the change in one sentence
26
+ 2. Classify the change type:
27
+ - **Tech Swap**: Replacing one technology with another
28
+ - **Scope Change**: Adding or removing feature areas
29
+ - **Architecture Shift**: Changing system structure
30
+ - **Goal Pivot**: Changing project purpose or target
31
+
32
+ ### Step 2: Impact Scan
33
+
34
+ Read ALL state files and identify what needs updating:
35
+
36
+ 1. **docs/project-brief.md**:
37
+ - Does Vision need rewording?
38
+ - Do Goals need updating?
39
+ - Do Non-Goals need updating?
40
+ - Do Key Technical Decisions need changing?
41
+ - Record the decision with reasoning in the Decision Log section
42
+
43
+ 2. **docs/features.md**:
44
+ - Which existing features are affected?
45
+ - Which features should be marked `⛔ dropped`?
46
+ - Are new features needed?
47
+
48
+ 3. **docs/dependency-map.md**:
49
+ - Which modules are obsoleted by this change?
50
+ - Which new modules are needed?
51
+ - Which dependency relationships change?
52
+
53
+ 4. **docs/project-state.md**:
54
+ - Which in-progress stories are affected?
55
+ - Does the current sprint goal change?
56
+ - Update Quick Summary to reflect the pivot
57
+
58
+ 5. **docs/failure-patterns.md**:
59
+ - Are any existing patterns invalidated by this change?
60
+ - Mark invalidated patterns as `Status: Obsolete (pivot: [reason])`
61
+
62
+ 6. **Rules files** (`.vscode/instructions/*.md`) — optional, flag only:
63
+ - Do any instruction files reference old direction (e.g., old framework names, deprecated patterns)?
64
+ - Flag for user to update manually if tech stack or architecture changed
65
+ - Note: Pivot does NOT auto-update rules files — they are outside harness scope. Only flag them for the user's attention.
66
+
67
+ ### Step 3: Present Change Plan
68
+
69
+ Before writing anything, present a summary to the user:
70
+
71
+ ```
72
+ ## Pivot: [one-sentence description]
73
+ Type: [Tech Swap | Scope Change | Architecture Shift | Goal Pivot]
74
+
75
+ ### State File Changes:
76
+ - docs/project-brief.md: [what changes]
77
+ - docs/features.md: [N features affected, M dropped, K added]
78
+ - docs/dependency-map.md: [N modules obsoleted, M added, K relationships changed]
79
+ - docs/project-state.md: [N stories affected]
80
+ - docs/failure-patterns.md: [N patterns obsoleted]
81
+
82
+ ### Confirm? (yes/no)
83
+ ```
84
+
85
+ - If **yes**: Proceed to Step 4 (update all state files)
86
+ - If **no**: Pivot is cancelled — no state files modified, return to current direction
87
+
88
+ ### Step 4: Execute Updates
89
+
90
+ After user confirms, update ALL state files in order:
91
+
92
+ 1. **docs/project-brief.md** first (source of truth for direction)
93
+ 2. **docs/features.md** second (what we're building)
94
+ 3. **docs/dependency-map.md** third (how it connects)
95
+ 4. **docs/project-state.md** fourth (current work status)
96
+ 5. **docs/failure-patterns.md** last (historical patterns)
97
+
98
+ ### Step 5: Decision Log Entry
99
+
100
+ Add an entry to the Decision Log section in docs/project-brief.md:
101
+
102
+ ```markdown
103
+ ### [YYYY-MM-DD] [Decision Title]
104
+ - **Change**: [What changed]
105
+ - **Reason**: [Why this decision was made]
106
+ - **Impact**: [What was affected]
107
+ - **Alternatives Considered**: [1-2 bullet points on what was rejected and why]
108
+ ```
109
+
110
+ ### 🧭 Navigation — After Pivot
111
+
112
+ After pivot completes, always append a 🧭 block:
113
+
114
+ | Pivot Result | 🧭 Next Step |
115
+ |---|---|
116
+ | All state files updated | `planner` — "변경된 방향에 맞춰 재계획해줘" |
117
+ | Crew artifacts exist for new direction | `bootstrap` (🟣) — "crew 산출물을 기반으로 state를 다시 세팅해줘" |
118
+ | User cancelled | 🏁 No action — "기존 방향을 유지합니다" |
119
+
120
+ Example 🧭 block:
121
+ ```
122
+ ---
123
+ 🧭 Next Step
124
+ → Next: `planner`
125
+ → Prompt: "변경된 방향에 맞춰 재계획해줘"
126
+ → Why: Direction changed — re-plan features for new goals
127
+ → Pipeline: 🟡 Step 2/2
128
+ ---
129
+ ```
130
+
131
+ ## Rules
132
+
133
+ - **Never skip the confirmation step** — the user must approve before any state file is written
134
+ - **Never update partially** — if you update docs/project-brief.md, you MUST check and update all other state files too
135
+ - **Preserve history** — mark dropped features as `⛔ dropped`, don't delete rows
136
+ - **Record the why** — every pivot must have a Decision Log entry with reasoning
137
+
138
+ ## Team Mode
139
+
140
+ If `.harness/` directory exists (Team mode is active):
141
+
142
+ - **pivot MUST be run on the default branch** by the designated authority (per project-brief.md → Key Technical Decisions; default: team lead) only
143
+ - Feature branches should NOT run pivot independently
144
+ - If a direction change is needed from a feature branch:
145
+ 1. Document the proposed change
146
+ 2. Share with the team
147
+ 3. The designated authority runs pivot on the default branch
148
+ 4. All developers pull the latest shared state files
149
+ 5. Each developer's `.harness/` personal state is unaffected (update manually if needed)
150
+
151
+ <!-- TEAM_MODE_START -->
152
+ ## Team Mode: Pivot Lock
153
+
154
+ ### Who Can Run Pivot
155
+ - **The designated authority** runs pivot, and **only on the default branch** (per project-brief.md → Key Technical Decisions; default: team lead on main)
156
+ - If you are not the designated authority, propose the direction change instead:
157
+ 1. Document proposed change in a GitHub issue or Slack message
158
+ 2. Discuss with the team
159
+ 3. The designated authority runs pivot after consensus
160
+
161
+ ### Branch Check
162
+ Before running pivot, verify:
163
+ 1. You are on the default branch (per project-brief.md; default: main): `git branch --show-current`
164
+ 2. Your working tree is clean: `git status` must show no uncommitted changes
165
+ 3. You have pulled the latest: `git pull`
166
+
167
+ ### After Pivot
168
+ 1. Commit and push the updated shared files
169
+ 2. Notify all team members to pull the latest shared state files
170
+ 3. Each developer's personal .harness/ files are NOT auto-updated — developers should review the pivot changes and manually update their personal state if needed
171
+ <!-- TEAM_MODE_END -->
@@ -0,0 +1,101 @@
1
+ # Security Checklist
2
+
3
+ ## Purpose
4
+
5
+ Inspect for security risks before committing code.
6
+ Prevents credential leaks and accidental commits of sensitive files. (FP-004)
7
+
8
+ ## Invoked By
9
+
10
+ - **reviewer** agent — Step 4: Security risk inspection
11
+
12
+ ## When to Apply
13
+
14
+ - Before running `git add` or committing
15
+ - When creating new files
16
+ - When modifying config or environment files
17
+ - When changing authentication/authorization code
18
+
19
+ ## Procedure
20
+
21
+ 1. **Check staging area**: Run `git diff --cached --name-only` to list files staged for commit
22
+ 2. **Read docs/failure-patterns.md**: Check FP-004 status. If frequency > 0, apply extra scrutiny:
23
+ - Review ALL .gitignore patterns for completeness
24
+ - Search code for hardcoded secrets using regex patterns (e.g., `password\s*=`, `api_key`, `secret`)
25
+ - Verify `.env.example` exists but `.env` is gitignored
26
+ 3. **Scan for forbidden files**: Check if .env, credentials, *.pem, *.key, *.keystore, *.jks, *.p12, *.pfx, *.pkcs12, firebase.json, secrets.yml, docker-compose.override.yml files are staged
27
+ 4. **Scan for hardcoded secrets**: Search staged files for passwords, API keys, tokens using these mandatory regex patterns:
28
+
29
+ | Pattern | Catches |
30
+ |---|---|
31
+ | `password\s*[=:]\s*["'][^"']+` | Hardcoded passwords |
32
+ | `api[_-]?key\s*[=:]\s*["'][^"']+` | API keys |
33
+ | `(secret|token)\s*[=:]\s*["'][^"']+` | Secrets and tokens |
34
+ | `(aws_access_key_id|aws_secret_access_key)\s*=` | AWS credentials |
35
+ | `-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----` | Private key contents |
36
+ | `mongodb(\+srv)?://[^\s]+` | Database connection strings |
37
+ | `eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}` | JWT tokens (base64 header.payload) |
38
+ | `client[_-]?secret\s*[=:]\s*["'][^"']+` | OAuth2 client secrets |
39
+
40
+ Run: `grep -rEn '<pattern>' <staged files>` for each pattern.
41
+ 5. **Verify .gitignore**: Ensure new environment files are covered by .gitignore
42
+ 6. **Check for temp files**: Verify tmp_*, debug_*, coverage_* files are not staged
43
+
44
+ ## Checklist
45
+
46
+ - [ ] docs/failure-patterns.md reviewed for FP-004 history
47
+ - [ ] (FP-004) No .env, credentials, *.key files in staging area
48
+ - [ ] (FP-004) No hardcoded passwords, API keys, or tokens in code
49
+ - [ ] Sensitive file patterns are registered in .gitignore
50
+ - [ ] No temp files (tmp_*, debug_*, coverage_*) in staging area
51
+ - [ ] Recommended: Use explicit per-file staging unless your team allows `git add .` (per project-brief.md → Key Technical Decisions)
52
+
53
+ ## Example
54
+
55
+ ### Good
56
+ ```bash
57
+ git add src/auth/login.ts tests/auth/login.test.ts
58
+ # Environment variable via config module
59
+ const dbPassword = process.env.DB_PASSWORD;
60
+ ```
61
+
62
+ ### Bad
63
+ ```bash
64
+ git add .
65
+ # Hardcoded password
66
+ const dbPassword = "super_secret_123";
67
+ ```
68
+
69
+ ## State File Updates (mandatory)
70
+
71
+ After completing the security check:
72
+
73
+ - [ ] **docs/failure-patterns.md**: If a security issue was found (credentials staged, hardcoded secret), add a new FP-NNN entry or increment FP-004 Frequency.
74
+ - [ ] **docs/project-state.md**: If security issues were found, add ONE summary entry to Recent Changes: "⚠️ Security: [N] issues found and fixed — [brief description]". This ensures the next session's Quick Summary includes the security context.
75
+
76
+ ### 🧭 Navigation — After Security Check
77
+
78
+ Security-checklist is invoked BY `reviewer` (Step 4). After completion, control returns to the reviewer's flow.
79
+ If invoked directly by the user, append:
80
+
81
+ ```
82
+ ---
83
+ 🧭 Next Step
84
+ → Next: `reviewer`
85
+ → Prompt: "코드를 리뷰해줘"
86
+ → Why: Security scan complete — proceed with full review
87
+ → Pipeline: N/A (utility skill — invoked by reviewer Step 4)
88
+ ---
89
+ ```
90
+
91
+ ## Related Failure Patterns
92
+
93
+ - FP-004: Dangerous file committed → Checklist items 2, 5 (no forbidden files, no temp files)
94
+
95
+ <!-- TEAM_MODE_START -->
96
+ ## Team Mode: Security
97
+
98
+ - Personal state files (.harness/) are gitignored — they cannot leak via git
99
+ - When committing shared config files (docs/), verify no team credentials or shared secrets are included
100
+ - If a security issue is found in a shared module, notify the module Owner before fixing
101
+ <!-- TEAM_MODE_END -->
@@ -0,0 +1,94 @@
1
+ # Test Integrity
2
+
3
+ ## Purpose
4
+
5
+ Ensure test mocks stay synchronized when repository/service interfaces change.
6
+ Prevents the most common LLM coding failure: updating an interface but forgetting to update corresponding mocks. (FP-001)
7
+
8
+ ## Invoked By
9
+
10
+ - **reviewer** agent — Step 3: Mock synchronization verification
11
+
12
+ ## When to Apply
13
+
14
+ - Adding, removing, or modifying methods on a repository/service interface
15
+ - Creating a new repository or service
16
+ - When a use case starts calling a new interface method
17
+
18
+ ## Procedure
19
+
20
+ 1. **Read docs/failure-patterns.md**: Check FP-001 status. If frequency > 0, this project has a history of mock sync failures — apply extra scrutiny to every interface change.
21
+ 2. **Identify changed interfaces**: Find modified files in your interface directory
22
+ 3. **Map to mock files**: Locate the corresponding mock file for each changed interface. Convention depends on project structure (see project-brief.md → Key Technical Decisions). Common patterns:
23
+ - `src/domain/Interface.ts` → `tests/__mocks__/Interface.mock.ts`
24
+ - `src/services/Service.ts` → `src/services/__mocks__/Service.ts`
25
+ 4. **Sync methods**: Verify every interface method exists in the mock
26
+ 5. **Verify return types**: Confirm mock return values match the interface return types (FP-002: watch for type confusion)
27
+ 6. **Check consumers**: Verify use case tests correctly use the new mock methods. Each new mock method must have at least one test that: (1) calls the method, (2) checks return value, (3) verifies behavior (e.g., await/resolve if async)
28
+
29
+ ## Checklist
30
+
31
+ - [ ] docs/failure-patterns.md reviewed for FP-001 history
32
+ - [ ] (FP-001) Every changed interface method is reflected in its mock
33
+ - [ ] (FP-002) Mock return types match interface signatures (no type confusion)
34
+ - [ ] New methods have default mock return values set
35
+ - [ ] Use case tests correctly use the new mock methods
36
+ - [ ] Existing tests still pass
37
+
38
+ ## Example
39
+
40
+ ### Good
41
+ ```
42
+ Interface adds findByFilters() → Mock adds findByFilters with mockResolvedValue([])
43
+ Both changes in the same commit.
44
+ ```
45
+
46
+ ### Bad
47
+ ```
48
+ Interface adds findByFilters() → Mock unchanged
49
+ → Runtime error: method not found on mock object
50
+ ```
51
+
52
+ ## State File Updates (mandatory)
53
+
54
+ After synchronizing mocks:
55
+
56
+ - [ ] **docs/failure-patterns.md**: If mock sync was missed and caused a test failure, increment FP-001 Frequency.
57
+ - [ ] **docs/dependency-map.md**: If the interface change altered module relationships, update the relevant row.
58
+ - [ ] **docs/project-state.md**: If mock sync issues were found and fixed, add to Recent Changes: "🔧 Test: [interface] mock synchronized". This ensures the next session is aware of the fix.
59
+
60
+ ## Testing Rules (enforced during this skill)
61
+
62
+ - Mocks must implement ALL interface methods. Missing method = build failure.
63
+ - Recommended: Avoid `any` type casting on mocks — create mocks using the actual interface type (adjust per project-brief.md → Key Technical Decisions). If typing is complex, extract to a shared mock type file.
64
+ - New methods must have default mock return values (e.g., `mockResolvedValue`, stub returns).
65
+ - Recommended: No `skip`, `only`, or debug statements in committed test files.
66
+ - Async tests must use `await`. No floating promises.
67
+ - Each test must be independent. No shared state between tests.
68
+
69
+ ### 🧭 Navigation — After Test Integrity
70
+
71
+ Test-integrity is invoked BY `reviewer` (Step 3). After completion, control returns to the reviewer's flow.
72
+ If invoked directly by the user, append:
73
+
74
+ ```
75
+ ---
76
+ 🧭 Next Step
77
+ → Next: `reviewer`
78
+ → Prompt: "코드를 리뷰해줘"
79
+ → Why: Mock sync verified — proceed with full review
80
+ → Pipeline: N/A (utility skill — invoked by reviewer Step 3)
81
+ ---
82
+ ```
83
+
84
+ ## Related Failure Patterns
85
+
86
+ - FP-001: Interface changed, mock not updated → Checklist item 2
87
+ - FP-002: Type confusion → Step 5 return type verification
88
+
89
+ <!-- TEAM_MODE_START -->
90
+ ## Team Mode: Test Integrity
91
+
92
+ - If the interface you changed is owned by another developer (check docs/dependency-map.md Owner), notify them about the mock update requirement
93
+ - When updating shared test fixtures or mocks, run `git pull` first to avoid overwriting teammates' changes
94
+ <!-- TEAM_MODE_END -->