@esoteric-logic/praxis-harness 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,16 +17,18 @@ Praxis gives Claude Code a three-layer operating system:
17
17
  ## Quick start
18
18
 
19
19
  ```bash
20
- npx praxis-harness
20
+ npx @esoteric-logic/praxis-harness@latest
21
21
  ```
22
22
 
23
23
  One command. Copies rules, commands, skills, and kits directly into `~/.claude/`. Node.js 18+ must be installed first.
24
24
 
25
+ > **Always use `@latest`** — `npx` caches packages locally. Without `@latest`, you may get a stale version on machines that installed previously.
26
+
25
27
  **Subsequent commands:**
26
28
  ```bash
27
- npx praxis-harness update # re-copy from latest npm version
28
- npx praxis-harness health # verify install integrity
29
- npx praxis-harness uninstall # remove Praxis-owned files from ~/.claude/
29
+ npx @esoteric-logic/praxis-harness@latest update # re-copy from latest npm version
30
+ npx @esoteric-logic/praxis-harness@latest health # verify install integrity
31
+ npx @esoteric-logic/praxis-harness@latest uninstall # remove Praxis-owned files from ~/.claude/
30
32
  ```
31
33
 
32
34
  ## After install
@@ -167,18 +169,20 @@ Praxis auto-documents your work in the vault with zero manual effort. Two indepe
167
169
  ### Updating the harness
168
170
 
169
171
  ```bash
170
- npx praxis-harness update
172
+ npx @esoteric-logic/praxis-harness@latest update
171
173
  ```
172
174
 
173
175
  Re-copies all hooks, skills, rules, and kits from the latest npm package version. Config file is preserved.
174
176
 
177
+ > **Always use `@latest`** to avoid `npx` serving a cached older version.
178
+
175
179
  ### Updating existing projects
176
180
 
177
181
  After a harness update that adds new vault files (like `decision-log.md`), run `/scaffold-exist` in a Claude Code session to audit your vault and add any missing files. This is non-destructive — it never overwrites existing content.
178
182
 
179
183
  ```
180
- Step 1: npx praxis-harness update → deploys new hooks, skills, rules to ~/.claude/
181
- Step 2: /scaffold-exist → audits vault, adds missing files
184
+ Step 1: npx @esoteric-logic/praxis-harness@latest update → deploys new hooks, skills, rules
185
+ Step 2: /scaffold-exist → audits vault, adds missing files
182
186
  ```
183
187
 
184
188
  New projects get everything automatically via `/scaffold-new`.
@@ -186,7 +190,7 @@ New projects get everything automatically via `/scaffold-new`.
186
190
  ## Uninstalling
187
191
 
188
192
  ```bash
189
- npx praxis-harness uninstall
193
+ npx @esoteric-logic/praxis-harness@latest uninstall
190
194
  ```
191
195
 
192
196
  Removes all Praxis-owned files from `~/.claude/`. Does not delete config, vault templates, or installed plugins.
package/base/CLAUDE.md CHANGED
@@ -81,7 +81,13 @@ Registered via `claude mcp add`. Persist globally across sessions.
81
81
  | context7 | Live library/API docs | None |
82
82
  | github | Repo operations, PRs, issues | `GITHUB_PERSONAL_ACCESS_TOKEN` |
83
83
 
84
- Optional: `perplexity` (AI web search). Run `bash scripts/onboard-mcp.sh perplexity` to add.
84
+ **Optional servers** enhance but don't require Praxis:
85
+
86
+ | Server | Purpose | Install | Degrades without |
87
+ |--------|---------|---------|-----------------|
88
+ | perplexity | AI web search | `bash scripts/onboard-mcp.sh perplexity` | No web research in `/discover` |
89
+ | filesystem | Direct vault file access | `claude mcp add filesystem` | Uses shell for vault reads |
90
+ | sequential-thinking | Multi-step reasoning | `claude mcp add sequential-thinking` | Standard reasoning only |
85
91
 
86
92
  Check: `claude mcp list` | Manage: `bash scripts/onboard-mcp.sh [server|all]`
87
93
  Missing servers are non-blocking — features degrade gracefully.
@@ -116,6 +122,9 @@ Kits activate via `/kit:<n>` slash command. Kits are idempotent — double-activ
116
122
  |-----|----------|--------|
117
123
  | web-designer | `/kit:web-designer` | Design system → components → accessibility → production lint |
118
124
  | infrastructure | `/kit:infrastructure` | Terraform → Azure → GitHub Actions → compliance |
125
+ | api | `/kit:api` | RESTful conventions → OpenAPI specs → contract testing |
126
+ | security | `/kit:security` | Threat modeling → IAM review → OWASP audit |
127
+ | data | `/kit:data` | Schema design → migration planning → query optimization |
119
128
 
120
129
  Kit manifests live in `~/.claude/kits/<name>/KIT.md`.
