@event4u/agent-config 1.29.0 → 1.31.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 (46) hide show
  1. package/.agent-src/commands/agents/audit.md +101 -197
  2. package/.agent-src/commands/{copilot-agents → agents}/init.md +18 -10
  3. package/.agent-src/commands/agents/optimize.md +181 -0
  4. package/.agent-src/commands/agents.md +19 -12
  5. package/.agent-src/commands/optimize/agents-dir.md +111 -0
  6. package/.agent-src/commands/optimize.md +10 -8
  7. package/.agent-src/contexts/communication/rules-auto/guidelines-mechanics.md +6 -0
  8. package/.agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +2 -3
  9. package/.agent-src/contexts/contracts/agents-md-anatomy.md +132 -0
  10. package/.agent-src/skills/agents-md-thin-root/SKILL.md +8 -1
  11. package/.agent-src/skills/command-writing/SKILL.md +49 -0
  12. package/.agent-src/skills/copilot-agents-optimization/SKILL.md +3 -3
  13. package/.agent-src/skills/error-handling-patterns/SKILL.md +2 -2
  14. package/.agent-src/skills/{repomix → repomix-packer}/SKILL.md +8 -8
  15. package/.agent-src/skills/roadmap-writing/SKILL.md +9 -0
  16. package/.agent-src/skills/rule-writing/SKILL.md +21 -0
  17. package/.agent-src/skills/skill-writing/SKILL.md +19 -0
  18. package/.agent-src/skills/testing-anti-patterns/SKILL.md +7 -0
  19. package/.agent-src/templates/AGENTS.md +9 -10
  20. package/.claude-plugin/marketplace.json +5 -8
  21. package/AGENTS.md +1 -2
  22. package/CHANGELOG.md +86 -0
  23. package/CONTRIBUTING.md +90 -0
  24. package/README.md +3 -3
  25. package/docs/architecture.md +2 -2
  26. package/docs/catalog.md +11 -13
  27. package/docs/contracts/command-clusters.md +20 -3
  28. package/docs/contracts/file-ownership-matrix.json +205 -56
  29. package/docs/getting-started.md +1 -1
  30. package/docs/guidelines/code-clarity.md +95 -0
  31. package/docs/guidelines/php/general.md +8 -0
  32. package/docs/guidelines/php/php-coding-patterns.md +1 -0
  33. package/docs/skills-catalog.md +27 -3
  34. package/llms.txt +26 -2
  35. package/package.json +1 -1
  36. package/scripts/chat_history.py +166 -36
  37. package/scripts/check_command_count_messaging.py +12 -3
  38. package/scripts/check_portability.py +1 -0
  39. package/scripts/lint_agents_md.py +33 -0
  40. package/scripts/release.py +77 -2
  41. package/scripts/skill_linter.py +10 -3
  42. package/.agent-src/commands/agents/cleanup.md +0 -194
  43. package/.agent-src/commands/agents/prepare.md +0 -141
  44. package/.agent-src/commands/copilot-agents/optimize.md +0 -255
  45. package/.agent-src/commands/copilot-agents.md +0 -44
  46. package/.agent-src/commands/optimize/agents.md +0 -144
@@ -27,13 +27,13 @@
27
27
  "load_context": [],
28
28
  "load_context_eager": []
29
29
  },
