k-harness 0.3.0 → 0.5.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 CHANGED
@@ -1,16 +1,17 @@
1
1
  # K-Harness
2
2
 
3
- LLM Development Harness IDE-agnostic rules, skills, and agents that prevent common AI coding failures.
3
+ Project Direction Management Framework for LLM-Driven Development.
4
4
 
5
5
  ## What It Does
6
6
 
7
- K-Harness installs structured instruction files into your project that guide LLM coding agents (Copilot, Claude, Cursor, Codex, Windsurf) to avoid common mistakes:
7
+ K-Harness manages your **project's direction** goals, decisions, scope so LLM coding agents stay aligned across sessions. It combines BMAD's systematic project management with gstack's simplicity: zero dependencies, IDE-native format generation, and minimal context overhead.
8
8
 
9
- - **Iron Laws** — Hard rules the LLM must follow every session (mock sync, type checking, security)
10
- - **Skills** — Step-by-step procedures for specific tasks (debugging, code review, security checks)
11
- - **Agents** — Role-based personas (reviewer, sprint manager)
9
+ - **Direction Guard** — Every coding request is checked against project goals/non-goals before execution
10
+ - **State Files** — 5 markdown files that persist project knowledge across LLM sessions
11
+ - **Skills** — Step-by-step procedures for planning, review, debugging, and direction changes
12
+ - **Agents** — Role-based personas that enforce the workflow (planner, reviewer, sprint-manager)
12
13
  - **Failure Patterns** — Project-specific failure log that prevents repeat mistakes
13
- - **State Tracking** — Sprint/Story state so the LLM knows what to work on
14
+ - **Decision Log** — Records why decisions were made so LLMs don't re-debate settled choices
14
15
 
15
16
  ## Quick Start
16
17
 
@@ -20,6 +21,12 @@ npx k-harness init
20
21
 
21
22
  Select your IDE when prompted. Files are installed into the current directory.
22
23
 
24
+ After installation, ask your LLM to run the `bootstrap` skill:
25
+
26
+ > "Run bootstrap to onboard this project."
27
+
28
+ This scans your codebase and fills all 5 state files automatically.
29
+
23
30
  ### Non-interactive
24
31
 
25
32
  ```bash
@@ -46,13 +53,13 @@ npx k-harness init --ide antigravity
46
53
  |-----|-------------|-------------------|--------|--------|
47
54
  | **VS Code Copilot** | `.github/copilot-instructions.md` | `.vscode/instructions/*.instructions.md` | `.github/skills/*/SKILL.md` | `.github/agents/*.agent.md` |
48
55
  | **Claude Code** | `CLAUDE.md` | (merged into CLAUDE.md) | `.claude/skills/*/SKILL.md` | (merged into CLAUDE.md) |
49
- | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` |
56
+ | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | (merged into rules) | (merged into rules) |
50
57
  | **Codex** | `AGENTS.md` | (merged into AGENTS.md) | `.agents/skills/*/SKILL.md` | (merged into AGENTS.md) |
51
58
  | **Windsurf** | `.windsurfrules` | (merged) | (merged) | (merged) |
52
59
  | **Augment Code** | `.augment/rules/core.md` | `.augment/rules/*.md` | `.augment/skills/*/SKILL.md` | `.augment/skills/*/SKILL.md` |
53
60
  | **Google Antigravity** | `.agent/rules/core.md` | `.agent/rules/*.md` | `.agent/skills/*/SKILL.md` | `.agent/skills/*/SKILL.md` |
54
61
 
55
- All IDEs also get `project-state.md`, `failure-patterns.md`, `features.md`, and `project-brief.md` at the project root.
62
+ All IDEs also get `project-state.md`, `project-brief.md`, `features.md`, `failure-patterns.md`, and `dependency-map.md` at the project root.
56
63
 
57
64
  ## What Gets Installed
58
65
 
@@ -62,47 +69,69 @@ All IDEs also get `project-state.md`, `failure-patterns.md`, `features.md`, and
62
69
  - **Backend Rules** — Dependency inversion, type safety, explicit staging (applied to source files)
63
70
 
64
71
  ### Skills (on-demand procedures)
72
+ - **bootstrap** — Onboard project into K-Harness: scans codebase + fills state files automatically
73
+ - **learn** — End-of-session wrap-up: captures failure patterns, updates project state
74
+ - **pivot** — Propagate direction changes across all state files when goals/tech/scope changes
65
75
  - **test-integrity** — Verify mock/interface synchronization before committing
