@esoteric-logic/praxis-harness 2.0.0 → 2.0.2

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.
Files changed (45) hide show
  1. package/base/CLAUDE.md +17 -15
  2. package/base/hooks/auto-format.sh +40 -0
  3. package/base/hooks/identity-check.sh +55 -0
  4. package/base/hooks/secret-scan.sh +1 -1
  5. package/base/hooks/settings-hooks.json +61 -0
  6. package/base/rules/git-workflow.md +7 -7
  7. package/base/rules/profile.md +10 -7
  8. package/base/rules/vault.md +12 -3
  9. package/base/{rules/architecture.md → skills/architecture-patterns/SKILL.md} +6 -14
  10. package/base/skills/code-gc/SKILL.md +1 -5
  11. package/base/{rules/communication.md → skills/communication-standards/SKILL.md} +7 -12
  12. package/base/{commands/context-reset.md → skills/context-reset/SKILL.md} +2 -0
  13. package/base/skills/context7-lookup/SKILL.md +49 -0
  14. package/base/{commands/debug.md → skills/debug/SKILL.md} +2 -0
  15. package/base/{commands/discover.md → skills/discover/SKILL.md} +2 -0
  16. package/base/{commands/discuss.md → skills/discuss/SKILL.md} +2 -0
  17. package/base/{commands/execute.md → skills/execute/SKILL.md} +2 -1
  18. package/base/{commands/fast.md → skills/fast/SKILL.md} +2 -0
  19. package/base/{commands/kit.md → skills/kit/SKILL.md} +2 -1
  20. package/base/skills/managing-git-identities/SKILL.md +94 -0
  21. package/base/{commands/next.md → skills/next/SKILL.md} +2 -0
  22. package/base/{commands/plan.md → skills/plan/SKILL.md} +2 -0
  23. package/base/skills/plan-writer/SKILL.md +69 -0
  24. package/base/skills/pre-commit-lint/SKILL.md +1 -5
  25. package/base/{commands/quick.md → skills/quick/SKILL.md} +2 -0
  26. package/base/{commands/review.md → skills/review/SKILL.md} +32 -9
  27. package/base/{commands/risk.md → skills/risk/SKILL.md} +2 -0
  28. package/base/skills/scaffold-exist/SKILL.md +1 -3
  29. package/base/skills/scaffold-new/SKILL.md +1 -4
  30. package/base/skills/secret-scan/SKILL.md +55 -0
  31. package/base/skills/session-retro/SKILL.md +1 -4
  32. package/base/{commands/ship.md → skills/ship/SKILL.md} +3 -1
  33. package/base/skills/{code-simplifier → simplify}/SKILL.md +3 -6
  34. package/base/{commands/spec.md → skills/spec/SKILL.md} +2 -0
  35. package/base/{commands/standup.md → skills/standup/SKILL.md} +2 -0
  36. package/base/skills/status-update/SKILL.md +47 -0
  37. package/base/skills/vault-gc/SKILL.md +1 -4
  38. package/base/{commands/verify.md → skills/verify/SKILL.md} +2 -0
  39. package/base/skills/verify-app/SKILL.md +1 -5
  40. package/package.json +1 -1
  41. package/scripts/lint-harness.sh +7 -3
  42. package/base/commands/simplify.md +0 -15
  43. package/base/rules/code-quality.md +0 -65
  44. package/base/rules/security.md +0 -40
  45. package/base/skills/subagent-review/SKILL.md +0 -127
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: plan-writer
3
+ disable-model-invocation: true
4
+ description: "Writes a dated work plan to the vault plans/ directory. Creates the plan file with YAML frontmatter, milestones, and acceptance criteria. Updates status.md current_plan field. Called by /plan and /discuss workflows."
5
+ ---
6
+
7
+ # plan-writer Skill
8
+
9
+ ## Inputs
10
+
11
+ | Input | Required | Source |
12
+ |-------|----------|--------|
13
+ | SPEC block | Yes | From `/discuss` output or user-provided scope |
14
+ | vault_path | Yes | From `~/.claude/praxis.config.json` |
15
+ | project_slug | Yes | From CWD → `_index.md` detection |
16
+
17
+ ## Output
18
+
19
+ A plan file at `{vault_path}/plans/{YYYY-MM-DD}_{task-slug}.md`
20
+
21
+ ## Plan File Format
22
+
23
+ ```markdown
24
+ ---
25
+ tags: [plan, {project-slug}]
26
+ date: {YYYY-MM-DD}
27
+ status: active
28
+ source: agent
29
+ ---
30
+
31
+ # Plan: {task title}
32
+
33
+ ## SPEC
34
+ PROBLEM: {from discuss}
35
+ DELIVERABLE: {from discuss}
36
+ ACCEPTANCE: {from discuss}
37
+ BOUNDARIES: {from discuss}
38
+
39
+ ## Milestones
40
+
41
+ ### M1 — {milestone title}
42
+ - [ ] {step}
43
+ - [ ] {step}
44
+ **Acceptance:** {how to verify this milestone}
45
+
46
+ ### M2 — {milestone title}
47
+ ...
48
+
49
+ ## Verification
50
+ {end-to-end checks that prove the plan is complete}
51
+ ```
52
+
53
+ ## Steps
54
+
55
+ 1. Read vault_path from config
56
+ 2. Detect project from CWD matching `local_path` in vault `_index.md`
57
+ 3. Generate task slug from the SPEC PROBLEM field (kebab-case, max 40 chars)
58
+ 4. Write the plan file with frontmatter
59
+ 5. Update `status.md`:
60
+ - Set `current_plan:` to the plan file path
61
+ - Set `loop_position: PLAN`
62
+ - Set `last_updated:` to today
63
+
64
+ ## Constraints
65
+
66
+ - Each milestone must be independently verifiable
67
+ - Max 5 milestones per plan — if more are needed, split into sub-plans
68
+ - Never write a milestone without acceptance criteria
69
+ - Plan files are immutable once execution starts — create a new plan for scope changes
@@ -1,11 +1,7 @@
1
1
  ---