121
130
 
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: context-probe
3
+ disable-model-invocation: true
4
+ description: "Assess current context health and recommend action. Reads session data and conversation signals to estimate context bracket (FRESH/MODERATE/DEPLETED/CRITICAL)."
5
+ ---
6
+
7
+ # context-probe Skill
8
+
9
+ You are assessing the current session's context health.
10
+
11
+ ## Vault Path Resolution
12
+ Read vault_path from `~/.claude/praxis.config.json`.
13
+
14
+ ---
15
+
16
+ **Step 1 — Gather signals**
17
+
18
+ Assess these indicators (do NOT read external files just for this — use what you already know):
19
+
20
+ | Signal | How to assess |
21
+ |--------|--------------|
22
+ | Conversation length | Estimate from your sense of how much has been discussed |
23
+ | Tool calls made | Rough count of reads, writes, bash calls this session |
24
+ | Files touched | How many files have been read or edited |
25
+ | Corrections received | How many times the user corrected your output |
26
+ | Compaction occurred | Did you receive a compaction bootstrap? |
27
+ | Active task complexity | Simple (1-2 files) vs complex (5+ files, multi-milestone) |
28
+
29
+ **Step 2 — Estimate bracket**
30
+
31
+ | Bracket | Signals | Action |
32
+ |---------|---------|--------|
33
+ | **FRESH** | <10 tool calls, <5 files, no corrections, no compaction | Full speed. Batch aggressively. Load full context. |
34
+ | **MODERATE** | 10-30 tool calls, 5-15 files, 0-1 corrections | Re-read key requirements before decisions. Prefer concise output. |
35
+ | **DEPLETED** | 30+ tool calls, 15+ files, 2+ corrections, OR scope drift detected | Checkpoint to vault NOW. Write milestone summaries. Suggest `/session-retro` + `/clear`. |
36
+ | **CRITICAL** | Post-compaction, OR repeated corrections, OR instruction drift | STOP new work. Complete current milestone only. Write all state to vault. Start new session. |
37
+
38
+ **Step 3 — Report**
39
+
40
+ ```
41
+ CONTEXT PROBE
42
+ ━━━━━━━━━━━━━━━━━━━━━
43
+ Bracket: {FRESH | MODERATE | DEPLETED | CRITICAL}
44
+ Signals: {key indicators}
45
+ Action: {recommendation}
46
+ ━━━━━━━━━━━━━━━━━━━━━
47
+ ```
48
+
49
+ **Step 4 — Act on DEPLETED/CRITICAL**
50
+
51
+ If DEPLETED or CRITICAL:
52
+ 1. Update `{vault_path}/status.md` with current state
53
+ 2. Write any in-progress decisions to the active plan file
54
+ 3. Suggest: "Context is [bracket name]. Recommend `/session-retro` then `/clear` for a fresh start."
55
+
56
+ ## Removal Condition
57
+ Remove when Claude Code exposes token count or context utilization metrics natively.
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: repair
3
+ disable-model-invocation: true
4
+ description: "Structured repair phase for failed milestones. 3-attempt fix-and-verify loop with root cause analysis. Triggered by /verify failure or manually."
5
+ ---
6
+
7
+ # repair Skill
8
+
9
+ You are running a structured repair cycle for a failed milestone.
10
+
11
+ ## Vault Path Resolution
12
+ Read vault_path from `~/.claude/praxis.config.json`.
13
+
14
+ ## Acceptance
15
+ - [ ] Failure captured with exact error, file, line
16
+ - [ ] Root cause classified (flawed implementation vs flawed spec)
17
+ - [ ] Fix applied with minimal diff
18
+ - [ ] Validation passes after fix
19
+ - [ ] Repair trace written to vault
20
+
21
+ ## Boundaries
22
+ - No refactoring — fix the failure, nothing else
23
+ - No scope expansion — do not add features or change behavior beyond the fix
24
+ - No new files unless the fix requires them
25
+ - Maximum 3 attempts before STOP
26
+
27
+ ---
28
+
29
+ **Step 1 — Capture failure**
30
+ - Read the failure output from `/verify` (or ask user for the error)
31
+ - Extract: exact error message, file(s), line number(s), test name (if applicable)
32
+ - State the failure in one sentence:
33
+ `Failure: {what failed} in {file}:{line} because {symptom}.`
34
+
35
+ **Step 2 — Classify root cause**
36
+ Determine whether this is:
37
+ - **Flawed implementation** → the code doesn't match the spec. Fix forward.
38
+ - **Flawed spec** → the spec itself is wrong or incomplete. STOP.
39
+ Report to user: "Spec issue detected: [describe the issue]. Run `/discuss` to re-spec before continuing."
40
+ Do not attempt to fix spec issues — that's a different phase.
41
+
42
+ **Step 3 — Fix attempt (attempt {n}/3)**
43
+ - State what you're changing and why in one sentence
44
+ - Apply the minimal fix — smallest diff that addresses the root cause
45
+ - Do not refactor surrounding code
46
+ - Do not fix unrelated issues discovered during repair
47
+
48
+ **Step 4 — Re-validate**
49
+ Run the full validation sequence from `/verify` Step 1:
50
+ 1. Test suite
51
+ 2. Linter
52
+ 3. Typecheck (if applicable)
53
+ 4. Build (if applicable)
54
+
55
+ **Step 5 — Evaluate result**
56
+ - **PASS** → Milestone repaired. Commit the fix. Return to workflow.
57
+ Output: `Repaired: {what was fixed} in {file}. Next: continue with /execute or /verify.`
58
+ - **FAIL (same error)** → Root cause was misidentified. Re-analyze in Step 2.
59
+ - **FAIL (different error)** → Fix introduced a regression. Revert the fix, re-analyze.
60
+ - Track attempt count. If attempt 3 fails → Step 6.
61
+
62
+ **Step 6 — STOP after 3 failures**
63
+ Do not attempt a 4th fix. Report:
64
+
65
+ ```
66
+ REPAIR FAILED — 3 attempts exhausted
67
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
68
+
69
+ What: {original failure + all 3 attempt descriptions}
70
+ So What: {root cause analysis — why 3 fixes didn't work}
71
+ Now What: {recommended next step: re-spec, different approach, escalate}
72
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
73
+ ```
74
+
75
+ **Step 7 — Write repair trace to vault**
76
+ Whether the repair succeeded or failed, write to `{vault_path}/notes/{YYYY-MM-DD}_repair-trace.md`:
77
+
78
+ ```markdown
79
+ ---
80
+ tags: [repair, {project-slug}]
81
+ date: {YYYY-MM-DD}
82
+ source: agent
83
+ ---
84
+ # Repair Trace — {short title}
85
+
86
+ ## Original Failure
87
+ {error message, file, line}
88
+
89
+ ## Root Cause
90
+ {classification: flawed implementation | flawed spec}
91
+ {root cause statement}
92
+
93
+ ## Attempts
94
+ ### Attempt 1
95
+ - Fix: {what was changed}
96
+ - Result: {PASS | FAIL — error}
97
+
98
+ ### Attempt 2 (if applicable)
99
+ - Fix: {what was changed}
100
+ - Result: {PASS | FAIL — error}
101
+
102
+ ### Attempt 3 (if applicable)
103
+ - Fix: {what was changed}
104
+ - Result: {PASS | FAIL — error}
105
+
106
+ ## Resolution
107
+ {Fixed in attempt N | FAILED — escalated}
108
+ ```
109
+
110
+ **Step 8 — Write learning (if applicable)**
111
+ If the repair reveals a recurring pattern, write a `[LEARN:bugfix]` entry to `{vault_path}/notes/learnings.md`.
112
+
113
+ ## Error Handling
114
+
115
+ | Condition | Action |
116
+ |-----------|--------|
117
+ | No failure output provided | Ask user for error details |
118
+ | Spec issue detected | STOP, redirect to `/discuss` |
119
+ | Fix causes new failure | Revert fix, count as failed attempt |
120
+ | Cannot identify root cause | Count as failed attempt, try different angle |
121
+
122
+ ## Callers
123
+
124
+ | Caller | When |
125
+ |--------|------|
126
+ | `/verify` Step 4 | On FAIL — delegates to `/repair` |
127
+ | Manual `/repair` | Any time a fix is needed |
128
+
129
+ ## Removal Condition
130
+ Remove when an automated repair agent (e.g., SWE-agent) handles fix-and-verify loops with equivalent quality.
@@ -28,6 +28,7 @@ Ask: "Review staged changes, last commit, or specific SHA?"
28
28
  - Any file → `~/.claude/rules/coding.md`
29
29
 
30
30
  **Step 4 — Launch subagent review**
