k-harness 0.2.0 → 0.4.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
 
@@ -29,13 +30,14 @@ npx k-harness init --ide cursor
29
30
  npx k-harness init --ide codex
30
31
  npx k-harness init --ide windsurf
31
32
  npx k-harness init --ide augment
33
+ npx k-harness init --ide antigravity
32
34
  ```
33
35
 
34
36
  ### Options
35
37
 
36
38
  | Flag | Description |
37
39
  |------|-------------|
38
- | `--ide <name>` | Target IDE: `vscode`, `claude`, `cursor`, `codex`, `windsurf`, `augment` |
40
+ | `--ide <name>` | Target IDE: `vscode`, `claude`, `cursor`, `codex`, `windsurf`, `augment`, `antigravity` |
39
41
  | `--dir <path>` | Target directory (default: current directory) |
40
42
  | `--overwrite` | Overwrite existing files |
41
43
 
@@ -45,12 +47,13 @@ npx k-harness init --ide augment
45
47
  |-----|-------------|-------------------|--------|--------|
46
48
  | **VS Code Copilot** | `.github/copilot-instructions.md` | `.vscode/instructions/*.instructions.md` | `.github/skills/*/SKILL.md` | `.github/agents/*.agent.md` |
47
49
  | **Claude Code** | `CLAUDE.md` | (merged into CLAUDE.md) | `.claude/skills/*/SKILL.md` | (merged into CLAUDE.md) |
48
- | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` |
50
+ | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | (merged into rules) | (merged into rules) |
49
51
  | **Codex** | `AGENTS.md` | (merged into AGENTS.md) | `.agents/skills/*/SKILL.md` | (merged into AGENTS.md) |
50
52
  | **Windsurf** | `.windsurfrules` | (merged) | (merged) | (merged) |
51
- | **Augment Code** | `.augment/rules/core.md` | `.augment/rules/*.md` | `.augment/rules/*.md` | `.augment/rules/*.md` |
53
+ | **Augment Code** | `.augment/rules/core.md` | `.augment/rules/*.md` | `.augment/skills/*/SKILL.md` | `.augment/skills/*/SKILL.md` |
54
+ | **Google Antigravity** | `.agent/rules/core.md` | `.agent/rules/*.md` | `.agent/skills/*/SKILL.md` | `.agent/skills/*/SKILL.md` |
52
55
 
53
- All IDEs also get `project-state.md`, `failure-patterns.md`, `features.md`, and `project-brief.md` at the project root.
56
+ All IDEs also get `project-state.md`, `project-brief.md`, `features.md`, `failure-patterns.md`, and `dependency-map.md` at the project root.
54
57
 
55
58
  ## What Gets Installed
56
59
 
@@ -60,47 +63,79 @@ All IDEs also get `project-state.md`, `failure-patterns.md`, `features.md`, and
60
63
  - **Backend Rules** — Dependency inversion, type safety, explicit staging (applied to source files)
61
64
 
62
65
  ### Skills (on-demand procedures)
66
+ - **bootstrap** — Onboard project into K-Harness: scans codebase + fills state files automatically
67
+ - **learn** — End-of-session wrap-up: captures failure patterns, updates project state
68
+ - **pivot** — Propagate direction changes across all state files when goals/tech/scope changes
63
69
  - **test-integrity** — Verify mock/interface synchronization before committing
64
70
  - **security-checklist** — Pre-commit security risk scan
65
71
  - **investigate** — 4-phase systematic debugging (evidence → scope → fix → verify)
72
+ - **impact-analysis** — Assess change blast radius before modifying shared modules
73
+ - **feature-breakdown** — Decompose features into dependency-ordered implementation tasks
66
74
 
67
75
  ### Agents (role-based personas)
68
- - **reviewer** — Code review: architecture, tests, security, failure pattern cross-check
69
- - **sprint-manager** — Sprint/Story state management, scope drift prevention
76
+ - **planner** — Feature planning, dependency analysis, Direction Alignment (goal/non-goal/decision check)
77
+ - **reviewer** — Code review + State File Audit (verifies state files were actually updated)
78
+ - **sprint-manager** — Sprint/Story state management, scope drift prevention, Next Step Recommendation
70
79
 
71
- ### State Files
72
- - **project-state.md** — Current sprint, stories, and progress tracking
73
- - **failure-patterns.md** — Template for logging project-specific failure patterns
80
+ ### State Files (project memory)
81
+ - **project-brief.md** — Project vision, goals, non-goals, Decision Log (the "why")
82
+ - **project-state.md** — Current sprint, stories, and progress tracking (the "where")
83
+ - **features.md** — Living feature registry so LLMs know what exists (the "what")
84
+ - **dependency-map.md** — Module dependency graph for impact analysis (the "how")
85
+ - **failure-patterns.md** — Project-specific failure patterns that prevent repeat mistakes (the "watch out")
74
86
 
75
- ## After Installation
87
+ ## How It Works
76
88
 
77
- 1. **Edit `project-state.md`** — Set up your first sprint and stories
78
- 2. **Customize global rules** — Add your architecture, type rules, and directory structure
79
- 3. **Log failures** When an LLM makes a repeated mistake, record it in `failure-patterns.md`
80
-
81
- ## Design Principles
82
-
83
- 1. **State Injection** — Project state injected at every session start
84
- 2. **Rigid Workflow** — Hard "do/don't" rules; soft suggestions get ignored by LLMs
85
- 3. **Failure-Driven Rules** — Rules derived only from actual project failures
86
- 4. **Completion Status Protocol** — DONE / BLOCKED / NEEDS_CONTEXT reporting
87
- 5. **Scope Lock** — Escalate before modifying files outside current story scope
89
+ ### 1. Bootstrap (once)
90
+ ```bash
91
+ npx k-harness init --ide vscode
92
+ ```
93
+ Then ask your LLM to run the `bootstrap` skill — it scans your codebase and fills all 5 state files automatically.
88
94
 
89
- ## Research & Analysis
95
+ ### 2. Direction Guard (every request)
96
+ Before ANY coding task, the LLM reads `project-brief.md` and checks:
97
+ - Does this align with Goals? → proceed
98
+ - Does this fall under Non-Goals? → warn, suggest `pivot`
99
+ - Does this contradict a Decision Log entry? → warn, suggest `pivot`
90
100
 
101
+ ### 3. Workflow Pipeline
91
102
  ```
92
- docs/
93
- ├── analysis/ # Framework comparisons
94
- │ ├── comparison.md # BMAD vs gstack
95
- │ ├── bmad-deep-dive.md
96
- │ └── gstack-deep-dive.md
97
- ├── architecture/ # K-Harness design
98
- │ ├── design-principles.md
99
- │ ├── file-structure.md
100
- │ └── skill-spec.md
101
- └── case-study/
102
- └── mcphub-lessons.md
103
+ bootstrap → planner → [code] → reviewer → sprint-manager → learn
103
104
  ```