2
2
  name: pre-commit-lint
3
3
  disable-model-invocation: true
4
- description: Generate a stack-aware pre-commit hook script for a repo. Use when setting
5
- up a new repo, when asked to "install pre-commit checks", "add linting to commits",
6
- or "wire pre-commit-lint". Also invoked by scaffold-new Phase 5.5.
7
- NOT invoked at commit time — generates a shell script that runs at commit time.
8
- allowed-tools: Bash, Read, Write, Edit
4
+ description: "Generate a stack-aware pre-commit hook script for a repo. Use when setting up a new repo, when asked to install pre-commit checks, add linting to commits, or wire pre-commit-lint. Also invoked by scaffold-new Phase 5.5. NOT invoked at commit time — generates a shell script that runs at commit time."
9
5
  ---
10
6
 
11
7
  # pre-commit-lint Skill
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: quick
3
+ disable-model-invocation: true
2
4
  description: Ad-hoc task with full quality guarantees in a single compressed flow. Use for tasks that need planning but aren't worth the full loop.
3
5
  ---
4
6
 
@@ -1,7 +1,11 @@
1
1
  ---
2
- description: Manual code review trigger. Launches a subagent to review a diff for bugs, security, and convention violations. Use independently of Praxis phases.
2
+ name: review
3
+ disable-model-invocation: true
4
+ description: "Manual code review trigger. Launches a subagent to review a diff for bugs, security, and convention violations. Use independently of Praxis phases."
3
5
  ---
4
6
 
7
+ # review Skill
8
+
5
9
  You are running a manual code review.
6
10
 
7
11
  **Step 1 — Determine diff scope**
@@ -21,7 +25,7 @@ Ask: "Review staged changes, last commit, or specific SHA?"
21
25
  - `.tf` / `.tfvars` → `~/.claude/rules/terraform.md`
22
26
  - `.yml` / `.yaml` in `.github/` → `~/.claude/rules/github-actions.md`
23
27
  - `.ps1` / `.psm1` → `~/.claude/rules/powershell.md`
24
- - Any file → `~/.claude/rules/coding.md`, `~/.claude/rules/security.md`
28
+ - Any file → `~/.claude/rules/coding.md`
25
29
 
26
30
  **Step 4 — Launch subagent review**
