@esoteric-logic/praxis-harness 1.1.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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -0
  3. package/base/CLAUDE.md +148 -0
  4. package/base/commands/context-reset.md +72 -0
  5. package/base/commands/debug.md +63 -0
  6. package/base/commands/discover.md +49 -0
  7. package/base/commands/gsd-discuss.md +53 -0
  8. package/base/commands/gsd-execute.md +60 -0
  9. package/base/commands/gsd-verify.md +78 -0
  10. package/base/commands/kit.md +62 -0
  11. package/base/commands/plan.md +91 -0
  12. package/base/commands/ralph.md +110 -0
  13. package/base/commands/review.md +81 -0
  14. package/base/commands/risk.md +53 -0
  15. package/base/commands/ship.md +74 -0
  16. package/base/commands/spec.md +121 -0
  17. package/base/commands/standup.md +57 -0
  18. package/base/rules/architecture.md +51 -0
  19. package/base/rules/azure.md +90 -0
  20. package/base/rules/code-quality.md +65 -0
  21. package/base/rules/coding.md +139 -0
  22. package/base/rules/communication.md +69 -0
  23. package/base/rules/context-management.md +136 -0
  24. package/base/rules/execution-loop.md +84 -0
  25. package/base/rules/git-workflow.md +51 -0
  26. package/base/rules/github-actions.md +48 -0
  27. package/base/rules/powershell.md +72 -0
  28. package/base/rules/profile.md +31 -0
  29. package/base/rules/security.md +40 -0
  30. package/base/rules/terraform.md +48 -0
  31. package/base/rules/vault.md +134 -0
  32. package/base/skills/code-gc/SKILL.md +205 -0
  33. package/base/skills/code-simplifier/SKILL.md +132 -0
  34. package/base/skills/prd-writer/SKILL.md +108 -0
  35. package/base/skills/prd-writer/references/prd-template.md +22 -0
  36. package/base/skills/pre-commit-lint/SKILL.md +71 -0
  37. package/base/skills/scaffold-exist/SKILL.md +85 -0
  38. package/base/skills/scaffold-new/SKILL.md +177 -0
  39. package/base/skills/scaffold-new/references/claude-progress-template.json +24 -0
  40. package/base/skills/scaffold-new/references/gitignore-template.txt +65 -0
  41. package/base/skills/scaffold-new/references/repo-CLAUDE-md-template.md +87 -0
  42. package/base/skills/scaffold-new/references/vault-index-template.md +31 -0
  43. package/base/skills/scaffold-new/references/vault-learnings-template.md +21 -0
  44. package/base/skills/scaffold-new/references/vault-status-template.md +21 -0
  45. package/base/skills/scaffold-new/references/vault-tasks-template.md +20 -0
  46. package/base/skills/session-retro/SKILL.md +146 -0
  47. package/base/skills/subagent-review/SKILL.md +126 -0
  48. package/base/skills/vault-gc/SKILL.md +93 -0
  49. package/base/skills/verify-app/SKILL.md +156 -0
  50. package/bin/praxis.js +385 -0
  51. package/kits/infrastructure/KIT.md +66 -0
  52. package/kits/infrastructure/commands/infra-apply.md +44 -0
  53. package/kits/infrastructure/commands/infra-compliance.md +65 -0
  54. package/kits/infrastructure/commands/infra-drift.md +45 -0
  55. package/kits/infrastructure/commands/infra-plan.md +45 -0
  56. package/kits/infrastructure/install.sh +43 -0
  57. package/kits/infrastructure/rules/infrastructure.md +82 -0
  58. package/kits/infrastructure/teardown.sh +14 -0
  59. package/kits/web-designer/KIT.md +76 -0
  60. package/kits/web-designer/commands/web-audit.md +67 -0
  61. package/kits/web-designer/commands/web-component.md +54 -0
  62. package/kits/web-designer/commands/web-init.md +42 -0
  63. package/kits/web-designer/commands/web-tokens-sync.md +49 -0
  64. package/kits/web-designer/install.sh +41 -0
  65. package/kits/web-designer/rules/web-design.md +79 -0
  66. package/kits/web-designer/teardown.sh +26 -0
  67. package/package.json +28 -0
  68. package/scripts/health-check.sh +160 -0
  69. package/scripts/lint-harness.sh +195 -0
  70. package/scripts/onboard-mcp.sh +326 -0
  71. package/scripts/update.sh +88 -0
  72. package/templates/_index.md +33 -0
  73. package/templates/adr.md +28 -0
  74. package/templates/claude-progress.json +24 -0
  75. package/templates/plan.md +46 -0
  76. package/templates/project-index.md +31 -0
  77. package/templates/session-note.md +21 -0
  78. package/templates/status.md +27 -0
  79. package/templates/tasks.md +27 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ 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