105
+ - **planner**: Checks direction alignment, breaks down features
106
+ - **reviewer**: Reviews code + audits state file updates
107
+ - **sprint-manager**: Tracks progress, recommends next action
108
+ - **learn**: Captures lessons before session ends
109
+
110
+ ### 4. Direction Changes
111
+ When goals, technology, or scope changes, run the `pivot` skill:
112
+ - Updates ALL 5 state files consistently
113
+ - Records the decision with reasoning in Decision Log
114
+ - Prevents silent inconsistencies across files
115
+
116
+ ## Design Principles
117
+
118
+ 1. **Direction First** — Every request checked against project goals before code is written
119
+ 2. **State Injection** — Project state injected at every session start
120
+ 3. **Rigid Workflow** — Hard "do/don't" rules; soft suggestions get ignored by LLMs
121
+ 4. **Enforced Updates** — Reviewer audits that state files were actually updated, not just instructed
122
+ 5. **Failure-Driven Rules** — Rules derived only from actual project failures
123
+ 6. **Context Minimization** — ≤3 files per task, zero dependencies, one `npm install`
124
+
125
+ ## Why Not BMAD or gstack?
126
+
127
+ | | BMAD v6.2.2 | gstack v0.15.1 | K-Harness |
128
+ |---|---|---|---|
129
+ | Focus | Enterprise SDLC methodology | 1-person software factory | Project direction management |
130
+ | Files | 200+ | ~40 | 15 |
131
+ | Dependencies | Node 20+ | Bun + Node + Playwright | Zero |
132
+ | IDE support | 20+ (installer) | 5 (setup --host) | 7 (native format) |
133
+ | Direction management | ❌ | ❌ | ✅ (Direction Guard + pivot + Decision Log) |
134
+ | Cold start | ❌ | ❌ | ✅ (bootstrap) |
135
+ | State file audit | ❌ | ❌ | ✅ (reviewer Step 8) |
136
+ | Context per task | 4-6 files | 1 file | 2-3 files |
137
+
138
+ See [docs/analysis/comparison.md](docs/analysis/comparison.md) for the full analysis.
104
139
 
105
140
  ## License
106
141
 
@@ -28,10 +28,24 @@ 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
+ - `project-brief.md` — Must have Vision and Goals filled
35
+ - `features.md` — Must have at least one feature row
36
+ - `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 `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.
43
+ 1. Read `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.
35
49
  3. Read `features.md` to understand what already exists
36
50
  4. Read `dependency-map.md` to understand current architecture
37
51
  5. Read `project-state.md` for current Sprint context
@@ -19,6 +19,14 @@ Finds issues and auto-fixes where safe, escalates where not.
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
+ - `failure-patterns.md` — Must exist (needed for Step 5 cross-check)
26
+ - `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`)
@@ -59,6 +67,17 @@ Changed file list (user-provided or from `git diff --name-only`)
59
67
  - [ ] If module was deleted/renamed, verify 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
+ - [ ] **project-state.md**: If stories were worked on, is Quick Summary current? Are story statuses updated?
74
+ - [ ] **features.md**: If new features were added, are they registered? If features were completed, is status updated?
75
+ - [ ] **dependency-map.md**: If new modules were created, are they registered? If dependencies changed, are relationships updated?
76
+ - [ ] **failure-patterns.md**: If a bug was fixed that matched a pattern, was frequency incremented?
77
+ - [ ] **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
  ```
@@ -12,6 +12,14 @@ Keeps the LLM focused on the current work item.
12
12
 
13
13
  ## Procedure
14
14
 
15
+ ### Step 0: State File Readiness
16
+
17
+ Before handling any request, verify `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 `project-state.md` is empty/placeholder-only → **Recommend running `bootstrap` skill first.** Report: "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"
@@ -21,7 +29,31 @@ User request: "next task", "current status", "story done", "new sprint", "scope
21
29
  **Request: "current status" / "where are we"**
22
30
  1. Read 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 `project-state.md`, `features.md`, `project-brief.md`, `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
+ | project-brief.md has no Vision/Goals | → "Fill out 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
59
  1. Update the Story status to `done` in project-state.md