27
31
  Launch a subagent with ONLY these inputs (zero conversation history):
@@ -30,13 +34,17 @@ Launch a subagent with ONLY these inputs (zero conversation history):
30
34
  - Relevant rules files (from Step 3)
31
35
 
32
36
  Subagent prompt:
33
- > Review this diff for bugs, edge cases, error handling gaps, security issues,
34
- > and convention violations. Rate each finding:
35
- > Critical / Major / Minor.
37
+ > You are a critical code reviewer. Review this diff for bugs, edge cases,
38
+ > error handling gaps, security issues, and convention violations.
39
+ > Rate each finding: Critical / Major / Minor.
36
40
  > Format: `{file}:{line} — {severity} — {description} — {fix}`
41
+ > If the diff is clean, say "No findings."
42
+
43
+ Do NOT include any conversation history, project context, or user preferences
44
+ beyond the explicitly provided inputs.
37
45
 
38
46
  **Step 5 — Present findings**
39
- Structure output by severity:
47
+ Parse the subagent output and structure by severity:
40
48
 
41
49
  ```
42
50
  ━━━ REVIEW RESULTS ━━━
@@ -72,10 +80,25 @@ CLEAN
72
80
  source: agent
73
81
  ---
74
82
  ```
75
- - Vault indexing is automatic.
76
83
 
77
- **Rules:**
84
+ ## Error Handling
85
+
86
+ | Condition | Action |
87
+ |-----------|--------|
88
+ | Empty diff | "Nothing to review." Exit. |
89
+ | Subagent fails to launch | Return error, do not retry |
90
+ | Subagent output unparseable | Return raw output as single Minor finding |
91
+ | Rules file missing | Warn, proceed with available rules |
92
+
93
+ ## Callers
94
+
95
+ | Caller | Context |
96
+ |--------|---------|
97
+ | User via `/review` | Manual review trigger |
98
+ | `/verify` Step 5 | Post-milestone Self-Review Protocol |
99
+ | `execution-loop.md` | Self-Review Protocol reference |
100
+
101
+ ## Rules
78
102
  - Works independently of Praxis phases.
79
103
  - Never skip the subagent — review must come from fresh context.
80
104
  - Subagent receives zero conversation history.
81
- - If no project CLAUDE.md exists: proceed with base rules only.
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: risk
3
+ disable-model-invocation: true
2
4
  description: Add a new risk register entry to the current project vault. Assigns a risk ID, severity, mitigation, and writes to specs/risk-register.md.
3
5
  ---
4
6
 
@@ -1,9 +1,7 @@
1
1
  ---
2
2
  name: scaffold-exist
3
3
  disable-model-invocation: true
4
- description: Scaffold an existing project into the full harness. Invoke with /scaffold-exist only.
5
- Adds missing harness files to projects that predate the scaffold standard.
6
- Non-destructive — never overwrites without confirmation. Side-effect skill — never auto-triggers.
4
+ description: "Scaffold an existing project into the full harness. Invoke with /scaffold-exist only. Adds missing harness files to projects that predate the scaffold standard. Non-destructive — never overwrites without confirmation. Side-effect skill — never auto-triggers."
7
5
  ---
8
6
 
9
7
  # scaffold-exist Skill
@@ -1,9 +1,7 @@
1
1
  ---
2
2
  name: scaffold-new
3
3
  disable-model-invocation: true
4
- description: Scaffold a brand new project into the full harness. Invoke with /scaffold-new only.
5
- Creates repo CLAUDE.md, vault subtree, git identity verification, gitignore,
6
- pre-commit hook, and Project Registry entry. Side-effect skill — never auto-triggers.
4
+ description: "Scaffold a brand new project into the full harness. Invoke with /scaffold-new only. Creates repo CLAUDE.md, vault subtree, git identity verification, gitignore, pre-commit hook, and Project Registry entry. Side-effect skill — never auto-triggers."
7
5
  ---
8
6
 
9
7
  # scaffold-new Skill
@@ -14,7 +12,6 @@ If config is missing: STOP. Tell user to run `praxis/install.sh`.
14
12
 
15
13
  ## Boundaries — Rules Loading
16
14
  - Do NOT load `git-workflow.md` — identity and init handled inline
