@codeyam/codeyam-cli 0.1.0-staging.323686 → 0.1.0-staging.483fdc2

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 (171) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +2 -2
  4. package/analyzer-template/packages/ai/index.ts +6 -1
  5. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +39 -17
  6. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
  7. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +308 -50
  8. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +15 -6
  9. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +664 -242
  10. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +20 -1
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +35 -13
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +160 -0
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +289 -83
  17. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +269 -1
  18. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
  19. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +11 -3
  20. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
  21. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +297 -7
  22. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
  23. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
  24. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
  25. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
  26. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -3
  27. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
  28. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
  29. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  30. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  31. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  32. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  33. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  34. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  35. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +20 -6
  36. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +14 -4
  37. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  38. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +0 -3
  39. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  40. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
  41. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +57 -13
  42. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +29 -0
  43. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +35 -4
  44. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
  45. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +199 -17
  46. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  47. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  48. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  49. package/analyzer-template/packages/aws/package.json +1 -1
  50. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
  51. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  52. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  53. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  54. package/analyzer-template/packages/github/package.json +1 -1
  55. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
  56. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  57. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
  58. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  59. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  60. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  61. package/analyzer-template/project/constructMockCode.ts +54 -9
  62. package/analyzer-template/project/writeMockDataTsx.ts +73 -2
  63. package/background/src/lib/virtualized/project/constructMockCode.js +45 -3
  64. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  65. package/background/src/lib/virtualized/project/writeMockDataTsx.js +71 -2
  66. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  67. package/codeyam-cli/scripts/apply-setup.js +146 -0
  68. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  69. package/codeyam-cli/src/commands/debug.js +7 -5
  70. package/codeyam-cli/src/commands/debug.js.map +1 -1
  71. package/codeyam-cli/src/utils/install-skills.js +22 -0
  72. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  73. package/codeyam-cli/src/utils/reviewedRules.js +92 -0
  74. package/codeyam-cli/src/utils/reviewedRules.js.map +1 -0
  75. package/codeyam-cli/src/webserver/build/client/assets/globals-CX9f-5xM.css +1 -0
  76. package/codeyam-cli/src/webserver/build/client/assets/{manifest-7522edd4.js → manifest-bba56ec1.js} +1 -1
  77. package/codeyam-cli/src/webserver/build/client/assets/memory-DuTFSyJ2.js +92 -0
  78. package/codeyam-cli/src/webserver/build/client/assets/{root-eVAaavTS.js → root-DTfSQARG.js} +6 -6
  79. package/codeyam-cli/src/webserver/build/server/assets/{index-DVzYx8PN.js → index-TD1f-DHV.js} +1 -1
  80. package/codeyam-cli/src/webserver/build/server/assets/server-build-BQ-1XyEa.js +258 -0
  81. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  82. package/codeyam-cli/src/webserver/build-info.json +5 -5
  83. package/codeyam-cli/templates/codeyam:memory.md +174 -233
  84. package/codeyam-cli/templates/codeyam:new-rule.md +41 -2
  85. package/codeyam-cli/templates/rule-reflection-hook.py +161 -0
  86. package/codeyam-cli/templates/rules-instructions.md +126 -0
  87. package/package.json +1 -1
  88. package/packages/ai/index.js +2 -1
  89. package/packages/ai/index.js.map +1 -1
  90. package/packages/ai/src/lib/analyzeScope.js +29 -12
  91. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  92. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
  93. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  94. package/packages/ai/src/lib/astScopes/processExpression.js +239 -43
  95. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  96. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +503 -165
  97. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  98. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  99. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  100. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  101. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  102. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +22 -1
  103. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  104. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +34 -9
  105. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  106. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +159 -0
  107. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  108. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  109. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  110. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +237 -73
  111. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  112. package/packages/ai/src/lib/generateEntityScenarioData.js +195 -1
  113. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  114. package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
  115. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  116. package/packages/ai/src/lib/generateExecutionFlows.js +10 -2
  117. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  118. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +209 -3
  119. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
  120. package/packages/ai/src/lib/mergeStatements.js +70 -51
  121. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  122. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
  123. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  124. package/packages/ai/src/lib/resolvePathToControllable.js +24 -14
  125. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
  126. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  127. package/packages/analyze/src/lib/FileAnalyzer.js +60 -36
  128. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  129. package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
  130. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  131. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  132. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  133. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  134. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  135. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  136. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  137. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  138. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  139. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  140. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  141. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  142. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  143. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +13 -5
  144. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  145. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +14 -4
  146. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  147. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  148. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  149. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +0 -3
  150. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  151. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  152. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  153. package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
  154. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  155. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +52 -10
  156. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  157. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +25 -8
  158. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  159. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +34 -4
  160. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  161. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
  162. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  163. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +168 -9
  164. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  165. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  166. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  167. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  168. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  169. package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
  170. package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +0 -92
  171. package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +0 -257