30
- ".agent-src.uncompressed/commands/agents/cleanup.md": {
30
+ ".agent-src.uncompressed/commands/agents/init.md": {
31
31
  "kind": "command",
32
32
  "rule_type": null,
33
33
  "load_context": [],
34
34
  "load_context_eager": []
35
35
  },
36
- ".agent-src.uncompressed/commands/agents/prepare.md": {
36
+ ".agent-src.uncompressed/commands/agents/optimize.md": {
37
37
  "kind": "command",
38
38
  "rule_type": null,
39
39
  "load_context": [],
@@ -141,24 +141,6 @@
141
141
  "load_context": [],
142
142
  "load_context_eager": []
143
143
  },
144
- ".agent-src.uncompressed/commands/copilot-agents.md": {
145
- "kind": "command",
146
- "rule_type": null,
147
- "load_context": [],
148
- "load_context_eager": []
149
- },
150
- ".agent-src.uncompressed/commands/copilot-agents/init.md": {
151
- "kind": "command",
152
- "rule_type": null,
153
- "load_context": [],
154
- "load_context_eager": []
155
- },
156
- ".agent-src.uncompressed/commands/copilot-agents/optimize.md": {
157
- "kind": "command",
158
- "rule_type": null,
159
- "load_context": [],
160
- "load_context_eager": []
161
- },
162
144
  ".agent-src.uncompressed/commands/cost-report.md": {
163
145
  "kind": "command",
164
146
  "rule_type": null,
@@ -423,7 +405,7 @@
423
405
  "load_context": [],
424
406
  "load_context_eager": []
425
407
  },
426
- ".agent-src.uncompressed/commands/optimize/agents.md": {
408
+ ".agent-src.uncompressed/commands/optimize/agents-dir.md": {
427
409
  "kind": "command",
428
410
  "rule_type": null,
429
411
  "load_context": [],
@@ -699,6 +681,12 @@
699
681
  "load_context": [],
700
682
  "load_context_eager": []
701
683
  },
684
+ ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md": {
685
+ "kind": "context",
686
+ "rule_type": null,
687
+ "load_context": [],
688
+ "load_context_eager": []
689
+ },
702
690
  ".agent-src.uncompressed/contexts/contracts/artifact-engagement-flow.md": {
703
691
  "kind": "context",
704
692
  "rule_type": null,
@@ -1938,7 +1926,7 @@
1938
1926
  "load_context": [],
1939
1927
  "load_context_eager": []
1940
1928
  },
1941
- ".agent-src.uncompressed/skills/repomix/SKILL.md": {
1929
+ ".agent-src.uncompressed/skills/repomix-packer/SKILL.md": {
1942
1930
  "kind": "skill",
1943
1931
  "rule_type": null,
1944
1932
  "load_context": [],
@@ -2183,6 +2171,13 @@
2183
2171
  "via": "self",
2184
2172
  "depth": 0
2185
2173
  },
2174
+ {
2175
+ "source": ".agent-src.uncompressed/commands/agents.md",
2176
+ "target": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
2177
+ "type": "READ_ONLY",
2178
+ "via": "body_link",
2179
+ "depth": 1
2180
+ },
2186
2181
  {
2187
2182
  "source": ".agent-src.uncompressed/commands/agents/audit.md",
2188
2183
  "target": ".agent-src.uncompressed/commands/agents/audit.md",
@@ -2191,19 +2186,110 @@
2191
2186
  "depth": 0
2192
2187
  },
2193
2188
  {
2194
- "source": ".agent-src.uncompressed/commands/agents/cleanup.md",
2195
- "target": ".agent-src.uncompressed/commands/agents/cleanup.md",
2189
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2190
+ "target": ".agent-src.uncompressed/commands/agents/optimize.md",
2191
+ "type": "READ_ONLY",
2192
+ "via": "body_link",
2193
+ "depth": 1
2194
+ },
2195
+ {
2196
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2197
+ "target": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
2198
+ "type": "READ_ONLY",
2199
+ "via": "body_link",
2200
+ "depth": 1
2201
+ },
2202
+ {
2203
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2204
+ "target": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
2205
+ "type": "READ_ONLY",
2206
+ "via": "body_link",
2207
+ "depth": 1
2208
+ },
2209
+ {
2210
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2211
+ "target": ".agent-src.uncompressed/rules/commit-policy.md",
2212
+ "type": "READ_ONLY",
2213
+ "via": "body_link",
2214
+ "depth": 1
2215
+ },
2216
+ {
2217
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2218
+ "target": ".agent-src.uncompressed/rules/rule-type-governance.md",
2219
+ "type": "READ_ONLY",
2220
+ "via": "body_link",
2221
+ "depth": 1
2222
+ },
2223
+ {
2224
+ "source": ".agent-src.uncompressed/commands/agents/audit.md",
2225
+ "target": ".agent-src.uncompressed/skills/agents-md-thin-root/SKILL.md",
2226
+ "type": "READ_ONLY",
2227
+ "via": "body_link",
2228
+ "depth": 1
2229
+ },
2230
+ {
2231
+ "source": ".agent-src.uncompressed/commands/agents/init.md",
2232
+ "target": ".agent-src.uncompressed/commands/agents/init.md",
2196
2233
  "type": "WRITE",
2197
2234
  "via": "self",
2198
2235
  "depth": 0
2199
2236
  },
2200
2237
  {
2201
- "source": ".agent-src.uncompressed/commands/agents/prepare.md",
2202
- "target": ".agent-src.uncompressed/commands/agents/prepare.md",
2238
+ "source": ".agent-src.uncompressed/commands/agents/init.md",
2239
+ "target": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
2240
+ "type": "READ_ONLY",
2241
+ "via": "body_link",
2242
+ "depth": 1
2243
+ },
2244
+ {
2245
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2246
+ "target": ".agent-src.uncompressed/commands/agents/optimize.md",
2203
2247
  "type": "WRITE",
2204
2248
  "via": "self",
2205
2249
  "depth": 0
2206
2250
  },
2251
+ {
2252
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2253
+ "target": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
2254
+ "type": "READ_ONLY",
2255
+ "via": "body_link",
2256
+ "depth": 1
2257
+ },
2258
+ {
2259
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2260
+ "target": ".agent-src.uncompressed/contexts/contracts/emergency-triage-block.md",
2261
+ "type": "READ_ONLY",
2262
+ "via": "body_link",
2263
+ "depth": 1
2264
+ },
2265
+ {
2266
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2267
+ "target": ".agent-src.uncompressed/rules/commit-policy.md",
2268
+ "type": "READ_ONLY",
2269
+ "via": "body_link",
2270
+ "depth": 1
2271
+ },
2272
+ {
2273
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2274
+ "target": ".agent-src.uncompressed/rules/scope-control.md",
2275
+ "type": "READ_ONLY",
2276
+ "via": "body_link",
2277
+ "depth": 1
2278
+ },
2279
+ {
2280
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2281
+ "target": ".agent-src.uncompressed/rules/verify-before-complete.md",
2282
+ "type": "READ_ONLY",
2283
+ "via": "body_link",
2284
+ "depth": 1
2285
+ },
2286
+ {
2287
+ "source": ".agent-src.uncompressed/commands/agents/optimize.md",
2288
+ "target": ".agent-src.uncompressed/skills/agents-md-thin-root/SKILL.md",
2289
+ "type": "READ_ONLY",
2290
+ "via": "body_link",
2291
+ "depth": 1
2292
+ },
2207
2293
  {
2208
2294
  "source": ".agent-src.uncompressed/commands/analyze-reference-repo.md",
2209
2295
  "target": ".agent-src.uncompressed/commands/analyze-reference-repo.md",
@@ -2533,27 +2619,6 @@
2533
2619
  "via": "self",
2534
2620
  "depth": 0
2535
2621
  },
2536
- {
2537
- "source": ".agent-src.uncompressed/commands/copilot-agents.md",
2538
- "target": ".agent-src.uncompressed/commands/copilot-agents.md",
2539
- "type": "WRITE",
2540
- "via": "self",
2541
- "depth": 0
2542
- },
2543
- {
2544
- "source": ".agent-src.uncompressed/commands/copilot-agents/init.md",
2545
- "target": ".agent-src.uncompressed/commands/copilot-agents/init.md",
2546
- "type": "WRITE",
2547
- "via": "self",
2548
- "depth": 0
2549
- },
2550
- {
2551
- "source": ".agent-src.uncompressed/commands/copilot-agents/optimize.md",
2552
- "target": ".agent-src.uncompressed/commands/copilot-agents/optimize.md",
2553
- "type": "WRITE",
2554
- "via": "self",
2555
- "depth": 0
2556
- },
2557
2622
  {
2558
2623
  "source": ".agent-src.uncompressed/commands/cost-report.md",
2559
2624
  "target": ".agent-src.uncompressed/commands/agent-status.md",
@@ -3058,6 +3123,13 @@
3058
3123
  "via": "body_link",
3059
3124
  "depth": 1
3060
3125
  },
3126
+ {
3127
+ "source": ".agent-src.uncompressed/commands/optimize.md",
3128
+ "target": ".agent-src.uncompressed/commands/agents.md",
3129
+ "type": "READ_ONLY",
3130
+ "via": "body_link",
3131
+ "depth": 1
3132
+ },
3061
3133
  {
3062
3134
  "source": ".agent-src.uncompressed/commands/optimize.md",
3063
3135
  "target": ".agent-src.uncompressed/commands/optimize.md",
@@ -3066,12 +3138,54 @@
3066
3138
  "depth": 0
3067
3139
  },
3068
3140
  {
3069
- "source": ".agent-src.uncompressed/commands/optimize/agents.md",
3070
- "target": ".agent-src.uncompressed/commands/optimize/agents.md",
3141
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3142
+ "target": ".agent-src.uncompressed/commands/agents.md",
3143
+ "type": "READ_ONLY",
3144
+ "via": "body_link",
3145
+ "depth": 1
3146
+ },
3147
+ {
3148
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3149
+ "target": ".agent-src.uncompressed/commands/agents/audit.md",
3150
+ "type": "READ_ONLY",
3151
+ "via": "body_link",
3152
+ "depth": 1
3153
+ },
3154
+ {
3155
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3156
+ "target": ".agent-src.uncompressed/commands/agents/optimize.md",
3157
+ "type": "READ_ONLY",
3158
+ "via": "body_link",
3159
+ "depth": 1
3160
+ },
3161
+ {
3162
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3163
+ "target": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3071
3164
  "type": "WRITE",
3072
3165
  "via": "self",
3073
3166
  "depth": 0
3074
3167
  },
3168
+ {
3169
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3170
+ "target": ".agent-src.uncompressed/rules/commit-policy.md",
3171
+ "type": "READ_ONLY",
3172
+ "via": "body_link",
3173
+ "depth": 1
3174
+ },
3175
+ {
3176
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3177
+ "target": ".agent-src.uncompressed/skills/agent-docs-writing/SKILL.md",
3178
+ "type": "READ_ONLY",
3179
+ "via": "body_link",
3180
+ "depth": 1
3181
+ },
3182
+ {
3183
+ "source": ".agent-src.uncompressed/commands/optimize/agents-dir.md",
3184
+ "target": ".agent-src.uncompressed/skills/override-management/SKILL.md",
3185
+ "type": "READ_ONLY",
3186
+ "via": "body_link",
3187
+ "depth": 1
3188
+ },
3075
3189
  {
3076
3190
  "source": ".agent-src.uncompressed/commands/optimize/augmentignore.md",
3077
3191
  "target": ".agent-src.uncompressed/commands/optimize/augmentignore.md",
@@ -3961,6 +4075,34 @@
3961
4075
  "via": "body_link",
3962
4076
  "depth": 1
3963
4077
  },
4078
+ {
4079
+ "source": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
4080
+ "target": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
4081
+ "type": "WRITE",
4082
+ "via": "self",
4083
+ "depth": 0
4084
+ },
4085
+ {
4086
+ "source": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
4087
+ "target": ".agent-src.uncompressed/contexts/contracts/consumer-agents-md-guide.md",
4088
+ "type": "READ_ONLY",
4089
+ "via": "body_link",
4090
+ "depth": 1
4091
+ },
4092
+ {
4093
+ "source": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
4094
+ "target": ".agent-src.uncompressed/contexts/contracts/emergency-triage-block.md",
4095
+ "type": "READ_ONLY",
4096
+ "via": "body_link",
4097
+ "depth": 1
4098
+ },
4099
+ {
4100
+ "source": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
4101
+ "target": ".agent-src.uncompressed/skills/agents-md-thin-root/SKILL.md",
4102
+ "type": "READ_ONLY",
4103
+ "via": "body_link",
4104
+ "depth": 1
4105
+ },
3964
4106
  {
3965
4107
  "source": ".agent-src.uncompressed/contexts/contracts/artifact-engagement-flow.md",
3966
4108
  "target": ".agent-src.uncompressed/contexts/contracts/artifact-engagement-flow.md",
@@ -5606,6 +5748,13 @@
5606
5748
  "via": "self",
5607
5749
  "depth": 0
5608
5750
  },
5751
+ {
5752
+ "source": ".agent-src.uncompressed/skills/agents-md-thin-root/SKILL.md",
5753
+ "target": ".agent-src.uncompressed/contexts/contracts/agents-md-anatomy.md",
5754
+ "type": "READ_ONLY",
5755
+ "via": "body_link",
5756
+ "depth": 1
5757
+ },
5609
5758
  {
5610
5759
  "source": ".agent-src.uncompressed/skills/agents-md-thin-root/SKILL.md",
5611
5760
  "target": ".agent-src.uncompressed/rules/size-enforcement.md",
@@ -7364,43 +7513,43 @@
7364
7513
  "depth": 1
7365
7514
  },
7366
7515
  {
7367
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7516
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7368
7517
  "target": ".agent-src.uncompressed/commands/analyze-reference-repo.md",
7369
7518
  "type": "READ_ONLY",
7370
7519
  "via": "body_link",
7371
7520
  "depth": 1
7372
7521
  },
7373
7522
  {
7374
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7523
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7375
7524
  "target": ".agent-src.uncompressed/skills/blast-radius-analyzer/SKILL.md",
7376
7525
  "type": "READ_ONLY",
7377
7526
  "via": "body_link",
7378
7527
  "depth": 1
7379
7528
  },
7380
7529
  {
7381
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7530
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7382
7531
  "target": ".agent-src.uncompressed/skills/judge-bug-hunter/SKILL.md",
7383
7532
  "type": "READ_ONLY",
7384
7533
  "via": "body_link",
7385
7534
  "depth": 1
7386
7535
  },
7387
7536
  {
7388
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7537
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7389
7538
  "target": ".agent-src.uncompressed/skills/judge-security-auditor/SKILL.md",
7390
7539
  "type": "READ_ONLY",
7391
7540
  "via": "body_link",
7392
7541
  "depth": 1
7393
7542
  },
7394
7543
  {
7395
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7544
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7396
7545
  "target": ".agent-src.uncompressed/skills/markitdown/SKILL.md",
7397
7546
  "type": "READ_ONLY",
7398
7547
  "via": "body_link",
7399
7548
  "depth": 1
7400
7549
  },
7401
7550
  {
7402
- "source": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7403
- "target": ".agent-src.uncompressed/skills/repomix/SKILL.md",
7551
+ "source": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7552
+ "target": ".agent-src.uncompressed/skills/repomix-packer/SKILL.md",
7404
7553
  "type": "WRITE",
7405
7554
  "via": "self",
7406
7555
  "depth": 0
@@ -153,7 +153,7 @@ Your agent now understands slash commands:
153
153
  | `/quality-fix` | Run and fix all quality checks |
154
154
  | `/chat-history` | Inspect the persistent chat-history log (read-only `show`) |
155
155
 
156
- → [Browse all 104 active commands](../.agent-src/commands/)
156
+ → [Browse all 101 active commands](../.agent-src/commands/)
157
157
 
158
158
  ---
159
159
 
@@ -0,0 +1,95 @@
1
+ # Code Clarity
2
+
3
+ > Cross-language coding-clarity conventions. Cited by language-specific
4
+ > guidelines (`php/general.md`, `php/php-coding-patterns.md`, …) so
5
+ > consumers in any stack get the same baseline.
6
+
7
+ Applies to PHP, JavaScript / TypeScript, Python, Go, Ruby, and any
8
+ other language the package guides. Language-specific files reference
9
+ this one — they don't duplicate it.
10
+
11
+ ## Don't assign single-use values to a variable
12
+
13
+ If a value is used **exactly once**, pass the expression directly.
14
+ Don't bind it to a temporary variable just to feed it into the next
15
+ call.
16
+
17
+ The named variable buys nothing — it adds a line, an identifier the
18
+ reader has to track, and a false signal that the value will be reused.
19
+
20
+ ```php
21
+ // ❌ Avoid — $db is referenced exactly once.
22
+ $db = db::getInstance();
23
+ $this->columnExists($db, 'table', 'column');
24
+
25
+ // ✅ Prefer — value flows directly to the call.
26
+ $this->columnExists(db::getInstance(), 'table', 'column');
27
+ ```
28
+
29
+ ```ts
30
+ // ❌ Avoid
31
+ const user = await getCurrentUser();
32
+ return renderProfile(user);
33
+
34
+ // ✅ Prefer
35
+ return renderProfile(await getCurrentUser());
36
+ ```
37
+
38
+ ```python
39
+ # ❌ Avoid
40
+ config = load_config()
41
+ return Worker(config)
42
+
43
+ # ✅ Prefer
44
+ return Worker(load_config())
45
+ ```
46
+
47
+ ## Carve-outs — keep the variable when
48
+
49
+ The rule is "single use, no extra meaning". Bind to a variable when
50
+ **any** of these hold:
51
+
52
+ | Carve-out | Why |
53
+ |---|---|
54
+ | **Used 2 or more times** | Inlining duplicates the expression — re-evaluation, repeated side effects, more diff churn. |
55
+ | **Expression has side effects** | A network call, a write, an `INSERT`, a counter bump must run exactly once and be visible to the reader as such. |
56
+ | **The name carries domain meaning** | `$activeMembership = …; allow($activeMembership)` — the identifier documents intent the call site can't. |
57
+ | **Inlining pushes past the line-length budget** | A 130-char single line is harder to read than two named lines. Match the project's formatter. |
58
+ | **Used inside a loop body** | Hoist the invariant out of the loop; keep the binding. |
59
+ | **Debugger / breakpoint affordance** | Stepping through a named value is materially easier than inspecting an expression mid-call. Prefer the variable in code paths under active investigation. |
60
+ | **Type-narrowing assertion** | `const x: Foo = maybeFoo!; …` where the binding pins the type for the type-checker. |
61
+
62
+ When in doubt — and the expression is short, side-effect-free, and
63
+ used once — inline it.
64
+
65
+ ## Why this matters
66
+
67
+ - **Smaller diffs.** Two lines (`$x = ...; f($x)`) become one (`f(...)`)
68
+ — fewer review points, less merge conflict surface.
69
+ - **Less cognitive load.** Readers don't track an identifier whose
70
+ whole purpose is "the next line".
71
+ - **Honest signals.** A named variable says "this value is reusable
72
+ or worth labeling". Single-use bindings break that contract and
73
+ train readers to ignore names.
74
+ - **Faster refactor.** Renaming the call site doesn't drag a now-stale
75
+ variable name with it.
76
+
77
+ ## Anti-patterns this rule rejects
78
+
79
+ - **"Variable for the debugger."** If the file is not under active
80
+ debugging, drop the binding. Don't ship debug scaffolding.
81
+ - **"Variable to align line lengths."** Use the formatter, not a
82
+ fake intermediate.
83
+ - **"Variable so I have somewhere to put the type."** Modern type
84
+ inference makes this redundant in PHP 8+, TS, Python 3.10+, Go,
85
+ Rust, etc. Annotate the parameter or return type instead.
86
+
87
+ ## See also
88
+
89
+ - Language-specific anchors that link to this guideline:
90
+ - PHP: `docs/guidelines/php/general.md` § Variables
91
+ - PHP: `docs/guidelines/php/php-coding-patterns.md` § Variables
92
+ - `minimal-safe-diff` rule — orthogonal but aligned: smallest change
93
+ that solves the stated problem.
94
+ - `direct-answers` rule — same spirit at the prose level: shortest
95
+ version that fully answers the question.
@@ -24,6 +24,14 @@
24
24
  - Retrieving: `getUser()`, `fetchUserData()` — not `user()`, `userData()`
25
25
  - Actions: `sendEmail()`, `processPayment()` — not `email()`, `payment()`
26
26
 
27
+ ## Variables
28
+
29
+ - **Don't assign single-use values to a variable** — pass the expression
30
+ directly to the call. Universal rule with carve-outs (side effects,
31
+ loops, debugger, type narrowing) lives in
32
+ [`code-clarity.md`](../code-clarity.md) § Don't assign single-use
33
+ values to a variable.
34
+
27
35
  ## Strings
28
36
 
29
37
  - Single quotes when no interpolation: `$table = 'users';`
@@ -15,6 +15,7 @@ _Origin: migrated from `.agent-src.uncompressed/rules/php-coding.md` per P4.2 of
15
15
  - No one-liner if statements.
16
16
  - Single quotes for strings without interpolation. `sprintf()` for complex strings.
17
17
  - Variables: `camelCase`. Array keys: `snake_case`. Constants: `UPPER_SNAKE_CASE`.
18
+ - Don't assign single-use values to a variable — pass the expression directly. Carve-outs (side effects, loops, type narrowing) in [`code-clarity.md`](../code-clarity.md).
18
19
  - Typed properties, parameters, and return types — always.
19
20
  - Constructor property promotion where it makes sense.
20
21