17
- - Do NOT load `security.md` — not relevant during scaffolding
18
15
  - Do NOT load `terraform.md` or `github-actions.md` — no infra files touched
19
16
 
20
17
  ## Overview
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: secret-scan
3
+ description: "Canonical secret scanning skill. Scans files for credential patterns (API keys, tokens, connection strings). Called by pre-commit-lint and ship workflows. Also usable standalone for repo-wide audits. Replaces all inline secret scan regex instances with a single authoritative source."
4
+ ---
5
+
6
+ # secret-scan Skill
7
+
8
+ ## The Pattern
9
+
10
+ Single authoritative regex for all secret detection in Praxis:
11
+
12
+ ```
13
+ (sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,}|DefaultEndpointsProtocol|AccountKey=)
14
+ ```
15
+
16
+ Covers: OpenAI (`sk-`), GitHub PAT (`ghp_`), Perplexity (`pplx-`), AWS (`AKIA`),
17
+ Bearer tokens, Azure Storage connection strings.
18
+
19
+ ## Modes
20
+
21
+ ### Staged files (pre-commit)
22
+ ```bash
23
+ rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,}|DefaultEndpointsProtocol|AccountKey=)" $(git diff --staged --name-only)
24
+ ```
25
+
26
+ ### Full repo audit
27
+ ```bash
28
+ rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,}|DefaultEndpointsProtocol|AccountKey=)" --glob "!*.lock" .
29
+ ```
30
+
31
+ ### .env files check
32
+ ```bash
33
+ git diff --staged --name-only | grep -E "\.env$|\.env\."
34
+ ```
35
+
36
+ ## Invocation
37
+
38
+ | Caller | When |
39
+ |--------|------|
40
+ | `secret-scan.sh` hook | PreToolUse on Write/Edit |
41
+ | `pre-commit-lint` skill | Before every commit |
42
+ | `/ship` workflow | Pre-flight Step 1 |
43
+ | Manual `/secret-scan` | On-demand repo audit |
44
+
45
+ ## On Detection
46
+
47
+ 1. Report file path and line number of each match.
48
+ 2. BLOCK — do not proceed until the secret is removed or confirmed false positive.
49
+ 3. If the match is in a regex pattern itself (e.g., in a rules file defining the scan):
50
+ that is a false positive — skip it.
51
+
52
+ ## Extending the Pattern
53
+
54
+ To add new credential patterns, update the regex in this skill.
55
+ All callers reference this skill as the canonical source.
@@ -1,10 +1,7 @@
1
1
  ---
2
2
  name: session-retro
3
3
  disable-model-invocation: true
4
- description: End-of-session retrospective. Invoke manually with /session-retro only.
5
- Writes [LEARN:tag] entries, proposes rule updates, updates claude-progress.json,
6
- triggers vault-gc lightweight check. Side-effect skill — never auto-triggers.
7
- allowed-tools: Bash, Read, Write, Edit
4
+ description: "End-of-session retrospective. Invoke manually with /session-retro only. Writes [LEARN:tag] entries, proposes rule updates, updates claude-progress.json, triggers vault-gc lightweight check. Side-effect skill — never auto-triggers."
8
5
  ---
9
6
 
10
7
  # session-retro Skill
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: ship
3
+ disable-model-invocation: true
2
4
  description: Commit, push, and open a PR in one shot. Runs pre-commit checks, crafts a commit message, pushes, and creates a PR with structured description. Use when a milestone or feature is complete and verified.
3
5
  ---
4
6
 
@@ -7,7 +9,7 @@ You are running the ship workflow — commit, push, and PR in one command.
7
9
  **Step 1 — Pre-flight checks**
8
10
  - Read project CLAUDE.md for build/test/lint commands
9
11
  - Run in order (all must pass):
10
- 1. Secret scan: `rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,})" $(git diff --staged --name-only)`
12
+ 1. Secret scan: `rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,}|DefaultEndpointsProtocol|AccountKey=)" $(git diff --staged --name-only)`
11
13
  2. Linter (from CLAUDE.md `## Commands`)
12
14
  3. Typecheck (if applicable)
13
15
  4. Test suite (from CLAUDE.md `## Commands`)