@@ -1 +1 @@
1
- import{Y as I,M as J,N as K,W as L,O as Z,R as _,T as $,V as rr,U as tr,X as or,Q as ir}from"./assets/server-build-4Cr0uToj.js";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"fetch-retry";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"typescript";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{I as assets,J as assetsBuildDirectory,K as basename,L as entry,Z as future,_ as isSpaMode,$ as prerender,rr as publicPath,tr as routeDiscovery,or as routes,ir as ssr};
1
+ import{Y as H,Z as I,M as J,N as K,W as L,O as _,R as $,T as rr,V as tr,U as or,X as ir,Q as pr}from"./assets/server-build-BQ-1XyEa.js";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"fetch-retry";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"typescript";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{H as allowedActionOrigins,I as assets,J as assetsBuildDirectory,K as basename,L as entry,_ as future,$ as isSpaMode,rr as prerender,tr as publicPath,or as routeDiscovery,ir as routes,pr as ssr};
@@ -1,7 +1,7 @@
1
1
  {
2
- "buildTimestamp": "2026-01-30T00:55:49.390Z",
3
- "buildTime": 1769734549390,
4
- "buildNumber": 569,
5
- "semanticVersion": "0.1.569",
6
- "version": "0.1.569 (2026-01-30T00:55)"
2
+ "buildTimestamp": "2026-02-04T17:33:55.043Z",
3
+ "buildTime": 1770226435043,
4
+ "buildNumber": 583,
5
+ "semanticVersion": "0.1.583",
6
+ "version": "0.1.583 (2026-02-04T17:33)"
7
7
  }
@@ -3,13 +3,29 @@ name: codeyam:memory
3
3
  autoApprove: true
4
4
  description: |
5
5
  Generate and maintain Claude Rules for your codebase based on thorough analysis.
6
- Use when: User wants to set up memory, claude rules, document confusing areas,
6
+ Use when: User wants to set up memory, claude rules, document confusing areas,
7
7
  or ensure Claude has proper context for working in the codebase.
8
8
  ---
9
9
 
10
10
  # CodeYam Memory Assistant
11
11
 
12
- This skill helps you generate and maintain Claude Rules (`.claude/rules/`) that provide context-specific guidance. The goal is robust coverage of anything confusing while avoiding documentation of things Claude can intuit.
12
+ This skill helps you generate and maintain Claude Rules (`.claude/rules/`) that provide context-specific guidance. The goal is to **document genuinely confusing aspects** of the codebase—not things Claude can figure out by reading code.
13
+
14
+ ## Core Principle: Document Confusion, Not Information
15
+
16
+ **Good rules** explain things that are NOT obvious from reading the code:
17
+
18
+ - Historical context (why code evolved this way)
19
+ - Hidden relationships (files that must change together)
20
+ - Gotchas that caused bugs
21
+ - Non-obvious conventions
22
+
23
+ **Bad rules** document things Claude can easily ascertain:
24
+
25
+ - What functions do (Claude can read the code)
26
+ - Type definitions (Claude can see them)
27
+ - Directory structure (Claude can explore it)
28
+ - Basic patterns (Claude knows common patterns)
13
29
 
14
30
  ## When to Use This Skill
15
31
 
@@ -43,9 +59,9 @@ Please see `.codeyam/rules/instructions.md` for guidance.
43
59
  After making any code changes please run `codeyam memory status` and follow the instructions.