@@ -2,18 +2,20 @@
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
@@ -42,8 +42,8 @@
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,6 +59,18 @@ 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 `project-brief.md` — check Vision, Goals, Non-Goals, and Decision Log
67
+ 2. If `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:
@@ -67,6 +79,33 @@ When starting a NEW chat session, read these files in order before doing any wor
67
79
  3. `failure-patterns.md` — What mistakes to avoid
68
80
  4. `project-brief.md` — Project vision, goals, and non-goals
69
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.
108
+
70
109
  ## References
71
110
 
72
111
  - project-brief.md — Project vision, goals, non-goals (the "why")
@@ -1,49 +1,69 @@
1
1
  # Project Brief
2
2
 
3
+ > **Fill this out immediately after running `k-harness init`.** The Planner agent uses this file for Direction Guard — without it, scope drift cannot be prevented.
4
+
3
5
  ## Vision
4
6
 
5
- <!-- What is this project and why does it exist?
6
- Example: "An open-source MCP hub that connects AI tools to enterprise services."
7
- Keep it to 1-2 sentences. This is the north star for all decisions. -->
7
+ <!-- What is this project and why does it exist? Keep it to 1-2 sentences.
8
+ This is the north star for all decisions.
9
+ Examples:
10
+ - "An open-source MCP hub that connects AI tools to enterprise services."
11
+ - "A CLI tool that generates IDE-specific instruction files for LLM agents."
12
+ - "An e-commerce platform focused on local artisan products."
13
+ -->
8
14
 
9
15
  ## Goals
10
16
 
11
- <!-- What must this project achieve? List 3-5 concrete goals.
12
- Example:
17
+ <!-- What must this project achieve? List 3-5 concrete, measurable goals.
18
+ Examples:
13
19
  - Support 50+ MCP servers with auto-discovery
14
20
  - Sub-100ms routing latency
15
21
  - Zero-config developer experience
22
+ - API coverage for all CRUD operations by v1.0
16
23
  -->
17
24
 
18
25
  ## Non-Goals
19
26
 
20
27
  <!-- What is explicitly OUT OF SCOPE? This is equally important as Goals.
21
- Example:
28
+ The Planner agent will WARN you when a requested feature falls here.
29
+ Examples:
22
30
  - Not a hosting platform — users deploy their own
23
31
  - Not supporting legacy REST APIs — MCP only
24
32
  - Not building a UI dashboard in v1
33
+ - No mobile app — web only
25
34
  -->
26
35
 
27
36
  ## Target Users
28
37
 
29
- <!-- Who is this for?
30
- Example: "Solo developers and small teams (1-3) using AI coding assistants."
38
+ <!-- Who is this for? Be specific.
39
+ Examples:
40
+ - "Solo developers and small teams (1-3) using AI coding assistants."
41
+ - "Enterprise teams migrating from monolith to microservices."
42
+ - "Data scientists who need reproducible ML pipelines."
31
43
  -->
32
44
 
33
45
  ## Key Technical Decisions
34
46
 
35
- <!-- Record major architecture choices that should NOT be reversed without discussion.
36
- Example:
37
- - TypeScript + Node.js (not Go, not Python)
38
- - SQLite for local storage (not PostgreSQL)
39
- - Monorepo with npm workspaces
47
+ <!-- Record foundational technology choices. Helps LLMs generate correct code.
48
+ Examples:
49
+ - Language: TypeScript 5.x (strict mode)
50
+ - Framework: Express + Prisma ORM
51
+ - Test runner: Vitest (not Jest)
52
+ - Database: PostgreSQL 16
53
+ - Architecture: Hexagonal (Port + Adapter)
54
+ - Language: Python 3.12, Framework: FastAPI, Tests: pytest
55
+ - Language: Go 1.22, no framework, Tests: go test
40
56
  -->
41
57
 
42
- ## Success Criteria
58
+ ## Decision Log
59
+
60
+ <!-- Record WHY key decisions were made. The Planner uses this to avoid re-debating settled decisions.
61
+ Use the `pivot` skill to add entries here when direction changes.
62
+ Format:
43
63
 
44
- <!-- How do we know this project is working?
45
- Example:
46
- - Users can install and run in under 5 minutes
47
- - All MCP tools discoverable without manual configuration
48
- - 90%+ test coverage on core modules
64
+ ### [YYYY-MM-DD] [Decision Title]
65
+ - **Change**: What changed
66
+ - **Reason**: Why this decision was made
67
+ - **Impact**: What was affected
68
+ - **Alternatives Considered**: What else was considered and rejected
49
69
  -->
@@ -0,0 +1,119 @@
1
+ # Bootstrap
2
+
3
+ ## Purpose
4
+
5
+ Onboard a new or existing project into K-Harness by filling state files automatically.
6
+ Solves the cold-start problem: users don't know which `.md` files to fill or how.
7
+
8
+ ## When to Apply
9
+
10
+ - Right after running `k-harness init` on a new project
11
+ - When joining an existing project that has empty state files
12
+ - When state files are outdated and need a refresh
13
+ - When any agent reports "state files are empty"
14
+
15
+ ## Procedure
16
+
17
+ ### Phase 1: Project Discovery (read-only)
18
+
19
+ 1. **Scan project root** for configuration files:
20
+ - `package.json`, `tsconfig.json` → Node.js/TypeScript
21
+ - `go.mod`, `go.sum` → Go
22
+ - `requirements.txt`, `pyproject.toml`, `setup.py` → Python
23
+ - `pom.xml`, `build.gradle` → Java
24
+ - `Cargo.toml` → Rust
25
+ - `Gemfile` → Ruby
26
+ 2. **Scan directory structure**: List top-level directories and identify patterns
27
+ - `src/`, `lib/`, `app/` → source code
28
+ - `tests/`, `test/`, `__tests__/`, `spec/` → test directories
29
+ - `docs/` → documentation
30
+ 3. **Scan for existing tests**: Find test files and map them to source modules
31
+ 4. **Scan imports/dependencies**: Trace module relationships from import statements
32
+
33
+ **Do NOT modify any code files in this phase.**
34
+
35
+ ### Phase 2: User Interview (interactive)
36
+
37
+ Ask the user these questions (skip any already answered by Phase 1):
38
+
39
+ 1. "What does this project do? (one sentence)"
40
+ 2. "What are the top 3 goals of this project?"
41
+ 3. "What is explicitly OUT of scope? (non-goals)"
42
+ 4. "What architecture pattern are you using?" (show detected pattern if found)
43
+ 5. "Are there any type decisions or conventions the AI should know about?"
44
+
45
+ ### Phase 3: Fill State Files
46
+
47
+ Using data from Phase 1 + Phase 2, fill the following files:
48
+
49
+ **project-brief.md**:
50
+ - Project Name → from package.json name, go.mod module, or user input
51
+ - Vision → from user answer #1
52
+ - Goals → from user answer #2
53
+ - Non-Goals → from user answer #3
54
+ - Key Technical Decisions → from Phase 1 scan + user answer #4, #5
55
+
56
+ **features.md**:
57
+ - Add one row per detected module/feature area
58
+ - Status: `✅ done` for modules with passing tests, `🔧 active` for modules without tests
59
+ - Key Files: actual file paths from scan
60
+ - Test Files: actual test file paths from scan
61
+
62
+ **dependency-map.md**:
63
+ - Add one row per module
64
+ - Layer: inferred from directory structure (domain/application/infrastructure/presentation)
65
+ - Depends On / Depended By: inferred from import scan
66
+
67
+ **project-state.md**:
68
+ - Quick Summary: filled with current project state
69
+ - Sprint 1 stories: based on what bootstrap discovered
70
+ - Module Registry: summary from dependency-map.md
71
+
72
+ **failure-patterns.md**:
73
+ - Keep FP-001 through FP-004 as templates (Frequency: 0)
74
+ - No changes unless user reports known issues
75
+
76
+ ### Phase 4: Verify
77
+
78
+ 1. Present a summary of all filled state files to the user
79
+ 2. Ask "Does this look correct? What should I change?"
80
+ 3. Apply corrections if any
81
+ 4. Report completion
82
+
83
+ ## Output Format
84
+
85
+ ```
86
+ ## Bootstrap Complete
87
+
88
+ ### Project: [name]
89
+ ### Tech Stack: [detected stack]
90
+ ### Modules Found: [count]
91
+ ### Features Mapped: [count]
92
+ ### Dependency Links: [count]
93
+
94
+ ### State Files Updated:
95
+ - [x] project-brief.md — [summary]
96
+ - [x] features.md — [N] features registered
97
+ - [x] dependency-map.md — [N] modules, [N] dependencies
98
+ - [x] project-state.md — Sprint 1 initialized
99
+ - [ ] failure-patterns.md — templates only (no changes)
100
+
101
+ STATUS: DONE
102
+ ```
103
+
104
+ ## Rules
105
+
106
+ - Never modify source code — this skill only writes to state files
107
+ - Always show the user what was discovered BEFORE writing files
108
+ - If the project has 0 source files, skip Phase 1 scan and go straight to Phase 2
109
+ - If a state file already has content, ask before overwriting
110
+ - Run this skill only once per project (or when explicitly requested for refresh)
111
+
112
+ ## Anti-patterns
113
+
114
+ | Anti-pattern | Correct Approach |
115
+ |---|---|
116
+ | Guess module boundaries | Scan actual directory structure and imports |
117
+ | Skip user interview | Phase 1 scan alone is insufficient — always confirm with user |
118
+ | Overwrite existing state files silently | Ask before overwriting non-empty files |
119
+ | Create perfect dependency map on first try | Start with what's detectable, refine over time |
@@ -41,20 +41,20 @@ Ensures bottom-up implementation: foundations first, then layers that depend on
41
41
 
42
42
  ### Wave 1 (no dependencies)
43
43
  - [ ] Task 1: [Module A] — Create entity + repository interface
44
- - Files: src/domain/entities/X.ts, src/domain/repositories/XRepository.ts
45
- - Tests: tests/domain/X.test.ts
44
+ - Files: <!-- list files to create/modify -->
45
+ - Tests: <!-- list test files -->
46
46
  - Depends on: none
47
47
 
48
48
  ### Wave 2 (depends on Wave 1)
49
49
  - [ ] Task 2: [Module B] — Implement use case
50
- - Files: src/application/usecases/DoX.ts
51
- - Tests: tests/application/DoX.test.ts
50
+ - Files: <!-- list files to create/modify -->
51
+ - Tests: <!-- list test files -->
52
52
  - Depends on: Task 1
53
53
 
54
54
  ### Wave 3 (depends on Wave 2)
55
- - [ ] Task 3: [Module C] — Add API endpoint
56
- - Files: src/presentation/routes/x.ts, src/presentation/dto/XDto.ts
57
- - Tests: tests/presentation/x.test.ts
55
+ - [ ] Task 3: [Module C] — Add API endpoint / UI integration
56
+ - Files: <!-- list files to create/modify -->
57
+ - Tests: <!-- list test files -->
58
58
  - Depends on: Task 2
59
59
 
60
60
  ### Dependency Map Updates
@@ -70,6 +70,14 @@ Ensures bottom-up implementation: foundations first, then layers that depend on
70
70
  - New modules MUST be registered in dependency-map.md (Iron Law #6)
71
71
  - If a task exceeds Story scope, stop and report to user
72
72
 
73
+ ## State File Updates (mandatory)
74
+
75
+ After completing the breakdown, update these files in the same session:
76
+
77
+ - [ ] **dependency-map.md**: Register all NEW_MODULE entries. Update "Depends On" / "Depended By" for INTERFACE_CHANGE entries.
78
+ - [ ] **features.md**: Add a new row for the feature with Status `🔧 active`, Key Files from Wave tasks, and Test Files.
79
+ - [ ] **project-state.md**: Add Stories to the Story Status table for each Wave.
80
+
73
81
  ## Anti-patterns
74
82
 
75
83
  | Anti-pattern | Correct Approach |
@@ -78,3 +86,4 @@ Ensures bottom-up implementation: foundations first, then layers that depend on
78
86
  | One giant task for the whole feature | Break into single-module tasks |
79
87
  | Skip dependency-map registration | Register immediately when creating module |
80
88
  | Tests "later" | Tests in the same task |
89
+ | Produce breakdown but skip state file updates | State file updates are part of the breakdown, not a separate step |
@@ -57,6 +57,13 @@ Plan: 4 files to update, all within S3-2 scope
57
57
  → Tests fail in 3 modules, mock out of sync, 2 hours wasted
58
58
  ```