@@ -1,13 +1,10 @@
1
1
  ---
2
- name: code-simplifier
2
+ name: simplify
3
3
  disable-model-invocation: true
4
- description: Post-implementation code simplification. Launches a subagent to review
5
- recent changes for unnecessary complexity, over-abstraction, and opportunities to
6
- simplify. Runs after any implementation phase. Side-effect skill — never auto-triggers.
7
- allowed-tools: Bash, Read, Edit
4
+ description: "Post-implementation code simplification. Launches a subagent to review recent changes for unnecessary complexity, over-abstraction, and opportunities to simplify. Runs after any implementation phase. Side-effect skill — never auto-triggers."
8
5
  ---
9
6
 
10
- # code-simplifier Skill
7
+ # simplify Skill
11
8
 
12
9
  ## Vault Path Resolution
13
10
  Read vault_path from `~/.claude/praxis.config.json`.
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: spec
3
+ disable-model-invocation: true
2
4
  description: Create a structured spec or ADR for the current project. Writes to vault specs/ directory. Use for architecture decisions, technical designs, and risk documentation — NOT for task framing (use /discuss for that).
3
5
  ---
4
6
 
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: standup
3
+ disable-model-invocation: true
2
4
  description: Generate a standup summary for the current project. Reads status.md, tasks.md, and active plan. Use at the start or end of any working session.
3
5
  ---
4
6
 
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: status-update
3
+ disable-model-invocation: true
4
+ description: "Atomic update to vault status.md. Ensures consistent format, enforces the 100-line limit, and archives resolved items. Called at milestone boundaries, session end, and phase transitions."
5
+ ---
6
+
7
+ # status-update Skill
8
+
9
+ ## Required Fields (top of status.md, always present)
10
+
11
+ ```yaml
12
+ current_plan: {path or "none"}
13
+ last_updated: {YYYY-MM-DD}
14
+ last_session: {ISO timestamp}
15
+ loop_position: DISCUSS | PLAN | EXECUTE | VERIFY | IDLE
16
+ ```
17
+
18
+ ## Steps
19
+
20
+ 1. Read vault_path from `~/.claude/praxis.config.json`
21
+ 2. Read current `{vault_path}/status.md`
22
+ 3. Update the required fields at the top
23
+ 4. Add or update the What / So What / Now What section:
24
+ - **What**: Facts only — what was done, what exists now
25
+ - **So What**: Why it matters — blockers, risks, progress
26
+ - **Now What**: Next actions, ordered by priority
27
+ 5. Check line count — if >100 lines, archive resolved sections:
28
+ - Move completed What/So What/Now What blocks to `{vault_path}/notes/{date}_status-archive.md`
29
+ - Keep only active/unresolved items in status.md
30
+ 6. Write the updated file
31
+
32
+ ## When to Call
33
+
34
+ | Trigger | What to Update |
35
+ |---------|---------------|
36
+ | Milestone complete | Add accomplishment to What, advance Now What |
37
+ | Phase transition | Update `loop_position` |
38
+ | Session end | Update `last_session`, write current state |
39
+ | Blocker hit | Add blocker to So What, propose resolution in Now What |
40
+ | Plan created/changed | Update `current_plan` |
41
+
42
+ ## Constraints
43
+
44
+ - status.md must stay under 100 lines — archive aggressively
45
+ - Never delete content — always archive to notes/
46
+ - A status.md older than 14 days is stale — vault-gc flags these
47
+ - Use `[[wikilinks]]` for all internal vault references
@@ -1,10 +1,7 @@
1
1
  ---
2
2
  name: vault-gc
3
3
  disable-model-invocation: true
4
- description: Audit vault health and detect entropy. Invoke manually with /vault-gc
5
- only. Two modes — full audit (manual) and lightweight staleness check (called
6
- inline by session-retro). Never auto-deletes. Side-effect skill — never auto-triggers.
7
- allowed-tools: Bash, Read, Write
4
+ description: "Audit vault health and detect entropy. Invoke manually with /vault-gc only. Two modes — full audit (manual) and lightweight staleness check (called inline by session-retro). Never auto-deletes. Side-effect skill — never auto-triggers."
8
5
  ---