44
60
  ```
45
61
 
46
- ### 1B. Create Instructions File
62
+ ### 1B. Verify Instructions File
47
63
 
48
- Create `.codeyam/rules/instructions.md` with the content from the Instructions File section at the end of this document.
64
+ Check that `.codeyam/rules/instructions.md` exists (it should be created during `codeyam init`). If missing, copy it from `codeyam-cli/templates/rules-instructions.md`.
49
65
 
50
66
  ### 1C. Install Pre-commit Hook
51
67
 
@@ -66,176 +82,170 @@ Ensure `.codeyam/bin/memory-hook.sh` exists and is executable (`chmod +x`).
66
82
 
67
83
  ---
68
84
 
69
- ## Phase 2: Deep Codebase Analysis
85
+ ## Phase 2: Confusion Archaeology
70
86
 
71
- Perform thorough analysis to identify areas that may be confusing. The goal is to find everything that might trip up someone (or Claude) working in this codebase.
87
+ The goal is to find areas where developers have **struggled**—not just areas that are complex. High churn alone doesn't mean confusion; we're looking for patterns that indicate something is genuinely non-obvious.
72
88
 
73
- ### 2A. Analyze Git Commit Messages for Problem Signals
89
+ ### 2A. Find Confusion Signals in Commit History
74
90
 
75
- Look for commits indicating gotchas, workarounds, or complexity:
91
+ **Files with rapid successive changes** (same file, multiple commits in short windows = iteration/confusion):
76
92
 
77
93
  ```bash
78
- # Find commits with problem-indicating keywords
79
- git log --oneline --since="6 months ago" --grep="fix" --grep="bug" --grep="workaround" --grep="hack" --grep="revert" --grep="oops" --grep="forgot" --grep="actually" --all-match | head -30
94
+ # Files changed 3+ times in last month (rapid iteration signal)
95
+ git log --since="1 month ago" --name-only --pretty=format: | sort | uniq -c | sort -rn | awk '$1 >= 3 {print}' | head -20
96
+ ```
80
97
 
81
- # Find commits with long messages (indicate complex changes)
82
- git log --since="6 months ago" --format="%h %s" | awk 'length($0) > 80' | head -20
98
+ **Reverts** (definite confusion signals—someone made a change that didn't work):
83
99
 
84
- # Find reverted commits
85
- git log --oneline --since="6 months ago" --grep="revert" -i | head -10
100
+ ```bash
101
+ git log --since="6 months ago" --oneline --grep="[Rr]evert" | head -10
86
102
  ```
87
103
 
88
- For interesting commits, examine the full message and changes:
104
+ **Correction language** (commits that fix misunderstandings):
89
105
 
90
106
  ```bash
91
- git show <commit-hash> --stat
92
- git log -1 --format="%B" <commit-hash>
107
+ git log --since="6 months ago" --oneline | grep -iE "(oops|forgot|actually|wrong|typo|missing|should have|meant to)" | head -15
93
108
  ```
94
109
 
95
- ### 2B. Identify Files with High Churn or Complexity Signals
110
+ **Files with multiple fix commits** (confusion hotspots):
96
111
 
97
112
  ```bash
98
- # Files changed most frequently (last 6 months)
99
- git log --since="6 months ago" --name-only --pretty=format: | sort | uniq -c | sort -rn | head -30
113
+ git log --since="3 months ago" --oneline --grep="fix" -i --name-only --pretty=format: | sort | uniq -c | sort -rn | awk '$1 >= 2 {print}' | head -15
114
+ ```
100
115
 
101
- # Files with many different authors (tribal knowledge risk)
102
- git shortlog -sn --since="6 months ago" -- . | head -20
116
+ **Long commit messages** (someone felt the need to explain—complexity that needs documentation):
103
117
 
104
- # Files frequently modified together (hidden dependencies)
105
- git log --since="6 months ago" --name-only --pretty=format: | awk '/^$/{if(NR>1)print "---"}; /./{print}' | head -100
118
+ ```bash
119
+ git log --since="6 months ago" --format="%h %s" | awk 'length($0) > 100' | head -15
106
120
  ```
107
121
 
108
- Look for patterns where the same 2-3 files appear together repeatedly.
122
+ ### 2B. Dig Into High-Confusion Files
109
123
 
110
- ### 2C. Scan for Developer Notes in Code
124
+ For each file that shows confusion signals, examine its evolution:
111
125
 
112
126
  ```bash
113
- # Find TODO, FIXME, HACK, XXX, NOTE comments
114
- grep -rn "TODO\|FIXME\|HACK\|XXX\|NOTE:" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.py" --include="*.rb" --include="*.go" --include="*.java" --include="*.rs" . 2>/dev/null | head -50
127
+ # View the story of changes to understand what kept going wrong
128
+ git log --since="6 months ago" --oneline -- path/to/confusing-file.ts
115
129
 
