devflow-kit 3.3.0 → 3.5.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 (220) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +8 -4
  3. package/dist/agents/code-edit.md +133 -0
  4. package/dist/agents/code-fix.md +165 -0
  5. package/dist/agents/code.md +187 -0
  6. package/{src/assets → dist}/agents/design.md +1 -2
  7. package/{src/assets → dist}/agents/diagnose.md +1 -2
  8. package/dist/agents/git.md +33 -722
  9. package/{src/assets → dist}/agents/knowledge.md +12 -5
  10. package/{src/assets → dist}/agents/research.md +8 -2
  11. package/{src/assets → dist}/agents/review.md +8 -11
  12. package/{src/assets → dist}/agents/scrutinize.md +4 -1
  13. package/dist/agents/skim.md +152 -0
  14. package/{src/assets → dist}/agents/triage.md +9 -2
  15. package/dist/cli/commands/behavior-prompts.js +77 -0
  16. package/dist/cli/commands/behavior.js +123 -0
  17. package/dist/cli/commands/flags.js +8 -2
  18. package/dist/cli/commands/init-seed.js +7 -3
  19. package/dist/cli/commands/init.js +134 -5
  20. package/dist/cli/commands/learning.js +38 -3
  21. package/dist/cli/commands/rules.js +16 -0
  22. package/dist/cli/commands/tracker.js +112 -15
  23. package/dist/cli/commands/uninstall.js +42 -1
  24. package/dist/cli.js +2 -0
  25. package/dist/commands/bug-analysis.md +35 -13
  26. package/dist/commands/code-review.md +155 -69
  27. package/dist/commands/debug.md +39 -16
  28. package/dist/commands/dynamic-build.md +61 -72
  29. package/dist/commands/dynamic-plan.md +39 -25
  30. package/dist/commands/dynamic-profile.md +28 -14
  31. package/dist/commands/dynamic-tickets.md +38 -22
  32. package/dist/commands/explore.md +18 -16
  33. package/dist/commands/implement.md +121 -150
  34. package/dist/commands/plan.md +51 -31
  35. package/dist/commands/release.md +72 -6
  36. package/dist/commands/research.md +49 -20
  37. package/dist/commands/resolve.md +54 -46
  38. package/dist/commands/self-review.md +38 -25
  39. package/dist/core/agent-frontmatter.js +101 -0
  40. package/dist/core/agent-models.js +43 -0
  41. package/dist/core/assets.js +55 -10
  42. package/dist/core/claude-md-audit.js +190 -0
  43. package/dist/core/compliance-compose.js +6 -4
  44. package/dist/core/feature-switch.js +41 -1
  45. package/dist/core/flags.js +139 -0
  46. package/dist/core/fs-atomic.js +8 -3
  47. package/dist/core/learning-variants.js +213 -0
  48. package/dist/core/manifest.js +73 -3
  49. package/dist/core/mds-variants.js +98 -19
  50. package/dist/core/plugins.js +111 -72
  51. package/dist/core/project-paths.js +0 -4
  52. package/dist/core/proxy-log.js +1 -1
  53. package/dist/core/proxy-state.js +1 -1
  54. package/dist/core/tracker.js +120 -2
  55. package/dist/learning-off/agents/code-edit.md +129 -0
  56. package/dist/learning-off/agents/code-fix.md +161 -0
  57. package/dist/learning-off/agents/code.md +183 -0
  58. package/dist/learning-off/agents/design.md +118 -0
  59. package/dist/learning-off/agents/diagnose.md +210 -0
  60. package/dist/learning-off/agents/knowledge.md +96 -0
  61. package/dist/learning-off/agents/research.md +155 -0
  62. package/dist/learning-off/agents/review.md +224 -0
  63. package/dist/learning-off/agents/scrutinize.md +120 -0
  64. package/{src/assets → dist/learning-off}/agents/skim.md +5 -8
  65. package/dist/learning-off/agents/triage.md +170 -0
  66. package/dist/learning-off/commands/bug-analysis.md +420 -0
  67. package/dist/learning-off/commands/code-review.md +530 -0
  68. package/dist/learning-off/commands/debug.md +314 -0
  69. package/dist/learning-off/commands/dynamic-build.md +1245 -0
  70. package/dist/learning-off/commands/dynamic-plan.md +426 -0
  71. package/dist/learning-off/commands/dynamic-profile.md +214 -0
  72. package/dist/learning-off/commands/dynamic-tickets.md +634 -0
  73. package/dist/learning-off/commands/explore.md +210 -0
  74. package/dist/learning-off/commands/implement.md +774 -0
  75. package/dist/learning-off/commands/plan.md +671 -0
  76. package/dist/learning-off/commands/release.md +311 -0
  77. package/dist/learning-off/commands/research.md +229 -0
  78. package/dist/learning-off/commands/resolve.md +842 -0
  79. package/dist/learning-off/commands/self-review.md +266 -0
  80. package/dist/skills/git/references/learn-conventions.md +27 -3
  81. package/dist/skills/git/references/pr/check-ci-status.md +19 -0
  82. package/dist/skills/git/references/pr/check-merge-readiness.md +19 -0
  83. package/dist/skills/git/references/pr/fetch-review-threads.md +30 -0
  84. package/dist/skills/git/references/pr/post-resolution-summary.md +18 -0
  85. package/dist/skills/git/references/pr/post-review-summary.md +20 -0
  86. package/dist/skills/git/references/pr/resolve-review-threads.md +28 -4
  87. package/dist/skills/git/references/pr/update-pr-evidence.md +13 -0
  88. package/dist/skills/git/references/pr/validate-branch.md +26 -0
  89. package/dist/skills/git/references/tracker/_contract.md +33 -0
  90. package/dist/skills/git/references/tracker/github/associate-release.md +24 -0
  91. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +31 -1
  92. package/dist/skills/git/references/tracker/github/create-release.md +30 -1
  93. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +89 -2
  94. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +16 -1
  95. package/dist/skills/git/references/tracker/github/fetch-issue.md +38 -1
  96. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +49 -1
  97. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +29 -0
  98. package/dist/skills/git/references/tracker/github/manage-debt.md +21 -1
  99. package/dist/skills/git/references/tracker/github/post-wave-report.md +17 -1
  100. package/dist/skills/git/references/tracker/github/setup-task.md +53 -1
  101. package/dist/skills/git/references/tracker/jira/associate-release.md +25 -1
  102. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +31 -1
  103. package/dist/skills/git/references/tracker/jira/create-release.md +30 -1
  104. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +89 -2
  105. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +16 -1
  106. package/dist/skills/git/references/tracker/jira/fetch-issue.md +38 -1
  107. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +49 -1
  108. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +29 -0
  109. package/dist/skills/git/references/tracker/jira/manage-debt.md +21 -1
  110. package/dist/skills/git/references/tracker/jira/post-wave-report.md +17 -1
  111. package/dist/skills/git/references/tracker/jira/setup-task.md +55 -3
  112. package/dist/skills/git/references/tracker/linear/associate-release.md +25 -1
  113. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +31 -1
  114. package/dist/skills/git/references/tracker/linear/create-release.md +30 -1
  115. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +89 -2
  116. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +16 -1
  117. package/dist/skills/git/references/tracker/linear/fetch-issue.md +38 -1
  118. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +49 -1
  119. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +29 -0
  120. package/dist/skills/git/references/tracker/linear/manage-debt.md +21 -1
  121. package/dist/skills/git/references/tracker/linear/post-wave-report.md +17 -1
  122. package/dist/skills/git/references/tracker/linear/setup-task.md +55 -3
  123. package/dist/targets/claude-code/agent-type-owner.js +164 -0
  124. package/dist/targets/claude-code/behavior-install.js +111 -0
  125. package/dist/targets/claude-code/installer.js +140 -37
  126. package/dist/targets/claude-code/language-stamp.js +185 -0
  127. package/dist/targets/claude-code/learning-install.js +497 -0
  128. package/dist/targets/claude-code/tracker-install.js +33 -16
  129. package/dist/targets/claude-code/tracker-servers.js +107 -0
  130. package/package.json +4 -3
  131. package/src/assets/agents/_partials/_code.mds +109 -0
  132. package/src/assets/agents/code-edit.mds +81 -0
  133. package/src/assets/agents/code-fix.mds +113 -0
  134. package/src/assets/agents/code.mds +135 -0
  135. package/src/assets/agents/design.mds +148 -0
  136. package/src/assets/agents/diagnose.mds +225 -0
  137. package/src/assets/agents/evaluate.md +8 -4
  138. package/src/assets/agents/explore.md +58 -0
  139. package/src/assets/agents/git.mds +33 -722
  140. package/src/assets/agents/knowledge.mds +131 -0
  141. package/src/assets/agents/learning.md +19 -69
  142. package/src/assets/agents/research.mds +182 -0
  143. package/src/assets/agents/review.mds +282 -0
  144. package/src/assets/agents/scrutinize.mds +135 -0
  145. package/src/assets/agents/simplify.md +3 -0
  146. package/src/assets/agents/skim.mds +165 -0
  147. package/src/assets/agents/synthesize.md +26 -352
  148. package/src/assets/agents/test.md +8 -0
  149. package/src/assets/agents/tracker.md +20 -7
  150. package/src/assets/agents/triage.mds +201 -0
  151. package/src/assets/agents/validate.md +13 -6
  152. package/src/assets/commands/_partials/_compliance.mds +41 -4
  153. package/src/assets/commands/_partials/_decisions.mds +33 -2
  154. package/src/assets/commands/_partials/_engine.mds +14 -6
  155. package/src/assets/commands/_partials/_knowledge.mds +25 -12
  156. package/src/assets/commands/_partials/_preamble.mds +34 -10
  157. package/src/assets/commands/_partials/_publication.mds +5 -4
  158. package/src/assets/commands/_partials/_roster.mds +4 -3
  159. package/src/assets/commands/_partials/_settings.mds +13 -5
  160. package/src/assets/commands/_partials/_wave.mds +9 -1
  161. package/src/assets/commands/bug-analysis.mds +27 -5
  162. package/src/assets/commands/code-review.mds +158 -52
  163. package/src/assets/commands/debug.mds +41 -3
  164. package/src/assets/commands/dynamic-build.mds +47 -27
  165. package/src/assets/commands/dynamic-plan.mds +40 -9
  166. package/src/assets/commands/dynamic-profile.mds +9 -1
  167. package/src/assets/commands/dynamic-tickets.mds +21 -6
  168. package/src/assets/commands/explore.mds +28 -2
  169. package/src/assets/commands/implement.mds +126 -129
  170. package/src/assets/commands/plan.mds +58 -14
  171. package/src/assets/commands/{release.md → release.mds} +30 -26
  172. package/src/assets/commands/research.mds +42 -11
  173. package/src/assets/commands/resolve.mds +59 -15
  174. package/src/assets/commands/self-review.mds +30 -5
  175. package/src/assets/mds/.mdsroot +4 -0
  176. package/src/assets/mds/git/_ops.mds +383 -0
  177. package/src/assets/mds/git/_ops_pr.mds +201 -0
  178. package/src/assets/mds/git/_ops_steps.mds +147 -0
  179. package/src/assets/mds/git/_pr.mds +39 -44
  180. package/src/assets/mds/git/_references.mds +6 -3
  181. package/src/assets/mds/tracker/_common.mds +5 -5
  182. package/src/assets/mds/tracker/_contract.mds +73 -0
  183. package/src/assets/mds/tracker/_github.mds +73 -16
  184. package/src/assets/mds/tracker/_jira.mds +77 -19
  185. package/src/assets/mds/tracker/_linear.mds +77 -19
  186. package/src/assets/mds/tracker/_mcp.mds +2 -2
  187. package/src/assets/mds/tracker/_steps.mds +98 -0
  188. package/src/assets/rules/behavior.md +6 -0
  189. package/src/assets/rules/context-economy.md +10 -0
  190. package/src/assets/rules/go.md +1 -0
  191. package/src/assets/rules/java.md +1 -0
  192. package/src/assets/rules/python.md +1 -0
  193. package/src/assets/rules/rust.md +1 -0
  194. package/src/assets/rules/typescript.md +1 -0
  195. package/src/assets/scripts/claude-md-audit.cjs +611 -0
  196. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +3 -3
  197. package/src/assets/scripts/hooks/json-helper.cjs +13 -5
  198. package/src/assets/scripts/hooks/json-parse +34 -10
  199. package/src/assets/scripts/hooks/lib/project-paths.cjs +0 -6
  200. package/src/assets/scripts/hooks/session-start-context +315 -7
  201. package/src/assets/skills/agent-references/SKILL.md +33 -0
  202. package/src/assets/skills/agent-references/references/learning/maintain.md +71 -0
  203. package/src/assets/skills/agent-references/references/synthesize/bug-analysis.md +71 -0
  204. package/src/assets/skills/agent-references/references/synthesize/design.md +36 -0
  205. package/src/assets/skills/agent-references/references/synthesize/exploration.md +38 -0
  206. package/src/assets/skills/agent-references/references/synthesize/planning.md +60 -0
  207. package/src/assets/skills/agent-references/references/synthesize/research.md +61 -0
  208. package/src/assets/skills/agent-references/references/synthesize/review.md +76 -0
  209. package/src/assets/skills/apply-decisions/SKILL.md +1 -1
  210. package/src/assets/skills/apply-feature-knowledge/SKILL.md +5 -5
  211. package/src/assets/skills/compliance/SKILL.md +1 -1
  212. package/src/assets/skills/docs-framework/SKILL.md +80 -83
  213. package/src/assets/skills/docs-framework/references/patterns.md +14 -25
  214. package/src/assets/skills/docs-framework/references/violations.md +7 -7
  215. package/src/assets/skills/feature-knowledge/SKILL.md +43 -12
  216. package/src/assets/skills/gap-analysis/SKILL.md +0 -16
  217. package/src/assets/skills/gap-analysis/references/compliance.md +19 -0
  218. package/src/assets/skills/quality-gates/SKILL.md +1 -1
  219. package/dist/skills/git/references/pr/ensure-pr-ready.md +0 -24
  220. package/src/assets/agents/code.md +0 -330