9
6
 
10
7
  # vault-gc Skill
@@ -1,4 +1,6 @@
1
1
  ---
2
+ name: verify
3
+ disable-model-invocation: true
2
4
  description: Validation phase — runs test/lint/typecheck/build and reports PASS or FAIL. Use after each milestone completion.
3
5
  ---
4
6
 
@@ -1,11 +1,7 @@
1
1
  ---
2
2
  name: verify-app
3
3
  disable-model-invocation: true
4
- description: End-to-end application verification. Launches a subagent to run the full
5
- test suite, check build, verify runtime behavior, and confirm acceptance criteria.
6
- Use after implementation to catch integration issues that unit tests miss.
7
- Side-effect skill — never auto-triggers.
8
- allowed-tools: Bash, Read
4
+ description: "End-to-end application verification. Launches a subagent to run the full test suite, check build, verify runtime behavior, and confirm acceptance criteria. Use after implementation to catch integration issues that unit tests miss. Side-effect skill — never auto-triggers."
9
5
  ---
10
6
 
11
7
  # verify-app Skill
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esoteric-logic/praxis-harness",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Layered Claude Code harness — workflow discipline, AI-Kits, persistent vault integration",
5
5
  "bin": {
6
6
  "praxis-harness": "./bin/praxis.js"
@@ -46,7 +46,7 @@ fi
46
46
 
47
47
  # ─── 2. Skill frontmatter ───
48
48
  echo ""
49
- echo "Skills (name:, disable-model-invocation:, description:):"
49
+ echo "Skills (name:, description:):"
50
50
  if [[ -d "$REPO_PATH/base/skills" ]]; then
51
51
  for skill_dir in "$REPO_PATH"/base/skills/*/; do
52
52
  [[ -d "$skill_dir" ]] || continue
@@ -60,10 +60,14 @@ if [[ -d "$REPO_PATH/base/skills" ]]; then
60
60
  header=$(head -10 "$skill_file")
61
61
  missing=""
62
62
  echo "$header" | grep -q "^name:" || missing="$missing name:"
63
- echo "$header" | grep -q "^disable-model-invocation:" || missing="$missing disable-model-invocation:"
64
63
  echo "$header" | grep -q "^description:" || missing="$missing description:"
65
64
  if [[ -z "$missing" ]]; then
66
- ok "skills/$skill_name"
65
+ # Note auto-invocable skills (no disable-model-invocation)
66
+ if echo "$header" | grep -q "^disable-model-invocation:"; then
67
+ ok "skills/$skill_name"
68
+ else
69
+ ok "skills/$skill_name (auto-invocable)"
70
+ fi
67
71
  else
68
72
  error "skills/$skill_name SKILL.md missing:$missing"
69
73
  fi
@@ -1,15 +0,0 @@
1
- ---
2
- description: Post-implementation code cleanup. Launches a subagent to find and
3
- simplify over-abstraction, dead paths, verbosity, and missed idioms in the
4
- recent diff. Run after implementation, before /verify-app or /ship.
5
- ---
6
-
7
- Invoke the code-simplifier skill on the current project's recent changes.
8
-
9
- Accept an optional scope argument:
10
- - No argument → `git diff HEAD~1` (default)
11
- - `staged` → staged changes only
12
- - `HEAD~N` or SHA → specific range
13
-
14
- The code-simplifier skill handles all phases: scope detection, subagent launch,
15
- finding presentation, user-approved edits, and optional [LEARN:simplify] capture.
@@ -1,65 +0,0 @@
1
- # Code Quality — Rules
2
- # Scope: All projects, all sessions
3
- # Complements `coding.md` with structural quality thresholds.
4
-
5
- ## Invariants — BLOCK on violation
6
-
7
- ### No deep nesting
8
- - Conditionals nested >3 levels deep must be refactored (extract function, early return, guard clause).
9
- - Applies to if/else, try/catch, loops, and match/switch statements.
10
-
11
- ### Cyclomatic complexity
12
- - Functions with cyclomatic complexity >15: BLOCK. Refactor before commit.
13
- - Measure by counting decision points (if, else if, for, while, case, &&, ||, catch).
14
-
15
- ### Public function documentation
16
- - All public functions and methods must have doc comments.
17
- - Doc comments describe intent and constraints, not implementation.
18
- - Internal/private helpers: doc comments optional, but name must be self-describing.
19
-
20
- ### No commented-out code
21
- - No commented-out code blocks in committed files.
22
- - Dead code belongs in git history, not in source files.
23
- - `// TODO:` and `// FIXME:` are annotations, not commented-out code — these are allowed.
24
-
25
- ---
26
-
27
- ## Conventions — WARN on violation
28
-
29
- ### Complexity awareness
30
- - Cyclomatic complexity >10: WARN. Consider splitting the function.
31
- - Functions longer than 50 lines: review for single-responsibility violation.
32
-
33
- ### No magic numbers
34
- - No magic numbers without a named constant and a comment explaining the value.
35
- - Exception: 0, 1, -1, and values obvious from immediate context (e.g., `array.length - 1`).
36
-
37
- ### Single responsibility
38
- - Each function does one thing. If the description requires "and", split it.
39
- - Each file has one primary concern. Utility grab-bags indicate missing abstractions.
40
-
41
- ### No hardcoded environment values
42
- - No hardcoded URLs, ports, hostnames, or credentials specific to an environment.
43
- - Use environment variables, config files, or parameter injection.
44
- - Cross-ref: `coding.md` — No hardcoded values invariant.
45
-
46
- ---
47
-
48
- ## Verification Commands
49
-
50
- ```bash
51
- # Find deeply nested blocks (rough heuristic — look for 4+ indent levels)
52
- rg '^\s{16,}(if|for|while|try)' --type-add 'code:*.{ts,js,py,go,rs}' -t code
53
-
54
- # Find commented-out code blocks (multi-line)
55
- rg '^\s*//\s*(const|let|var|function|class|import|return|if|for)' --type-add 'code:*.{ts,js}' -t code
56
- rg '^\s*#\s*(def |class |import |return |if |for )' -t py
57
-
58
- # Find magic numbers in staged files
59
- git diff --staged | grep -E '[^0-9][2-9][0-9]{2,}[^0-9]' | grep -v 'const\|#\|//'
60
- ```
61
-
62
- ---
63
-
64
- ## Removal Condition
65
- Permanent. Structural quality thresholds apply regardless of project or language.
@@ -1,40 +0,0 @@
1
- # Security — Rules
2
- # Scope: All projects, all sessions
3
-
4
- ## Invariants (BLOCK on violation)
5
-
6
- ### Secrets
7
- - NEVER hardcode secrets — no API keys, tokens, passwords, connection strings in code.
8
- Use environment variables or a secrets manager.
9
- - If a secret is found in code: flag immediately, do not proceed until remediated.
10
- - Pre-commit scan (always): `rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,})" $(git diff --staged --name-only)`
11
- - Secrets in logs: never log request bodies, headers, or responses that may contain credentials. Redact before logging.
12
-
13
- ### Input Validation
14
- - Validate all inputs at boundaries — APIs, user input, file uploads, environment variables.
15
- - Never trust external data without validation.
16
- - Validate response shape, not just status code — 200 with error body is a silent failure.
17
-
18
- ### Permissions
19
- - Least privilege — request only permissions and scopes needed.
20
- - No wildcard IAM policies. No `chmod 777`.
21
- - GitHub Actions: pin action versions to commit SHA, not tags.
22
-
23
- ## Conventions (WARN on violation)
24
-
25
- ### Dependencies
26
- - Audit new dependencies before adding: `npm audit`, `pip audit`, or equivalent.
27
- - Check for known CVEs before adding any package.
28
- - Pin to exact versions. No floating ranges in production.
29
-
30
- ## Verification Commands
31
- ```bash
32
- # Secret scan staged files
33
- rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,})" $(git diff --staged --name-only)
34
-
35
- # Secret scan entire repo (audit mode)
36
- rg "(sk-|ghp_|pplx-|AKIA|Bearer [A-Za-z0-9+/]{20,})" --glob "!*.lock" .
37
-
38
- # Check for .env files accidentally staged
39
- git diff --staged --name-only | grep -E "\.env$|\.env\."
40
- ```