66
76
  - **security-checklist** — Pre-commit security risk scan
67
77
  - **investigate** — 4-phase systematic debugging (evidence → scope → fix → verify)
78
+ - **impact-analysis** — Assess change blast radius before modifying shared modules
79
+ - **feature-breakdown** — Decompose features into dependency-ordered implementation tasks
68
80
 
69
81
  ### Agents (role-based personas)
70
- - **reviewer** — Code review: architecture, tests, security, failure pattern cross-check
71
- - **sprint-manager** — Sprint/Story state management, scope drift prevention
72
-
73
- ### State Files
74
- - **project-state.md** — Current sprint, stories, and progress tracking
75
- - **failure-patterns.md** — Template for logging project-specific failure patterns
76
-
77
- ## After Installation
82
+ - **planner** — Feature planning, dependency analysis, Direction Alignment (goal/non-goal/decision check)
83
+ - **reviewer** — Code review + State File Audit (verifies state files were actually updated)
84
+ - **sprint-manager** — Sprint/Story state management, scope drift prevention, Next Step Recommendation
78
85
 
79
- 1. **Edit `project-state.md`** — Set up your first sprint and stories
80
- 2. **Customize global rules** — Add your architecture, type rules, and directory structure
81
- 3. **Log failures** — When an LLM makes a repeated mistake, record it in `failure-patterns.md`
86
+ ### State Files (project memory)
87
+ - **project-brief.md** — Project vision, goals, non-goals, Decision Log (the "why")
88
+ - **project-state.md** — Current sprint, stories, and progress tracking (the "where")
89
+ - **features.md** — Living feature registry so LLMs know what exists (the "what")
90
+ - **dependency-map.md** — Module dependency graph for impact analysis (the "how")
91
+ - **failure-patterns.md** — Project-specific failure patterns that prevent repeat mistakes (the "watch out")
82
92
 
83
- ## Design Principles
93
+ ## How It Works
84
94
 
85
- 1. **State Injection** — Project state injected at every session start
86
- 2. **Rigid Workflow** — Hard "do/don't" rules; soft suggestions get ignored by LLMs
87
- 3. **Failure-Driven Rules** — Rules derived only from actual project failures
88
- 4. **Completion Status Protocol** — DONE / BLOCKED / NEEDS_CONTEXT reporting
89
- 5. **Scope Lock** — Escalate before modifying files outside current story scope
95
+ ### 1. Bootstrap (once)
96
+ After `k-harness init`, run the `bootstrap` skill. It scans your codebase, interviews you about goals/non-goals, and fills all 5 state files automatically. **This is the most important step** — without it, Direction Guard and other skills have no context.
90
97
 
91
- ## Research & Analysis
98
+ ### 2. Direction Guard (every request)
99
+ Before ANY coding task, the LLM reads `project-brief.md` and checks:
100
+ - Does this align with Goals? → proceed
101
+ - Does this fall under Non-Goals? → warn, suggest `pivot`
102
+ - Does this contradict a Decision Log entry? → warn, suggest `pivot`
92
103
 
104
+ ### 3. Workflow Pipeline
93
105
  ```
94
- docs/
95
- ├── analysis/ # Framework comparisons
96
- │ ├── comparison.md # BMAD vs gstack
97
- │ ├── bmad-deep-dive.md
98
- │ └── gstack-deep-dive.md
99
- ├── architecture/ # K-Harness design
100
- │ ├── design-principles.md
101
- │ ├── file-structure.md
102
- │ └── skill-spec.md
103
- └── case-study/
104
- └── mcphub-lessons.md
106
+ bootstrap → planner → [code] → reviewer → sprint-manager → learn
105
107
  ```
108
+ - **planner**: Checks direction alignment, breaks down features
109
+ - **reviewer**: Reviews code + audits state file updates
110
+ - **sprint-manager**: Tracks progress, recommends next action
111
+ - **learn**: Captures lessons before session ends
112
+
113
+ ### 4. Direction Changes
114
+ When goals, technology, or scope changes, run the `pivot` skill:
115
+ - Updates ALL 5 state files consistently
116
+ - Records the decision with reasoning in Decision Log
117
+ - Prevents silent inconsistencies across files
118
+
119
+ ## Documentation
120
+
121
+ See [docs/reference.md](docs/reference.md) for detailed descriptions of every skill, agent, rule, and state file.
122
+
123
+ ## Why Not BMAD or gstack?
124
+
125
+ | | BMAD v6.2.2 | gstack v0.15.1 | K-Harness |
126
+ |---|---|---|---|
127
+ | Focus | Enterprise SDLC methodology | 1-person software factory | Project direction management |
128
+ | Files | 200+ | ~40 | 15 |
129
+ | Dependencies | Node 20+ | Bun + Node + Playwright | Zero |
130
+ | IDE support | 20+ (installer) | 5 (setup --host) | 7 (native format) |
131
+ | Direction management | ❌ | ❌ | ✅ (Direction Guard + pivot + Decision Log) |
132
+ | Cold start | ❌ | ❌ | ✅ (bootstrap) |
133
+ | State file audit | ❌ | ❌ | ✅ (reviewer Step 8) |
134
+ | Context per task | 4-6 files | 1 file | 2-3 files |
106
135
 