31
+ Follow the subagent dispatch protocol (see `/subagent` skill for reference).
31
32
  Launch a subagent with ONLY these inputs (zero conversation history):
32
33
  - The diff
33
34
  - The SPEC (if available from Step 3)
@@ -35,6 +35,7 @@ Determine what to simplify:
35
35
 
36
36
  ## Phase 2 — Launch Subagent
37
37
 
38
+ Follow the subagent dispatch protocol (see `/subagent` skill for reference).
38
39
  Launch a subagent with ONLY these inputs (zero conversation history):
39
40
 
40
41
  ```
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: subagent
3
+ disable-model-invocation: true
4
+ description: "Reference protocol for subagent dispatch. Defines how to package context, spawn, interpret results, and escalate findings. Not invoked directly — referenced by review, simplify, verify-app, and verify skills."
5
+ ---
6
+
7
+ # Subagent Dispatch Protocol
8
+
9
+ This is a reference protocol, not a directly invocable skill. Skills that spawn subagents
10
+ (review, simplify, verify-app, verify) follow this protocol for consistency.
11
+
12
+ ---
13
+
14
+ ## Step 1 — Package Context
15
+
16
+ Subagents receive ONLY these inputs. Zero conversation history.
17
+
18
+ | Input | Source | Required |
19
+ |-------|--------|----------|
20
+ | Diff | `git diff` output scoped to the task | Yes |
21
+ | SPEC | `## SPEC` section from the active plan file | If available |
22
+ | Rules | Relevant `~/.claude/rules/*.md` based on file types in diff | Yes |
23
+ | Project config | Project CLAUDE.md `## Commands` and `## Code Style` | If available |
24
+
25
+ **Never include:**
26
+ - Conversation history
27
+ - User preferences or profile
28
+ - Vault state or session notes
29
+ - Full plan file (only SPEC section)
30
+
31
+ ## Step 2 — Define Role
32
+
33
+ One sentence. The role constrains the subagent's perspective.
34
+
35
+ Examples:
36
+ - "You are a critical code reviewer."
37
+ - "You are a code simplification expert."
38
+ - "You are a regression analyst."
39
+ - "You are a security auditor."
40
+
41
+ ## Step 3 — Define Task
42
+
43
+ Specific questions or analysis to perform. Include:
44
+ - What to look for (bugs, complexity, regressions, etc.)
45
+ - What NOT to do (don't suggest features, don't change behavior)
46
+ - Scope boundaries (only these files, only this diff)
47
+
48
+ ## Step 4 — Define Output Format
49
+
50
+ All subagent findings use this structure:
51
+
52
+ ```
53
+ {file}:{line} — {severity} — {category} — {description} — {fix}
54
+ ```
55
+
56
+ **Severity levels** (consistent across all subagent types):
57
+ - **Critical** — Must fix before proceeding. Blocks merge/ship.
58
+ - **Major** — Should fix before merge. Recommend addressing.
59
+ - **Minor** — Note for future cleanup. Does not block.
60
+
61
+ **If the subagent finds nothing:** Output "No findings." (not an empty list)
62
+
63
+ ## Step 5 — Spawn
64
+
65
+ Launch an Agent with:
66
+ - `subagent_type`: use `general-purpose` for review/analysis tasks
67
+ - `prompt`: role + task + inputs + output format
68
+ - Description: short (3-5 words) summary of what the subagent does
69
+
70
+ ```
71
+ Agent(
72
+ description: "Review diff for bugs",
73
+ prompt: "{role}\n\n{task}\n\n## Diff\n{diff}\n\n## SPEC\n{spec}\n\n## Rules\n{rules}\n\n{output format}"
74
+ )
75
+ ```
76
+
77
+ ## Step 6 — Interpret Results
78
+
79
+ Parse the subagent output:
80
+ 1. Group findings by severity (Critical → Major → Minor)
81
+ 2. Count findings per severity
82
+ 3. If output is unparseable: treat entire output as a single Minor finding
83
+
84
+ ## Step 7 — Escalate
85
+
86
+ | Severity | Action |
87
+ |----------|--------|
88
+ | Critical (any) | Block. Address immediately before proceeding. |
89
+ | Major (any) | Recommend fixing before merge. |
90
+ | Minor only | Note for future cleanup. Proceed. |
91
+ | No findings | "Clean." Proceed. |
92
+
93
+ **Re-review threshold:** If >3 findings were addressed, re-run the subagent (max 3 rounds).
94
+
95
+ ---
96
+
97
+ ## Callers
98
+
99
+ | Skill | Subagent Role | Spawned At |
100
+ |-------|---------------|------------|
101
+ | `/review` | Critical code reviewer | Step 4 |
102
+ | `/simplify` | Code simplification expert | Phase 2 |
103
+ | `/verify-app` | Regression analyst | Phase 3 |
104
+ | `/verify` | Critical code reviewer (self-review) | Step 5 |
105
+ | `/repair` | (uses /verify internally, which spawns subagent) | — |
106
+
107
+ ## Removal Condition
108
+ Remove when Claude Code provides a native subagent dispatch API with
109
+ structured input/output handling.
@@ -69,12 +69,11 @@ After self-review passes, write phase summary:
69
69
  - `/simplify` runs after UNIFY, before shipping. It is the quality gate between "it works" and "it's clean".
70
70
 
71
71
  **Step 4 — On FAIL (Stop-and-Fix)**
72
- 1. Identify the failure: exact error, file, line
73
- 2. Fix NOW. Do not proceed to the next milestone.
74
- 3. Re-run the full validation sequence (Step 1)
75
- 4. If still failing after 3 attempts: STOP.
76
- Report: **What** (full error + 3 attempts) → **So What** (root cause) → **Now What** (next steps)
77
- 5. Write failure details to the active plan file if >1 attempt was needed
72
+ Run `/repair` it handles the structured fix-and-verify loop:
73
+ - Captures the failure, classifies root cause, attempts up to 3 fixes
74
+ - Re-runs validation after each attempt
75
+ - STOPs with What/So What/Now What after 3 failures
76
+ - Writes repair trace and learnings to vault
78
77
 
79
78
  **Rules:**
80
79
  - Never say "tests pass" without showing output.
@@ -76,6 +76,7 @@ For each item in the plan's `## Done When`:
76
76
 
77
77
  ## Phase 3 — Regression Check
78
78
 
79
+ Follow the subagent dispatch protocol (see `/subagent` skill for reference).
79
80
  Launch a subagent with zero conversation history:
80
81
 