59
59
 
60
+ ## State File Updates (mandatory)
61
+
62
+ After completing the analysis, update these files:
63
+
64
+ - [ ] **dependency-map.md**: Update the Interface Change Log table with: Date, Module, Change description, Affected Modules, Status.
65
+ - [ ] **project-state.md**: If scope exceeds current Story, add a note to Recent Changes.
66
+
60
67
  ## Related Failure Patterns
61
68
 
62
69
  - FP-001: Interface changed, mock not updated → Checklist item 5
@@ -67,6 +67,13 @@ Phase 4: Tests pass, null case test added
67
67
  → Root cause unknown, no reproduction conditions recorded, same error possible elsewhere
68
68
  ```
69
69
 
70
+ ## State File Updates (mandatory)
71
+
72
+ After the fix is verified (Phase 4):
73
+
74
+ - [ ] **failure-patterns.md**: If the root cause is a repeatable pattern, add a new FP-NNN entry or increment the Frequency of an existing one. This is NOT optional.
75
+ - [ ] **project-state.md**: Add the fix to Recent Changes with the root cause hypothesis.
76
+
70
77
  ## Related Failure Patterns
71
78
 
72
79
  - FP-002: Type confusion → Phase 1 requires verifying actual types
@@ -0,0 +1,100 @@
1
+ # Learn
2
+
3
+ ## Purpose
4
+
5
+ Capture lessons from the current session before ending.
6
+ Updates failure-patterns.md with new patterns and refreshes project-state.md Quick Summary.
7
+ This is K-Harness's memory mechanism — without it, the same mistakes repeat across sessions.
8
+
9
+ ## When to Apply
10
+
11
+ - Before ending a chat session (recommended as the LAST skill invoked)
12
+ - After a debugging session where a non-obvious fix was found
13
+ - After a review revealed a repeated mistake
14
+ - When the user explicitly asks to record a lesson
15
+
16
+ ## Procedure
17
+
18
+ ### Step 1: Review Session Activity
19
+
20
+ 1. Scan recent git changes: `git log --oneline -10` and `git diff --stat HEAD~3`
21
+ 2. Identify what was accomplished in this session
22
+ 3. Identify any errors, failures, or unexpected issues that occurred
23
+
24
+ ### Step 2: Failure Pattern Detection
25
+
26
+ For each issue/error that occurred in this session:
27
+
28
+ 1. Read `failure-patterns.md`
29
+ 2. Check if this matches an existing pattern (FP-NNN):
30
+ - **If match found**: Increment the Frequency counter, add the Sprint/Story to "Occurred"
31
+ - **If new pattern**: Assign next FP-NNN number, create a new entry using this format:
32
+
33
+ ```markdown
34
+ ## FP-NNN: [Short description]
35
+
36
+ - **Occurred**: S[sprint]-[story]
37
+ - **Frequency**: 1
38
+ - **Cause**: [What went wrong and why]
39
+ - **Prevention**: [Specific check to prevent recurrence]
40
+ - **Applied in**: [Which skills/agents/rules should enforce this]
41
+ - **Status**: Active
42
+ ```
43
+
44
+ 3. If the failure relates to a specific skill or agent, note it for that skill's checklist
45
+
46
+ ### Step 3: Update project-state.md
47
+
48
+ 1. Update **Quick Summary** (3 lines):
49
+ - Line 1: What was accomplished in this session
50
+ - Line 2: What is currently in progress
51
+ - Line 3: What should be done next
52
+ 2. Update **Story Status** table if any stories changed
53
+ 3. Add to **Recent Changes** section with date and summary
54
+
55
+ ### Step 4: Update features.md (if applicable)
56
+
57
+ 1. If new features were added → add row to Feature List
58
+ 2. If existing features were modified → update Key Files and Test Files columns
59
+ 3. If features were completed → update Status to `✅ done`
60
+
61
+ ### Step 5: Report
62
+
63
+ Present a summary of all updates made.
64
+
65
+ ## Output Format
66
+
67
+ ```
68
+ ## Session Learn Complete
69
+
70
+ ### Lessons Captured:
71
+ - [FP-NNN] (new/updated): [description]
72
+
73
+ ### State Files Updated:
74
+ - [x] project-state.md — Quick Summary refreshed
75
+ - [x] failure-patterns.md — [N] patterns added/updated
76
+ - [x] features.md — [N] features updated (if applicable)
77
+
78
+ ### Next Session Should:
79
+ 1. [recommended first action]
80
+ 2. [next priority]
81
+
82
+ STATUS: DONE
83
+ ```
84
+
85
+ ## Rules
86
+
87
+ - Never invent patterns that didn't actually occur — record only real failures
88
+ - Keep failure pattern descriptions concise (1-2 sentences for Cause and Prevention)
89
+ - If no failures occurred, skip Step 2 and just update state files
90
+ - Do not modify source code — this skill only updates state files
91
+ - Quick Summary must be exactly 3 lines — concise enough for the next session to scan instantly
92
+
93
+ ## Anti-patterns
94
+
95
+ | Anti-pattern | Correct Approach |
96
+ |---|---|
97
+ | Record theoretical risks as failure patterns | Only record failures that actually happened |
98
+ | Write vague descriptions ("something broke") | Be specific: file name, error message, root cause |
99
+ | Skip this skill because "nothing went wrong" | Still update Quick Summary and Story Status |
100
+ | Update failure-patterns.md but not project-state.md | Always update both — they serve different purposes |
@@ -0,0 +1,102 @@
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: project-brief.md says "GraphQL" but dependency-map.md still references REST modules.
7
+
8
+ ## When to Apply
9
+
10
+ - Technology change: "Switch from REST to GraphQL", "Replace PostgreSQL with MongoDB"
11
+ - Scope change: "Add real-time features", "Remove mobile support", "Downscope to MVP"
12
+ - Architecture shift: "Move from monolith to microservices", "Switch from SSR to SPA"
13
+ - Goal change: "Pivot from B2C to B2B", "Change target users"
14
+ - Any time the user says "let's change direction", "pivot", "switch to", "drop [feature area]"
15
+
16
+ ## Procedure
17
+
18
+ ### Step 1: Capture the Change
19
+
20
+ 1. Ask the user to describe the change in one sentence
21
+ 2. Classify the change type:
22
+ - **Tech Swap**: Replacing one technology with another
23
+ - **Scope Change**: Adding or removing feature areas
24
+ - **Architecture Shift**: Changing system structure
25
+ - **Goal Pivot**: Changing project purpose or target
26
+
27
+ ### Step 2: Impact Scan
28
+
29
+ Read ALL state files and identify what needs updating:
30
+
31
+ 1. **project-brief.md**:
32
+ - Does Vision need rewording?
33
+ - Do Goals need updating?
34
+ - Do Non-Goals need updating?
35
+ - Do Key Technical Decisions need changing?
36
+ - Record the decision with reasoning in the Decision Log section
37
+
38
+ 2. **features.md**:
39
+ - Which existing features are affected?
40
+ - Which features should be marked `⛔ dropped`?
41
+ - Are new features needed?
42
+
43
+ 3. **dependency-map.md**:
44
+ - Which modules are obsoleted by this change?
45
+ - Which new modules are needed?
46
+ - Which dependency relationships change?
47
+
48
+ 4. **project-state.md**:
49
+ - Which in-progress stories are affected?
50
+ - Does the current sprint goal change?
51
+ - Update Quick Summary to reflect the pivot
52
+
53
+ 5. **failure-patterns.md**:
54
+ - Are any existing patterns invalidated by this change?
55
+ - Mark invalidated patterns as `Status: Obsolete (pivot: [reason])`
56
+
57
+ ### Step 3: Present Change Plan
58
+
59
+ Before writing anything, present a summary to the user:
60
+
61
+ ```
62
+ ## Pivot: [one-sentence description]
63
+ Type: [Tech Swap | Scope Change | Architecture Shift | Goal Pivot]
64
+
65
+ ### State File Changes:
66
+ - project-brief.md: [what changes]
67
+ - features.md: [N features affected, M dropped, K added]
68
+ - dependency-map.md: [N modules obsoleted, M added, K relationships changed]
69
+ - project-state.md: [N stories affected]
70
+ - failure-patterns.md: [N patterns obsoleted]
71
+
72
+ ### Confirm? (yes/no)
73
+ ```
74
+
75
+ ### Step 4: Execute Updates
76
+
77
+ After user confirms, update ALL state files in order:
78
+
79
+ 1. **project-brief.md** first (source of truth for direction)
80
+ 2. **features.md** second (what we're building)
81
+ 3. **dependency-map.md** third (how it connects)
82
+ 4. **project-state.md** fourth (current work status)
83
+ 5. **failure-patterns.md** last (historical patterns)
84
+
85
+ ### Step 5: Decision Log Entry
86
+
87
+ Add an entry to the Decision Log section in project-brief.md:
88
+
89
+ ```markdown
90
+ ### [YYYY-MM-DD] [Decision Title]
91
+ - **Change**: [What changed]
92
+ - **Reason**: [Why this decision was made]
93
+ - **Impact**: [What was affected]
94
+ - **Alternatives Considered**: [What else was considered and rejected]
95
+ ```
96
+
97
+ ## Rules
98
+
99
+ - **Never skip the confirmation step** — the user must approve before any state file is written
100
+ - **Never update partially** — if you update project-brief.md, you MUST check and update all other state files too
101
+ - **Preserve history** — mark dropped features as `⛔ dropped`, don't delete rows
102
+ - **Record the why** — every pivot must have a Decision Log entry with reasoning
@@ -44,6 +44,12 @@ git add .
44
44
  const dbPassword = "super_secret_123";
45
45
  ```