@@ -19,11 +19,8 @@ Correct patterns for Devflow documentation artifacts with templates and helper f
19
19
  │ └── {timestamp}/ # Incremental review
20
20
  │ └── ...
21
21
  ├── design/ # Implementation plans
22
- │ └── {topic-slug}.{timestamp}.md
23
- ├── status/ # Development logs
24
- │ ├── {timestamp}.md
25
- │ ├── compact/{timestamp}.md
26
- │ └── INDEX.md
22
+ │ ├── {ISSUE_ID}-{topic-slug}.{timestamp}.md # /plan (multi-{topic-slug} / {topic-slug} without an issue)
23
+ │ └── {slug}/{timestamp}/ # /dynamic-plan: {ticket-slug}-plan.md, DECISIONS-NEEDED.md
27
24
  └── CATCH_UP.md # Latest summary (overwritten)
28
25
  ```
29
26
 
@@ -32,8 +29,6 @@ Correct patterns for Devflow documentation artifacts with templates and helper f
32
29
  **Minimal (new project):**
33
30
  ```
34
31
  .devflow/docs/
35
- ├── status/
36
- │ └── INDEX.md
37
32
  └── CATCH_UP.md
38
33
  ```
39
34
 
@@ -51,9 +46,6 @@ Correct patterns for Devflow documentation artifacts with templates and helper f
51
46
  │ ├── regression.md
52
47
  │ ├── tests.md
53
48
  │ └── review-summary.md
54
- ├── status/
55
- │ ├── 2025-01-05_1430.md
56
- │ └── INDEX.md
57
49
  └── CATCH_UP.md
58
50
  ```