116
- # Find "workaround" or "hack" mentions in comments
117
- grep -rni "workaround\|hack\|temporary\|legacy" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.py" . 2>/dev/null | head -30
130
+ # Read the full commit messages for context
131
+ git log --since="6 months ago" --format="%h %s%n%b" -- path/to/confusing-file.ts | head -100
118
132
  ```
119
133
 
120
- ### 2D. Analyze Project Structure
134
+ **As you analyze, ask:**
121
135
 
122
- ```bash
123
- # Get directory structure (2 levels deep)
124
- find . -type d -maxdepth 3 | grep -v node_modules | grep -v .git | grep -v dist | grep -v build | head -50
136
+ - What was the initial implementation?
137
+ - What kept breaking or needed fixing?
138
+ - What was non-obvious about the fix?
139
+ - What knowledge would have prevented the issue?
125
140
 
126
- # Find config files
127
- find . -name "*.config.*" -o -name "*.rc" -o -name ".env*" -o -name "tsconfig*" -o -name "package.json" 2>/dev/null | grep -v node_modules | head -30
141
+ ### 2C. Find Hidden Dependencies
128
142
 
129
- # Find test directories
130
- find . -type d -name "*test*" -o -type d -name "*spec*" -o -type d -name "__tests__" 2>/dev/null | grep -v node_modules | head -20
143
+ **Files that always change together** (may have non-obvious relationships):
144
+
145
+ ```bash
146
+ # Look for file pairs that frequently appear in the same commits
147
+ git log --since="3 months ago" --name-only --pretty=format: | awk 'NF' | sort | uniq -c | sort -rn | head -30
131
148
  ```
132
149
 
133
- ### 2E. Check for Environment and Configuration Complexity
150
+ When you see the same files appearing together repeatedly, investigate why they're coupled.
134
151
 
