claude-dev-env 1.0.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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/agents/agent-writer.md +157 -0
  4. package/agents/clasp-deployment-orchestrator.md +609 -0
  5. package/agents/clean-coder.md +295 -0
  6. package/agents/code-quality-agent.md +40 -0
  7. package/agents/code-standards-agent.md +93 -0
  8. package/agents/config-centralizer.md +686 -0
  9. package/agents/config-extraction-agent.md +225 -0
  10. package/agents/doc-orchestrator.md +47 -0
  11. package/agents/docs-agent.md +112 -0
  12. package/agents/docx-agent.md +211 -0
  13. package/agents/git-commit-crafter.md +100 -0
  14. package/agents/magic-value-eliminator-agent.md +72 -0
  15. package/agents/mandatory-agent-workflow-agent.md +88 -0
  16. package/agents/parallel-workflow-coordinator.md +779 -0
  17. package/agents/pdf-agent.md +302 -0
  18. package/agents/plan-executor.md +226 -0
  19. package/agents/pr-description-writer.md +87 -0
  20. package/agents/project-context-loader.md +238 -0
  21. package/agents/project-docs-analyzer.md +54 -0
  22. package/agents/project-structure-organizer-agent.md +72 -0
  23. package/agents/readability-review-agent.md +76 -0
  24. package/agents/refactoring-specialist.md +69 -0
  25. package/agents/right-sized-engineer.md +129 -0
  26. package/agents/session-continuity-manager.md +53 -0
  27. package/agents/skill-to-agent-converter.md +371 -0
  28. package/agents/skill-writer-agent.md +470 -0
  29. package/agents/stub-detector-agent.md +140 -0
  30. package/agents/tdd-test-writer.md +62 -0
  31. package/agents/test-data-builder.md +68 -0
  32. package/agents/tooling-builder.md +78 -0
  33. package/agents/user-docs-writer.md +67 -0
  34. package/agents/validation-expert.md +71 -0
  35. package/agents/workflow-visual-documenter.md +82 -0
  36. package/agents/xlsx-agent.md +169 -0
  37. package/bin/install.mjs +256 -0
  38. package/commands/commit.md +28 -0
  39. package/commands/docupdate.md +322 -0
  40. package/commands/implement.md +102 -0
  41. package/commands/initialize.md +91 -0
  42. package/commands/plan.md +63 -0
  43. package/commands/pr-comments.md +47 -0
  44. package/commands/readability-review.md +20 -0
  45. package/commands/review-plan.md +7 -0
  46. package/commands/right-size.md +15 -0
  47. package/commands/stubcheck.md +89 -0
  48. package/commands/sum.md +30 -0
  49. package/docs/CODE_RULES.md +186 -0
  50. package/docs/DJANGO_PATTERNS.md +80 -0
  51. package/docs/REACT_PATTERNS.md +185 -0
  52. package/docs/TEST_QUALITY.md +104 -0
  53. package/hooks/advisory/migration-safety-advisor.py +49 -0
  54. package/hooks/advisory/refactor-guard.py +205 -0
  55. package/hooks/blocking/block-main-commit.py +168 -0
  56. package/hooks/blocking/code-rules-enforcer.py +549 -0
  57. package/hooks/blocking/destructive-command-blocker.py +107 -0
  58. package/hooks/blocking/docker-settings-guard.py +44 -0
  59. package/hooks/blocking/hedging-language-blocker.py +130 -0
  60. package/hooks/blocking/parallel-task-blocker.py +69 -0
  61. package/hooks/blocking/pr-description-enforcer.py +87 -0
  62. package/hooks/blocking/pyautogui-scroll-blocker.py +74 -0
  63. package/hooks/blocking/sensitive-file-protector.py +70 -0
  64. package/hooks/blocking/tdd-enforcer.py +62 -0
  65. package/hooks/blocking/test-preflight-check.py +343 -0
  66. package/hooks/blocking/write-existing-file-blocker.py +63 -0
  67. package/hooks/git-hooks/post-commit.py +103 -0
  68. package/hooks/github-action/test_workflow.py +33 -0
  69. package/hooks/hooks.json +246 -0
  70. package/hooks/lifecycle/config-change-guard.py +84 -0
  71. package/hooks/lifecycle/session-end-cleanup.py +59 -0
  72. package/hooks/notification/attention-needed-notify.py +63 -0
  73. package/hooks/notification/claude-notification-handler.py +59 -0
  74. package/hooks/notification/notification_utils.py +206 -0
  75. package/hooks/rewrite-plugin-paths.py +116 -0
  76. package/hooks/session/bulk-edit-reminder.py +30 -0
  77. package/hooks/session/code-rules-reminder.py +97 -0
  78. package/hooks/session/compact-context-reinject.py +39 -0
  79. package/hooks/session/hook-structure-context.py +140 -0
  80. package/hooks/session/plugin-data-dir-cleanup.py +39 -0
  81. package/hooks/validation/code-style-validator.py +145 -0
  82. package/hooks/validation/e2e-test-validator.py +142 -0
  83. package/hooks/validation/hook-format-validator.py +66 -0
  84. package/hooks/validation/mypy_validator.py +180 -0
  85. package/hooks/validators/README.md +125 -0
  86. package/hooks/validators/VALIDATION_REPORT.md +287 -0
  87. package/hooks/validators/__init__.py +19 -0
  88. package/hooks/validators/abbreviation_checks.py +82 -0
  89. package/hooks/validators/code_quality_checks.py +133 -0
  90. package/hooks/validators/comment_checks.py +188 -0
  91. package/hooks/validators/file_structure_checks.py +182 -0
  92. package/hooks/validators/git_checks.py +107 -0
  93. package/hooks/validators/health_check.py +214 -0
  94. package/hooks/validators/magic_value_checks.py +81 -0
  95. package/hooks/validators/mypy_integration.py +52 -0
  96. package/hooks/validators/output_formatter.py +266 -0
  97. package/hooks/validators/pr_reference_checks.py +72 -0
  98. package/hooks/validators/python_antipattern_checks.py +110 -0
  99. package/hooks/validators/python_style_checks.py +364 -0
  100. package/hooks/validators/react_checks.py +90 -0
  101. package/hooks/validators/ruff_integration.py +80 -0
  102. package/hooks/validators/run_all_validators.py +772 -0
  103. package/hooks/validators/security_checks.py +135 -0
  104. package/hooks/validators/test_abbreviation_checks.py +76 -0
  105. package/hooks/validators/test_bad.tsx +7 -0
  106. package/hooks/validators/test_code_quality_checks.py +129 -0
  107. package/hooks/validators/test_file_structure_checks.py +307 -0
  108. package/hooks/validators/test_files/01_basic_component.tsx +10 -0
  109. package/hooks/validators/test_files/02_component_without_react.tsx +10 -0
  110. package/hooks/validators/test_files/03_pure_component.tsx +10 -0
  111. package/hooks/validators/test_files/04_pure_component_import.tsx +10 -0
  112. package/hooks/validators/test_files/05_typescript_generics.tsx +14 -0
  113. package/hooks/validators/test_files/06_typescript_two_generics.tsx +18 -0
  114. package/hooks/validators/test_files/07_multiline_declaration.tsx +11 -0
  115. package/hooks/validators/test_files/08_error_boundary_valid.tsx +14 -0
  116. package/hooks/validators/test_files/09_error_boundary_with_other_class.tsx +20 -0
  117. package/hooks/validators/test_files/10_inheritance_chain.tsx +16 -0
  118. package/hooks/validators/test_files/11_ts_file.ts +10 -0
  119. package/hooks/validators/test_files/12_non_react_class.tsx +14 -0
  120. package/hooks/validators/test_files/13_functional_component.tsx +8 -0
  121. package/hooks/validators/test_files/14_indented_class.tsx +13 -0
  122. package/hooks/validators/test_files/15_getDerivedStateFromError.tsx +14 -0
  123. package/hooks/validators/test_files/16_mixed_components.tsx +20 -0
  124. package/hooks/validators/test_files/EXECUTIVE_SUMMARY.md +175 -0
  125. package/hooks/validators/test_files/TEST_RESULTS_TABLE.txt +60 -0
  126. package/hooks/validators/test_files/VALIDATION_REPORT.md +201 -0
  127. package/hooks/validators/test_files/async_views.py +23 -0
  128. package/hooks/validators/test_files/async_with_imports.py +14 -0
  129. package/hooks/validators/test_files/bad_inline_imports.py +37 -0
  130. package/hooks/validators/test_files/management/commands/cmd_01_no_debug_check.py +10 -0
  131. package/hooks/validators/test_files/management/commands/cmd_02_proper_debug_check.py +14 -0
  132. package/hooks/validators/test_files/management/commands/cmd_03_debug_check_with_return.py +14 -0
  133. package/hooks/validators/test_files/management/commands/cmd_04_imported_DEBUG.py +14 -0
  134. package/hooks/validators/test_files/management/commands/cmd_05_debug_check_in_helper.py +16 -0
  135. package/hooks/validators/test_files/management/commands/cmd_06_debug_check_late.py +22 -0
  136. package/hooks/validators/test_files/management/commands/cmd_07_positive_debug_check.py +15 -0
  137. package/hooks/validators/test_files/management/commands/cmd_08_debug_with_and.py +14 -0
  138. package/hooks/validators/test_files/not_management_command.py +10 -0
  139. package/hooks/validators/test_files/skip_decorators/test_01_simple_skip.py +8 -0
  140. package/hooks/validators/test_files/skip_decorators/test_02_pytest_skipif.py +8 -0
  141. package/hooks/validators/test_files/skip_decorators/test_03_unittest_skipIf.py +8 -0
  142. package/hooks/validators/test_files/skip_decorators/test_04_skip_with_parens.py +8 -0
  143. package/hooks/validators/test_files/skip_decorators/test_05_xfail.py +7 -0
  144. package/hooks/validators/test_files/skip_decorators/test_06_custom_skip.py +11 -0
  145. package/hooks/validators/test_files/skip_decorators/test_07_capital_Skip.py +8 -0
  146. package/hooks/validators/test_files/skip_decorators/test_08_skipUnless.py +7 -0
  147. package/hooks/validators/test_files/skip_decorators/test_09_pytest_mark_skip_simple.py +7 -0
  148. package/hooks/validators/test_files/test_async_functions.py +45 -0
  149. package/hooks/validators/test_files/test_purecomponent/PureComponentExample.tsx +7 -0
  150. package/hooks/validators/test_files/test_purecomponent/ReactPureComponentExample.tsx +7 -0
  151. package/hooks/validators/test_git_checks.py +295 -0
  152. package/hooks/validators/test_good.tsx +5 -0
  153. package/hooks/validators/test_health_check.py +57 -0
  154. package/hooks/validators/test_magic_value_checks.py +63 -0
  155. package/hooks/validators/test_mypy_integration.py +27 -0
  156. package/hooks/validators/test_output_formatter.py +150 -0
  157. package/hooks/validators/test_pr_reference_checks.py +41 -0
  158. package/hooks/validators/test_python_antipattern_checks.py +113 -0
  159. package/hooks/validators/test_python_style_checks.py +439 -0
  160. package/hooks/validators/test_react_checks.py +213 -0
  161. package/hooks/validators/test_results.txt +25 -0
  162. package/hooks/validators/test_ruff_integration.py +27 -0
  163. package/hooks/validators/test_run_all_validators.py +228 -0
  164. package/hooks/validators/test_run_all_validators_integration.py +48 -0
  165. package/hooks/validators/test_safety_checks.py +243 -0
  166. package/hooks/validators/test_security_checks.py +105 -0
  167. package/hooks/validators/test_test_safety_checks.py +321 -0
  168. package/hooks/validators/test_todo_checks.py +39 -0
  169. package/hooks/validators/test_type_safety_checks.py +85 -0
  170. package/hooks/validators/test_useless_test_checks.py +55 -0
  171. package/hooks/validators/test_validator_base.py +26 -0
  172. package/hooks/validators/test_verify_paths.py +34 -0
  173. package/hooks/validators/todo_checks.py +59 -0
  174. package/hooks/validators/type_safety_checks.py +101 -0
  175. package/hooks/validators/useless_test_checks.py +92 -0
  176. package/hooks/validators/validator_base.py +19 -0
  177. package/hooks/validators/verify_paths.py +57 -0
  178. package/hooks/workflow/auto-formatter.py +114 -0
  179. package/hooks/workflow/investigation-tracker-reset.py +46 -0
  180. package/package.json +30 -0
  181. package/rules/agent-spawn-protocol.md +47 -0
  182. package/rules/cleanup-temp-files.md +27 -0
  183. package/rules/code-reviews.md +11 -0
  184. package/rules/code-standards.md +43 -0
  185. package/rules/conservative-action.md +20 -0
  186. package/rules/context7.md +12 -0
  187. package/rules/explore-thoroughly.md +27 -0
  188. package/rules/git-workflow.md +42 -0
  189. package/rules/parallel-tools.md +23 -0
  190. package/rules/research-mode.md +23 -0
  191. package/rules/right-sized-engineering.md +28 -0
  192. package/rules/tdd.md +7 -0
  193. package/rules/testing.md +12 -0
  194. package/skills/agent-prompt/SKILL.md +102 -0
  195. package/skills/anthropic-plan/SKILL.md +107 -0
  196. package/skills/everything-search/SKILL.md +144 -0
  197. package/skills/ingest/SKILL.md +40 -0
  198. package/skills/npm-creator/SKILL.md +183 -0
  199. package/skills/pr-review-responder/EXAMPLES.md +590 -0
  200. package/skills/pr-review-responder/PRINCIPLES.md +539 -0
  201. package/skills/pr-review-responder/README.md +209 -0
  202. package/skills/pr-review-responder/SKILL.md +202 -0
  203. package/skills/pr-review-responder/TESTING.md +407 -0
  204. package/skills/pr-review-responder/scripts/respond_to_reviews.py +376 -0
  205. package/skills/pr-review-responder/update_skill.py +297 -0
  206. package/skills/prompt-generator/REFERENCE.md +150 -0
  207. package/skills/prompt-generator/SKILL.md +154 -0
  208. package/skills/readability-review/SKILL.md +127 -0
  209. package/skills/recall/SKILL.md +27 -0
  210. package/skills/remember/SKILL.md +63 -0
  211. package/skills/rule-audit/SKILL.md +307 -0
  212. package/skills/rule-creator/SKILL.md +150 -0
  213. package/skills/skill-writer/REFERENCE.md +246 -0
  214. package/skills/skill-writer/SKILL.md +270 -0
  215. package/skills/tdd-team/SKILL.md +128 -0