59
51
 
@@ -71,8 +63,6 @@ Correct patterns for Devflow documentation artifacts with templates and helper f
71
63
  │ ├── security.md
72
64
  │ ├── ...
73
65
  │ └── review-summary.md
74
- ├── status/
75
- │ └── INDEX.md
76
66
  └── CATCH_UP.md
77
67
  ```
78
68
 
@@ -89,7 +79,7 @@ Format: `YYYY-MM-DD_HHMM` (sortable, readable)
89
79
  TIMESTAMP=$(date +%Y-%m-%d_%H%M)
90
80
  # Output: 2025-01-05_1430
91
81
 
92
- # With seconds (only if needed for uniqueness)
82
+ # With seconds (a run directory that already exists: a second run in the same minute)
93
83
  TIMESTAMP_SEC=$(date +%Y-%m-%d_%H%M%S)
94
84
  # Output: 2025-01-05_143025
95
85
  ```
@@ -99,7 +89,7 @@ TIMESTAMP_SEC=$(date +%Y-%m-%d_%H%M%S)
99
89
  Replace `/` with `-`, provide fallback for detached HEAD.
100
90
 
101
91
  ```bash
102
- BRANCH_SLUG=$(git branch --show-current 2>/dev/null | sed 's/\//-/g' || echo "standalone")
92
+ BRANCH_SLUG=$(b=$(git branch --show-current 2>/dev/null); echo "${b:-standalone}" | sed 's/\//-/g')
103
93
 
104
94
  # Examples:
105
95
  # feature/auth -> feature-auth
@@ -111,15 +101,15 @@ BRANCH_SLUG=$(git branch --show-current 2>/dev/null | sed 's/\//-/g' || echo "st
111
101
 
112
102
  ### Topic Slugs
113
103
 
114
- Lowercase, dashes, alphanumeric only, max 50 chars.
104
+ Lowercase, each run of characters outside `a-z0-9` becomes one dash, no leading or trailing dash, max 50 chars, `untitled` when nothing is left.
115
105
 
116
106
  ```bash