135
- ```bash
136
- # Find environment variable references
137
- grep -rn "process.env\|os.environ\|ENV\[" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.py" . 2>/dev/null | head -30
152
+ ### 2D. Scan for Developer Notes
138
153
 
139
- # Find multiple config files that might conflict or confuse
140
- ls -la *.config.* .*.rc tsconfig*.json 2>/dev/null
154
+ **TODO/FIXME/HACK comments** often mark confusion points:
155
+
156
+ ```bash
157
+ grep -rn "TODO\|FIXME\|HACK\|XXX" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.py" . 2>/dev/null | head -30
141
158
  ```
142
159
 
143
- ### 2F. Review Existing Documentation
160
+ Focus on comments that explain **why** something is the way it is, not just **what** needs to be done.
144
161
 
145
- Read these files if they exist:
162
+ ### 2E. Review Existing Documentation
163
+
164
+ Read these files if they exist to understand what's already documented:
146
165
 
147
166
  - `README.md`
148
167
  - `CLAUDE.md`
149
168
  - `CONTRIBUTING.md`
150
169
  - `docs/` directory
151
- - Any `*.md` files in the root
152
-
153
- Note what's already documented and what gaps exist.
154
170
 
155
- ### 2G. Examine Import/Dependency Patterns
156
-
157
- ```bash
158
- # Find files with many imports (high coupling)
159
- for f in $(find . -name "*.ts" -o -name "*.tsx" -o -name "*.js" 2>/dev/null | grep -v node_modules | head -100); do
160
- count=$(grep -c "^import\|^from\|require(" "$f" 2>/dev/null || echo 0)
161
- if [ "$count" -gt 15 ]; then
162
- echo "$count $f"
163
- fi
164
- done | sort -rn | head -20
165
-
166
- # Find commonly imported local modules (core utilities)
167
- grep -rh "from '\.\|from \"\.\|require('\.\|require(\"\." --include="*.ts" --include="*.tsx" --include="*.js" . 2>/dev/null | sort | uniq -c | sort -rn | head -20
168
- ```
171
+ Note gaps between what's documented and the confusion signals you found.
169
172
 
170
173
  ---
171
174
 
172
- ## Phase 3: Cluster and Prioritize Findings
175
+ ## Phase 3: Distinguish Important from Confusing
173
176
 
174
- After gathering signals, organize them by area/module:
177
+ Not all high-churn areas need documentation. Filter your findings:
175
178
 
176
- 1. **Group findings by directory** - Which parts of the codebase have the most signals?
177
- 2. **Identify themes**:
178
- - Architecture patterns (how things connect)
179
- - Testing complexity (special setup needed)
180
- - Configuration/environment gotchas
181
- - Historical workarounds still in place
182
- - Non-obvious conventions
179
+ ### Skip These (High Churn but NOT Confusing)
183
180
 
184
- 3. **Score areas** - More signals = higher priority for documentation
181
+ - Lock files (`pnpm-lock.yaml`, `package-lock.json`)
182
+ - Build outputs (`dist/`, `build/`)
183
+ - Generated files (`.build-info.json`, etc.)
184
+ - Files with mechanical changes (version bumps, auto-formatting)
185
185
 
186
- Create a mental map of:
186
+ ### Document These (High Churn AND Confusing)
187
187
 
188
- - Which directories/modules are most complex?
189
- - What relationships exist between different parts?
190
- - Where are the gotchas hiding?
188
+ - Files with multiple fix commits in short windows
189
+ - Files with reverts (someone's approach didn't work)
190
+ - Files where commit messages explain complex reasoning
191
+ - Files where the same area keeps breaking
192
+ - Files that must change together but aren't obviously related
191
193
 
192
- ---
194
+ ### Confusion Scoring
193
195
 
194
- ## Phase 4: Ask Specific Questions
196
+ Prioritize areas with stronger confusion signals:
195
197
 
196
- Based on your analysis, ask the user specific questions about the actual findings. Reference the concrete evidence you found (file names, commit messages, code patterns) and ask about the substance.
198
+ | Signal | Weight | Example |
199
+ | ------------------------- | ------ | --------------------------------- |
200
+ | Reverts | 5 | "Revert 'Track useState sources'" |
201
+ | Correction language | 5 | "Oops, forgot to import..." |
202
+ | Follow-up fix within days | 5 | Fix commit 2 days after change |
203
+ | "Workaround" or "hack" | 3 | "Workaround for webpack issue" |
204
+ | Long commit message | 3 | >100 chars explaining complexity |
205
+ | Multiple fix commits | 2 | 3+ fixes to same file |
206
+ | Numbered fix series | 1 | "Analysis Fixes 4", "Fixes 5" |
197
207
 
198
- Always include "I'm not sure - please investigate" as an option so users can delegate investigation to you.
208
+ Focus your documentation efforts on areas with the highest confusion scores.
209
+
210
+ ---
199
211
 
200
- ### Question Format
212
+ ## Phase 4: Ask Evidence-Based Questions
201
213
 
202
- Ask about the **specific finding**, not the file generally:
214
+ Questions must reference **specific confusion evidence** you found. Don't ask generic questions about files; ask about the specific commits, patterns, or problems you discovered.
203
215
 
204
- **For high-churn files with concerning commits:**
216
+ Always include "I'm not sure - please investigate" as an option so users can delegate investigation to you.
205
217
 
206
- > "ScopeDataStructure.ts has commits mentioning 'exponential blowup' and 'execution flows'. What causes this blowup? When does it happen?"
207
- >
208
- > Options: [Explain the cause] [I'm not sure - please investigate]
218
+ ### Question Examples
209
219
 
210
- **For files frequently modified together:**
220
+ **For rapid successive changes:**
211
221
 
212
- > "`src/api/auth.ts` and `src/middleware/session.ts` are modified together in 12 commits. Why do these need to change together?"
222
+ > "I found 5 commits to `ScopeDataStructure.ts` in 3 weeks, including 'Fix exponential blowup' and 'scope data structure optimization'. What kept causing issues here? What would someone need to know to avoid similar problems?"
213
223
  >
214
- > Options: [Explain the relationship] [I'm not sure - please investigate]
224
+ > Options: [Explain the pattern] [I'm not sure - please investigate]
215
225
 
216
- **For commits with workaround language:**
226
+ **For reverts:**
217
227
 
218
- > "Commit `abc123` says 'workaround for webpack issue'. What's the underlying issue and what's the workaround?"
228
+ > "Commit `a9fbd6385` reverted 'Track useState initialization sources'. Why didn't that approach work? What should be done instead?"
219
229
  >
220
- > Options: [Explain] [I'm not sure - please investigate]
230
+ > Options: [Explain what went wrong] [I'm not sure - please investigate]
221
231
 
222
- **For multiple config files:**
232
+ **For correction commits:**
223
233
 
224
- > "There are 3 tsconfig files. When is each one used?"
234
+ > "Commit `31e4a3842` says 'Oops, lost an import'. What import was lost and why is it easy to miss?"
225
235
  >
226
- > Options: [Explain usage] [I'm not sure - please investigate]
236
+ > Options: [Explain the gotcha] [I'm not sure - please investigate]
227
237
 
228
- **For TODO/FIXME comments:**
238
+ **For files that change together:**
229
239
 
230
- > "There's a FIXME in `src/parser.ts:142` about 'handle nested callbacks'. What's the issue with nested callbacks here?"
240
+ > "I noticed `auth.ts` and `session.ts` are modified together in 8 commits. Is there an invariant that must be maintained between them? What would break if someone changed one without the other?"
231
241
  >
232
- > Options: [Explain] [I'm not sure - please investigate]
242
+ > Options: [Explain the relationship] [I'm not sure - please investigate]
233
243
 
234
- **For test organization:**
244
+ **For long explanatory commits:**
235
245
 
236
- > "Tests are split between `__tests__/` folders and colocated `*.test.ts` files. When should each approach be used?"
246
+ > "Commit `abc123` has a detailed message about 'why we need to track execution flows separately'. What's the key insight here that should be documented?"
237
247
  >
238
- > Options: [Explain convention] [I'm not sure - please investigate]
248
+ > Options: [Summarize the insight] [I'm not sure - please investigate]
239
249
 
240
250
  ### Process
241
251
 
@@ -249,11 +259,59 @@ Ask about the **specific finding**, not the file generally:
249
259
 
250
260
  ---
251
261
 
252
- ## Phase 5: Generate Rules
262
+ ## Phase 5: Generate and Validate Rules
263
+
264
+ For each area where you have enough information, create a rule file—but **validate it first**.
265
+
266
+ ### 5A. Rule Validation (Before Writing)
267
+
268
+ Before generating each rule, verify it passes these tests:
269
+
270
+ **1. Evidence check**: Does the rule reference actual confusion evidence from commit history?
271
+
272
+ - If no evidence of confusion, reconsider whether the rule is needed
273
+
274
+ **2. Code-derivable check**: Read the files the rule will cover. Could the rule's content be determined by reading those files alone?
275
+
276
+ - If YES → rule probably not needed (Claude can read the code)
277
+ - If NO (historical context, edge cases, non-obvious behavior) → rule is valuable
278
+
279
+ **3. Prevention check**: Would this rule have prevented one of the confusion commits you found?
280
+
281
+ - If YES → definitely document it
282
+ - If NO → reconsider its value
283
+
284
+ ### Rule Quality Examples
285
+
286
+ **✅ Good rule** (passes all tests):
253
287
 
254
- For each area where you have enough information, create a rule file.
288
+ ```markdown
289
+ ## Path Prefix Matching Must Check Boundaries
290
+
291
+ When checking if one schema path is a prefix of another using `startsWith()`,
292
+ you must verify the match is at a path boundary. Otherwise sibling properties
293
+ with similar names incorrectly match.
294
+
295
+ This caused a bug where `entity` matched `entityCode` (siblings, not parent-child).
296
+ ```
255
297
 
256
- ### Rule File Guidelines:
298
+ - Evidence: Learned from actual bug (commit history evidence)
299
+ - Not code-derivable: Code doesn't explain why boundary checking matters
300
+ - Prevention: Would prevent future prefix-matching bugs
301
+
302
+ **❌ Bad rule** (fails tests):
303
+
304
+ ```markdown
305
+ ## Running Tests
306
+
307
+ Use `pnpm jest` to run tests. Configuration is in `jest.config.ts`.
308
+ ```
309
+
310
+ - No confusion evidence (no commits showing people struggled with this)
311
+ - Code-derivable: Anyone can see `jest.config.ts` exists
312
+ - Doesn't prevent any confusion
313
+
314
+ ### 5B. Rule File Guidelines
257
315
 
258
316
  1. **Location mirrors code structure**
259
317
  - Rule for `src/api/` → `.claude/rules/src/api/architecture.md`
@@ -263,16 +321,15 @@ For each area where you have enough information, create a rule file.
263
321
  - Good: `paths: ['src/api/**/*.ts']`
264
322
  - Bad: `paths: ['**/*.ts']` (too broad, wastes context)
265
323
 
266
- 3. **Content should be actionable**
267
- - Focus on "how to" and "what to know"
268
- - Avoid warnings unless truly critical
324
+ 3. **Content should explain "why" not just "what"**
325
+ - Focus on the reasoning, history, or gotcha
269
326
  - Be concise - every word costs context
270
327
 
271
328
  4. **Timestamp must be current**
272
329
  - Use ISO 8601 format: `2026-01-27T15:30:00Z`
273
330
  - This enables the pre-commit hook enforcement
274
331
 
275
- ### Rule Template:
332
+ ### Rule Template
276
333
 
277
334
  ```markdown