46
46
 
47
+ ## State File Updates (mandatory)
48
+
49
+ After completing the security check:
50
+
51
+ - [ ] **failure-patterns.md**: If a security issue was found (credentials staged, hardcoded secret), add a new FP-NNN entry or increment FP-004 Frequency.
52
+
47
53
  ## Related Failure Patterns
48
54
 
49
55
  - FP-004: Dangerous file committed → Checklist items 1, 4
@@ -41,6 +41,13 @@ Interface adds findByFilters() → Mock unchanged
41
41
  → Runtime error: method not found on mock object
42
42
  ```
43
43
 
44
+ ## State File Updates (mandatory)
45
+
46
+ After synchronizing mocks:
47
+
48
+ - [ ] **failure-patterns.md**: If mock sync was missed and caused a test failure, increment FP-001 Frequency.
49
+ - [ ] **dependency-map.md**: If the interface change altered module relationships, update the relevant row.
50
+
44
51
  ## Related Failure Patterns
45
52
 
46
53
  - FP-001: Interface changed, mock not updated → Checklist item 1
@@ -11,9 +11,9 @@
11
11
  ## Forbidden
12
12
 
13
13
  - Casting mocks with `any` type. Create mocks using the actual interface type.
14
- - Creating mocks with bare `jest.fn()` only. Set default return values with `mockResolvedValue` etc.
14
+ - Creating mocks with no default return values. Always set sensible defaults (e.g. `mockResolvedValue`, stub returns).
15
15
  - Committing with `skip` or `only` left in test files.
16
- - Committing with `console.log` debugging statements.
16
+ - Committing with debugging statements (e.g. `console.log`, `print`, `println`).
17
17
 
18
18
  ## References
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k-harness",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "LLM Development Harness — IDE-agnostic rules, skills, and agents that prevent common AI coding failures",
5
5
  "keywords": [
6
6
  "llm",
@@ -35,6 +35,9 @@
35
35
  "engines": {
36
36
  "node": ">=18.0.0"
37
37
  },
38
+ "scripts": {
39
+ "test": "node --test tests/*.test.js"
40
+ },
38
41
  "publishConfig": {
39
42
  "access": "public"
40
43
  }
package/src/init.js CHANGED
@@ -24,6 +24,61 @@ function writeFile(targetDir, relPath, content, overwrite) {
24
24
  return true;
25
25
  }
26
26
 
27
+ // ─── Shared definitions ──────────────────────────────────────
28
+
29
+ const SKILLS = [
30
+ { id: 'test-integrity', desc: 'Ensure test mocks stay synchronized when interfaces change. Use when modifying repository or service interfaces.' },
31
+ { id: 'security-checklist', desc: 'Security risk inspection before commits. Use when reviewing code for security issues.' },
32
+ { id: 'investigate', desc: 'Investigate and diagnose issues. Use when debugging or analyzing unexpected behavior.' },
33
+ { id: 'impact-analysis', desc: 'Assess change blast radius. Use when modifying shared modules or interfaces.' },
34
+ { id: 'feature-breakdown', desc: 'Break down features into implementable stories. Use when planning new features.' },
35
+ { id: 'bootstrap', desc: 'Onboard project into K-Harness. Scans codebase and fills state files. Use after k-harness init or when state files are empty.' },
36
+ { id: 'learn', desc: 'Capture session lessons and update state files. Use at the end of every session.' },
37
+ { id: 'pivot', desc: 'Propagate direction changes across all state files. Use when project goals, technology, scope, or architecture changes.' },
38
+ ];
39
+
40
+ const AGENTS = [
41
+ { id: 'reviewer', file: 'agents/reviewer.md', desc: 'Code review + auto-fix. Validates quality, security, and test integrity before commits.' },
42
+ { id: 'sprint-manager', file: 'agents/sprint-manager.md', desc: 'Sprint/Story state tracking, next task guidance, scope drift prevention.' },
43
+ { id: 'planner', file: 'agents/planner.md', desc: 'Feature planning and dependency management. Analyze architecture, break down features.' },
44
+ ];
45
+
46
+ const STATE_FILES = [
47
+ 'project-state.md',
48
+ 'failure-patterns.md',
49
+ 'dependency-map.md',
50
+ 'features.md',
51
+ 'project-brief.md',
52
+ ];
53
+
54
+ // ─── Shared writers ──────────────────────────────────────────
55
+
56
+ function writeStateFiles(targetDir, overwrite) {
57
+ for (const file of STATE_FILES) {
58
+ writeFile(targetDir, file, readTemplate(file), overwrite);
59
+ }
60
+ }
61
+
62
+ function writeSkills(targetDir, skillsDir, overwrite) {
63
+ for (const skill of SKILLS) {
64
+ const content = readTemplate(`skills/${skill.id}.md`);
65
+ const skillMd =
66
+ `---\nname: ${skill.id}\ndescription: '${skill.desc}'\n---\n\n` +
67
+ content;
68
+ writeFile(targetDir, `${skillsDir}/${skill.id}/SKILL.md`, skillMd, overwrite);
69
+ }
70
+ }
71
+
72
+ function writeAgentsAsSkills(targetDir, skillsDir, overwrite) {
73
+ for (const agent of AGENTS) {
74
+ const content = readTemplate(agent.file);
75
+ const skillMd =
76
+ `---\nname: ${agent.id}\ndescription: '${agent.desc}'\n---\n\n` +
77
+ content;
78
+ writeFile(targetDir, `${skillsDir}/${agent.id}/SKILL.md`, skillMd, overwrite);
79
+ }
80
+ }
81
+
27
82
  // ─── IDE Generators ──────────────────────────────────────────
28
83
 
29
84
  function generateVscode(targetDir, overwrite) {
@@ -45,38 +100,20 @@ function generateVscode(targetDir, overwrite) {
45
100
  backendRules;
46
101
  writeFile(targetDir, '.vscode/instructions/backend.instructions.md', backendWithFrontmatter, overwrite);
47
102
 
48
- // Skills (.github/skills — VS Code default search path)
49
- writeFile(targetDir, '.github/skills/test-integrity/SKILL.md', readTemplate('skills/test-integrity.md'), overwrite);
50
- writeFile(targetDir, '.github/skills/security-checklist/SKILL.md', readTemplate('skills/security-checklist.md'), overwrite);
51
- writeFile(targetDir, '.github/skills/investigate/SKILL.md', readTemplate('skills/investigate.md'), overwrite);
52
- writeFile(targetDir, '.github/skills/impact-analysis/SKILL.md', readTemplate('skills/impact-analysis.md'), overwrite);
53
- writeFile(targetDir, '.github/skills/feature-breakdown/SKILL.md', readTemplate('skills/feature-breakdown.md'), overwrite);
54
-
55
- // Agents (.github/agents — VS Code default search path)
56
- const reviewerContent = readTemplate('agents/reviewer.md');
57
- const reviewerAgent =
58
- '---\nname: reviewer\ndescription: "Code review + auto-fix. Validates quality, security, and test integrity before commits."\n---\n\n' +
59
- reviewerContent;
60
- writeFile(targetDir, '.github/agents/reviewer.agent.md', reviewerAgent, overwrite);
61
-
62
- const sprintContent = readTemplate('agents/sprint-manager.md');
63
- const sprintAgent =
64
- '---\nname: sprint-manager\ndescription: "Sprint/Story state tracking, next task guidance, scope drift prevention."\n---\n\n' +
65
- sprintContent;
66
- writeFile(targetDir, '.github/agents/sprint-manager.agent.md', sprintAgent, overwrite);
67
-
68
- const plannerContent = readTemplate('agents/planner.md');
69
- const plannerAgent =
70
- '---\nname: planner\ndescription: "Feature planning and dependency management. Analyze architecture, break down features, track module relationships."\n---\n\n' +
71
- plannerContent;
72
- writeFile(targetDir, '.github/agents/planner.agent.md', plannerAgent, overwrite);
103
+ // Skills (.github/skills — VS Code default search path, SKILL.md with frontmatter)
104
+ writeSkills(targetDir, '.github/skills', overwrite);
105
+
106
+ // Agents (.github/agents — VS Code uses .agent.md format with frontmatter)
107
+ for (const agent of AGENTS) {
108
+ const content = readTemplate(agent.file);
109
+ const agentMd =
110
+ `---\nname: ${agent.id}\ndescription: "${agent.desc}"\n---\n\n` +
111
+ content;
112
+ writeFile(targetDir, `.github/agents/${agent.id}.agent.md`, agentMd, overwrite);
113
+ }
73
114
 
74
115
  // State files
75
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
76
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
77
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
78
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
79
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
116
+ writeStateFiles(targetDir, overwrite);
80
117
  }
81
118
 
82
119
  function generateClaude(targetDir, overwrite) {
@@ -90,19 +127,11 @@ function generateClaude(targetDir, overwrite) {
90
127
  ].join('');
91
128
  writeFile(targetDir, 'CLAUDE.md', merged, overwrite);
92
129
 
93
- // Skills (Claude uses same SKILL.md format)
94
- writeFile(targetDir, '.claude/skills/test-integrity/SKILL.md', readTemplate('skills/test-integrity.md'), overwrite);
95
- writeFile(targetDir, '.claude/skills/security-checklist/SKILL.md', readTemplate('skills/security-checklist.md'), overwrite);
96
- writeFile(targetDir, '.claude/skills/investigate/SKILL.md', readTemplate('skills/investigate.md'), overwrite);
97
- writeFile(targetDir, '.claude/skills/impact-analysis/SKILL.md', readTemplate('skills/impact-analysis.md'), overwrite);
98
- writeFile(targetDir, '.claude/skills/feature-breakdown/SKILL.md', readTemplate('skills/feature-breakdown.md'), overwrite);
130
+ // Skills (SKILL.md with frontmatter for slash commands)
131
+ writeSkills(targetDir, '.claude/skills', overwrite);
99
132
 
100
133
  // State files
101
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
102
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
103
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
104
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
105
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
134
+ writeStateFiles(targetDir, overwrite);
106
135
  }
107
136
 
108
137
  function generateCursor(targetDir, overwrite) {
@@ -126,35 +155,25 @@ function generateCursor(targetDir, overwrite) {
126
155
  writeFile(targetDir, '.cursor/rules/backend.mdc', backendMdc, overwrite);
127
156
 
128
157
  // Skills as rules
129
- const skills = ['test-integrity', 'security-checklist', 'investigate', 'impact-analysis', 'feature-breakdown'];
130
- for (const skill of skills) {
131
- const content = readTemplate(`skills/${skill}.md`);
158
+ for (const skill of SKILLS) {
159
+ const content = readTemplate(`skills/${skill.id}.md`);
132
160
  const mdc =
133
- `---\ndescription: Skill — ${skill}\nalwaysApply: false\n---\n\n` +
161
+ `---\ndescription: Skill — ${skill.id}\nalwaysApply: false\n---\n\n` +
134
162
  content;
135
- writeFile(targetDir, `.cursor/rules/${skill}.mdc`, mdc, overwrite);
163
+ writeFile(targetDir, `.cursor/rules/${skill.id}.mdc`, mdc, overwrite);
136
164
  }
137
165
 
138
166
  // Agents as rules
139
- const agents = [
140
- { name: 'reviewer', file: 'agents/reviewer.md' },
141
- { name: 'sprint-manager', file: 'agents/sprint-manager.md' },
142
- { name: 'planner', file: 'agents/planner.md' },
143
- ];
144
- for (const agent of agents) {
167
+ for (const agent of AGENTS) {
145
168
  const content = readTemplate(agent.file);
146
169
  const mdc =
147
- `---\ndescription: Agent — ${agent.name}\nalwaysApply: false\n---\n\n` +
170
+ `---\ndescription: Agent — ${agent.id}\nalwaysApply: false\n---\n\n` +
148
171
  content;
149
- writeFile(targetDir, `.cursor/rules/${agent.name}.mdc`, mdc, overwrite);
172
+ writeFile(targetDir, `.cursor/rules/${agent.id}.mdc`, mdc, overwrite);
150
173
  }
151
174
 
152
175
  // State files
153
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
154
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
155
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
156
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
157
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
176
+ writeStateFiles(targetDir, overwrite);
158
177
  }
159
178
 
160
179
  function generateCodex(targetDir, overwrite) {
@@ -168,19 +187,11 @@ function generateCodex(targetDir, overwrite) {
168
187
  ].join('');
169
188
  writeFile(targetDir, 'AGENTS.md', merged, overwrite);
170
189
 
171
- // Skills (Codex uses .agents/skills/ format)
172
- writeFile(targetDir, '.agents/skills/test-integrity/SKILL.md', readTemplate('skills/test-integrity.md'), overwrite);
173
- writeFile(targetDir, '.agents/skills/security-checklist/SKILL.md', readTemplate('skills/security-checklist.md'), overwrite);
174
- writeFile(targetDir, '.agents/skills/investigate/SKILL.md', readTemplate('skills/investigate.md'), overwrite);
175
- writeFile(targetDir, '.agents/skills/impact-analysis/SKILL.md', readTemplate('skills/impact-analysis.md'), overwrite);
176
- writeFile(targetDir, '.agents/skills/feature-breakdown/SKILL.md', readTemplate('skills/feature-breakdown.md'), overwrite);
190
+ // Skills (SKILL.md with frontmatter for slash commands)
191
+ writeSkills(targetDir, '.agents/skills', overwrite);
177
192
 
178
193
  // State files
179
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
180
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
181
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
182
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
183
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
194
+ writeStateFiles(targetDir, overwrite);
184
195
  }
185
196
 
186
197
  function generateWindsurf(targetDir, overwrite) {
@@ -190,24 +201,18 @@ function generateWindsurf(targetDir, overwrite) {
190
201
  readTemplate('testing-rules.md'),
191
202
  readTemplate('backend-rules.md'),
192
203
  '---\n\n# Skills\n\n',
193
- readTemplate('skills/test-integrity.md'),
194
- readTemplate('skills/security-checklist.md'),
195
- readTemplate('skills/investigate.md'),
196
- readTemplate('skills/impact-analysis.md'),
197
- readTemplate('skills/feature-breakdown.md'),
198
- '---\n\n# Agents\n\n',
199
- readTemplate('agents/reviewer.md'),
200
- readTemplate('agents/sprint-manager.md'),
201
- readTemplate('agents/planner.md'),
202
204
  ];
205
+ for (const skill of SKILLS) {
206
+ sections.push(readTemplate(`skills/${skill.id}.md`));
207
+ }
208
+ sections.push('---\n\n# Agents\n\n');
209
+ for (const agent of AGENTS) {
210
+ sections.push(readTemplate(agent.file));
211
+ }
203
212
  writeFile(targetDir, '.windsurfrules', sections.join('\n\n---\n\n'), overwrite);
204
213
 
205
214
  // State files
206
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
207
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
208
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
209
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
210
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
215
+ writeStateFiles(targetDir, overwrite);
211
216
  }
212
217
 
213
218
  function generateAugment(targetDir, overwrite) {
@@ -230,46 +235,51 @@ function generateAugment(targetDir, overwrite) {
230
235
  backendRules;
231
236
  writeFile(targetDir, '.augment/rules/backend.md', backendRule, overwrite);
232
237
 
233
- // Skills as Auto rules
234
- const skills = ['test-integrity', 'security-checklist', 'investigate', 'impact-analysis', 'feature-breakdown'];
235
- for (const skill of skills) {
236
- const content = readTemplate(`skills/${skill}.md`);
237
- const rule =
238
- `---\ndescription: Skill — ${skill}\ntype: manual\n---\n\n` +
239
- content;
240
- writeFile(targetDir, `.augment/rules/${skill}.md`, rule, overwrite);
241
- }
238
+ // .augment/skills/ SKILL.md format (enables / slash commands)
239
+ writeSkills(targetDir, '.augment/skills', overwrite);
240
+ writeAgentsAsSkills(targetDir, '.augment/skills', overwrite);
242
241
 
243
- // Agents as Manual rules
244
- const agents = [
245
- { name: 'reviewer', file: 'agents/reviewer.md' },
246
- { name: 'sprint-manager', file: 'agents/sprint-manager.md' },
247
- { name: 'planner', file: 'agents/planner.md' },
248
- ];
249
- for (const agent of agents) {
250
- const content = readTemplate(agent.file);
251
- const rule =
252
- `---\ndescription: Agent — ${agent.name}\ntype: manual\n---\n\n` +
253
- content;
254
- writeFile(targetDir, `.augment/rules/${agent.name}.md`, rule, overwrite);
255
- }
242
+ // State files
243
+ writeStateFiles(targetDir, overwrite);
244
+ }
245
+
246
+ function generateAntigravity(targetDir, overwrite) {
247
+ // .agent/rules/ — Always-type rules (same as Augment format, read by Antigravity)
248
+ const coreRules = readTemplate('core-rules.md');
249
+ const coreRule =
250
+ '---\ndescription: Core project rules — Iron Laws, completion protocol, concreteness\ntype: always\n---\n\n' +
251
+ coreRules;
252
+ writeFile(targetDir, '.agent/rules/core.md', coreRule, overwrite);
253
+
254
+ const testingRules = readTemplate('testing-rules.md');
255
+ const testingRule =
256
+ '---\ndescription: Testing rules — mock sync, forbidden patterns\ntype: auto\nglobs: "**/*.test.*,**/*.spec.*,**/__mocks__/**,**/__tests__/**"\n---\n\n' +
257
+ testingRules;
258
+ writeFile(targetDir, '.agent/rules/testing.md', testingRule, overwrite);
259
+
260
+ const backendRules = readTemplate('backend-rules.md');
261
+ const backendRule =
262
+ '---\ndescription: Backend code rules — architecture enforcement, type safety\ntype: auto\nglobs: "src/**/*.ts,src/**/*.js"\n---\n\n' +
263
+ backendRules;
264
+ writeFile(targetDir, '.agent/rules/backend.md', backendRule, overwrite);
265
+
266
+ // .agent/skills/ — SKILL.md format (enables / slash commands)
267
+ writeSkills(targetDir, '.agent/skills', overwrite);
268
+ writeAgentsAsSkills(targetDir, '.agent/skills', overwrite);
256
269
 
257
270
  // State files
258
- writeFile(targetDir, 'project-state.md', readTemplate('project-state.md'), overwrite);
259
- writeFile(targetDir, 'failure-patterns.md', readTemplate('failure-patterns.md'), overwrite);
260
- writeFile(targetDir, 'dependency-map.md', readTemplate('dependency-map.md'), overwrite);
261
- writeFile(targetDir, 'features.md', readTemplate('features.md'), overwrite);
262
- writeFile(targetDir, 'project-brief.md', readTemplate('project-brief.md'), overwrite);
271
+ writeStateFiles(targetDir, overwrite);
263
272
  }
264
273
 
265
274
  // ─── IDE registry ────────────────────────────────────────────
266
275
  const GENERATORS = {
267
- vscode: { name: 'VS Code Copilot', fn: generateVscode },
268
- claude: { name: 'Claude Code', fn: generateClaude },
269
- cursor: { name: 'Cursor', fn: generateCursor },
270
- codex: { name: 'Codex (OpenAI)', fn: generateCodex },
271
- windsurf: { name: 'Windsurf', fn: generateWindsurf },
272
- augment: { name: 'Augment Code', fn: generateAugment },
276
+ vscode: { name: 'VS Code Copilot', fn: generateVscode },
277
+ claude: { name: 'Claude Code', fn: generateClaude },
278
+ cursor: { name: 'Cursor', fn: generateCursor },
279
+ codex: { name: 'Codex (OpenAI)', fn: generateCodex },
280
+ windsurf: { name: 'Windsurf', fn: generateWindsurf },
281
+ augment: { name: 'Augment Code', fn: generateAugment },
282
+ antigravity: { name: 'Google Antigravity', fn: generateAntigravity },
273
283
  };
274
284
 
275
285
  // ─── Interactive prompt ──────────────────────────────────────
@@ -309,7 +319,7 @@ function showHelp() {
309
319
  npx k-harness init [options]
310
320
 
311
321
  Options:
312
- --ide <name> IDE target: vscode, claude, cursor, codex, windsurf, augment
322
+ --ide <name> IDE target: vscode, claude, cursor, codex, windsurf, augment, antigravity
313
323
  --dir <path> Target directory (default: current directory)
314
324
  --overwrite Overwrite existing files
315
325
  --help Show this help