107
136
  ## License
108
137
 
@@ -0,0 +1,25 @@
1
+ # Planner Memory
2
+
3
+ > 이 파일은 planner 에이전트가 세션 간 학습 내용을 유지하기 위해 자동 업데이트합니다.
4
+ > learn 스킬이 세션 종료 시 갱신합니다. 직접 편집하지 마세요.
5
+
6
+ ## 추정 정확도
7
+
8
+ <!-- 예시:
9
+ - Wave 1 추정: 정확 (실제 소요시간과 일치)
10
+ - Wave 3+ 추정: 낙관적 경향 — 실제로 2배 소요
11
+ -->
12
+
13
+ ## 프로젝트 아키텍처 인사이트
14
+
15
+ <!-- 예시:
16
+ - 이 프로젝트는 domain → application → infrastructure 순으로 의존
17
+ - shared/ 폴더 변경 시 전체 리빌드 필요
18
+ -->
19
+
20
+ ## 반복 패턴
21
+
22
+ <!-- 예시:
23
+ - 새 기능 추가 시 항상 middleware + route + controller + service 4파일 세트
24
+ - DB 마이그레이션 파일 생성을 빠뜨리는 경향
25
+ -->
@@ -0,0 +1,24 @@
1
+ # Reviewer Memory
2
+
3
+ > 이 파일은 reviewer 에이전트가 세션 간 학습 내용을 유지하기 위해 자동 업데이트합니다.
4
+ > learn 스킬이 세션 종료 시 갱신합니다. 직접 편집하지 마세요.
5
+
6
+ ## 프로젝트별 리뷰 패턴
7
+
8
+ <!-- 예시:
9
+ - SQL injection 패턴이 빈번 — req.params를 직접 쿼리에 넣는 코드가 반복됨
10
+ - mock sync 누락률 높음 — interface 변경 시 50%가 mock 미동기화
11
+ -->
12
+
13
+ ## 자주 놓치는 항목
14
+
15
+ <!-- 예시:
16
+ - docs/features.md 업데이트 누락 (Iron Law #7)
17
+ - 테스트 파일에 실제 DB 연결하는 코드
18
+ -->
19
+
20
+ ## 리뷰 통계
21
+
22
+ - 총 리뷰 횟수: 0
23
+ - 자동 수정 건수: 0
24
+ - 에스컬레이션 건수: 0
@@ -0,0 +1,26 @@
1
+ # Sprint Manager Memory
2
+
3
+ > 이 파일은 sprint-manager 에이전트가 세션 간 학습 내용을 유지하기 위해 자동 업데이트합니다.
4
+ > learn 스킬이 세션 종료 시 갱신합니다. 직접 편집하지 마세요.
5
+
6
+ ## Velocity 추적
7
+
8
+ <!-- 예시:
9
+ - Sprint 1: 3 stories 완료 / 5 stories 계획 (60%)
10
+ - Sprint 2: 4 stories 완료 / 4 stories 계획 (100%)
11
+ - 평균 velocity: 스프린트당 3.5 stories
12
+ -->
13
+
14
+ ## 스코프 드리프트 이력
15
+
16
+ <!-- 예시:
17
+ - S1-003에서 스코프 밖 파일 3개 수정 발생 — 사전 경고 부족
18
+ - S2-001에서 방향 전환 요청 → pivot 스킬로 전환
19
+ -->
20
+
21
+ ## 추천 패턴
22
+
23
+ <!-- 예시:
24
+ - 이 프로젝트는 스프린트당 4 stories가 적절
25
+ - Story 크기가 5파일 이상이면 분할 권장
26
+ -->
@@ -13,11 +13,11 @@ The Planner is the entry point for new features — use it BEFORE writing code.
13
13
 
14
14
  ## Referenced Files
15
15
 
16
- - project-brief.md — Project vision, goals, and non-goals
17
- - features.md — Feature registry
18
- - dependency-map.md
19
- - project-state.md
20
- - failure-patterns.md
16
+ - docs/project-brief.md — Project vision, goals, and non-goals
17
+ - docs/features.md — Feature registry
18
+ - docs/dependency-map.md
19
+ - docs/project-state.md
20
+ - docs/failure-patterns.md
21
21
 
22
22
  ## Input
23
23
 
@@ -28,31 +28,45 @@ One of:
28
28
 
29
29
  ## Procedure
30
30
 
31
+ ### Step 0: State File Readiness
32
+
33
+ Before proceeding, verify that required state files have content (not just TODO placeholders):
34
+ - `docs/project-brief.md` — Must have Vision and Goals filled
35
+ - `docs/features.md` — Must have at least one feature row
36
+ - `docs/dependency-map.md` — Must have at least one module row (for existing projects)
37
+
38
+ If ALL files are empty/placeholder-only → **Stop and run the `bootstrap` skill first.** Report: "State files are empty. Running bootstrap to onboard this project."
39
+ If `docs/project-brief.md` alone is empty → Warn the user but proceed (the plan will lack direction guard).
40
+
31
41
  ### For New Feature
32
42
 
33
- 1. Read `project-brief.md` to understand project vision, goals, and **non-goals**
34
- 2. **Direction Guard**: Verify the requested feature aligns with the project goals and does NOT fall into non-goals. If it conflicts, warn the user before proceeding.
35
- 3. Read `features.md` to understand what already exists
36
- 4. Read `dependency-map.md` to understand current architecture
37
- 5. Read `project-state.md` for current Sprint context
43
+ 1. Read `docs/project-brief.md` to understand project vision, goals, **non-goals**, and **Decision Log**
44
+ 2. **Direction Alignment**: Verify the requested feature against three checkpoints:
45
+ - **Goal Alignment**: Does it serve a listed Goal? If no clear link, warn the user.
46
+ - **Non-Goal Violation**: Does it fall into Non-Goals? If yes, **stop and ask** — this may be a pivot.
47
+ - **Decision Consistency**: Does it contradict any Decision Log entry? If yes, warn that a previous decision conflicts — recommend running the `pivot` skill before proceeding.
48
+ If the request represents a clear direction change → recommend running the `pivot` skill instead of proceeding with planning.
49
+ 3. Read `docs/features.md` to understand what already exists
50
+ 4. Read `docs/dependency-map.md` to understand current architecture
51
+ 5. Read `docs/project-state.md` for current Sprint context
38
52
  6. Identify which existing modules are affected
39
53
  7. Identify new modules that need to be created
40
54
  8. Run **feature-breakdown** skill to create ordered task list
41
55
  9. Run **impact-analysis** skill for each existing module being modified
42
- 10. Check `failure-patterns.md` for relevant past mistakes
56
+ 10. Check `docs/failure-patterns.md` for relevant past mistakes
43
57
  11. Produce implementation plan (see Output Format)
44
- 12. Update `project-state.md` with the new Story
45
- 13. Update `features.md` with the new feature entry
58
+ 12. Update `docs/project-state.md` with the new Story
59
+ 13. Update `docs/features.md` with the new feature entry
46
60
 
47
61
  ### For Architecture Query
48
62
 
49
- 1. Read `dependency-map.md`
63
+ 1. Read `docs/dependency-map.md`
50
64
  2. Answer the query with specific module names, dependencies, and layer info
51
65
  3. If the query reveals missing entries in the map, flag them
52
66
 
53
67
  ### For Refactor Plan
54
68
 
55
- 1. Read `dependency-map.md` to map the blast radius
69
+ 1. Read `docs/dependency-map.md` to map the blast radius
56
70
  2. Run **impact-analysis** skill on each module being refactored
57
71
  3. Identify safe refactoring order (leaf modules first, core modules last)
58
72
  4. Produce refactoring plan with rollback checkpoints
@@ -79,7 +93,7 @@ One of:
79
93
  - [Any high-coupling areas to watch]
80
94
 
81
95
  ### Dependency Map Changes
82
- [Additions/modifications to dependency-map.md]
96
+ [Additions/modifications to docs/dependency-map.md]
83
97
  ```
84
98
 
85
99
  ### Architecture Query Response
@@ -93,8 +107,8 @@ One of:
93
107
 
94
108
  ## Constraints
95
109
 
96
- - Never skip reading dependency-map.md — the plan is only as good as the map
97
- - If dependency-map.md is empty or outdated, report this FIRST
110
+ - Never skip reading docs/dependency-map.md — the plan is only as good as the map
111
+ - If docs/dependency-map.md is empty or outdated, report this FIRST
98
112
  - All plans must include test tasks (no code without tests)
99
113
  - If a feature affects 5+ modules, flag as High Risk
100
114
  - If the plan exceeds one Sprint's worth of work, suggest splitting into sub-features
@@ -13,12 +13,20 @@ Finds issues and auto-fixes where safe, escalates where not.
13
13
 
14
14
  ## Referenced Files
15
15
 
16
- - failure-patterns.md — Project failure patterns
17
- - project-state.md — Current Story scope
18
- - dependency-map.md — Module dependency graph
16
+ - docs/failure-patterns.md — Project failure patterns
17
+ - docs/project-state.md — Current Story scope
18
+ - docs/dependency-map.md — Module dependency graph
19
19
 
20
20
  ## Procedure
21
21
 
22
+ ### Step 0: State File Readiness
23
+
24
+ Before reviewing, verify that required state files exist and are not empty:
25
+ - `docs/failure-patterns.md` — Must exist (needed for Step 5 cross-check)
26
+ - `docs/project-state.md` — Must have current Sprint info (needed for scope check)
27
+
28
+ If state files are empty/placeholder-only → Warn: "State files are not filled. Review will proceed but scope check and failure pattern cross-check will be limited. Consider running `bootstrap` skill."
29
+
22
30
  ### Input
23
31
 
24
32
  Changed file list (user-provided or from `git diff --name-only`)
@@ -27,7 +35,7 @@ Changed file list (user-provided or from `git diff --name-only`)
27
35
 
28
36
  **Step 1: Identify Change Scope**
29
37
  - Run `git diff --cached --stat` or `git diff --stat` to see changed files
30
- - Compare against current Story scope in project-state.md
38
+ - Compare against current Story scope in docs/project-state.md
31
39
 
32
40
  **Step 2: Architecture Rule Check**
33
41
  - [ ] No imports from infrastructure in domain layer
@@ -45,20 +53,31 @@ Changed file list (user-provided or from `git diff --name-only`)
45
53
  - [ ] No injection vulnerabilities (SQL, XSS)
46
54
 
47
55
  **Step 5: Failure Pattern Cross-Check**
48
- - Compare current changes against all FP-NNN items in failure-patterns.md
56
+ - Compare current changes against all FP-NNN items in docs/failure-patterns.md
49
57
  - Warn if any pattern applies
50
58
 
51
59
  **Step 6: Feature Registry Check**
52
- - [ ] If a new feature was added, verify it is registered in features.md (Iron Law #7)
53
- - [ ] If feature files changed, verify features.md key files are up to date
54
- - [ ] If tests were added/removed, verify features.md test files column is accurate
60
+ - [ ] If a new feature was added, verify it is registered in docs/features.md (Iron Law #7)
61
+ - [ ] If feature files changed, verify docs/features.md key files are up to date
62
+ - [ ] If tests were added/removed, verify docs/features.md test files column is accurate
55
63
 
56
64
  **Step 7: Dependency Map Check**
57
- - [ ] If new modules were added, verify they are registered in dependency-map.md (Iron Law #6)
65
+ - [ ] If new modules were added, verify they are registered in docs/dependency-map.md (Iron Law #6)
58
66
  - [ ] If module interfaces changed, verify "Depends On" / "Depended By" columns are updated
59
- - [ ] If module was deleted/renamed, verify dependency-map.md is cleaned up
67
+ - [ ] If module was deleted/renamed, verify docs/dependency-map.md is cleaned up
60
68
  - [ ] Run impact-analysis skill if interface changes affect 2+ dependent modules
61
69
 
70
+ **Step 8: State File Audit**
71
+
72
+ Verify that state file updates actually happened. Check each:
73
+ - [ ] **docs/project-state.md**: If stories were worked on, is Quick Summary current? Are story statuses updated?
74
+ - [ ] **docs/features.md**: If new features were added, are they registered? If features were completed, is status updated?
75
+ - [ ] **docs/dependency-map.md**: If new modules were created, are they registered? If dependencies changed, are relationships updated?
76
+ - [ ] **docs/failure-patterns.md**: If a bug was fixed that matched a pattern, was frequency incremented?
77
+ - [ ] **docs/project-brief.md**: If a technology or architectural decision was made, is it in Decision Log?
78
+
79
+ For each missing update: flag as `[STATE-AUDIT]` in the output and provide the exact update that should be made.
80
+
62
81
  ### Output Format
63
82
 
64
83
  ```
@@ -7,11 +7,19 @@ Keeps the LLM focused on the current work item.
7
7
 
8
8
  ## Referenced Files
9
9
 
10
- - project-state.md — Current state (this is the core file)
11
- - failure-patterns.md — Recurring failure tracking
10
+ - docs/project-state.md — Current state (this is the core file)
11
+ - docs/failure-patterns.md — Recurring failure tracking
12
12
 
13
13
  ## Procedure
14
14
 
15
+ ### Step 0: State File Readiness
16
+
17
+ Before handling any request, verify `docs/project-state.md` has content:
18
+ - Quick Summary must not be all TODO placeholders
19
+ - Story Status table must have at least one row
20
+
21
+ If `docs/project-state.md` is empty/placeholder-only → **Recommend running `bootstrap` skill first.** Report: docs/project-state.md is empty. Run bootstrap to initialize project state before tracking sprints."
22
+
15
23
  ### Input
16
24
 
17
25
  User request: "next task", "current status", "story done", "new sprint", "scope check"
@@ -19,26 +27,50 @@ User request: "next task", "current status", "story done", "new sprint", "scope
19
27
  ### Handlers
20
28
 
21
29
  **Request: "current status" / "where are we"**
22
- 1. Read project-state.md
30
+ 1. Read docs/project-state.md
23
31
  2. Summarize: current Sprint, in-progress Story, completed Stories
24
- 3. Recommend next action
32
+ 3. Run **Next Step Recommendation** (see below)
33
+
34
+ **Next Step Recommendation**
35
+
36
+ After every status check, recommend the next action based on current context:
37
+
38
+ 1. Read `docs/project-state.md`, `docs/features.md`, `docs/project-brief.md`, `docs/failure-patterns.md`
39
+ 2. Determine the project phase and recommend accordingly:
40
+
41
+ | Situation | Recommendation |
42
+ |-----------|---------------|
43
+ | State files are empty | → "Run `bootstrap` to onboard this project" |
44
+ |docs/project-brief.md has no Vision/Goals | → "Fill out docs/project-brief.md — this is critical for direction" |
45
+ | No stories exist | → "Run `planner` to break down your first feature" |
46
+ | A story is in-progress | → "Continue S{N}-{M}: [title]. Scope: [files]" |
47
+ | All stories in sprint are done | → "Run `learn` to capture session lessons, then start a new sprint" |
48
+ | A direction change was discussed | → "Run `pivot` to update all state files before continuing" |
49
+ | Recent failure patterns apply | → "Watch out for FP-{NNN}: [description]" |
50
+
51
+ 3. Format the recommendation as:
52
+ ```
53
+ 💡 Recommended next: [action]
54
+ Why: [one-sentence reason]
55
+ Command: [exact skill/agent to invoke]
56
+ ```
25
57
 
26
58
  **Request: "story done" / "S{N}-{M} done"**
27
- 1. Update the Story status to `done` in project-state.md
59
+ 1. Update the Story status to `done` in docs/project-state.md
28
60
  2. Add completion record to "Recent Changes" section
29
61
  3. Guide to next Story if available
30
62
 
31
63
  **Request: "new story" / "next task"**
32
- 1. Find next `todo` Story in project-state.md
64
+ 1. Find next `todo` Story in docs/project-state.md
33
65
  2. Change its status to `in-progress`
34
66
  3. Specify Story scope (related files/directories)
35
- 4. Alert relevant failure-patterns.md items
67
+ 4. Alert relevant docs/failure-patterns.md items
36
68
 
37
69
  **Request: "new sprint"**
38
70
  1. Check all Stories in current Sprint
39
71
  2. Warn if incomplete Stories exist
40
72
  3. Confirm new Sprint number and theme (user input)
41
- 4. Update project-state.md
73
+ 4. Update docs/project-state.md
42
74
 
43
75
  **Scope Check (automatic)**
44
76
  - If user requests a file modification outside current Story scope:
@@ -69,5 +101,5 @@ STATUS: DONE
69
101
  ## Constraints
70
102
 
71
103
  - Do not modify code directly — manage state only
72
- - Only write to project-state.md; read-only for all other files
104
+ - Only write to docs/project-state.md; read-only for all other files
73
105
  - Always confirm with user before modifying scope boundaries
@@ -2,21 +2,23 @@
2
2
 
3
3
  ## Required
4
4
 
5
- - Follow the project's architecture patterns strictly:
5
+ - Follow the project's architecture patterns strictly.
6
+ <!-- TODO: Define your architecture layers. Examples:
6
7
  - Domain layer must not import from infrastructure.
7
8
  - Application layer accesses data only through domain interfaces.
8
9
  - Infrastructure implements domain interfaces.
9
- - Presentation handles routing and DTO conversion only. No business logic.
10
- - Before calling any constructor, read the actual source file to verify parameters. Do not trust memory. (FP-002)
10
+ - Controllers/routes handle request/response only. No business logic.
11
+ -->
12
+ - Before calling any constructor or factory, read the actual source file to verify parameters. Do not trust memory. (FP-002)
11
13
 
12
14
  ## Forbidden
13
15
 
14
- - Importing infrastructure from domain (dependency inversion violation).
15
- - `any` type usage when unavoidable, add `// eslint-disable-next-line` with reason comment.
16
- - Hardcoding environment variables in code. Use `process.env` with centralized config.
16
+ - Violating the project's dependency direction (e.g. importing infrastructure from domain).
17
+ - Suppressing type safety without an explicit reason comment.
18
+ - Hardcoding environment variables or secrets in code. Use centralized config.
17
19
  - `git add .` or `git add -A` — use explicit per-file staging.
18
20
 
19
21
  ## References
20
22
 
21
- - failure-patterns.md FP-002: Type confusion
22
- - failure-patterns.md FP-004: Unnecessary files committed
23
+ - docs/failure-patterns.md FP-002: Type confusion
24
+ - docs/failure-patterns.md FP-004: Unnecessary files committed
@@ -32,18 +32,18 @@
32
32
 
33
33
  1. **Mock Sync**: When you modify a repository/service interface, update corresponding mocks in the same commit.
34
34
  2. **Type Check**: Before calling a constructor or factory, read the actual source file to verify parameters. Do not rely on memory.
35
- 3. **Scope Compliance**: Do not modify files outside the current Story scope (see project-state.md) without reporting first.
35
+ 3. **Scope Compliance**: Do not modify files outside the current Story scope (see docs/project-state.md) without reporting first.
36
36
  4. **Security**: Never include credentials, passwords, or API keys in code or commits.
37
37
  5. **3-Failure Stop**: If the same approach fails 3 times, stop and report to the user.
38
- 6. **Dependency Map**: When adding or modifying a module, update dependency-map.md in the same commit. Register new modules, update relationship columns.
39
- 7. **Feature Registry**: When adding a new feature, register it in features.md in the same commit. Include key files and test files.
40
- 8. **Session Handoff**: Before ending a chat session, update project-state.md Quick Summary. Never leave the project in an undocumented state.
38
+ 6. **Dependency Map**: When adding or modifying a module, update docs/dependency-map.md in the same commit. Register new modules, update relationship columns.
39
+ 7. **Feature Registry**: When adding a new feature, register it in docs/features.md in the same commit. Include key files and test files.
40
+ 8. **Session Handoff**: Before ending a chat session, update docs/project-state.md Quick Summary. Never leave the project in an undocumented state.
41
41
 
42
42
  ## Test Rules
43
43
 
44
44
  - New feature = New test. Do not commit feature code without tests.
45
- - Test command: `npm test` <!-- TODO: customize -->
46
- - Mock location: `tests/__mocks__/` <!-- TODO: customize -->
45
+ - Test command: <!-- TODO: e.g. npm test, pytest, go test ./..., mvn test -->
46
+ - Mock location: <!-- TODO: e.g. tests/__mocks__/, test/fixtures/ -->
47
47
 
48
48
  ## Completion Status Protocol
49
49
 
@@ -59,18 +59,68 @@ Report completion using one of:
59
59
  - When tests fail, quote the test name and error message.
60
60
  - When type errors occur, specify expected type and actual type.
61
61
 
62
+ ## Direction Guard (Every Request)
63
+
64
+ Before starting ANY coding task, do this:
65
+
66
+ 1. Read `docs/project-brief.md` — check Vision, Goals, Non-Goals, and Decision Log
67
+ 2. If `docs/project-brief.md` is empty → run the `bootstrap` skill first, then return to the request
68
+ 3. If the request conflicts with **Non-Goals** → stop and warn: "This falls under Non-Goals. Do you want to proceed? If yes, run `pivot` skill first."
69
+ 4. If the request contradicts a **Decision Log** entry → warn: "This conflicts with a previous decision: [entry]. Run `pivot` skill to update direction."
70
+ 5. If aligned → proceed
71
+
72
+ This applies to EVERY request, not just new sessions. Skip only for trivial questions ("what does this function do?").
73
+
62
74
  ## New Session Bootstrap
63
75
 
64
76
  When starting a NEW chat session, read these files in order before doing any work:
65
- 1. `project-state.md` — Quick Summary tells you where we left off
66
- 2. `features.md` — What features exist in this project
67
- 3. `failure-patterns.md` — What mistakes to avoid
68
- 4. `project-brief.md` — Project vision, goals, and non-goals
77
+ 1. `docs/project-state.md` — Quick Summary tells you where we left off
78
+ 2. `docs/features.md` — What features exist in this project
79
+ 3. `docs/failure-patterns.md` — What mistakes to avoid
80
+ 4. `docs/project-brief.md` — Project vision, goals, and non-goals
81
+
82
+ If ALL state files are empty (only TODOs/placeholders), run the `bootstrap` skill before doing anything else.
83
+
84
+ ## Workflow Pipeline
85
+
86
+ Follow this order for different workflows. Each step's output feeds the next.
87
+
88
+ ### New Feature
89
+ ```
90
+ bootstrap (if state files empty) → planner → [code] → reviewer → sprint-manager → learn
91
+ ```
92
+
93
+ ### Bug Fix
94
+ ```
95
+ investigate → [fix] → test-integrity → reviewer → learn
96
+ ```
97
+
98
+ ### Session Lifecycle
99
+ ```
100
+ [session start] → sprint-manager ("where are we?") → [work] → learn → [session end]
101
+ ```
102
+
103
+ ### Key Rules
104
+ - **planner before code**: Never start coding a feature without running planner first.
105
+ - **reviewer before commit**: Never commit without running reviewer.
106
+ - **learn before closing**: Run learn as the last skill of every session.
107
+ - **bootstrap once**: Run bootstrap once when state files are empty. Not needed after that.
69
108
 
70
109
  ## References
71
110
 
72
- - project-brief.md — Project vision, goals, non-goals (the "why")
73
- - features.md — Feature registry (the "what")
74
- - project-state.md — Sprint/Story tracking, module registry (the "where")
75
- - dependency-map.md — Module dependency graph (the "how")
76
- - failure-patterns.md — Log of known failure patterns (the "watch out")
111
+ - docs/project-brief.md — Project vision, goals, non-goals (the "why")
112
+ - docs/features.md — Feature registry (the "what")
113
+ - docs/project-state.md — Sprint/Story tracking, module registry (the "where")
114
+ - docs/dependency-map.md — Module dependency graph (the "how")
115
+ - docs/failure-patterns.md — Log of known failure patterns (the "watch out")
116
+ - docs/agent-memory/ — Per-agent persistent memory (the "learned")
117
+
118
+ ## State File Size Limits
119
+
120
+ State files must stay compact to fit in LLM context windows. Enforce these limits:
121
+ - **docs/project-brief.md**: Max 200 lines. Keep Vision/Goals/Non-Goals concise.
122
+ - **docs/project-state.md**: Max 300 lines. Archive completed sprints when exceeding limit.
123
+ - **docs/failure-patterns.md**: Max 50 patterns. Periodically remove `Status: Resolved` entries.
124
+ - **docs/dependency-map.md**: Max 100 modules. Merge trivial internal modules.
125
+ - **docs/features.md**: Max 50 features. Archive shipped features when exceeding limit.
126
+ - **docs/agent-memory/*.md**: Max 100 lines each. Keep only actionable learnings.
@@ -29,7 +29,7 @@ When modifying a module:
29
29
  3. For each dependent module:
30
30
  - Check if the change affects the public interface
31
31
  - Update tests and mocks for all affected dependents
32
- 4. Record the change in project-state.md
32
+ 4. Record the change in docs/project-state.md
33
33
 
34
34
  ## Interface Change Log
35
35
 
@@ -32,7 +32,7 @@ Keep resolved patterns for regression prevention.
32
32
  - **Occurred**: <!-- Sprint/Story where this happened -->
33
33
  - **Frequency**: 0
34
34
  - **Cause**: LLM lost track of current scope in large workflows. Skipped "report and wait for approval" steps.
35
- - **Prevention**: Track current Story in project-state.md. Sprint manager agent detects scope violations.
35
+ - **Prevention**: Track current Story in docs/project-state.md. Sprint manager agent detects scope violations.
36
36
  - **Applied in**: sprint-manager agent, global instructions
37
37
  - **Status**: Template — activate when first occurrence is logged
38
38