278
335
  ---
@@ -284,11 +341,15 @@ timestamp: [CURRENT_ISO_TIMESTAMP]
284
341
 
285
342
  ## [Clear, Descriptive Title]
286
343
 
287
- [Concise explanation of what this covers]
344
+ [What's the gotcha/insight/non-obvious thing?]
345
+
346
+ ### Why This Matters
347
+
348
+ [What would go wrong if someone didn't know this?]
288
349
 
289
- ### [Section as appropriate]
350
+ ### The Solution/Pattern
290
351
 
291
- [Specific, actionable content]
352
+ [What should someone do differently?]
292
353
  ```
293
354
 
294
355
  ---
@@ -298,6 +359,7 @@ timestamp: [CURRENT_ISO_TIMESTAMP]
298
359
  After generating rules based on your analysis and user answers:
299
360
 
300
361
  1. **Present a summary** of all rules created
362
+
301
363
  2. **Ask the user:**
302
364
 
303
365
  > "I've created rules covering [list areas]. Are there any other areas of the codebase that you know are confusing or have tribal knowledge that I might have missed?"
@@ -339,124 +401,3 @@ To proceed:
339
401
  2. Update content if needed
340
402
  3. Update the `timestamp` to current time
341
403
  4. Stage and commit
342
-
343
- ---
344
-
345
- ## Instructions File Content
346
-
347
- Create `.codeyam/rules/instructions.md` with this content:
348
-
349
- ```markdown
350
- # Memory Guide
351
-
352
- ## Maintaining Rules
353
-
354
- - It is your responsibility to maintain all rules
355
- - Rules should be concise and to the point. We want to be very conscientious about abusing the context window with too much text.
356
- - Use bullets and tables to communicate information efficiently
357
- - Review relevant rules after every code change using `codeyam memory status`
358
- - Constantly seek to improve rules. They will ensure every future coding session is more effective!
359
-
360
- ## Editing Rules
361
-
362
- We focus on three categories of documentation:
363
-
364
- 1. Architecture
365
-
366
- - Any time there is a specific relationship between files please capture the architecture
367
- - Note how the files relate, how data flows, and how changes should be approached
368
-
369
- 2. Testing
370
-
371
- - For complex areas of the app where both manual and automated testing is complex track:
372
- - Helpful commands used in debugging and testing
373
- - Where test files are located if it is not obvious (and the command to run them if not obvious)
374
-
375
- 3. FAQ
376
-
377
- - If you are ever confused about something that does not fit into the above categories document it here.
378
- - Anything you have to figure out or ask the user about should be captured here.
379
-
380
- **Please do not add to rules that are serving a different purpose. Create a new rule.**
381
-
382
- - Rules should be short and concise. Look for opportunities to improve them.
383
- - Use bullets and tables to communicate information efficiently.
384
- - Break up rules and create new rules if they are getting too long or are discussin different topics.
385
-
386
- ## Creating a New Rule
387
-
388
- 1. **Ask the user** If not obvious ask the user what they want to document (architecture, testing pattern, or gotcha/FAQ)
389
- 2. **Read the relevant source files** to understand the patterns
390
- 3. **Ask clarifying questions** if anything is unclear
391
- 4. **Determine the file location** - rules mirror the source code structure (see below)
392
- 5. **Create the rule file** with proper YAML frontmatter and concise content
393
- 6. **Remind the user** to commit the rule and suggest running `codeyam` to view it in the dashboard
394
-
395
- ## File Locations
396
-
397
- Rules mirror the source code structure:
398
-
399
- | Source Path | Rule Path |
400
- | -------------------- | ----------------------------------------- |
401
- | `src/api/auth.ts` | `.claude/rules/src/api/auth.md` |
402
- | `src/utils/**` | `.claude/rules/src/utils/architecture.md` |
403
- | Project-wide testing | `.claude/rules/testing-patterns.md` |
404
-
405
- ## YAML Frontmatter (Required)
406
-
407
- Every rule file MUST have this structure:
408
-
409
- ## \`\`\`yaml
410
-
411
- paths:
412
-
413
- - 'specific/path/\*_/_.ts'
414
- - 'another/path/\*.tsx'
415
- category: architecture | testing | faq
416
- timestamp: 2026-01-27T15:30:00Z
417
-
418
- ---
419
-
420
- \`\`\`
421
-
422
- ### Fields
423
-
424
- | Field | Required | Description |
425
- | ----------- | -------- | ---------------------------------------------------- |
426
- | `paths` | Yes | Glob patterns - be specific to avoid wasting context |
427
- | `category` | Yes | `architecture`, `testing`, or `faq` |
428
- | `timestamp` | Yes | ISO 8601 - must update when reviewing rule |
429
-
430
- ### Timestamp Enforcement
431
-
432
- The pre-commit hook blocks commits when:
433
-
434
- - You modify files matching a rule's `paths`
435
- - The rule's `timestamp` is older than your changes
436
-
437
- To proceed: review the rule, update timestamp, commit.
438
-
439
- ## Content Guidelines
440
-
441
- ### Be Specific and Actionable
442
-
443
- - Good: "Run `pnpm test:api` for API tests, `pnpm test:ui` for component tests"
444
- - Bad: "Make sure to run the appropriate tests"
445
-
446
- ### Be Concise
447
-
448
- Every word costs context window space. Trim aggressively.
449
-
450
- ### Focus on Positive Instructions
451
-
452
- - Good: "Auth tokens are stored in httpOnly cookies managed by `src/auth/cookies.ts`"
453
- - Bad: "WARNING: Don't store tokens in localStorage!"
454
-
455
- ## Categories
456
-
457
- **architecture** - Design decisions, file relationships, data flow, "why X is done this way"
458
-
459
- **testing** - Test commands, mock patterns, fixtures, "how to test X"
460
-
461
- **faq** - Gotchas, workarounds, common questions, "if you see X, do Y"
462
- ```
@@ -8,6 +8,45 @@ description: |
8
8
 
9
9
  # Create New Claude Rule
10
10
 
11
- Read `.codeyam/rules/instructions.md` for guidance on how to create and structure a new rule.
11
+ ## Before Creating: The Confusion Test
12
12
 
13
- If the instructions file doesn't exist, inform the user they should run `/codeyam:memory` first to set up the rules system.
13
+ Only create rules that document genuinely confusing aspects—not things Claude can figure out by reading code.
14
+
15
+ **Ask yourself:**
16
+
17
+ 1. **Could Claude figure this out by reading the code?**
18
+ - If YES → don't create the rule
19
+ - If NO → proceed
20
+
21
+ 2. **Does this explain "why" not just "what"?**
22
+ - Good: Historical context, gotchas, non-obvious behavior
23
+ - Bad: What functions do, how files are structured
24
+
25
+ 3. **Would this have prevented a past mistake?**
26
+ - If you can point to a bug or confusion this would have prevented → create it
27
+ - If it's just "nice to know" → skip it
28
+
29
+ ## Creating the Rule
30
+
31
+ Read `.codeyam/rules/instructions.md` for detailed guidance on structure and formatting.
32
+
33
+ If the instructions file doesn't exist, copy it from `codeyam-cli/templates/rules-instructions.md`.
34
+
35
+ ### Quick Template
36
+
37
+ ```markdown
38
+ ---
39
+ paths:
40
+ - 'specific/path/**/*.ts'
41
+ category: architecture | testing | faq
42
+ timestamp: [CURRENT_ISO_TIMESTAMP]
43
+ ---
44
+
45
+ ## [Clear, Descriptive Title]
46
+
47
+ [What's the gotcha/insight/non-obvious thing?]
48
+
49
+ ### Why This Matters
50
+
51
+ [What would go wrong if someone didn't know this?]
52
+ ```