+ ---
4
+
5
+ You are generating a standup summary for the current project.
6
+
7
+ **Step 1 — Load project state**
8
+ Read vault_path from `~/.claude/praxis.config.json`. Then read in order (detect from CWD — do not ask):
9
+ 1. `{vault_path}/_index.md` → project name, stack, goals
10
+ 1b. `{vault_path}/claude-progress.json` → check `ralph_state`
11
+ 2. `{vault_path}/status.md` → current_plan, last_updated, What/So What/Now What
12
+ 3. `{vault_path}/tasks.md` → Active, Blocked sections
13
+ 4. If `current_plan` is set → read `{vault_path}/plans/{current_plan}` → Milestones, Blockers
14
+
15
+ **Ralph state check:**
16
+ - If `.ralph_state.current_story` is set: note "Ralph iteration active" for output
17
+ - Use `completed_stories` count and `last_iteration` alongside `status.md`
18
+ - If `status.md` last_updated is stale but `ralph_state.last_iteration` is recent: suppress stale warning
19
+
20
+ **Step 2 — Output standup format**
21
+
22
+ ```
23
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
24
+ STANDUP — {Project Name} ({today_date})
25
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
26
+
27
+ DONE
28
+ {bullet from completed milestones or tasks}
29
+
30
+ IN PROGRESS
31
+ {active plan name} — {next milestone}
32
+
33
+ RALPH STATUS
34
+ {current story if active, or "No Ralph iteration running"}
35
+ Completed: {n} stories | Last: {last_iteration}
36
+
37
+ BLOCKED
38
+ {blocker with owner if known}
39
+
40
+ NEXT
41
+ {first item from Now What in status.md}
42
+
43
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44
+ Last updated: {last_updated from status.md}
45
+ Active plan: {current_plan or "none"}
46
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
47
+ ```
48
+
49
+ **Rules:**
50
+ - If status.md `## What` is empty: say so — do not invent state.
51
+ - If no active plan: say "No active plan — check tasks.md backlog."
52
+ - If last_updated is >7 days ago: warn "⚠ status.md is {N} days stale"
53
+ - Standup = facts only. No opinions or recommendations.
54
+
55
+ **Step 3 — Offer next action**
56
+ After printing standup, ask one question only:
57
+ "Update status.md with today's progress, or continue working?"
@@ -0,0 +1,51 @@
1
+ # Architecture Rules
2
+ <!-- Universal — applies when designing systems, documenting decisions, writing proposals -->
3
+
4
+ ## Invariants — BLOCK on violation
5
+
6
+ ### Decision capture
7
+ - Architecture decisions affecting system design, network topology, identity model,
8
+ data residency, security posture, or compliance scope MUST be written to
9
+ `{vault_path}/specs/` as an ADR before implementation.
10
+ - Never leave a significant decision only in conversation.
11
+ - ADR minimum structure: Decision / Context / Options Considered / Consequences.
12
+
13
+ ### What / So What / Now What
14
+ - Every status update, blocker report, and spec summary MUST follow this structure:
15
+ - **What**: Facts only. What exists, what was done, what failed.
16
+ - **So What**: Why it matters. Risk, dependency, compliance gap, or opportunity.
17
+ - **Now What**: Ordered actions informed by the above.
18
+ - Never write a What without a So What. Facts without implications are incomplete.
19
+
20
+ ### Vault vs repo boundary
21
+ - Code and configuration: repo. Decisions, rationale, risk context, research: vault.
22
+ - If in doubt: repo = what runs, vault = why it runs that way.
23
+ - Never put credentials, client-specific data, or engagement PII in the repo.
24
+
25
+ ---
26
+
27
+ ## Conventions — WARN on violation
28
+
29
+ ### Specs before implementation
30
+ - Significant changes need a spec before implementation begins. A single ADR is sufficient.
31
+
32
+ ### Phase and milestone tracking
33
+ - Active engagements with defined phases must track completion in `claude-progress.json`.
34
+ - Phase completion criteria documented before the phase begins — not retroactively.
35
+ - 99% complete is not complete. One remaining blocker = log it, don't round to done.
36
+
37
+ ---
38
+
39
+ ## Verification Commands
40
+ ```bash
41
+ # Check for ADRs missing required sections
42
+ grep -rL "## Decision\|## Context\|## Consequences" {vault_path}/specs/ 2>/dev/null
43
+
44
+ # Find specs older than 90 days that may be stale
45
+ find {vault_path}/specs/ -name "*.md" -mtime +90 -ls 2>/dev/null
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Removal Condition
51
+ Permanent. These are workflow guardrails, not project-specific.
@@ -0,0 +1,90 @@
1
+ ---
2
+ paths:
3
+ - "**/*.tf"
4
+ - "**/*.tfvars"
5
+ - "**/*.bicep"
6
+ - "**/*.azcli"
7
+ - "**/azure-*"
8
+ - "**/arm-*"
9
+ ---
10
+ # Azure Rules
11
+ <!-- Scope: Azure infrastructure work -->
12
+ <!-- CUSTOMIZE: Add engagement-specific naming, tags, and subscription rules -->
13
+
14
+ ## Invariants — BLOCK on violation
15
+
16
+ ### Naming
17
+ - Resource names MUST follow the engagement naming convention before any deployment.
18
+ <!-- CUSTOMIZE: Define your naming standard per engagement -->
19
+ <!-- Example: `{project}-{env}-{region}-{resource_type}` -->
20
+ - Never use default Azure-generated names (e.g., `resource-group-1`, `vnet-eastus`).
21
+
22
+ ### Mandatory Tags
23
+ <!-- CUSTOMIZE: Define required tags per engagement -->
24
+ <!-- Example: Every resource must include `project`, `environment`, `owner` -->
25
+ - Never deploy or script a resource block missing required tags. Add them first.
26
+
27
+ ### Subscription Boundaries
28
+ - Never reference resources across subscription boundaries without explicit cross-subscription
29
+ peering or private endpoint design.
30
+ - Never suggest moving a resource across subscriptions without first checking:
31
+ Recovery Services Vault compatibility, private endpoint re-registration,
32
+ NSG rule updates, and RBAC re-assignment.
33
+
34
+ ### Identity and RBAC
35
+ - Never recommend Owner or Contributor at subscription scope as a permanent assignment.
36
+ - Never suggest disabling MFA for any account, service principal, or managed identity.
37
+ - Managed Identity is preferred over Service Principal for Azure-native workloads.
38
+ - RBAC changes to production subscriptions must be documented in `specs/` before implementation.
39
+
40
+ ### Network Security
41
+ - Never recommend NSG rules with `source: Any` and `destination: Any`.
42
+ - Private Endpoints are the default for PaaS data services (Storage, SQL, Key Vault).
43
+ Public endpoints require explicit justification written to `specs/`.
44
+
45
+ ### Secrets and Credentials
46
+ - Never output real connection strings, SAS tokens, storage keys, or client secrets.
47
+ - Key Vault is the required secret store. Hard-coded credentials in any artifact = BLOCK.
48
+ - Certificate-based auth over password-based for service principals.
49
+
50
+ ---
51
+
52
+ ## Conventions — WARN on violation
53
+
54
+ ### Cost Awareness
55
+ - Flag any change estimated to increase monthly cost by >5%.
56
+ - Flag when a stable workload is a good Reserved Instance candidate (>1 year, predictable).
57
+
58
+ ### Defender and Monitoring
59
+ - Defender for Cloud recommendations rated HIGH or CRITICAL: note in `status.md`.
60
+ - Confirm Log Analytics workspace exists before suggesting new diagnostic settings.
61
+
62
+ ### Documentation
63
+ - Architecture decisions affecting subscription design, network topology, or identity model
64
+ belong in `specs/` as an ADR.
65
+
66
+ ---
67
+
68
+ ## Verification Commands
69
+ ```bash
70
+ # Audit missing mandatory tags across a resource group
71
+ az resource list -g <rg-name> \
72
+ --query "[?tags.project == null].[name,type]" -o table
73
+
74
+ # Find any-any NSG rules
75
+ az network nsg list \
76
+ --query "[].securityRules[?sourceAddressPrefix=='*' && destinationAddressPrefix=='*'].[name]" -o table
77
+
78
+ # Verify no public endpoints on storage accounts
79
+ az storage account list -g <rg-name> \
80
+ --query "[?publicNetworkAccess!='Disabled'].[name,publicNetworkAccess]" -o table
81
+
82
+ # Check Owner/Contributor at subscription scope
83
+ az role assignment list --scope /subscriptions/<sub-id> \
84
+ --query "[?roleDefinitionName=='Owner' || roleDefinitionName=='Contributor'].[principalName,roleDefinitionName]" -o table
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Removal Condition
90
+ Remove or archive when no active Azure engagements remain in the project registry.
@@ -0,0 +1,65 @@
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.
@@ -0,0 +1,139 @@
1
+ # Coding — Universal Rules
2
+ <!-- Universal — applies to ALL code regardless of language or stack -->
3
+ <!-- Merged from coding.md + code-quality.md -->
4
+
5
+ ---
6
+
7
+ ## Invariants — BLOCK on violation
8
+
9
+ ### Documentation lookup before implementation
10
+ - Before implementing anything that uses an external library, framework, or API:
11
+ use Context7 to get current docs. Training data has a cutoff. Context7 does not.
12
+ - Append "use context7" to any prompt involving a library not personally verified as current.
13
+ - Never suggest a method, constructor, or API signature from memory for a library
14
+ that releases frequently. Look it up first via Context7.
15
+ - If Context7 is unavailable: state that docs could not be verified and flag the
16
+ specific method/API as "unverified against current version."
17
+
18
+ ### Error handling
19
+ - Never silently swallow exceptions. Every catch block must either re-throw,
20
+ log with context, or return a typed error.
21
+ - No empty catch blocks. No fallback defaults unless explicitly asked.
22
+ - Error messages MUST include context: request params, response body, status codes.
23
+ - Use structured logging fields, not string interpolation.
24
+ - External calls: retries with exponential backoff + warnings, then raise last error.
25
+ - Validate response shape, not just status code — a 200 with error body is a silent failure.
26
+ - Every function that can fail must have an explicit failure path.
27
+ - Validate inputs at the boundary. Never assume callers pass correct data.
28
+
29
+ ### No hardcoded values
30
+ - No credentials, tokens, connection strings, or API keys inline. Ever.
31
+ Use environment variables, Key Vault references, or parameter files.
32
+ - No hardcoded paths specific to one machine. Use relative paths or env-derived roots.
33
+ - No magic numbers without a named constant and a comment explaining the value.
34
+
35
+ ### State and side effects
36
+ - Pure functions where possible. If a function mutates state, its name must signal that.
37
+ - Never mutate input parameters. Return new values.
38
+ - Write pure functions — only modify return values, never inputs or global state.
39
+
40
+ ### Typing
41
+ - Strict typing everywhere: function signatures, variables, collections.
42
+ - No implicit `any` or untyped parameters in typed languages.
43
+
44
+ ### No flag parameters
45
+ - Never write a function with a boolean/enum parameter that switches behavior.
46
+ Write separate named functions instead.
47
+
48
+ ### Dead code
49
+ - Delete dead code. Do not comment it out.
50
+ Commented-out code belongs in git history, not in files.
51
+ - Check if logic already exists before writing new code: `rg` to search first.
52
+
53
+ ---
54
+
55
+ ## Conventions — WARN on violation
56
+
57
+ ### Code structure
58
+ - Functions do one thing. If you are writing "and" in a function description,
59
+ split it into two functions.
60
+ - Prefer functional programming in greenfield code; classes only for connectors/interfaces.
61
+ Follow existing project conventions in established codebases.
62
+ - All imports at the top of the file.
63
+ - Follow DRY, KISS, YAGNI.
64
+
65
+ ### Naming
66
+ - Variable names describe what they contain: `subscriptionIds` not `ids`,
67
+ `retryDelayMs` not `delay`.
68
+ - Functions: verb-noun format. Name signals intent and side effects.
69
+
70
+ ### Testing
71
+ - Write tests for ALL new code in production paths.
72
+ - Spike/prototype carve-out: skip tests only if explicitly marked spike/prototype.
73
+ Flag test debt in `status.md` under `## Test Debt`.
74
+ - Run tests before marking any task complete.
75
+ - Mock external dependencies only — never mock the code under test.
76
+ - Test edge cases and error paths, not just happy paths.
77
+ - If existing tests break: fix them. Do not claim they are unrelated.
78
+ - Never say "this should work" — demonstrate it with output, log line, or test result.
79
+
80
+ ### Dependency management
81
+ Before adding any new package:
82
+ 1. Search first — check if functionality exists in codebase or stdlib (`rg`).
83
+ 2. Evaluate: maintenance status, last publish, open issues, bus factor.
84
+ 3. Minimize surface area — implement yourself if you only need one function.
85
+ 4. Pin versions — exact versions in lockfiles. No floating ranges in production deps.
86
+ 5. New production dependency requires explicit approval.
87
+
88
+ ### Documentation
89
+ - Comments explain WHY, not WHAT. If the comment describes what the code does,
90
+ rewrite the code to be self-describing instead.
91
+ - Update docs and comments when changing logic. Stale comments actively mislead.
92
+ - Code is primary documentation — clear naming, types, docstrings.
93
+ - YAML frontmatter on all markdown files:
94
+ ```yaml
95
+ ---
96
+ created: YYYY-MM-DD
97
+ status: draft|active|completed
98
+ tags: [relevant, tags]
99
+ source: agent
100
+ ---
101
+ ```
102
+
103
+ ### Scripts
104
+ - Scripts that modify resources must have a dry-run or preview step before live run.
105
+
106
+ ### Tool preferences
107
+ - Use Read/Edit/Write tools instead of cat/sed/echo.
108
+ - Use `rg` (ripgrep) for searching code, not grep.
109
+ - Use `git --no-pager` for all git commands.
110
+ - Use subagents for context-heavy research and code review.
111
+ - Non-interactive commands only — no interactive prompts.
112
+ - Prefer MCP tools for current documentation (context7, Playwright).
113
+
114
+ ---
115
+
116
+ ## Verification Commands
117
+
118
+ ```bash
119
+ # Verify Context7 MCP is active
120
+ claude mcp list | grep context7
121
+
122
+ # Check for hardcoded credential patterns in staged files
123
+ git diff --staged | grep -iE "(password|secret|token|key)\s*=\s*['\"][^'\"$]"
124
+
125
+ # Find TODO/FIXME left in staged files
126
+ git diff --staged | grep -E "(TODO|FIXME|HACK|XXX)"
127
+
128
+ # Find commented-out code blocks (language-agnostic)
129
+ git diff --staged | grep -E "^\+\s*(#|//|--|\*)\s*(def |function |class |var |const |let )"
130
+
131
+ # Check for untyped any in TypeScript staged files
132
+ git diff --staged -- '*.ts' | grep -E ": any"
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Removal Condition
138
+ Permanent. Remove only if a dedicated AI coding assistant replaces Claude Code
139
+ entirely and handles all enforcement automatically without instruction.
@@ -0,0 +1,69 @@
1
+ # Communication Rules
2
+ <!-- Universal — applies to all client-facing writing, proposals, status reports, specs -->
3
+
4
+ ## Invariants — BLOCK on violation
5
+
6
+ ### Executive summary first
7
+ - Every client-facing document must open with a plain-language summary of 1–3 sentences
8
+ before any technical detail. The summary answers: what is this, what does the reader
9
+ need to know, what action if any is required.
10
+
11
+ ### No AI attribution in commits or documents
12
+ - Never include: "Generated by Claude", "AI-assisted", "Co-authored by Claude",
13
+ or similar in git commits, document footers, spec headers, PR descriptions,
14
+ or any client-facing artifact.
15
+ - Commit messages describe the change, not the tool. Conventional commits only.
16
+
17
+ ### No AI-style filler prose
18
+ - Never use: "Certainly!", "Absolutely!", "Great question!", "I'd be happy to",
19
+ "It's worth noting that", "In conclusion", "To summarize the above".
20
+ - Never open with "In today's rapidly evolving landscape" or equivalent.
21
+
22
+ ---
23
+
24
+ ## Conventions — WARN on violation
25
+
26
+ ### Proposal structure
27
+ Every proposal follows this order:
28
+ 1. Executive Summary (1–3 sentences)
29
+ 2. Current State (facts only)
30
+ 3. Gaps / Problems (specific, measurable where possible)
31
+ 4. Recommendations (ranked by impact or urgency)
32
+ 5. Investment / Effort (time, cost, risk introduced)
33
+ 6. Next Steps (dated, owned)
34
+
35
+ ### Audience calibration
36
+ - Technical detail belongs in appendices or separate specs — not in the executive narrative.
37
+ - Non-technical stakeholders: no acronyms without definition on first use.
38
+ - Technical implementers: be precise. Specify the command, the flag, the exact resource name.
39
+
40
+ ### Status reports
41
+ - Use What / So What / Now What. Always.
42
+ - "We are working on X" is not a status update. State what is done, what is in progress,
43
+ and what the blocker or next step is.
44
+
45
+ ### .gitignore — AI and Local File Hygiene
46
+ Every repo scaffolded by scaffold-new must include these in `.gitignore`:
47
+ ```gitignore
48
+ CLAUDE.md
49
+ .claude/
50
+ .mcp.json
51
+ *.claude-session
52
+ agent-memory.jsonl
53
+ .context7-cache/
54
+ .vault-path
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Verification Commands
60
+ ```bash
61
+ # Check commit messages for AI attribution
62
+ git log --oneline -20 | grep -iE "(claude|ai-generated|co-authored by ai)"
63
+
64
+ # Check staged markdown for AI filler phrases
65
+ git diff --staged -- "*.md" | grep -iE "(certainly|absolutely|great question|i'd be happy)"
66
+
67
+ # Verify .gitignore covers CLAUDE.md
68
+ grep -q "CLAUDE.md" .gitignore && echo "✓ CLAUDE.md ignored" || echo "✗ CLAUDE.md NOT in .gitignore"
69
+ ```
@@ -0,0 +1,136 @@
1
+ # Context Management — Rules
2
+ # Scope: All projects, all sessions
3
+ # Prevents context rot via GSD phase discipline and Ralph story sizing
4
+
5
+ ## GSD Phase Discipline — Invariants (BLOCK on violation)
6
+
7
+ ### Phase-scoped context loading
8
+ - Load ONLY context required for the current GSD phase.
9
+ SPEC needs requirements and constraints — not implementation details.
10
+ IMPLEMENT needs the plan and relevant source files — not research notes.
11
+ - At the end of each phase: write a phase summary to the active plan file.
12
+ The summary replaces conversation memory — files are the record.
13
+ - Never carry raw conversation reasoning forward across phases.
14
+ If it matters, it is written to a file. If it is not written, it does not persist.
15
+ - One feature per session. Do not mix unrelated tasks.
16
+
17
+ ### File-based handoff at phase boundaries
18
+ - Phase transitions produce artifacts, not conversation continuity.
19
+ SPEC → PLAN: the plan file captures all decisions from the spec phase.
20
+ PLAN → IMPLEMENT: the approved plan is the sole implementation guide.
21
+ IMPLEMENT → VALIDATE: test output and lint output are the evidence.
22
+ - Use subagents for exploration, research, and review to protect the main context.
23
+
24
+ ## Ralph Story Sizing — Invariants (BLOCK on violation)
25
+
26
+ ### Size constraint
27
+ - Each Ralph PRD story must be completable in a single context window (~10k output tokens).
28
+ - Right-sized stories: add one component, one migration, one service method,
29
+ one test suite, or one configuration change.
30
+ - Too large: any story requiring >3 file groups or >1 architectural decision.
31
+ Split before execution.
32
+ - Stories requiring cross-story reasoning belong in GSD, not Ralph.
33
+ Ralph stories must be independently verifiable.
34
+
35
+ ### State contract
36
+ - `claude-progress.json` is the ONLY state bridge between Ralph iterations.
37
+ - The `ralph_state` object is authoritative:
38
+ ```json
39
+ {
40
+ "mode": "idle | active",
41
+ "prd_path": null,
42
+ "completed_stories": [],
43
+ "current_story": null
44
+ }
45
+ ```
46
+ - Ralph reads `ralph_state` at iteration start, writes at iteration end.
47
+ - Never reference conversation history as source of truth in Ralph mode.
48
+
49
+ ## When to Use GSD vs Ralph — Conventions (WARN on violation)
50
+
51
+ | Trigger | Use | Reason |
52
+ |---------|-----|--------|
53
+ | <5 stories, needs reasoning continuity | GSD | Decisions compound across stories |
54
+ | Architectural decisions required | GSD | Context must persist through tradeoff analysis |
55
+ | Exploratory or ambiguous scope | GSD | Needs human-in-the-loop at phase gates |
56
+ | >5 independent stories | Ralph | Parallelizable, no cross-story dependencies |
57
+ | Overnight/unattended execution | Ralph | Fresh context per story prevents drift |
58
+ | Mechanical transformations (migrations, renames) | Ralph | Repetitive, well-scoped, low judgment |
59
+
60
+ Default to GSD. Use Ralph only when stories are clearly independent and well-scoped.
61
+
62
+ ## Compaction Safety — Invariants (BLOCK on violation)
63
+
64
+ ### Ralph mid-run takes precedence
65
+ - If `claude-progress.json` → `.ralph_state.current_story` is set, ALWAYS read it — even if an active plan exists.
66
+ - Ralph mid-run state is authoritative over plan state. The story must complete or be explicitly blocked before plan-level work resumes.
67
+
68
+ ## Subagent Discipline — Conventions (WARN on violation)
69
+
70
+ ### Subagent scope
71
+ - Use subagents for exploration, research, and review — never for the main implementation thread.
72
+ - Subagents protect the main context window from excessive results.
73
+ - Each subagent receives ONLY the context it needs (diff, SPEC, relevant rules). NOT the full conversation history.
74
+ - Do not spawn subagents for tasks that take fewer tokens than the subagent overhead.
75
+
76
+ ## Context Reset Protocol — Conventions (WARN on violation)
77
+
78
+ ### When to reset
79
+ - Repeated corrections on the same issue (model is not incorporating feedback)
80
+ - Loop behavior (attempting the same failed approach)
81
+ - Instruction drift (ignoring rules that were followed earlier in the session)
82
+ - After 2 failed corrections: suggest `/context-reset` and `/clear`
83
+
84
+ ### How to reset
85
+ 1. Run `/context-reset` to checkpoint current state to vault files
86
+ 2. Run `/clear` to reset the conversation
87
+ 3. Re-bootstrap from project CLAUDE.md — the files contain everything needed
88
+ 4. The vault drives work. Conversation is the interface, not the record.
89
+
90
+ ## Context Brackets — Conventions (WARN on violation)
91
+
92
+ Adapt behavior based on estimated remaining context. Detect bracket by
93
+ conversation length heuristic (not token count — we cannot read session JSONL).
94
+
95
+ ### FRESH (early session, <30% of typical session length)
96
+ - Batch aggressively — minimize round trips
97
+ - Lean output — trust that recent context is available
98
+ - Load full plan context if needed — budget is high
99
+
100
+ ### MODERATE (mid-session, ~30-60%)
101
+ - Re-read key requirements before implementation decisions
102
+ - Reinforce constraint awareness — re-state SPEC if drifting
103
+ - Prefer concise output — save context for implementation
104
+
105
+ ### DEPLETED (late session, >60%)
106
+ - Checkpoint progress to vault files before continuing
107
+ - Write milestone summaries proactively (don't wait for verify)
108
+ - Suggest `/session-retro` + `/clear` if remaining work is substantial
109
+ - Prepare handoff: ensure status.md and plan file capture all state
110
+
111
+ ### CRITICAL (after compaction or context warning)
112
+ - Use DEPLETED rules
113
+ - STOP new work. Complete current milestone only.
114
+ - Write all state to vault immediately
115
+ - Suggest new session for remaining milestones
116
+
117
+ ---
118
+
119
+ ## Verification Commands
120
+
121
+ ```bash
122
+ # Check that claude-progress.json has ralph_state field
123
+ jq '.ralph_state' {vault_path}/claude-progress.json
124
+
125
+ # Verify active plan file exists and has phase summaries
126
+ ls -la {vault_path}/plans/
127
+
128
+ # Check status.md was updated this session
129
+ stat -f "%Sm" {vault_path}/status.md
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Removal Condition
135
+ Permanent. Context rot is inherent to LLM context windows.
136
+ Remove only if the underlying model architecture eliminates attention decay.