81
82
  ```
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: api
3
+ version: 1.0.0
4
+ description: "API design — RESTful conventions, OpenAPI specs, contract testing, endpoint review"
5
+ activation: /kit:api
6
+ deactivation: /kit:off
7
+ skills_chain:
8
+ - phase: spec
9
+ skills: []
10
+ status: planned
11
+ - phase: review
12
+ skills: []
13
+ status: planned
14
+ - phase: contract
15
+ skills: []
16
+ status: planned
17
+ mcp_servers: []
18
+ rules:
19
+ - api-design.md
20
+ removal_condition: >
21
+ Remove when API design is fully handled by a dedicated API gateway or design tool
22
+ with no manual Claude-driven operations remaining.
23
+ ---
24
+
25
+ # API Kit
26
+
27
+ ## Purpose
28
+ Enforce API design best practices across RESTful and GraphQL endpoints.
29
+ Covers spec generation, endpoint review, and contract test scaffolding.
30
+
31
+ ## Skills Chain
32
+
33
+ | # | Phase | Command | What It Provides |
34
+ |---|-------|---------|-----------------|
35
+ | 1 | Spec | `/api:spec` | Generate or validate OpenAPI spec from code |
36
+ | 2 | Review | `/api:review` | Endpoint naming, versioning, error codes, auth patterns |
37
+ | 3 | Contract | `/api:contract` | Generate contract tests from OpenAPI spec |
38
+
39
+ ## Workflow Integration
40
+
41
+ This kit operates WITHIN the Praxis workflow:
42
+ - **Praxis** structures the work (discuss → plan → execute → verify → simplify → ship)
43
+ - **This kit** adds API-specific rules and commands
44
+
45
+ ## Prerequisites
46
+
47
+ Run `install.sh` in this directory to check for required CLI tools.
48
+ Verify with `/kit:api` after install.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: "Generate contract tests from an OpenAPI spec or route definitions"
3
+ ---
4
+
5
+ # api:contract
6
+
7
+ ## Steps
8
+
9
+ 1. **Locate spec** — read `docs/openapi.yaml` or detect routes from code
10
+ 2. **For each endpoint**, generate a contract test that verifies:
11
+ - Response status code matches expected
12
+ - Response body matches schema
13
+ - Required fields are present
14
+ - Error responses follow the standard format
15
+ 3. **Detect test framework** — Jest, pytest, Go testing, etc.
16
+ 4. **Write tests** to project test directory
17
+ 5. **Run tests** — execute and report results
18
+ 6. **Report** — tests generated, pass/fail counts
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: "Review API endpoints for naming, versioning, error handling, and auth patterns"
3
+ ---
4
+
5
+ # api:review
6
+
7
+ ## Steps
8
+
9
+ 1. **Identify scope** — review all endpoints, or specific routes if user specifies
10
+ 2. **Launch subagent** (follow `/subagent` protocol) with role: "API design reviewer"
11
+ 3. **Check against api-design rules:**
12
+ - RESTful naming conventions
13
+ - HTTP status code usage
14
+ - Error response format consistency
15
+ - Authentication/authorization patterns
16
+ - Pagination implementation
17
+ - Versioning strategy
18
+ 4. **Present findings** by severity (Critical/Major/Minor)
19
+ 5. **Write review** to vault `specs/api-review-{date}.md`
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: "Generate or validate an OpenAPI spec from the current codebase"
3
+ ---
4
+
5
+ # api:spec
6
+
7
+ ## Steps
8
+
9
+ 1. **Detect API framework** — scan for route definitions (Express, FastAPI, Gin, etc.)
10
+ 2. **Extract endpoints** — list all routes with methods, paths, handlers
11
+ 3. **Generate OpenAPI 3.x spec** — for each endpoint:
12
+ - Path and method
13
+ - Request parameters (path, query, header)
14
+ - Request body schema (from types/models)
15
+ - Response schemas (success + error)
16
+ - Authentication requirements
17
+ 4. **Validate against api-design rules** — flag violations
18
+ 5. **Write spec** to `docs/openapi.yaml` (or project-configured location)
19
+ 6. **Report** — endpoints found, violations flagged, spec location
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Installing api kit ==="
5
+ echo ""
6
+
7
+ PASS=0
8
+ TOTAL=0
9
+
10
+ check() {
11
+ TOTAL=$((TOTAL + 1))
12
+ if command -v "$1" &>/dev/null; then
13
+ echo " ✓ $1 found ($(command -v "$1"))"
14
+ PASS=$((PASS + 1))
15
+ else
16
+ echo " ✗ $1 not found"
17
+ echo " Install: $2"
18
+ fi
19
+ }
20
+
21
+ echo "Checking optional CLI tools..."
22
+ echo ""
23
+
24
+ check "jq" "brew install jq OR apt-get install jq"
25
+ check "curl" "pre-installed on macOS/Linux"
26
+
27
+ echo ""
28
+ echo " $PASS/$TOTAL tools found"
29
+ echo ""
30
+
31
+ echo "Note: This kit uses Claude's built-in analysis capabilities."
32
+ echo "No external API linting tools required."
33
+ echo ""
34
+ echo "Commands available: /api:spec, /api:review, /api:contract"
35
+ echo ""
36
+ echo "=== api kit check complete ==="
37
+ echo "Activate with: /kit:api"
38
+ echo ""
@@ -0,0 +1,63 @@
1
+ # API Design — Rules
2
+ # Scope: Loads when api kit is active
3
+ # Paths: **/*.ts, **/*.js, **/*.py, **/*.go (API route files)
4
+
5
+ ## Invariants — BLOCK on violation
6
+
7
+ ### RESTful naming
8
+ - Resources are nouns, plural: `/users`, `/orders`, not `/getUser`, `/createOrder`
9
+ - Nested resources for relationships: `/users/{id}/orders`
10
+ - No verbs in URLs — HTTP methods convey the action
11
+ - Query parameters for filtering, sorting, pagination: `?status=active&sort=created_at&page=2`
12
+
13
+ ### HTTP status codes
14
+ - 200: success with body. 201: created. 204: success no body.
15
+ - 400: client error (validation). 401: not authenticated. 403: not authorized. 404: not found.
16
+ - 409: conflict. 422: unprocessable entity.
17
+ - 500: server error (never leak internals).
18
+ - Never return 200 with an error body — use the appropriate 4xx/5xx code.
19
+
20
+ ### Error response format
21
+ All error responses use a consistent structure:
22
+ ```json
23
+ {
24
+ "error": {
25
+ "code": "VALIDATION_ERROR",
26
+ "message": "Human-readable description",
27
+ "details": [{"field": "email", "issue": "required"}]
28
+ }
29
+ }
30
+ ```
31
+ Never return raw stack traces or internal error messages.
32
+
33
+ ### Versioning
34
+ - URL path versioning preferred: `/v1/users`, `/v2/users`
35
+ - Header versioning acceptable: `Accept: application/vnd.api.v2+json`
36
+ - Never break existing versions without a migration path
37
+ - Deprecation: announce in response headers before removal
38
+
39
+ ### Authentication
40
+ - Bearer tokens in Authorization header, not query parameters
41
+ - API keys in headers, never in URLs (URLs are logged)
42
+ - Short-lived tokens with refresh mechanism for user-facing APIs
43
+
44
+ ## Conventions — WARN on violation
45
+
46
+ ### Pagination
47
+ - Cursor-based for large/real-time datasets
48
+ - Offset-based acceptable for small, static datasets
49
+ - Always return: `total`, `page`/`cursor`, `per_page`, `next`/`prev` links
50
+
51
+ ### Request/Response
52
+ - Use camelCase for JSON fields (or snake_case — be consistent per project)
53
+ - Dates in ISO 8601: `2024-01-15T10:30:00Z`
54
+ - IDs as strings (UUIDs preferred over sequential integers for external APIs)
55
+ - Envelope responses only when metadata is needed — prefer flat responses
56
+
57
+ ### Rate limiting
58
+ - Return `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` headers
59
+ - 429 status code with `Retry-After` header when exceeded
60
+
61
+ ### Documentation
62
+ - Every endpoint must have: method, path, description, request body, response body, error codes
63
+ - OpenAPI 3.x spec as source of truth — code generates from spec or spec generates from code
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Removing api kit ==="
5
+ echo ""
6
+ echo "This kit has no npm skills or MCP servers to remove."
7
+ echo ""
8
+ echo "To fully remove:"
9
+ echo " 1. Remove /kit:api from any project CLAUDE.md '## Active kit' sections"
10
+ echo " 2. Delete this directory: rm -rf ~/.claude/kits/api"
11
+ echo ""
12
+ echo "=== api kit removed ==="
13
+ echo ""
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: data
3
+ version: 1.0.0
4
+ description: "Data engineering — schema design, migration planning, query optimization"
5
+ activation: /kit:data
6
+ deactivation: /kit:off
7
+ skills_chain:
8
+ - phase: schema
9
+ skills: []
10
+ status: planned
11
+ - phase: migration
12
+ skills: []
13
+ status: planned
14
+ - phase: query
15
+ skills: []
16
+ status: planned
17
+ mcp_servers: []
18
+ rules:
19
+ - data.md
20
+ removal_condition: >
21
+ Remove when data operations are fully handled by a dedicated DBA tool
22
+ with no manual Claude-driven operations remaining.
23
+ ---
24
+
25
+ # Data Kit
26
+
27
+ ## Purpose
28
+ Enforce data engineering best practices for schema design, migrations,
29
+ and query optimization across SQL and NoSQL databases.
30
+
31
+ ## Skills Chain
32
+
33
+ | # | Phase | Command | What It Provides |
34
+ |---|-------|---------|-----------------|
35
+ | 1 | Schema | `/data:schema` | Schema design review with normalization analysis |
36
+ | 2 | Migration | `/data:migration` | Migration planning with rollback strategy |
37
+ | 3 | Query | `/data:query` | Query optimization and N+1 detection |
38
+
39
+ ## Workflow Integration
40
+
41
+ This kit operates WITHIN the Praxis workflow:
42
+ - **Praxis** structures the work (discuss → plan → execute → verify → simplify → ship)
43
+ - **This kit** adds data-specific rules and commands
44
+
45
+ ## Prerequisites
46
+
47
+ Run `install.sh` in this directory to check for required CLI tools.
48
+ Verify with `/kit:data` after install.
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: "Plan a database migration with rollback strategy and safety checks"
3
+ ---
4
+
5
+ # data:migration
6
+
7
+ ## Steps
8
+
9
+ 1. **Understand the change** — what schema changes are needed and why
10
+ 2. **Classify risk level:**
11
+ - **Low**: add nullable column, add index, add table
12
+ - **Medium**: rename column, add NOT NULL with default, modify index
13
+ - **High**: drop column/table, change column type, data transformation
14
+ 3. **Generate migration:**
15
+ - Up script (apply changes)
16
+ - Down script (reverse changes)
17
+ - Data migration script (if needed, separate from schema migration)
18
+ 4. **Safety checklist:**
19
+ - [ ] Down migration tested?
20
+ - [ ] Production data volume considered? (large table ALTERs may lock)
21
+ - [ ] Backward compatible? (old code works with new schema during deploy)
22
+ - [ ] Indexes added for new query patterns?
23
+ 5. **Write plan** to vault `specs/migration-plan-{date}.md`
@@ -0,0 +1,21 @@
1
+ ---
2
+ description: "Review SQL queries and data access patterns for performance and correctness"
3
+ ---
4
+
5
+ # data:query
6
+
7
+ ## Steps
8
+
9
+ 1. **Identify queries** — scan for SQL in code, ORM queries, or user-provided queries
10
+ 2. **Analyze each query:**
11
+ - Missing indexes (check WHERE, JOIN, ORDER BY columns)
12
+ - N+1 patterns (loop with individual queries instead of batch)
13
+ - Unbounded results (missing LIMIT/pagination)
14
+ - SELECT * usage
15
+ - Correlated subqueries that could be joins
16
+ 3. **Check data access patterns:**
17
+ - Connection pooling configuration
18
+ - Transaction scope (too broad or too narrow)
19
+ - Read replica usage for read-heavy workloads
20
+ 4. **Suggest optimizations** with before/after examples
21
+ 5. **Write review** to vault `specs/query-review-{date}.md`
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: "Review database schema design for normalization, indexing, and best practices"
3
+ ---
4
+
5
+ # data:schema
6
+
7
+ ## Steps
8
+
9
+ 1. **Identify schema files** — find migration files, model definitions, or SQL schemas
10
+ 2. **Analyze structure:**
11
+ - Normalization level (1NF → 3NF)
12
+ - Primary key strategy
13
+ - Foreign key relationships and ON DELETE behavior
14
+ - Index coverage on foreign keys and query columns
15
+ - Missing created_at/updated_at timestamps
16
+ 3. **Check for anti-patterns:**
17
+ - God tables (>20 columns)
18
+ - Missing indexes on foreign keys
19
+ - Polymorphic associations without proper constraints
20
+ - Over-normalization causing excessive joins
21
+ 4. **Present findings** by severity
22
+ 5. **Write review** to vault `specs/schema-review-{date}.md`
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Installing data kit ==="
5
+ echo ""
6
+
7
+ PASS=0
8
+ TOTAL=0
9
+
10
+ check() {
11
+ TOTAL=$((TOTAL + 1))
12
+ if command -v "$1" &>/dev/null; then
13
+ echo " ✓ $1 found ($(command -v "$1"))"
14
+ PASS=$((PASS + 1))
15
+ else
16
+ echo " ✗ $1 not found (optional)"
17
+ echo " Install: $2"
18
+ fi
19
+ }
20
+
21
+ echo "Checking optional CLI tools..."
22
+ echo ""
23
+
24
+ check "psql" "brew install postgresql OR apt-get install postgresql-client"
25
+ check "mysql" "brew install mysql-client OR apt-get install mysql-client"
26
+ check "mongosh" "brew install mongosh OR https://www.mongodb.com/try/download/shell"
27
+ check "jq" "brew install jq OR apt-get install jq"
28
+
29
+ echo ""
30
+ echo " $PASS/$TOTAL tools found"
31
+ echo ""
32
+
33
+ echo "Note: This kit uses Claude's built-in analysis for schema and query review."
34
+ echo "Database CLI tools are needed only for live query testing."
35
+ echo ""
36
+ echo "Commands available: /data:schema, /data:migration, /data:query"
37
+ echo ""
38
+ echo "=== data kit check complete ==="
39
+ echo "Activate with: /kit:data"
40
+ echo ""
@@ -0,0 +1,43 @@
1
+ # Data Engineering — Rules
2
+ # Scope: Loads when data kit is active
3
+ # Paths: **/*.sql, **/migrations/**, **/models/**, **/schema/**
4
+
5
+ ## Invariants — BLOCK on violation
6
+
7
+ ### Migration safety
8
+ - Every migration must be reversible — include both up and down scripts
9
+ - Never drop columns or tables in a single migration — deprecate first, remove later
10
+ - Add columns as nullable or with defaults — never add NOT NULL without a default to existing tables
11
+ - Test migrations against a copy of production data before applying
12
+ - No data transformations in schema migrations — separate data migrations
13
+
14
+ ### Query safety
15
+ - No `SELECT *` in production code — specify columns explicitly
16
+ - No unbounded queries — always include LIMIT or pagination
17
+ - No raw SQL string interpolation — use parameterized queries
18
+ - Validate that DELETE/UPDATE statements have WHERE clauses
19
+
20
+ ### Schema design
21
+ - Primary keys on every table — prefer UUIDs for distributed systems, auto-increment for single-node
22
+ - Foreign keys with explicit ON DELETE behavior (CASCADE, SET NULL, RESTRICT)
23
+ - Created/updated timestamps on every table
24
+ - Indexes on all foreign keys and frequently queried columns
25
+
26
+ ## Conventions — WARN on violation
27
+
28
+ ### Naming
29
+ - Tables: plural, snake_case (`user_accounts`, not `UserAccount`)
30
+ - Columns: snake_case, descriptive (`created_at`, not `ts`)
31
+ - Indexes: `idx_{table}_{columns}` pattern
32
+ - Constraints: `fk_{table}_{ref_table}`, `uq_{table}_{columns}`
33
+
34
+ ### Performance
35
+ - Detect N+1 query patterns — suggest eager loading or joins
36
+ - Large tables (>1M rows estimated): require index analysis before new queries
37
+ - Avoid correlated subqueries — prefer joins or CTEs
38
+ - Connection pooling required for production applications
39
+
40
+ ### Normalization
41
+ - Aim for 3NF unless denormalization is justified by read performance
42
+ - Document denormalization decisions as ADRs in vault `specs/`
43
+ - JSON columns acceptable for truly flexible schemas — not for avoiding normalization
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Removing data kit ==="
5
+ echo ""
6
+ echo "This kit has no npm skills or MCP servers to remove."
7
+ echo "Database CLI tools are system-level and not managed by this kit."
8
+ echo ""
9
+ echo "To fully remove:"
10
+ echo " 1. Remove /kit:data from any project CLAUDE.md '## Active kit' sections"
11
+ echo " 2. Delete this directory: rm -rf ~/.claude/kits/data"
12
+ echo ""
13
+ echo "=== data kit removed ==="
14
+ echo ""
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: security
3
+ version: 1.0.0
4
+ description: "Security review — threat modeling, IAM audit, OWASP checks, secrets management"
5
+ activation: /kit:security
6
+ deactivation: /kit:off
7
+ skills_chain:
8
+ - phase: threat-model
9
+ skills: []
10
+ status: planned
11
+ - phase: iam-review
12
+ skills: []
13
+ status: planned
14
+ - phase: audit
15
+ skills: []
16
+ status: planned
17
+ mcp_servers: []
18
+ rules:
19
+ - security.md
20
+ removal_condition: >
21
+ Remove when security review is fully handled by a dedicated SAST/DAST pipeline
22
+ with no manual Claude-driven operations remaining.
23
+ ---
24
+
25
+ # Security Kit
26
+
27
+ ## Purpose
28
+ Structured security analysis for applications and infrastructure.
29
+ Covers threat modeling, IAM policy review, and OWASP top 10 auditing.
30
+
31
+ ## Skills Chain
32
+
33
+ | # | Phase | Command | What It Provides |
34
+ |---|-------|---------|-----------------|
35
+ | 1 | Threat Model | `/security:threat-model` | STRIDE-based threat modeling for the current system |
36
+ | 2 | IAM Review | `/security:iam-review` | Review IAM policies, roles, permissions for least privilege |
37
+ | 3 | Audit | `/security:audit` | OWASP top 10 check against codebase |
38
+
39
+ ## Workflow Integration
40
+
41
+ This kit operates WITHIN the Praxis workflow:
42
+ - **Praxis** structures the work (discuss → plan → execute → verify → simplify → ship)
43
+ - **This kit** adds security-specific rules and commands
44
+ - Extends the base `secret-scan` hook with deeper analysis
45
+
46
+ ## Prerequisites
47
+
48
+ Run `install.sh` in this directory to check for required CLI tools.
49
+ Verify with `/kit:security` after install.
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: "Review IAM policies and permissions for least-privilege compliance"
3
+ ---
4
+
5
+ # security:iam-review
6
+
7
+ ## Steps
8
+
9
+ 1. **Identify IAM scope** — cloud provider (AWS/Azure/GCP), service accounts, user roles
10
+ 2. **Collect policies** — read IAM policy files, role definitions, permission sets
11
+ 3. **Check for violations:**
12
+ - Wildcard permissions (`*` actions or resources)
13
+ - Overly broad roles (admin/owner where reader/contributor suffices)
14
+ - Service accounts with user-level permissions
15
+ - Cross-account access without justification
16
+ - Unused roles or permissions (if access logs available)
17
+ 4. **Present findings** by severity (Critical/Major/Minor)
18
+ 5. **Recommend** least-privilege alternatives for each violation
19
+ 6. **Write review** to vault `specs/iam-review-{date}.md`
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: "OWASP top 10 check against the current codebase"
3
+ ---
4
+
5
+ # security:audit
6
+
7
+ ## Steps
8
+
9
+ 1. **Scan codebase** for OWASP Top 10 (2021) vulnerabilities:
10
+ - A01: Broken Access Control
11
+ - A02: Cryptographic Failures
12
+ - A03: Injection (SQL, NoSQL, OS command, LDAP)
13
+ - A04: Insecure Design
14
+ - A05: Security Misconfiguration
15
+ - A06: Vulnerable and Outdated Components
16
+ - A07: Identification and Authentication Failures
17
+ - A08: Software and Data Integrity Failures
18
+ - A09: Security Logging and Monitoring Failures
19
+ - A10: Server-Side Request Forgery (SSRF)
20
+ 2. **Launch subagent** (follow `/subagent` protocol) with role: "Security auditor"
21
+ 3. **Run external tools** if available (trivy, semgrep) for additional coverage
22
+ 4. **Present findings** grouped by OWASP category with severity
23
+ 5. **Write audit report** to vault `specs/security-audit-{date}.md`
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: "STRIDE-based threat modeling for the current system"
3
+ ---
4
+
5
+ # security:threat-model
6
+
7
+ ## Steps
8
+
9
+ 1. **Identify system scope** — ask user for the component or feature to model
10
+ 2. **Map data flows** — identify trust boundaries, data stores, external entities, processes
11
+ 3. **Apply STRIDE** for each component crossing a trust boundary:
12
+ - **S**poofing — can identity be faked?
13
+ - **T**ampering — can data be modified in transit/at rest?
14
+ - **R**epudiation — can actions be denied without audit trail?
15
+ - **I**nformation Disclosure — can data leak to unauthorized parties?
16
+ - **D**enial of Service — can the component be overwhelmed?
17
+ - **E**levation of Privilege — can a user gain unauthorized access?
18
+ 4. **Rate each threat**: likelihood (1-3) × impact (1-3) = risk score
19
+ 5. **Recommend mitigations** for high-risk threats
20
+ 6. **Write threat model** to vault `specs/threat-model-{date}-{component}.md`
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Installing security kit ==="
5
+ echo ""
6
+
7
+ PASS=0
8
+ TOTAL=0
9
+
10
+ check() {
11
+ TOTAL=$((TOTAL + 1))
12
+ if command -v "$1" &>/dev/null; then
13
+ echo " ✓ $1 found ($(command -v "$1"))"
14
+ PASS=$((PASS + 1))
15
+ else
16
+ echo " ✗ $1 not found (optional)"
17
+ echo " Install: $2"
18
+ fi
19
+ }
20
+
21
+ echo "Checking optional CLI tools..."
22
+ echo ""
23
+
24
+ check "trivy" "brew install trivy OR https://aquasecurity.github.io/trivy"
25
+ check "semgrep" "pip install semgrep OR brew install semgrep"
26
+ check "rg" "brew install ripgrep OR apt-get install ripgrep"
27
+
28
+ echo ""
29
+ echo " $PASS/$TOTAL tools found"
30
+ echo ""
31
+
32
+ echo "Note: This kit uses Claude's built-in analysis for most checks."
33
+ echo "External tools enhance scanning but are not required."
34
+ echo ""
35
+ echo "Commands available: /security:threat-model, /security:iam-review, /security:audit"
36
+ echo ""
37
+ echo "=== security kit check complete ==="
38
+ echo "Activate with: /kit:security"
39
+ echo ""
@@ -0,0 +1,57 @@
1
+ # Security — Rules
2
+ # Scope: Loads when security kit is active
3
+ # Extends base secret-scan with deeper analysis
4
+
5
+ ## Invariants — BLOCK on violation
6
+
7
+ ### Input validation
8
+ - Validate ALL user input at the boundary — never trust client data
9
+ - Use allowlists over denylists for input validation
10
+ - Parameterize all database queries — no string interpolation in SQL
11
+ - Sanitize HTML output — prevent XSS via output encoding
12
+ - Validate file uploads: type, size, content (not just extension)
13
+
14
+ ### Authentication
15
+ - Hash passwords with bcrypt/argon2 — never MD5/SHA1
16
+ - Enforce minimum password complexity at the application level
17
+ - Implement account lockout after N failed attempts
18
+ - Session tokens must be cryptographically random, sufficient length (128+ bits)
19
+ - Invalidate sessions on logout and password change
20
+
21
+ ### Authorization
22
+ - Enforce least privilege — default deny, explicit allow
23
+ - Check authorization on every request — never rely on client-side checks
24
+ - Use role-based (RBAC) or attribute-based (ABAC) access control
25
+ - Validate object-level access — prevent IDOR (Insecure Direct Object Reference)
26
+ - Log all authorization failures
27
+
28
+ ### Secrets
29
+ - No secrets in code, config files, or environment variable defaults
30
+ - Use secret managers (Vault, AWS Secrets Manager, Azure Key Vault)
31
+ - Rotate secrets on schedule and on compromise
32
+ - Audit secret access logs
33
+
34
+ ### Transport
35
+ - TLS 1.2+ for all external communication
36
+ - HSTS headers on all HTTP responses
37
+ - Certificate pinning for mobile/critical APIs
38
+
39
+ ## Conventions — WARN on violation
40
+
41
+ ### CORS
42
+ - Restrict `Access-Control-Allow-Origin` to specific domains — never `*` in production
43
+ - Limit allowed methods and headers to what's needed
44
+
45
+ ### CSP
46
+ - Content Security Policy headers on all HTML responses
47
+ - No `unsafe-inline` or `unsafe-eval` in production CSP
48
+
49
+ ### Dependencies
50
+ - Audit dependencies for known vulnerabilities before adding
51
+ - Pin dependency versions — no floating ranges in production
52
+ - Review transitive dependencies for supply chain risk
53
+
54
+ ### Logging
55
+ - Log security events: auth failures, privilege escalations, input validation failures
56
+ - Never log secrets, tokens, passwords, or PII
57
+ - Structured logging with correlation IDs for incident investigation
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ echo "=== Praxis: Removing security kit ==="
5
+ echo ""
6
+ echo "This kit has no npm skills or MCP servers to remove."
7
+ echo "CLI tools (trivy, semgrep) are system-level and not managed by this kit."
8
+ echo ""
9
+ echo "To fully remove:"
10
+ echo " 1. Remove /kit:security from any project CLAUDE.md '## Active kit' sections"
11
+ echo " 2. Delete this directory: rm -rf ~/.claude/kits/security"
12
+ echo ""
13
+ echo "=== security kit removed ==="
14
+ echo ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esoteric-logic/praxis-harness",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Layered Claude Code harness — workflow discipline, AI-Kits, persistent vault integration",
5
5
  "bin": {
6
6
  "praxis-harness": "./bin/praxis.js"
@@ -13,7 +13,7 @@
13
13
  "scripts/"
14
14
  ],
15
15
  "scripts": {
16
- "test": "node --check bin/praxis.js"
16
+ "test": "node --check bin/praxis.js && bash scripts/test-harness.sh"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -0,0 +1,172 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # ════════════════════════════════════════════════════════════════
5
+ # Praxis — Harness Test Suite
6
+ # Functional tests beyond what lint-harness.sh covers:
7
+ # shellcheck, JSON validation, cross-skill refs, hook wiring
8
+ # ════════════════════════════════════════════════════════════════
9
+
10
+ REPO_PATH="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
11
+
12
+ ERRORS=0
13
+ WARNINGS=0
14
+ PASS=0
15
+ TOTAL=0
16
+
17
+ error() {
18
+ echo " ✗ ERROR: $1"
19
+ ERRORS=$((ERRORS + 1))
20
+ TOTAL=$((TOTAL + 1))
21
+ }
22
+
23
+ warn() {
24
+ echo " ⚠ WARN: $1"
25
+ WARNINGS=$((WARNINGS + 1))
26
+ TOTAL=$((TOTAL + 1))
27
+ }
28
+
29
+ ok() {
30
+ echo " ✓ $1"
31
+ PASS=$((PASS + 1))
32
+ TOTAL=$((TOTAL + 1))
33
+ }
34
+
35
+ echo "Praxis Harness Tests"
36
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
37
+ echo " Repo: $REPO_PATH"
38
+
39
+ # ── 1. ShellCheck ──────────────────────────────────────────────
40
+ echo ""
41
+ echo "ShellCheck:"
42
+
43
+ if command -v shellcheck &>/dev/null; then
44
+ while IFS= read -r -d '' script; do
45
+ name=$(echo "$script" | sed "s|$REPO_PATH/||")
46
+ if shellcheck -S warning "$script" &>/dev/null; then
47
+ ok "$name"
48
+ else
49
+ warn "$name has shellcheck warnings"
50
+ fi
51
+ done < <(find "$REPO_PATH" -name "*.sh" -not -path "*/node_modules/*" -print0 2>/dev/null)
52
+ else
53
+ warn "shellcheck not installed — skipping (brew install shellcheck)"
54
+ fi
55
+
56
+ # ── 2. JSON Validation ────────────────────────────────────────
57
+ echo ""
58
+ echo "JSON validation:"
59
+
60
+ for json_file in \
61
+ "$REPO_PATH/base/hooks/settings-hooks.json" \
62
+ "$REPO_PATH/templates/claude-progress.json" \
63
+ "$REPO_PATH/package.json"; do
64
+ if [[ -f "$json_file" ]]; then
65
+ name=$(echo "$json_file" | sed "s|$REPO_PATH/||")
66
+ if jq . "$json_file" >/dev/null 2>&1; then
67
+ ok "$name"
68
+ else
69
+ error "$name is invalid JSON"
70
+ fi
71
+ fi
72
+ done
73
+
74
+ # ── 3. Hook Wiring ────────────────────────────────────────────
75
+ echo ""
76
+ echo "Hook wiring (settings-hooks.json → scripts exist):"
77
+
78
+ HOOKS_JSON="$REPO_PATH/base/hooks/settings-hooks.json"
79
+ if [[ -f "$HOOKS_JSON" ]]; then
80
+ # Extract all .sh filenames referenced in hook commands
81
+ hook_scripts=$(jq -r '.. | .command? // empty' "$HOOKS_JSON" 2>/dev/null | grep -oE '[a-z-]+\.sh' || true)
82
+ for script in $hook_scripts; do
83
+ if [[ -f "$REPO_PATH/base/hooks/$script" ]]; then
84
+ ok "hooks/$script exists"
85
+ else
86
+ error "hooks/$script referenced in settings-hooks.json but not found"
87
+ fi
88
+ done
89
+ fi
90
+
91
+ # ── 4. Cross-Skill References ─────────────────────────────────
92
+ echo ""
93
+ echo "Cross-skill references:"
94
+
95
+ # Skills that reference other skills — verify targets exist
96
+ declare -A SKILL_REFS
97
+ SKILL_REFS["verify"]="repair subagent"
98
+ SKILL_REFS["review"]="subagent"
99
+ SKILL_REFS["simplify"]="subagent"
100
+ SKILL_REFS["verify-app"]="subagent"
101
+ SKILL_REFS["repair"]="verify"
102
+ SKILL_REFS["execute"]="verify discuss"
103
+
104
+ for caller in "${!SKILL_REFS[@]}"; do
105
+ for target in ${SKILL_REFS[$caller]}; do
106
+ if [[ -d "$REPO_PATH/base/skills/$target" ]]; then
107
+ ok "$caller → $target"
108
+ else
109
+ error "$caller references skill '$target' which does not exist"
110
+ fi
111
+ done
112
+ done
113
+
114
+ # ── 5. Template Frontmatter ───────────────────────────────────
115
+ echo ""
116
+ echo "Template frontmatter:"
117
+
118
+ for tmpl in "$REPO_PATH"/templates/*.md; do
119
+ if [[ -f "$tmpl" ]]; then
120
+ name=$(basename "$tmpl")
121
+ if head -1 "$tmpl" | grep -q "^---"; then
122
+ ok "$name has frontmatter"
123
+ else
124
+ error "$name missing YAML frontmatter"
125
+ fi
126
+ fi
127
+ done
128
+
129
+ # ── 6. Kit Structure ──────────────────────────────────────────
130
+ echo ""
131
+ echo "Kit structure:"
132
+
133
+ for kit_dir in "$REPO_PATH"/kits/*/; do
134
+ if [[ -d "$kit_dir" ]]; then
135
+ kit_name=$(basename "$kit_dir")
136
+ for required in KIT.md install.sh teardown.sh; do
137
+ if [[ -f "$kit_dir/$required" ]]; then
138
+ ok "kits/$kit_name/$required"
139
+ else
140
+ error "kits/$kit_name/$required missing"
141
+ fi
142
+ done
143
+ fi
144
+ done
145
+
146
+ # ── 7. Installer Syntax ───────────────────────────────────────
147
+ echo ""
148
+ echo "Installer:"
149
+
150
+ if node --check "$REPO_PATH/bin/praxis.js" 2>/dev/null; then
151
+ ok "bin/praxis.js syntax valid"
152
+ else
153
+ error "bin/praxis.js has syntax errors"
154
+ fi
155
+
156
+ # ── Summary ───────────────────────────────────────────────────
157
+ echo ""
158
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
159
+ echo " Pass: $PASS"
160
+ echo " Errors: $ERRORS"
161
+ echo " Warnings: $WARNINGS"
162
+
163
+ if [[ $ERRORS -gt 0 ]]; then
164
+ echo " FAILED"
165
+ exit 1
166
+ else
167
+ if [[ $WARNINGS -gt 0 ]]; then
168
+ echo " PASSED with warnings"
169
+ else
170
+ echo " PASSED"
171
+ fi
172
+ fi