@@ -0,0 +1,307 @@
1
+ ---
2
+ name: rule-audit
3
+ description: Audit AGENTS.md, rules, hooks, and docs across user and project layers for enforcement gaps, duplication, and compliance
4
+ user-invocable: true
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # Rule Audit
9
+
10
+ Full enforcement audit of AGENTS.md, `.Codex/rules/`, hooks (settings.json), and referenced docs.
11
+
12
+ Works across **two layers** — user-global (`~/.Codex/`) and project-local (cwd). Detects cross-layer duplication where project rules restate user rules, wasting instruction budget.
13
+
14
+ Produces a scored report with corrective actions.
15
+
16
+ ## Phase 0: Layer Detection
17
+
18
+ Before launching agents, detect which layers exist:
19
+
20
+ ```
21
+ User layer (always present):
22
+ ~/.Codex/AGENTS.md
23
+ ~/.Codex/rules/*.md
24
+ ~/.Codex/settings.json (hooks)
25
+ ~/.Codex/docs/*.md
26
+
27
+ Project layer (check cwd):
28
+ <cwd>/AGENTS.md
29
+ <cwd>/.Codex/AGENTS.md
30
+ <cwd>/.Codex/rules/*.md
31
+ <cwd>/.Codex/settings.json (project hooks)
32
+
33
+ If cwd == ~ (home directory), skip project layer (same as user layer).
34
+ If no project-layer files exist, report "single-layer audit (user only)".
35
+ If project-layer files exist, report "dual-layer audit (user + project)".
36
+ ```
37
+
38
+ ## Phase 1: Inventory (Parallel Discovery)
39
+
40
+ Launch 3 agents in parallel to inventory the full enforcement landscape.
41
+
42
+ If dual-layer: each agent inventories BOTH layers, tagging each file with its layer (`user` or `project`).
43
+
44
+ ### Agent 1: Rules & AGENTS.md Inventory
45
+
46
+ Read and catalog every advisory-layer file:
47
+
48
+ ```
49
+ User layer:
50
+ ~/.Codex/AGENTS.md
51
+ ~/.Codex/rules/*.md
52
+
53
+ Project layer (if exists):
54
+ <cwd>/AGENTS.md
55
+ <cwd>/.Codex/AGENTS.md
56
+ <cwd>/.Codex/rules/*.md
57
+
58
+ For EACH file, extract:
59
+ - file_path
60
+ - layer (user | project)
61
+ - line_count
62
+ - purpose (1-sentence summary of what this file tries to enforce)
63
+ - rules (list of individual rules/instructions, one per line)
64
+ - framing (count of negative rules using "never/don't/do not/no" vs positive rules)
65
+ - has_rationale (does each rule explain WHY?)
66
+ - has_code_examples (are commands in code fences?)
67
+ - duplicates (rules that appear in multiple files -- list which files AND which layers)
68
+ ```
69
+
70
+ Output as structured markdown to the conversation.
71
+
72
+ ### Agent 2: Hook Inventory
73
+
74
+ Read settings.json hooks config and each referenced hook script:
75
+
76
+ ```
77
+ User hooks:
78
+ ~/.Codex/settings.json
79
+ ~/.Codex/hooks/**/*.py
80
+
81
+ Project hooks (if <cwd>/.Codex/settings.json exists):
82
+ <cwd>/.Codex/settings.json
83
+ <cwd>/.Codex/hooks/**/*.py
84
+
85
+ For EACH hook entry in settings.json (both layers):
86
+ - layer (user | project)
87
+ - event (PreToolUse, PostToolUse, SessionStart, etc.)
88
+ - matcher
89
+ - hook_script_path (extract from the command string after the last quote)
90
+ - Read the actual script file
91
+ - purpose (what rule does this hook enforce?)
92
+ - enforcement_type: "blocking" (exit 2 / permissionDecision deny) | "advisory" (stdout message) | "validation" (post-check)
93
+ - method: "exit_code_2" (deprecated) | "permissionDecision" (current) | "stdout" | "other"
94
+ - which_rule_file (which .Codex/rules/*.md or AGENTS.md rule does this correspond to?)
95
+ - orphaned (hook exists on disk but NOT in settings.json?)
96
+ ```
97
+
98
+ Also check for hook scripts on disk that are NOT referenced in settings.json (orphaned hooks).
99
+
100
+ ### Agent 3: Docs Inventory
101
+
102
+ Read referenced documentation files:
103
+
104
+ ```
105
+ User docs:
106
+ ~/.Codex/docs/*.md (glob to discover all)
107
+
108
+ Project docs (if exists):
109
+ <cwd>/.Codex/docs/*.md
110
+
111
+ For EACH file:
112
+ - file_path
113
+ - layer (user | project)
114
+ - line_count
115
+ - purpose
116
+ - loaded_when (is this always loaded, or on-demand via reference?)
117
+ - overlaps_with (which rules/*.md files cover the same topics?)
118
+ - hook_enforced (which rules in this doc are enforced by hooks vs purely advisory?)
119
+ ```
120
+
121
+ ## Phase 2: Cross-Reference Analysis
122
+
123
+ After all 3 agents return, analyze the combined inventory:
124
+
125
+ ### 2A: Duplication Map
126
+
127
+ Build a matrix of where each concept appears:
128
+
129
+ ```
130
+ | Rule/Concept | AGENTS.md | rules/*.md | docs/*.md | hooks | Count |
131
+ |---|---|---|---|---|---|
132
+ | TDD first | line 52, 92 | tdd.md | - | tdd-enforcer.py | 3 advisory + 1 hook |
133
+ | No magic values | - | code-standards.md | CODE_RULES.md:49 | code-rules-enforcer.py | 2 advisory + 1 hook |
134
+ | ... | ... | ... | ... | ... | ... |
135
+ ```
136
+
137
+ Flag any concept appearing 3+ times across advisory files (duplication tax on instruction budget).
138
+
139
+ ### 2B: Enforcement Gap Analysis
140
+
141
+ For each rule/concept, classify its enforcement level:
142
+
143
+ ```
144
+ | Level | Description | Example |
145
+ |---|---|---|
146
+ | ENFORCED | Hook blocks the action deterministically | destructive-command-blocker.py |
147
+ | VALIDATED | PostToolUse checks after the fact | mypy_validator.py, auto-formatter.py |
148
+ | ADVISORY | In AGENTS.md/rules but no hook backs it | most rules |
149
+ | REDUNDANT | Codex already does this by default | "write clean code" |
150
+ | ORPHANED | Hook exists but no corresponding rule | hook with no rule backing |
151
+ ```
152
+
153
+ ### 2C: Formatting Compliance Score
154
+
155
+ Score each rule file against research-backed criteria:
156
+
157
+ ```
158
+ | Criterion | Weight | Description |
159
+ |---|---|---|
160
+ | Positive framing | 25% | % of rules using positive "do X" vs negative "don't X" |
161
+ | Rationale included | 20% | % of rules with WHY explanation |
162
+ | Actionable | 20% | % of rules an agent could execute without interpretation |
163
+ | Concise | 15% | Line count relative to unique rule count (lower = better) |
164
+ | Code fences | 10% | Commands in code fences vs prose |
165
+ | No duplication | 10% | % of rules NOT duplicated elsewhere |
166
+ ```
167
+
168
+ Score: 0-100 per file. Weight by instruction count contribution.
169
+
170
+ ### 2D: Cross-Layer Duplication (dual-layer only)
171
+
172
+ If both user and project layers exist, compare them:
173
+
174
+ ```
175
+ | Rule/Concept | User Layer File | Project Layer File | Verdict |
176
+ |---|---|---|---|
177
+ | TDD first | code-standards.md | AGENTS.md line 5 | DUPLICATE — remove from project |
178
+ | No magic values | code-standards.md | rules/code-quality.md | DUPLICATE — remove from project |
179
+ | Use pytest fixtures | (not present) | rules/testing.md | PROJECT-ONLY — keep |
180
+ | Django migrations | docs/DJANGO_PATTERNS.md | AGENTS.md line 22 | DUPLICATE — remove from project |
181
+ ```
182
+
183
+ Verdicts:
184
+ - **DUPLICATE**: Rule exists in both layers. Project copy wastes budget. Remove from project unless it narrows/overrides the user rule.
185
+ - **OVERRIDE**: Project rule intentionally changes a user rule (e.g., user says "use pytest", project says "use unittest"). Keep and document.
186
+ - **PROJECT-ONLY**: Rule exists only in project layer. Keep — it's project-specific.
187
+ - **USER-ONLY**: Rule exists only in user layer. Expected for cross-cutting rules.
188
+
189
+ ### 2E: Combined Budget Analysis
190
+
191
+ Calculate the total instruction count across all loaded files from BOTH layers:
192
+
193
+ ```
194
+ User layer:
195
+ ~/.Codex/AGENTS.md: ~X instructions
196
+ ~/.Codex/rules/*.md total: ~Y instructions
197
+ ~/.Codex/docs (if loaded): ~Z instructions
198
+
199
+ Project layer (if exists):
200
+ <cwd>/AGENTS.md: ~A instructions
201
+ <cwd>/.Codex/AGENTS.md: ~B instructions
202
+ <cwd>/.Codex/rules/*.md: ~C instructions
203
+
204
+ COMBINED TOTAL: ~N instructions
205
+ Cross-layer duplicates: ~D instructions (wasted)
206
+ Effective total: ~(N - D) instructions
207
+
208
+ Research ceiling: 150 instructions (compliance degrades beyond this) [Source 1]
209
+ Budget remaining: 150 - (N - D) = deficit/surplus
210
+ ```
211
+
212
+ ## Phase 3: Corrective Action Plan
213
+
214
+ Generate a priority-ordered action plan:
215
+
216
+ ### Priority 1: Cut (Remove or Merge)
217
+
218
+ Items that waste instruction budget:
219
+ - Rules Codex already follows by default (REDUNDANT)
220
+ - Rules duplicated 3+ times across files (consolidate to ONE location)
221
+ - Rules in AGENTS.md that belong in scoped rules/*.md files
222
+ - Docs content that duplicates rules content
223
+
224
+ ### Priority 2: Rewrite (Improve Formatting)
225
+
226
+ Items scored below 60/100 in formatting compliance:
227
+ - Flip negative rules to positive framing
228
+ - Add rationale where missing
229
+ - Put commands in code fences
230
+ - Make vague rules actionable
231
+
232
+ ### Priority 3: Promote (Advisory -> Enforced)
233
+
234
+ Rules that SHOULD have hook enforcement but don't:
235
+ - High-violation rules that Codex repeatedly ignores
236
+ - Rules with deterministic criteria (can be pattern-matched)
237
+ - Safety-critical rules where violation has real cost
238
+
239
+ For each, specify:
240
+ - Which hook event (PreToolUse, PostToolUse, Stop)
241
+ - Blocking vs advisory
242
+ - Pattern to match
243
+ - Estimated implementation effort
244
+
245
+ ### Priority 4: Demote (Enforced -> Removed)
246
+
247
+ Hooks that add latency without value:
248
+ - Hooks that never fire (check if the pattern is too narrow)
249
+ - Advisory hooks that could be rules instead
250
+ - Hooks using deprecated methods (exit code 2 instead of permissionDecision)
251
+
252
+ ### Priority 5: Deduplicate Across Layers (dual-layer only)
253
+
254
+ For each DUPLICATE from 2D:
255
+ - If project rule is identical to user rule: delete from project
256
+ - If project rule narrows user rule: keep in project, add comment referencing user rule
257
+ - If project rule conflicts with user rule: flag for user decision (OVERRIDE vs mistake)
258
+
259
+ ### Priority 6: Restructure
260
+
261
+ Optimal placement recommendations:
262
+ - What stays in AGENTS.md (critical, cross-cutting, <50 lines target)
263
+ - What moves to rules/*.md (domain-specific, scopable)
264
+ - What moves to skills (on-demand workflows, not always relevant)
265
+ - What becomes a hook (deterministic enforcement)
266
+
267
+ ## Phase 4: Output
268
+
269
+ Write the audit report to the Obsidian vault:
270
+
271
+ **Path:** `sessions/[Project] Rule Audit [date].md`
272
+
273
+ **Format:**
274
+
275
+ ```markdown
276
+ ---
277
+ tags: [audit, rules, enforcement, Codex]
278
+ date: YYYY-MM-DD
279
+ type: rule-audit
280
+ ---
281
+
282
+ ## Rule Audit Report -- [Date]
283
+
284
+ ### Inventory Summary
285
+ [File counts, total instruction count, budget analysis]
286
+
287
+ ### Duplication Map
288
+ [Table from 2A]
289
+
290
+ ### Enforcement Gaps
291
+ [Table from 2B -- sorted by risk level]
292
+
293
+ ### Formatting Scores
294
+ [Table from 2C -- sorted by score ascending]
295
+
296
+ ### Corrective Actions
297
+ [Numbered list from Phase 3, grouped by priority]
298
+
299
+ ### Implementation Checklist
300
+ [ ] Priority 1 items (with specific file edits)
301
+ [ ] Priority 2 items (with before/after examples)
302
+ [ ] Priority 3 items (with hook specifications)
303
+ [ ] Priority 4 items (with removal justification)
304
+ [ ] Priority 5 items (with move-from/move-to)
305
+ ```
306
+
307
+ Present the report to the user and ask which priorities to tackle first.
@@ -0,0 +1,150 @@
1
+ ---
2
+ name: rule-creator
3
+ description: "Creates or hardens Codex rules in .Codex/rules/*.md. Analyzes behavioral patterns and converts them into persistent, enforceable rule files. Triggers: 'create rule', 'add rule', 'harden rule', 'enforce rule', 'new rule'."
4
+ ---
5
+
6
+ # Rule Creator
7
+
8
+ ## Overview
9
+
10
+ Creates well-structured `.Codex/rules/*.md` files that Codex loads into every session.
11
+
12
+ **Core principle:** Rules encode "always true" behaviors. A rule eliminates repeated manual prompting by making the instruction persistent and automatic.
13
+
14
+ **Announce at start:** "I'm using the rule-creator skill to [create/harden] a rule."
15
+
16
+ **Context:** Rules are loaded at session start. They complement AGENTS.md (high-level project instructions) and skills (on-demand workflows). Use rules for behavioral constraints that must always be active.
17
+
18
+ ## The Process
19
+
20
+ ### Step 1: Understand the Need
21
+
22
+ Before writing, clarify:
23
+
24
+ 1. **What behavior** should this rule enforce or prevent?
25
+ 2. **Why** is it needed? (What goes wrong without it? What do you manually correct?)
26
+ 3. **Scope** — all projects (`~/.Codex/rules/`) or project-specific (`.Codex/rules/`)?
27
+ 4. **Path-scoped?** — does it only apply to certain file types?
28
+
29
+ ### Step 2: Check for Overlap
30
+
31
+ Search existing rules before creating a new one:
32
+
33
+ 1. Read `~/.Codex/rules/*.md` and `.Codex/rules/*.md`
34
+ 2. Read AGENTS.md for related instructions
35
+ 3. If overlap exists: **harden the existing rule** instead of creating a duplicate
36
+
37
+ ### Step 3: Write the Rule
38
+
39
+ Follow these principles from Anthropic's prompting best practices and Codex docs:
40
+
41
+ **Structure:**
42
+ - Optional YAML frontmatter (only if path-scoped or needs `alwaysApply`)
43
+ - Markdown with headers and bullets
44
+ - Target under 50 lines per rule file (rules are loaded every session — token cost matters)
45
+
46
+ **Writing principles (source: [Anthropic Prompting Best Practices](https://platform.Codex.com/docs/en/build-with-Codex/prompt-engineering/Codex-prompting-best-practices)):**
47
+
48
+ 1. **Tell what TO do, not what NOT to do.** Positive instructions outperform negative ones.
49
+ - Instead of: "Do not guess CSS selectors"
50
+ - Write: "Read the actual HTML source before writing any CSS selector"
51
+
52
+ 2. **Add context/motivation (WHY).** Codex generalizes from explanations.
53
+ - Instead of: "NEVER use ellipses"
54
+ - Write: "Never use ellipses because the text-to-speech engine cannot pronounce them"
55
+
56
+ 3. **Be specific enough to verify.** Vague rules get ignored.
57
+ - Instead of: "Write clean code"
58
+ - Write: "Use 2-space indentation, no trailing whitespace"
59
+
60
+ 4. **Use XML tags for critical constraints.** Wrap non-negotiable rules in semantic tags.
61
+ ```
62
+ <investigate_before_answering>
63
+ Read referenced files before making claims about their contents.
64
+ </investigate_before_answering>
65
+ ```
66
+
67
+ 5. **Dial back aggressive language for the current model.** The model overtriggers on "CRITICAL", "MUST", "ALWAYS" — use normal prompting unless enforcement truly requires it.
68
+
69
+ **Frontmatter reference:**
70
+ ```yaml
71
+ # Path-scoped rule (loads only when matching files are opened):
72
+ ---
73
+ paths:
74
+ - "src/api/**/*.ts"
75
+ ---
76
+
77
+ # Always-apply rule (loads every session, no conditions):
78
+ # Simply omit frontmatter entirely — rules without frontmatter load unconditionally.
79
+
80
+ # AVOID using alwaysApply: false — it makes the rule load-on-demand only,
81
+ # which means it may never activate unless Codex happens to read matching files.
82
+ ```
83
+
84
+ ### Step 4: Choose Filename
85
+
86
+ - Lowercase, hyphens only: `investigate-first.md`, `parallel-tools.md`
87
+ - Descriptive of the behavior: name after what the rule DOES, not the problem it prevents
88
+ - Match naming convention of existing rules in the target directory
89
+
90
+ ### Step 5: Validate
91
+
92
+ Before writing the file:
93
+
94
+ - [ ] Under 50 lines (concise enough to load every session without waste)
95
+ - [ ] Positive instructions (tells what TO do)
96
+ - [ ] Includes WHY context where non-obvious
97
+ - [ ] Specific enough to verify compliance
98
+ - [ ] No overlap with existing rules or AGENTS.md
99
+ - [ ] No frontmatter if it should always load (omit = unconditional)
100
+ - [ ] Path-scoped frontmatter only if genuinely file-type-specific
101
+
102
+ ### Step 6: Write and Confirm
103
+
104
+ 1. Write the rule to the target directory
105
+ 2. Show the user the final content for review
106
+ 3. Note: rules take effect on the NEXT session (Codex caches at startup)
107
+
108
+ ## Hardening Existing Rules
109
+
110
+ When a rule exists but isn't being followed:
111
+
112
+ 1. **Check frontmatter** — `alwaysApply: false` prevents auto-loading. Remove it.
113
+ 2. **Check for conflicts** — contradictory rules in other files cause arbitrary behavior
114
+ 3. **Add WHY context** — unexplained rules get lower adherence
115
+ 4. **Reframe as positive** — convert "NEVER do X" to "Always do Y instead"
116
+ 5. **Add XML wrapper** — for critical rules, semantic tags improve parsing:
117
+ ```xml
118
+ <rule_name>
119
+ Instruction here.
120
+ </rule_name>
121
+ ```
122
+ 6. **Reduce aggressive language** — the current model overtriggers on "CRITICAL/MUST/ALWAYS". Use direct, normal language unless the rule truly requires absolute enforcement.
123
+
124
+ ## Red Flags — STOP
125
+
126
+ - Rule duplicates something already in AGENTS.md or another rule
127
+ - Rule is over 50 lines (split it or move details to a referenced doc)
128
+ - Rule uses only negative instructions ("NEVER", "DON'T") without positive alternatives
129
+ - Rule has `alwaysApply: false` for something that should always be active
130
+ - Rule is too vague to verify ("write good code")
131
+
132
+ ## Rationalization Prevention
133
+
134
+ | Excuse | Reality |
135
+ |--------|---------|
136
+ | "This is already in AGENTS.md" | If it's not being followed, it needs a dedicated rule with WHY context |
137
+ | "The rule is short enough, no WHY needed" | WHY context improves adherence even for short rules — Codex generalizes from explanations |
138
+ | "I'll use CRITICAL/MUST to make it stronger" | the current model overtriggers on aggressive language. Direct, calm instructions work better. |
139
+ | "alwaysApply: false is fine, Codex will find it" | On-demand loading means the rule may never activate. Omit frontmatter for always-on rules. |
140
+
141
+ ## Remember
142
+
143
+ - Omit frontmatter = always loads (this is what you want for most rules)
144
+ - `alwaysApply: false` = on-demand only (use sparingly)
145
+ - `paths:` frontmatter = loads when matching files are opened
146
+ - Positive instructions > negative instructions
147
+ - WHY context > bare commands
148
+ - Under 50 lines per rule file
149
+ - One behavior per rule file
150
+ - Rules take effect next session
@@ -0,0 +1,246 @@
1
+ # Skill Writer Reference
2
+
3
+ ## Table of Contents
4
+
5
+ 1. [Complete Frontmatter Fields](#complete-frontmatter-fields)
6
+ 2. [Progressive Disclosure Architecture](#progressive-disclosure-architecture)
7
+ 3. [Content Templates by Degree of Freedom](#content-templates)
8
+ 4. [Validation Checklist](#validation-checklist)
9
+
10
+ ---
11
+
12
+ ## Complete Frontmatter Fields
13
+
14
+ Source: [Claude Code Skills](https://platform.claude.com/docs/en/claude-code/skills)
15
+
16
+ ### Required Fields
17
+
18
+ | Field | Type | Constraints | Description |
19
+ |-------|------|-------------|-------------|
20
+ | `name` | string | Lowercase, hyphens, numbers. Max 64 chars. No `anthropic` or `claude`. | Must match directory name. Prefer gerund form. |
21
+ | `description` | string | Max 1024 chars. Third person. No XML tags. | What it does + when to use it + trigger phrases. |
22
+
23
+ ### Optional Fields
24
+
25
+ | Field | Type | Default | Description |
26
+ |-------|------|---------|-------------|
27
+ | `allowed-tools` | string | (all tools) | Tools permitted without asking. E.g., `Read, Grep, Bash(python *)` |
28
+ | `context` | string | (inline) | Set to `fork` to run in isolated subagent (no conversation history) |
29
+ | `agent` | string | (default) | Subagent type when `context: fork` is set |
30
+ | `model` | string | (inherits) | Model override when skill is active |
31
+ | `effort` | string | (inherits) | `low`, `medium`, `high`, or `max` (Opus only) |
32
+ | `user-invocable` | boolean | `true` | Set `false` to hide from `/` menu (background knowledge only) |
33
+ | `disable-model-invocation` | boolean | `false` | Set `true` for manual-only via `/name` |
34
+ | `paths` | string/list | (all files) | Glob patterns limiting activation. E.g., `"*.py"` or `["*.ts", "*.tsx"]` |
35
+ | `argument-hint` | string | (none) | Autocomplete hint. E.g., `[filename] [format]` |
36
+ | `shell` | string | `bash` | Shell for `!`command`` blocks. `bash` or `powershell` |
37
+ | `hooks` | object | (none) | Hooks scoped to this skill's lifecycle |
38
+
39
+ ### String Substitutions (available in SKILL.md body)
40
+
41
+ | Variable | Description |
42
+ |----------|-------------|
43
+ | `$ARGUMENTS` | All arguments passed when invoking |
44
+ | `$ARGUMENTS[N]` | Specific argument by 0-based index |
45
+ | `$N` | Shorthand for `$ARGUMENTS[N]` (e.g., `$0`, `$1`) |
46
+ | `${CLAUDE_SESSION_ID}` | Current session ID |
47
+ | `${CLAUDE_SKILL_DIR}` | Directory containing SKILL.md |
48
+ | `` !`command` `` | Dynamic context injection - shell command runs before Claude sees content |
49
+
50
+ ### Permission Syntax
51
+
52
+ ```
53
+ Skill(name) # Allow exact skill
54
+ Skill(name *) # Allow skill with any arguments
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Progressive Disclosure Architecture
60
+
61
+ Source: [Agent Skills Overview](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview)
62
+
63
+ Skills load in three levels to minimize context usage:
64
+
65
+ | Level | What Loads | Token Cost | When |
66
+ |-------|-----------|------------|------|
67
+ | **1. Metadata** | `name` and `description` from frontmatter | ~100 tokens | Always (system prompt) |
68
+ | **2. Instructions** | SKILL.md body | <5k tokens | When triggered by matching request |
69
+ | **3. Resources** | Additional files, scripts, schemas | Unlimited | When referenced from instructions |
70
+
71
+ ### Key implications:
72
+ - You can install many skills with minimal context cost (~100 tokens each)
73
+ - SKILL.md body should stay under 500 lines
74
+ - Scripts execute via bash - their code never enters context, only output does
75
+ - Reference files load only when Claude reads them
76
+
77
+ ---
78
+
79
+ ## Content Templates
80
+
81
+ ### High Freedom (Advisory)
82
+
83
+ Best for guidance where multiple approaches are valid.
84
+
85
+ ```markdown
86
+ ---
87
+ name: analyzing-data
88
+ description: "Analyzes datasets and generates statistical summaries. Use when working with CSV or Excel data requiring descriptive statistics, correlations, or visualizations."
89
+ ---
90
+
91
+ # Analyzing Data
92
+
93
+ ## Overview
94
+
95
+ Performs statistical analysis on tabular datasets.
96
+
97
+ **Announce at start:** "I'm using the analyzing-data skill."
98
+
99
+ ## Instructions
100
+
101
+ 1. Load and inspect the data structure
102
+ 2. Generate descriptive statistics
103
+ 3. Identify correlations and patterns
104
+ 4. Produce visualizations if requested
105
+
106
+ ## Examples
107
+
108
+ **Input:** "Analyze sales_2024.csv for trends"
109
+ **Output:** Summary statistics, monthly trend chart, top performers
110
+
111
+ ## Best Practices
112
+
113
+ - Always show data shape and types before analysis
114
+ - Handle missing values explicitly
115
+ - Use appropriate chart types for the data
116
+ ```
117
+
118
+ ### Medium Freedom (Structured Workflow)
119
+
120
+ Best for preferred patterns with some variation allowed.
121
+
122
+ ```markdown
123
+ ---
124
+ name: reviewing-plans
125
+ description: "Validates implementation plans against code standards, TDD compliance, and right-sized engineering. Use after writing plans and before executing them. Triggers: 'review plan', 'validate plan', 'check plan'."
126
+ ---
127
+
128
+ # Reviewing Plans
129
+
130
+ ## Overview
131
+
132
+ **Core principle:** Bad plans produce bad code. Review before you execute.
133
+
134
+ **Announce at start:** "I'm using the reviewing-plans skill to validate this plan."
135
+
136
+ **Context:** Use after write-plan and before plan-executor. Quality gate between planning and implementation.
137
+
138
+ ## The Process
139
+
140
+ ### Step 1: Identify Plan Files
141
+ Locate plan files in `.planning/phases/` or `docs/plans/`.
142
+
143
+ ### Step 2: Review Dimensions
144
+ Check structure, TDD compliance, code quality, right-sized engineering, task granularity.
145
+
146
+ ### Step 3: Report Verdict
147
+ READY or NEEDS REVISION with specific issues.
148
+
149
+ ## Output Format
150
+
151
+ | Dimension | Status |
152
+ |-----------|--------|
153
+ | Structure | PASS/FAIL |
154
+ | TDD | PASS/FAIL |
155
+ | Code quality | PASS/FAIL |
156
+
157
+ ## Red Flags - STOP
158
+
159
+ - Any placeholder text ("implement later")
160
+ - Missing TDD steps for production code
161
+ - Magic values in code blocks
162
+
163
+ ## Rationalization Prevention
164
+
165
+ | Excuse | Reality |
166
+ |--------|---------|
167
+ | "The plan is high-level" | Plans without complete code produce inconsistent implementations |
168
+ | "TDD makes it too long" | TDD in plan prevents skipping TDD during execution |
169
+ ```
170
+
171
+ ### Low Freedom (Critical/Exact)
172
+
173
+ Best for fragile operations where consistency is critical.
174
+
175
+ ```markdown
176
+ ---
177
+ name: filling-pdf-forms
178
+ description: "Fills PDF forms using pdf-lib JavaScript library with exact field mapping. Use when populating PDF forms programmatically. Triggers: 'fill PDF form', 'populate form', 'form filling'."
179
+ allowed-tools: Bash(node *), Read
180
+ ---
181
+
182
+ # Filling PDF Forms
183
+
184
+ ## MANDATORY PROTOCOL
185
+
186
+ Before filling ANY form:
187
+ 1. [ ] Read `${CLAUDE_SKILL_DIR}/FORMS.md` for field mapping reference
188
+ 2. [ ] Extract field names: `node ${CLAUDE_SKILL_DIR}/scripts/extract_fields.js input.pdf`
189
+ 3. [ ] Match extracted fields against the mapping
190
+
191
+ ## Workflow
192
+
193
+ ### Step 1: Extract Fields
194
+ ```bash
195
+ node ${CLAUDE_SKILL_DIR}/scripts/extract_fields.js "$0"
196
+ ```
197
+
198
+ ### Step 2: Generate Fill Script
199
+ Use the field mapping from FORMS.md. Every field must be explicitly set.
200
+
201
+ ### Step 3: Execute and Validate
202
+ ```bash
203
+ node fill_script.js && node ${CLAUDE_SKILL_DIR}/scripts/validate_fill.js output.pdf
204
+ ```
205
+
206
+ ### Feedback Loop
207
+ If validation fails -> read error output -> fix field mapping -> re-execute -> re-validate.
208
+
209
+ ## Critical Rules
210
+
211
+ **NEVER guess field names.** Always extract first.
212
+ **WHY:** Wrong field names silently produce empty forms.
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Validation Checklist
218
+
219
+ Source: [Best Practices Checklist](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices)
220
+
221
+ ### Core Quality
222
+ - [ ] Description is specific, includes key terms, and is in **third person**
223
+ - [ ] Description includes both what the Skill does and when to use it
224
+ - [ ] SKILL.md body is **under 500 lines**
225
+ - [ ] Additional details are in separate files (if needed)
226
+ - [ ] No time-sensitive information (or clearly marked as legacy)
227
+ - [ ] Consistent terminology throughout
228
+ - [ ] Examples are concrete, not abstract
229
+ - [ ] File references are **one level deep** from SKILL.md
230
+ - [ ] Files >100 lines have a **table of contents**
231
+ - [ ] Workflows have clear steps
232
+ - [ ] All file paths use **forward slashes**
233
+
234
+ ### Code and Scripts
235
+ - [ ] Scripts solve problems rather than punt to Claude
236
+ - [ ] Error handling is explicit and helpful
237
+ - [ ] No "voodoo constants" (all values justified)
238
+ - [ ] Required packages listed and verified as available
239
+ - [ ] MCP tools use **fully qualified names** (`ServerName:tool_name`)
240
+ - [ ] Validation/verification steps for critical operations
241
+ - [ ] Feedback loops included for quality-critical tasks
242
+
243
+ ### Testing
244
+ - [ ] At least 3 evaluation scenarios created
245
+ - [ ] Tested with representative real tasks
246
+ - [ ] If multi-model: tested with Haiku, Sonnet, and Opus