117
- TOPIC_SLUG=$(echo "$TOPIC" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed 's/[^a-z0-9-]//g' | cut -c1-50)
107
+ TOPIC_SLUG=$(s=$(echo "$TOPIC" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//' | cut -c1-50 | sed -E 's/-+$//'); echo "${s:-untitled}")
118
108
 
119
109
  # Examples:
120
110
  # "JWT Authentication" -> jwt-authentication
121
111
  # "Fix User Login Bug" -> fix-user-login-bug
122
- # "OAuth 2.0 Integration" -> oauth-20-integration
112
+ # "OAuth 2.0 Integration" -> oauth-2-0-integration
123
113
  # "Database Migration v2" -> database-migration-v2
124
114
  ```
125
115
 
@@ -171,12 +161,11 @@ get_branch_slug() {
171
161
 
172
162
  # Convert topic to slug format
173
163
  get_topic_slug() {
174
- local topic="$1"
175
- echo "$topic" | \
176
- tr '[:upper:]' '[:lower:]' | \
177
- tr ' ' '-' | \
178
- sed 's/[^a-z0-9-]//g' | \
179
- cut -c1-50
164
+ local slug
165
+ slug=$(echo "$1" | tr '[:upper:]' '[:lower:]' | \
166
+ sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//' | \
167
+ cut -c1-50 | sed -E 's/-+$//')
168
+ echo "${slug:-untitled}"
180
169
  }
181
170
 
182
171
  # The checkout's toplevel, else the working directory outside git
@@ -351,11 +340,11 @@ get_branch_slug # Returns: standalone
351
340
 
352
341
  ### Special Characters in Topics
353
342
 
354
- All special characters stripped:
343
+ Every run of special characters becomes one dash:
355
344
 
356
345
  ```bash
357
346
  get_topic_slug "Bug: User can't login (v2.0)"
358
- # Returns: bug-user-cant-login-v20
347
+ # Returns: bug-user-can-t-login-v2-0
359
348
  ```
360
349
 
361
350
  ### Long Topic Names
@@ -13,9 +13,9 @@ Common violations of documentation conventions with detection patterns and fixes
13
13
  | Unsanitized branch slug | `feature/auth` | `feature-auth` | Replace `/` with `-` |
14
14
  | Wrong case for artifacts | `Status-2025-01-05.md` | `2025-01-05_1430.md` | Use lowercase except special indexes |
15
15
  | Wrong case for indexes | `index.md` | `INDEX.md` | UPPERCASE for special indexes |
16
- | Files outside .docs | `docs/status.md` | `.devflow/docs/status/2025-01-05_1430.md` | Use `.devflow/docs/` root |
16
+ | Files outside .docs | `docs/status.md` | `.devflow/docs/reviews/feat-auth/2025-01-05_1430/review-summary.md` | Use `.devflow/docs/` root |
17
17
  | Missing INDEX.md | Status files without index | Create `INDEX.md` | Every directory needs index |
18
- | Special chars in slug | `oauth-2.0-auth` | `oauth-20-auth` | Strip non-alphanumeric except `-` |
18
+ | Special chars in slug | `oauth-2.0-auth` | `oauth-2-0-auth` | Replace each non-alphanumeric run with one `-` |
19
19
 
20
20
  ---
21
21
 
@@ -34,7 +34,7 @@ project/
34
34
 
35
35
  ```
36
36
  .devflow/docs/
37
- ├── logs/ # Should be status/
37
+ ├── logs/ # Should be reviews/{branch-slug}/
38
38
  ├── reports/ # Should be reviews/{branch-slug}/
39
39
  └── notes.md # Should be in appropriate subdir
40
40
  ```
@@ -90,8 +90,8 @@ BRANCH_SLUG=$(git branch --show-current | sed 's/\//-/g')
90
90
  BRANCH_SLUG=$(git branch --show-current)
91
91
  # Result: empty string -> broken path
92
92
 
93
- # RIGHT - with fallback
94
- BRANCH_SLUG=$(git branch --show-current 2>/dev/null | sed 's/\//-/g' || echo "standalone")
93
+ # RIGHT - with fallback (the fallback goes before the sed: a pipeline's status is sed's)
94
+ BRANCH_SLUG=$(b=$(git branch --show-current 2>/dev/null); echo "${b:-standalone}" | sed 's/\//-/g')
95
95
  # Result: (detached HEAD) -> standalone
96
96
  ```
97
97
 
@@ -106,8 +106,8 @@ BRANCH_SLUG=$(git branch --show-current 2>/dev/null | sed 's/\//-/g' || echo "st
106
106
  TOPIC="Bug: Can't login (v2.0)"
107
107
  SLUG="Bug:-Can't-login-(v2.0)"
108
108
 
109
- # RIGHT - stripped and normalized
110
- SLUG="bug-cant-login-v20"
109
+ # RIGHT - special runs normalized to one dash
110
+ SLUG="bug-can-t-login-v2-0"
111
111
  ```
112
112
 
113
113
  ### Not Truncating Long Names
@@ -102,16 +102,20 @@ updated: {ISO date}
102
102
 
103
103
  # {Feature Area Name}
104
104
 
105
+ ## Rules
106
+ - **KB-AP-1** [one-line anti-pattern or gotcha: what to avoid, and the consequence]
107
+ - **KB-INV-1** [one-line invariant that must hold]
108
+
105
109
  ## Overview
106
110
  [1-2 paragraphs: what this knowledge covers and why it matters for this codebase]
107
111
 
108
112
  ## [Main Sections — vary by category, see Category Templates below]
109
113
 
110
114
  ## Anti-Patterns
111
- [What to avoid and why — with explanation of consequences]
115
+ [The longer explanation of each anti-pattern, headed by its ID — never a restatement of the Rules bullet]
112
116
 
113
117
  ## Gotchas
114
- [Non-obvious behaviors, edge cases, things that break silently]
118
+ [Non-obvious behaviors, edge cases, things that break silently — headed by the ID of the Rules bullet each explains]
115
119
 
116
120
  ## Key Files
117
121
  [Most important files with one-line descriptions]
@@ -120,6 +124,23 @@ updated: {ISO date}
120
124
  [Links to other feature knowledge entries and key source files — never an ADR/PF ID]
121
125
  ```
122
126
 
127
+ ### Rules Section
128
+
129
+ `## Rules` comes first, after the title: the anti-patterns, gotchas and invariants of the feature area as one-line bullets, in about 3–5K characters. A bullet fits one line and never starts with `## `.
130
+
131
+ - **IDs**: anti-pattern and gotcha bullets take `KB-AP-n`; invariant bullets take `KB-INV-n`. Numbers are unique within a KB. A bullet keeps its ID across rewrites; a removed bullet's ID is retired and never reused. A citation names the slug and the ID together, as `{slug} KB-AP-n`; a bare ID is never cited.
132
+ - **Explanations**: `## Anti-Patterns` and `## Gotchas` stay below Rules as the longer explanations, each headed by the IDs it explains.
133
+ - **No volatile numbers**: a volatile number is a count, size, line number, version or threshold that changes when the code changes. Where a value matters, name the test or constant that pins it. Bullet IDs are not volatile numbers.
134
+ - **Legacy KBs**: a KB without `## Rules` is valid until curated. Readers take one to three entries from its Anti-Patterns or Gotchas, cited by section name, with the KB path and heading index.
135
+
136
+ ### Size Budget
137
+
138
+ Per KB: target 30,000 characters, ceiling 40,000. An index line is at most 300 characters and a description at most 220, so slug, areas and description fit one line. **Curate, never truncate**: reword or consolidate, and nothing is cut or dropped to meet the budget. Split into focused sub-knowledge bases (each with its own index entry) only when curation cannot bring a KB under the ceiling.
139
+
140
+ ### Refreshing an Existing KB
141
+
142
+ When `EXISTING_KB` is provided, change only the sections the new work touches, and add or update Rules bullets for what changed. Never renumber, and never rewrite untouched sections to meet the budget. A KB still above the ceiling after a refresh is written as it stands, and the final message says so.
143
+
123
144
  ### Category Templates
124
145
 
125
146
  Use the matching template as your main sections. Anti-Patterns, Gotchas, Key Files, and Related are shared across all categories.
@@ -159,6 +180,7 @@ The `description` field is how this feature knowledge entry gets discovered. It
159
180
  - Start with "Use when"
160
181
  - Name specific scenarios where this knowledge applies
161
182
  - Include keywords a developer would search for
183
+ - Stay within 220 characters
162
184
 
163
185
  Good: `"Use when adding a new vendor integration, implementing API clients, or connecting to external services. Keywords: integration, vendor, API client, webhook."`
164
186
  Bad: `"Integration stuff"`
@@ -205,7 +227,7 @@ Never include bare code snippets without context.
205
227
  | No code examples at all | Insufficient actionable guidance |
206
228
  | Examples without inline comments | Missing required context |
207
229
  | "In the future, we might..." | Speculative — remove it |
208
- | 500+ lines in a single file | Should be split into focused files |
230
+ | Over 40,000 characters, or volatile numbers in Rules | Curate it; name the pinning test or constant instead of a count |
209
231
  | No cross-references in Related | Isolated knowledge island |
210
232
 
211
233
  ---
@@ -228,7 +250,8 @@ Run through this before writing. If any check fails, go back and fix it.
228
250
  **Structure:**
229
251
  - [ ] Category is correct and main sections follow the matching template
230
252
  - [ ] Description field starts with "Use when" and includes keywords
231
- - [ ] File stays under 500 lines (split if necessary)
253
+ - [ ] `## Rules` comes first: one-line bullets with `KB-AP-n` / `KB-INV-n` IDs, about 3–5K characters, no volatile numbers
254
+ - [ ] File within the 40,000-character ceiling (curate, never truncate); description at most 220 characters
232
255
 
233
256
  **Connections:**
234
257
  - [ ] Cross-references to related feature knowledge entries in Related section; decisions and pitfalls stated in words, with no ADR/PF ID anywhere in the file
@@ -249,10 +272,10 @@ After writing KNOWLEDGE.md, update the index cache directly:
249
272
  - **{slug}** — {areas} — {Use-when description}
250
273
  ```
251
274
 
252
- Where:
275
+ The whole line is at most 300 characters; reword a longer one, never cut it. Where:
253
276
  - `{slug}` matches the `feature:` frontmatter field
254
277
  - `{areas}` is a comma-separated summary of the `directories:` frontmatter field
255
- - `{Use-when description}` is the `description:` frontmatter field value (the full "Use when..." sentence)
278
+ - `{Use-when description}` is the `description:` frontmatter field value (the full "Use when..." sentence, at most 220 characters)
256
279
 
257
280
  If `index.md` does not exist, create it with just this line. If the file already has an entry for this slug, replace that line in-place. This is the discoverable cache read by `knowledge_load()` — the KNOWLEDGE.md frontmatter is always authoritative.
258
281
 
@@ -275,9 +298,17 @@ updated: 2026-04-30
275
298
 
276
299
  # Third-Party Integrations
277
300
 
301
+ ## Rules
302
+
303
+ - **KB-AP-1** Fetch logic never lives in a command file: it breaks the lib/command split and cannot be tested alone.
304
+ - **KB-AP-2** URLs never live in lib modules: they go through `config.ts`.
305
+ - **KB-AP-3** A lib module never calls `showError()`: lib modules throw, commands catch and display.
306
+ - **KB-AP-4** `spawn` needs the binary on PATH: detect `ENOENT` and give an install URL.
307
+ - **KB-INV-1** Every external constant lives in `src/lib/config.ts`.
308
+
278
309
  ## Overview
279
310
 
280
- This project integrates with external systems in three ways: spawning CLI processes, fetching files from remote registries, and writing to directories that AI editors watch. Each integration lives in its own module under `src/lib/` and is wired into a command in `src/commands/`. All external constants are centralized in `src/lib/config.ts`.
311
+ This project integrates with external systems by spawning CLI processes, fetching files from remote registries, and writing to directories that AI editors watch. Each integration lives in its own module under `src/lib/` and is wired into a command in `src/commands/`. All external constants are centralized in `src/lib/config.ts`.
281
312
 
282
313
  The key cross-cutting pattern is the separation between lib modules (which integrate) and commands (which orchestrate). Violating this creates coupling that breaks the error handling model.
283
314
 
@@ -289,7 +320,7 @@ The key cross-cutting pattern is the separation between lib modules (which integ
289
320
 
290
321
  ## Standard Structure
291
322
 
292
- Every integration follows the same file organization. This example shows the pattern that all three existing integrations (Claude CLI, GitHub, AI editors) follow:
323
+ Every integration follows the same file organization. This example shows the pattern that every existing integration (Claude CLI, GitHub, AI editors) follows:
293
324
 
294
325
  ```
295
326
  src/lib/
@@ -309,13 +340,13 @@ All constants use `SCREAMING_SNAKE_CASE` with a descriptive prefix. If a value c
309
340
 
310
341
  ## Anti-Patterns
311
342
 
312
- - **Putting fetch logic in a command file** — breaks the lib/command separation and makes the integration untestable in isolation.
313
- - **Hardcoding URLs in lib modules** — always use `config.ts`. Scattered strings become stale and hard to find.
314
- - **Calling `showError()` from a lib module** — lib modules throw; commands catch and display.
343
+ - **KB-AP-1, putting fetch logic in a command file** — breaks the lib/command separation and makes the integration untestable in isolation.
344
+ - **KB-AP-2, hardcoding URLs in lib modules** — always use `config.ts`. Scattered strings become stale and hard to find.
345
+ - **KB-AP-3, calling `showError()` from a lib module** — lib modules throw; commands catch and display.
315
346
 
316
347
  ## Gotchas
317
348
 
318
- - `spawn` requires the binary on PATH. If integrating a tool that may not be globally installed, detect `ENOENT` and provide an install URL.
349
+ - **KB-AP-4**: `spawn` requires the binary on PATH. If integrating a tool that may not be globally installed, detect `ENOENT` and provide an install URL.
319
350
  - Temp files use `Date.now()`. If two processes run simultaneously, add a random suffix to avoid collisions.
320
351
 
321
352
  ## Key Files
@@ -103,22 +103,6 @@ Detect ordering constraints and shared resource conflicts across issues.
103
103
 
104
104
  **Evidence trigger:** Any issue that references state, contracts, or resources that may be in flux due to another issue in the batch.
105
105
 
106
- ### 7. Compliance (when the compliance lens is on)
107
-
108
- Detect regulatory gaps that security doesn't cover. Load `devflow:compliance` before analyzing, then `references/{id}.md` only for the ids in `COMPLIANCE_FRAMEWORKS` (`none`: generic controls only).
109
-
110
- **Detection patterns:**
111
- - Missing audit trails on regulated mutations — writes to financial records, PHI, PCI-scoped data without durable logging
112
- - PII flows without retention/erasure specification — data collected but deletion/expiry policy absent
113
- - Missing encryption requirements — regulated data at rest or in transit without specified encryption control
114
- - Sensitive data in observability — PII or credentials leaking into logs, traces, or metrics
115
- - IaC exposure — infrastructure definitions without required security controls (open ports, unencrypted storage, missing IAM boundaries)
116
- - Self-approval flows — change requires segregation of duties (SOX/SOC 2 CC8.1) but single-actor path exists in the design
117
-
118
- **Explicit scope note:** Do NOT duplicate §3 Security's checks (secrets, injection, authZ). Compliance focus is on regulatory control requirements — retention periods, erasure rights, audit completeness, and segregation of duties — not general application security.
119
-
120
- **Evidence trigger:** Any regulated-data flow or infrastructure element in the design that does not specify a required control (retention policy, encryption spec, audit log destination, approval workflow).
121
-
122
106
  ---
123
107
 
124
108
  ## Extended References
@@ -0,0 +1,19 @@
1
+ # Gap Analysis: Compliance Focus
2
+
3
+ The compliance focus's detection patterns. D-COMPLIANCE-INJECT: the `Design` agent's preload does not carry them. The `/plan` compliance-focus spawn names this file and the agent Reads it by path, so a lens-off run never loads it.
4
+
5
+ ## Compliance (when the compliance lens is on)
6
+
7
+ Detect regulatory gaps that security doesn't cover. Load `devflow:compliance` before analyzing, then the compliance skill's `references/{id}.md` only for the ids the spawn's compliance directive names (`none`: generic controls only).
8
+
9
+ **Detection patterns:**
10
+ - Missing audit trails on regulated mutations — writes to financial records, PHI, PCI-scoped data without durable logging
11
+ - PII flows without retention/erasure specification — data collected but deletion/expiry policy absent
12
+ - Missing encryption requirements — regulated data at rest or in transit without specified encryption control
13
+ - Sensitive data in observability — PII or credentials leaking into logs, traces, or metrics
14
+ - IaC exposure — infrastructure definitions without required security controls (open ports, unencrypted storage, missing IAM boundaries)
15
+ - Self-approval flows — change requires segregation of duties (SOX/SOC 2 CC8.1) but single-actor path exists in the design
16
+
17
+ **Explicit scope note:** Do NOT duplicate §3 Security's checks (secrets, injection, authZ). Compliance focus is on regulatory control requirements — retention periods, erasure rights, audit completeness, and segregation of duties — not general application security.
18
+
19
+ **Evidence trigger:** Any regulated-data flow or infrastructure element in the design that does not specify a required control (retention policy, encryption spec, audit log destination, approval workflow).
@@ -31,7 +31,7 @@ Based on [Google Engineering Practices](https://google.github.io/eng-practices/r
31
31
  ### P0 - Design
32
32
  Does the implementation fit the architecture? Follows existing patterns, respects layer boundaries, dependencies injected.
33
33
 
34
- If `FEATURE_KNOWLEDGE` is provided, verify implementation respects the feature area's documented architecture and anti-patterns. Flag deviations as P0-Design issues when the documented pattern is clearly intentional.
34
+ If `FEATURE_KNOWLEDGE` is provided (Rules bullets and the KB path, no heading index), verify implementation respects each bullet's anti-pattern, gotcha or invariant; Read a KB section from its path for the architecture. Flag deviations as P0-Design issues when the documented pattern is clearly intentional.
35
35
 
36
36
  ### P0 - Functionality
37
37
  Does the code work? Happy path, edge cases (null, empty, boundary), no race conditions.
@@ -1,24 +0,0 @@
1
- ## Operation: ensure-pr-ready
2
-
3
- Load for `ensure-pr-ready` under every tracker provider.
4
-
5
- **PR mechanics held here:** every step but step 4b's tracker half, which is the provider reference's.
6
-
7
- ### Process
8
-
9
- 1. Verify on feature branch (not main/master/develop/integration/trunk/release/*/staging/production) - error if not
10
- 2. Check for uncommitted changes - if any, create atomic commit using `devflow:git` patterns
11
- 3. Check if branch pushed to remote - if not, push with `-u` flag. If that push is refused and the branch's open PR is cross-repository with maintainer edits off (`gh pr view --json isCrossRepository,maintainerCanModify`), emit `TRACEABILITY: DEGRADED (cannot push to fork)` and go to 4a (4a–4c edit only the PR).
12
- 4a. Check if PR exists - if not, create PR using guidance from (in priority order): (a) `PR_DESCRIPTION_GUIDANCE` if given and not `(none)`, (b) generated from branch context. Compose the PR body via the `devflow:git` template to `$DEVFLOW_BODY_RAW` (a D11 sink: it publishes at repo visibility), then append the caller blocks. Apply the Comment-sink scrub (D11) — a failed one posts neither block; on success: `gh pr create … --body-file "$DEVFLOW_BODY"`.
13
- - **Caller blocks**, in order: `PR_WAVE_BLOCK` (`check wave`), then `PR_TEST_PLAN_BLOCK` (`check block`), each when given and not `(none)`. Write it byte for byte to a fresh `mktemp` file with the Write tool, never via a shell string, and run `node "$HOME/.devflow/scripts/verify-evidence.cjs" check <wave|block> <file>; echo "exit=$?"`. Only `exit=0` admits it, verbatim; else omit it, never repaired or partly pasted, and emit `TRACEABILITY: DEGRADED (wave block does not match its grammar)` or `TRACEABILITY: DEGRADED (test-plan block does not match its grammar)` with steps 4b/4c's lines. An admitted wave block is the body's only `## Related Issues`: skip 4b.
14
- 4c. Retitle, only when `APPLY_CONVENTIONS` is `true`: if the PR title breaks the convention in the PR Titles section of `.devflow/conventions.md`, retitle it; skip silently when that file is absent. Two rules, because the title derives from third-party PR titles:
15
- - **Validate before use.** Skip the retitle (leave the PR title as-is, no error) if the composed title contains any of `` $ ` \ " ' ; | & < > `` or a newline.
16
- - **Pass as argv, never as command text.** Bind it to a shell variable and pass that variable: `gh pr edit {PR_NUMBER} --title "$DEVFLOW_PR_TITLE"`. Never interpolate it: `$(...)`, backticks and `${...}` all expand inside double quotes.
17
-
18
- On any 4xx/5xx from `gh pr edit`: emit `TRACEABILITY: DEGRADED ({reason})` and continue — a failed retitle never blocks the PR.
19
- 5. Get base branch from PR
20
- 6. Derive branch-slug (replace `/` with `-`)
21
-
22
- ### Step 4b's PR-host half
23
-
24
- The provider reference's step 4b publishes its section only through this: find the open PR with `gh pr list --head {branch} --state open --limit 1`; compose the existing body plus the `## Related Issues` section to `$DEVFLOW_BODY_RAW` — the existing body is third-party-editable, so never interpolate it into a command string; apply the Comment-sink scrub (D11); on success: `gh pr edit {PR_NUMBER} --body-file "$DEVFLOW_BODY"`.