cc-codeconductor 0.2.9 → 0.3.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 (143) hide show
  1. package/README.md +105 -25
  2. package/dist/index.js +662 -291
  3. package/package.json +1 -1
  4. package/presets/agy/AGENTS.md +365 -0
  5. package/presets/agy/README.md +47 -0
  6. package/presets/agy/hooks.json +30 -0
  7. package/presets/agy/mcp_config.json +3 -0
  8. package/presets/agy/rules/commit-style.md +1 -0
  9. package/presets/agy/rules/graphify.md +14 -0
  10. package/presets/agy/scripts/post-tool.sh +25 -0
  11. package/presets/agy/scripts/pre-tool.sh +56 -0
  12. package/presets/agy/settings.json +8 -0
  13. package/presets/agy/skills/cc-api-contract/SKILL.md +71 -0
  14. package/presets/agy/skills/cc-db-migration/SKILL.md +70 -0
  15. package/presets/agy/skills/cc-feature/SKILL.md +115 -0
  16. package/presets/agy/skills/cc-fix/SKILL.md +124 -0
  17. package/presets/agy/skills/cc-pagespeed/SKILL.md +101 -0
  18. package/presets/agy/skills/cc-refactor/SKILL.md +149 -0
  19. package/presets/agy/skills/cc-review/SKILL.md +142 -0
  20. package/presets/agy/skills/cc-tdd-cycle/SKILL.md +226 -0
  21. package/presets/agy/skills/cc-test-plan/SKILL.md +145 -0
  22. package/presets/agy/skills/commit/SKILL.md +5 -0
  23. package/presets/agy/workflows/cc-api-contract.md +71 -0
  24. package/presets/agy/workflows/cc-db-migration.md +70 -0
  25. package/presets/agy/workflows/cc-feature.md +115 -0
  26. package/presets/agy/workflows/cc-fix.md +124 -0
  27. package/presets/agy/workflows/cc-pagespeed.md +101 -0
  28. package/presets/agy/workflows/cc-refactor.md +149 -0
  29. package/presets/agy/workflows/cc-review.md +142 -0
  30. package/presets/agy/workflows/cc-tdd-cycle.md +226 -0
  31. package/presets/agy/workflows/cc-test-plan.md +145 -0
  32. package/presets/agy/workflows/commit.md +1 -0
  33. package/presets/claude/CLAUDE.md +47 -3
  34. package/presets/claude/claude.json +6 -0
  35. package/presets/claude/commands/cc/pagespeed.md +103 -0
  36. package/presets/claude/settings.json +249 -2
  37. package/presets/claude/skills/android/SKILL.md +119 -0
  38. package/presets/claude/skills/conductor-setup/SKILL.md +125 -0
  39. package/presets/claude/skills/find-skills/SKILL.md +142 -0
  40. package/presets/claude/skills/laravel-specialist/SKILL.md +264 -0
  41. package/presets/claude/skills/laravel-specialist/references/eloquent.md +351 -0
  42. package/presets/claude/skills/laravel-specialist/references/livewire.md +512 -0
  43. package/presets/claude/skills/laravel-specialist/references/queues.md +423 -0
  44. package/presets/claude/skills/laravel-specialist/references/routing.md +362 -0
  45. package/presets/claude/skills/laravel-specialist/references/testing.md +522 -0
  46. package/presets/claude/skills/multi-agent-orchestration/README.md +144 -0
  47. package/presets/claude/skills/multi-agent-orchestration/SKILL.md +579 -0
  48. package/presets/claude/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  49. package/presets/claude/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  50. package/presets/claude/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  51. package/presets/claude/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  52. package/presets/claude/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  53. package/presets/claude/skills/pagespeed-insights/SKILL.md +443 -0
  54. package/presets/claude/skills/pagespeed-insights/reference.md +50 -0
  55. package/presets/claude/skills/pagespeed-perf/SKILL.md +279 -0
  56. package/presets/claude/skills/php-pro/SKILL.md +208 -0
  57. package/presets/claude/skills/php-pro/references/async-patterns.md +412 -0
  58. package/presets/claude/skills/php-pro/references/laravel-patterns.md +377 -0
  59. package/presets/claude/skills/php-pro/references/modern-php-features.md +323 -0
  60. package/presets/claude/skills/php-pro/references/symfony-patterns.md +466 -0
  61. package/presets/claude/skills/php-pro/references/testing-quality.md +466 -0
  62. package/presets/claude/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  63. package/presets/claude/skills/workflow-orchestration-patterns/references/details.md +223 -0
  64. package/presets/codex/AGENTS.md +38 -14
  65. package/presets/codex/skills/android/SKILL.md +119 -0
  66. package/presets/codex/skills/conductor-setup/SKILL.md +125 -0
  67. package/presets/codex/skills/find-skills/SKILL.md +142 -0
  68. package/presets/codex/skills/laravel-specialist/SKILL.md +264 -0
  69. package/presets/codex/skills/laravel-specialist/references/eloquent.md +351 -0
  70. package/presets/codex/skills/laravel-specialist/references/livewire.md +512 -0
  71. package/presets/codex/skills/laravel-specialist/references/queues.md +423 -0
  72. package/presets/codex/skills/laravel-specialist/references/routing.md +362 -0
  73. package/presets/codex/skills/laravel-specialist/references/testing.md +522 -0
  74. package/presets/codex/skills/multi-agent-orchestration/README.md +144 -0
  75. package/presets/codex/skills/multi-agent-orchestration/SKILL.md +579 -0
  76. package/presets/codex/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  77. package/presets/codex/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  78. package/presets/codex/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  79. package/presets/codex/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  80. package/presets/codex/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  81. package/presets/codex/skills/pagespeed-insights/SKILL.md +443 -0
  82. package/presets/codex/skills/pagespeed-insights/reference.md +50 -0
  83. package/presets/codex/skills/pagespeed-perf/SKILL.md +279 -0
  84. package/presets/codex/skills/php-pro/SKILL.md +208 -0
  85. package/presets/codex/skills/php-pro/references/async-patterns.md +412 -0
  86. package/presets/codex/skills/php-pro/references/laravel-patterns.md +377 -0
  87. package/presets/codex/skills/php-pro/references/modern-php-features.md +323 -0
  88. package/presets/codex/skills/php-pro/references/symfony-patterns.md +466 -0
  89. package/presets/codex/skills/php-pro/references/testing-quality.md +466 -0
  90. package/presets/codex/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  91. package/presets/codex/skills/workflow-orchestration-patterns/references/details.md +223 -0
  92. package/presets/opencode/README.md +11 -10
  93. package/presets/opencode/agents/orchestrator.md +121 -1
  94. package/presets/opencode/agents/reviewer.md +31 -0
  95. package/presets/opencode/commands/cc-pagespeed.md +100 -0
  96. package/presets/opencode/prompts/v0.3.0/architect.md +221 -0
  97. package/presets/opencode/prompts/v0.3.0/docs.md +189 -0
  98. package/presets/opencode/prompts/v0.3.0/implementer.md +162 -0
  99. package/presets/opencode/prompts/v0.3.0/orchestrator.md +360 -0
  100. package/presets/opencode/prompts/v0.3.0/repo-explorer.md +110 -0
  101. package/presets/opencode/prompts/v0.3.0/reviewer.md +225 -0
  102. package/presets/opencode/prompts/v0.3.0/task-coach.md +155 -0
  103. package/presets/opencode/prompts/v0.3.0/tester.md +251 -0
  104. package/presets/opencode/skills/android/SKILL.md +119 -0
  105. package/presets/opencode/skills/conductor-setup/SKILL.md +125 -0
  106. package/presets/opencode/skills/find-skills/SKILL.md +142 -0
  107. package/presets/opencode/skills/laravel-specialist/SKILL.md +264 -0
  108. package/presets/opencode/skills/laravel-specialist/references/eloquent.md +351 -0
  109. package/presets/opencode/skills/laravel-specialist/references/livewire.md +512 -0
  110. package/presets/opencode/skills/laravel-specialist/references/queues.md +423 -0
  111. package/presets/opencode/skills/laravel-specialist/references/routing.md +362 -0
  112. package/presets/opencode/skills/laravel-specialist/references/testing.md +522 -0
  113. package/presets/opencode/skills/multi-agent-orchestration/README.md +144 -0
  114. package/presets/opencode/skills/multi-agent-orchestration/SKILL.md +579 -0
  115. package/presets/opencode/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  116. package/presets/opencode/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  117. package/presets/opencode/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  118. package/presets/opencode/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  119. package/presets/opencode/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  120. package/presets/opencode/skills/pagespeed-insights/SKILL.md +443 -0
  121. package/presets/opencode/skills/pagespeed-insights/reference.md +50 -0
  122. package/presets/opencode/skills/pagespeed-perf/SKILL.md +279 -0
  123. package/presets/opencode/skills/php-pro/SKILL.md +208 -0
  124. package/presets/opencode/skills/php-pro/references/async-patterns.md +412 -0
  125. package/presets/opencode/skills/php-pro/references/laravel-patterns.md +377 -0
  126. package/presets/opencode/skills/php-pro/references/modern-php-features.md +323 -0
  127. package/presets/opencode/skills/php-pro/references/symfony-patterns.md +466 -0
  128. package/presets/opencode/skills/php-pro/references/testing-quality.md +466 -0
  129. package/presets/opencode/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  130. package/presets/opencode/skills/workflow-orchestration-patterns/references/details.md +223 -0
  131. package/presets/seo-hotel/commands/cc-seo-audit.md +17 -9
  132. package/presets/seo-hotel/settings.json +225 -0
  133. package/presets/seo-hotel/skills/find-skills/SKILL.md +142 -0
  134. package/presets/seo-hotel/skills/pagespeed-insights/SKILL.md +443 -0
  135. package/presets/seo-hotel/skills/pagespeed-insights/reference.md +50 -0
  136. package/src/presets/manifests/agy.yml +38 -3
  137. package/src/presets/manifests/claude.yml +8 -2
  138. package/src/presets/manifests/codex.yml +3 -2
  139. package/src/presets/manifests/cursor.yml +3 -2
  140. package/src/presets/manifests/gemini.yml +3 -2
  141. package/src/presets/manifests/opencode.yml +7 -2
  142. package/src/presets/models/agy.yml +16 -0
  143. package/src/presets/models/opencode.yml +6 -6
@@ -0,0 +1,279 @@
1
+ ---
2
+ id: pagespeed-perf
3
+ version: 1.0.0
4
+ name: PageSpeed Performance Audit
5
+ description: >
6
+ Web Performance Engineering — analyzes Core Web Vitals using the PageSpeed
7
+ Insights API (PSI v5) and applies the 80/20 principle: identify the 20% of
8
+ changes that produce 80% of the performance gain. Produces a prioritized
9
+ markdown report with quantified estimates and framework-specific code.
10
+ Trigger: When auditing page speed, analyzing Core Web Vitals, or optimizing
11
+ web performance for any URL.
12
+
13
+ user-invokable: true
14
+ license: MIT
15
+ metadata:
16
+ author: codeconductor
17
+ category: performance
18
+
19
+ compatibility:
20
+ tools: [claude, codex, gemini, agy, opencode]
21
+ stacks:
22
+ languages: []
23
+ frameworks: [astro, nextjs, react, vue, django, spring, wordpress]
24
+
25
+ risk:
26
+ level: medium
27
+ can_execute_shell: true
28
+ can_modify_files: false
29
+ requires_network: true
30
+
31
+ inputs:
32
+ - name: url
33
+ type: string
34
+ required: true
35
+ description: Full URL to audit (must include scheme: https://...)
36
+ - name: strategy
37
+ type: string
38
+ required: false
39
+ description: "mobile | desktop | both (default: both)"
40
+
41
+ outputs:
42
+ - name: report
43
+ type: markdown
44
+ description: >
45
+ Prioritized performance report saved as
46
+ {YYYY-MM-DD}_pagespeed-{hostname}-claude.md in the current directory.
47
+
48
+ quality:
49
+ reviewed_by: codeconductor-core
50
+ version: 1.0.0
51
+ ---
52
+
53
+ # PageSpeed Performance Audit — Web Performance Engineering (80/20)
54
+
55
+ ## Role and Purpose
56
+
57
+ Act as **Senior Web Performance Engineer, Frontend Architect, and Technical
58
+ Auditor**.
59
+
60
+ Always access the real site, measure real metrics via the PageSpeed Insights
61
+ API, analyze resources with the greatest impact, and produce a prioritized
62
+ Spanish-language report following the 80/20 principle: the **20% of critical
63
+ changes that produce 80% of the performance improvement**.
64
+
65
+ Never give generic recommendations. Every finding must be backed by data
66
+ observed from the specific URL being audited.
67
+
68
+ ---
69
+
70
+ ## Step 0 — Pre-flight: API Key and Output Filename
71
+
72
+ **MANDATORY. Execute before any analysis.**
73
+
74
+ ### 1. Read the API key from the environment
75
+
76
+ ```powershell
77
+ $env:PAGESPEED_API_KEY
78
+ ```
79
+
80
+ - Value present → store as `{API_KEY}`, use in all PSI calls.
81
+ - Empty → proceed without key (CrUX field data unavailable; rate limits apply).
82
+
83
+ ### 2. Define the output filename
84
+
85
+ ```powershell
86
+ $date = (Get-Date -Format "yyyy-MM-dd")
87
+ $website = ([System.Uri]"{URL}").Host -replace '[^a-zA-Z0-9]', '-'
88
+ $out = "${date}_pagespeed-${website}-claude.md"
89
+ Write-Host $out
90
+ ```
91
+
92
+ The final report **must** be written to this file.
93
+
94
+ ---
95
+
96
+ ## Data Collection
97
+
98
+ ### Primary Method — Bun Scripts (always try first)
99
+
100
+ ```powershell
101
+ bun --version # if available, use Primary Method; otherwise use Fallback
102
+ $skillDir = "$env:USERPROFILE\.claude\skills\pagespeed-perf\scripts"
103
+ bun run "$skillDir\run.ts" --url={URL}
104
+ ```
105
+
106
+ `run.ts` calls `psi-collect.ts` and `html-audit.ts` in parallel and returns
107
+ structured JSON. Key output fields:
108
+
109
+ ```
110
+ output.summary.mobileScore → Lighthouse mobile score (0-100)
111
+ output.summary.desktopScore → Lighthouse desktop score
112
+ output.summary.passesCWV → boolean — passes real CWV
113
+ output.summary.top5Actions → array ordered by 80/20 score
114
+
115
+ output.psi.mobile.lab.lcp → LCP (lab, mobile)
116
+ output.psi.mobile.lab.tbt → TBT
117
+ output.psi.mobile.lab.cls → CLS
118
+ output.psi.mobile.lab.fcp → FCP
119
+ output.psi.mobile.lab.ttfb → TTFB
120
+ output.psi.mobile.field → CrUX data (null if no key / no data)
121
+ output.psi.mobile.opportunities → array ordered by impact80_20 desc
122
+ output.psi.mobile.lcpElement → HTML snippet of the LCP element
123
+ output.psi.mobile.thirdParties → third-party scripts with blockingTime
124
+ output.psi.mobile.usedApiKey → boolean — confirms key was used
125
+
126
+ output.html.stack → detected framework / CMS
127
+ output.html.resourceHints → preloads, preconnects, prefetches
128
+ output.html.images → lazy, fetchpriority, list
129
+ output.html.scripts → blocking in <head>, third-party list
130
+ output.html.fonts → googleFonts, font-display, preloaded
131
+ output.html.issues → ordered by impact80_20
132
+ ```
133
+
134
+ ### Fallback Method — WebFetch (only if Bun unavailable)
135
+
136
+ ```
137
+ # With API key (preferred)
138
+ https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url={URL}&strategy=mobile&category=performance&key={API_KEY}
139
+ https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url={URL}&strategy=desktop&category=performance&key={API_KEY}
140
+
141
+ # Without key (rate-limited)
142
+ https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url={URL}&strategy=mobile&category=performance
143
+ ```
144
+
145
+ Key PSI response paths:
146
+
147
+ ```
148
+ lighthouseResult.categories.performance.score
149
+ lighthouseResult.audits.largest-contentful-paint
150
+ lighthouseResult.audits.total-blocking-time
151
+ lighthouseResult.audits.cumulative-layout-shift
152
+ lighthouseResult.audits.first-contentful-paint
153
+ lighthouseResult.audits.server-response-time
154
+ lighthouseResult.audits.largest-contentful-paint-element.details.items[0]
155
+ lighthouseResult.audits.render-blocking-resources.details.overallSavingsMs
156
+ lighthouseResult.audits.unused-javascript.details.overallSavingsBytes
157
+ lighthouseResult.audits.third-party-summary.details.items
158
+
159
+ loadingExperience.metrics.LARGEST_CONTENTFUL_PAINT_MS.percentile (CrUX)
160
+ loadingExperience.metrics.INTERACTION_TO_NEXT_PAINT.percentile (CrUX)
161
+ loadingExperience.metrics.CUMULATIVE_LAYOUT_SHIFT_SCORE.percentile (CrUX)
162
+ loadingExperience.overall_category → "FAST" | "AVERAGE" | "SLOW"
163
+ ```
164
+
165
+ Also fetch the site HTML via WebFetch and inspect the `<head>` for resource
166
+ hints, lazy loading, `fetchpriority`, `font-display`, blocking scripts, and
167
+ images without explicit dimensions.
168
+
169
+ ---
170
+
171
+ ## Core Web Vitals — Thresholds
172
+
173
+ | Metric | Good | Needs Improvement | Critical | Score weight |
174
+ | ------ | -------- | ----------------- | --------- | ------------ |
175
+ | LCP | ≤ 2.5 s | 2.5 s – 4.0 s | > 4.0 s | 25% |
176
+ | INP | ≤ 200 ms | 200 ms – 500 ms | > 500 ms | 10% |
177
+ | CLS | ≤ 0.1 | 0.1 – 0.25 | > 0.25 | 15% |
178
+ | FCP | ≤ 1.8 s | 1.8 s – 3.0 s | > 3.0 s | 10% |
179
+ | TBT | ≤ 200 ms | 200 ms – 600 ms | > 600 ms | 30% |
180
+ | TTFB | ≤ 800 ms | 800 ms – 1.8 s | > 1.8 s | — |
181
+
182
+ LCP + TBT represent 55% of the Lighthouse Performance Score.
183
+
184
+ ---
185
+
186
+ ## 80/20 Optimization Matrix
187
+
188
+ Score = `Impact (1–5) × Ease (1–5)`. Prioritize by descending score.
189
+
190
+ | Rank | Optimization | Primary metric | Impact | Ease | Score |
191
+ | ---- | --------------------------------- | -------------- | ------ | ---- | ----- |
192
+ | 1 | Preload LCP element | LCP | 5 | 5 | **25** |
193
+ | 1 | `fetchpriority="high"` on LCP img | LCP | 5 | 5 | **25** |
194
+ | 1 | Gzip / Brotli compression | FCP, LCP, TBT | 5 | 5 | **25** |
195
+ | 4 | WebP + explicit dimensions | LCP, CLS | 5 | 4 | **20** |
196
+ | 4 | Lazy loading offscreen images | LCP, TBT | 4 | 5 | **20** |
197
+ | 4 | `font-display: swap` | FCP | 4 | 5 | **20** |
198
+ | 4 | `preconnect` to critical origins | FCP, LCP, TTFB | 4 | 5 | **20** |
199
+ | 4 | Defer / facade third-party scripts| TBT, INP | 5 | 4 | **20** |
200
+ | 9 | Remove render-blocking resources | FCP, LCP | 5 | 3 | **15** |
201
+ | 9 | Long Cache-Control for assets | repeat visits | 3 | 5 | **15** |
202
+ | 11 | Remove unused JavaScript | TBT, INP | 4 | 3 | **12** |
203
+ | 12 | Remove unused CSS | FCP, TBT | 3 | 3 | **9** |
204
+ | 13 | CDN for static assets | TTFB, LCP | 4 | 2 | **8** |
205
+ | 14 | Code splitting | TBT, INP | 4 | 2 | **8** |
206
+
207
+ **Critical 20% (Score ≥ 20)** — address these first:
208
+ 1. Preload LCP element + `fetchpriority="high"`
209
+ 2. Brotli/Gzip compression at the server
210
+ 3. WebP images with explicit `width`/`height`
211
+ 4. Lazy loading of offscreen images
212
+ 5. `font-display: swap` for all fonts
213
+ 6. `preconnect` to all critical origins
214
+ 7. Defer or facade all third-party scripts
215
+
216
+ ---
217
+
218
+ ## Expected Impact by Optimization
219
+
220
+ | Optimization | Metric | Expected gain |
221
+ | ---------------------- | -------- | --------------------- |
222
+ | Preload + fetchpriority| LCP | −0.5 s to −2.0 s |
223
+ | Brotli compression | FCP, LCP | −0.3 s to −1.0 s |
224
+ | WebP + dimensions | LCP, CLS | −0.3 s to −1.2 s |
225
+ | Lazy loading | LCP | −0.2 s to −0.8 s |
226
+ | font-display: swap | FCP | −0.2 s to −0.8 s |
227
+ | preconnect | FCP, LCP | −0.1 s to −0.4 s each|
228
+ | Defer third parties | TBT, INP | −50 ms to −300 ms |
229
+
230
+ ---
231
+
232
+ ## Report Format (mandatory structure)
233
+
234
+ Save to `{YYYY-MM-DD}_pagespeed-{hostname}-claude.md`:
235
+
236
+ ```markdown
237
+ # Auditoría de Rendimiento Web — {URL}
238
+ Fecha: {YYYY-MM-DD} | Estrategia: Móvil + Escritorio | Archivo: {filename}.md
239
+
240
+ ## Resumen Ejecutivo
241
+ [2-3 párrafos: estado actual, score, bottleneck principal, potencial de mejora]
242
+
243
+ ## Métricas Actuales
244
+ [Tabla: Lab (Lighthouse) vs Campo (CrUX)]
245
+
246
+ ## Recursos con Mayor Impacto
247
+ [Tabla: URL, Tipo, Tamaño, Tiempo, Impacto, Razón]
248
+
249
+ ## Plan de Acción Priorizado (80/20)
250
+ [Tabla ordenada por Score 80/20 descendente]
251
+
252
+ ## Solución Técnica Detallada
253
+ [Por hallazgo: Problema, Evidencia, Implementación, Código, Impacto Esperado]
254
+
255
+ ## Quick Wins (< 1 day)
256
+ ## High Impact Changes
257
+ ## Roadmap
258
+ - Fase 1 — Inmediato (Semana 1)
259
+ - Fase 2 — Corto Plazo (2–4 semanas)
260
+ - Fase 3 — Mediano Plazo (1–3 meses)
261
+
262
+ ---
263
+ *Informe generado el {YYYY-MM-DD} · Herramienta: Claude Code + pagespeed-perf skill*
264
+ *API Key usada: {Sí / No} · Datos CrUX: {Disponibles / No disponibles}*
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Quality Rules — Never Violate
270
+
271
+ 1. **No data = no recommendation.** If PSI fails, try WebFetch directly.
272
+ 2. **Always quantify.** "Reduces LCP from 4.2 s to ~3.0 s" — never "would improve LCP".
273
+ 3. **Explicit evidence.** Cite the observed metric value for every finding.
274
+ 4. **Site-specific code.** Adapt templates to the detected framework (Next.js,
275
+ Astro, Django, etc.). Do not paste generic snippets unchanged.
276
+ 5. **80/20 order.** Always sort the action plan by descending score.
277
+ 6. **Separate field vs lab data.** CrUX = real user experience. Lighthouse = controlled lab.
278
+ 7. **Identify the framework.** Detect Next.js, Astro, Vue, WordPress, etc., and
279
+ provide framework-specific code samples.
@@ -0,0 +1,208 @@
1
+ ---
2
+ name: php-pro
3
+ description: Use when building PHP applications with modern PHP 8.3+ features, Laravel, or Symfony frameworks. Invokes strict typing, PHPStan level 9, async patterns with Swoole, and PSR standards. Creates controllers, configures middleware, generates migrations, writes PHPUnit/Pest tests, defines typed DTOs and value objects, sets up dependency injection, and scaffolds REST/GraphQL APIs. Use when working with Eloquent, Doctrine, Composer, Psalm, ReactPHP, or any PHP API development.
4
+ license: MIT
5
+ metadata:
6
+ author: https://github.com/Jeffallan
7
+ version: "1.1.0"
8
+ domain: language
9
+ triggers: PHP, Laravel, Symfony, Composer, PHPStan, PSR, PHP API, Eloquent, Doctrine
10
+ role: specialist
11
+ scope: implementation
12
+ output-format: code
13
+ related-skills: fullstack-guardian, fastapi-expert
14
+ ---
15
+
16
+ # PHP Pro
17
+
18
+ Senior PHP developer with deep expertise in PHP 8.3+, Laravel, Symfony, and modern PHP patterns with strict typing and enterprise architecture.
19
+
20
+ ## Core Workflow
21
+
22
+ 1. **Analyze architecture** — Review framework, PHP version, dependencies, and patterns
23
+ 2. **Design models** — Create typed domain models, value objects, DTOs
24
+ 3. **Implement** — Write strict-typed code with PSR compliance, DI, repositories
25
+ 4. **Secure** — Add validation, authentication, XSS/SQL injection protection
26
+ 5. **Verify** — Run `vendor/bin/phpstan analyse --level=9`; fix all errors before proceeding. Run `vendor/bin/phpunit` or `vendor/bin/pest`; enforce 80%+ coverage. Only deliver when both pass clean.
27
+
28
+ ## Reference Guide
29
+
30
+ Load detailed guidance based on context:
31
+
32
+ | Topic | Reference | Load When |
33
+ |-------|-----------|-----------|
34
+ | Modern PHP | `references/modern-php-features.md` | Readonly, enums, attributes, fibers, types |
35
+ | Laravel | `references/laravel-patterns.md` | Services, repositories, resources, jobs |
36
+ | Symfony | `references/symfony-patterns.md` | DI, events, commands, voters |
37
+ | Async PHP | `references/async-patterns.md` | Swoole, ReactPHP, fibers, streams |
38
+ | Testing | `references/testing-quality.md` | PHPUnit, PHPStan, Pest, mocking |
39
+
40
+ ## Constraints
41
+
42
+ ### MUST DO
43
+ - Declare strict types (`declare(strict_types=1)`)
44
+ - Use type hints for all properties, parameters, returns
45
+ - Follow PSR-12 coding standard
46
+ - Run PHPStan level 9 before delivery
47
+ - Use readonly properties where applicable
48
+ - Write PHPDoc blocks for complex logic
49
+ - Validate all user input with typed requests
50
+ - Use dependency injection over global state
51
+
52
+ ### MUST NOT DO
53
+ - Skip type declarations (no mixed types)
54
+ - Store passwords in plain text (use bcrypt/argon2)
55
+ - Write SQL queries vulnerable to injection
56
+ - Mix business logic with controllers
57
+ - Hardcode configuration (use .env)
58
+ - Deploy without running tests and static analysis
59
+ - Use var_dump in production code
60
+
61
+ ## Code Patterns
62
+
63
+ Every complete implementation delivers: a typed entity/DTO, a service class, and a test. Use these as the baseline structure.
64
+
65
+ ### Readonly DTO / Value Object
66
+
67
+ ```php
68
+ <?php
69
+
70
+ declare(strict_types=1);
71
+
72
+ namespace App\DTO;
73
+
74
+ final readonly class CreateUserDTO
75
+ {
76
+ public function __construct(
77
+ public string $name,
78
+ public string $email,
79
+ public string $password,
80
+ ) {}
81
+
82
+ public static function fromArray(array $data): self
83
+ {
84
+ return new self(
85
+ name: $data['name'],
86
+ email: $data['email'],
87
+ password: $data['password'],
88
+ );
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Typed Service with Constructor DI
94
+
95
+ ```php
96
+ <?php
97
+
98
+ declare(strict_types=1);
99
+
100
+ namespace App\Services;
101
+
102
+ use App\DTO\CreateUserDTO;
103
+ use App\Models\User;
104
+ use App\Repositories\UserRepositoryInterface;
105
+ use Illuminate\Support\Facades\Hash;
106
+
107
+ final class UserService
108
+ {
109
+ public function __construct(
110
+ private readonly UserRepositoryInterface $users,
111
+ ) {}
112
+
113
+ public function create(CreateUserDTO $dto): User
114
+ {
115
+ return $this->users->create([
116
+ 'name' => $dto->name,
117
+ 'email' => $dto->email,
118
+ 'password' => Hash::make($dto->password),
119
+ ]);
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### PHPUnit Test Structure
125
+
126
+ ```php
127
+ <?php
128
+
129
+ declare(strict_types=1);
130
+
131
+ namespace Tests\Unit\Services;
132
+
133
+ use App\DTO\CreateUserDTO;
134
+ use App\Models\User;
135
+ use App\Repositories\UserRepositoryInterface;
136
+ use App\Services\UserService;
137
+ use PHPUnit\Framework\MockObject\MockObject;
138
+ use PHPUnit\Framework\TestCase;
139
+
140
+ final class UserServiceTest extends TestCase
141
+ {
142
+ private UserRepositoryInterface&MockObject $users;
143
+ private UserService $service;
144
+
145
+ protected function setUp(): void
146
+ {
147
+ parent::setUp();
148
+ $this->users = $this->createMock(UserRepositoryInterface::class);
149
+ $this->service = new UserService($this->users);
150
+ }
151
+
152
+ public function testCreateHashesPassword(): void
153
+ {
154
+ $dto = new CreateUserDTO('Alice', 'alice@example.com', 'secret');
155
+ $user = new User(['name' => 'Alice', 'email' => 'alice@example.com']);
156
+
157
+ $this->users
158
+ ->expects($this->once())
159
+ ->method('create')
160
+ ->willReturn($user);
161
+
162
+ $result = $this->service->create($dto);
163
+
164
+ $this->assertSame('Alice', $result->name);
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### Enum (PHP 8.1+)
170
+
171
+ ```php
172
+ <?php
173
+
174
+ declare(strict_types=1);
175
+
176
+ namespace App\Enums;
177
+
178
+ enum UserStatus: string
179
+ {
180
+ case Active = 'active';
181
+ case Inactive = 'inactive';
182
+ case Banned = 'banned';
183
+
184
+ public function label(): string
185
+ {
186
+ return match($this) {
187
+ self::Active => 'Active',
188
+ self::Inactive => 'Inactive',
189
+ self::Banned => 'Banned',
190
+ };
191
+ }
192
+ }
193
+ ```
194
+
195
+ ## Output Templates
196
+
197
+ When implementing a feature, deliver in this order:
198
+ 1. Domain models (entities, value objects, enums)
199
+ 2. Service/repository classes
200
+ 3. Controller/API endpoints
201
+ 4. Test files (PHPUnit/Pest)
202
+ 5. Brief explanation of architecture decisions
203
+
204
+ ## Knowledge Reference
205
+
206
+ PHP 8.3+, Laravel 11, Symfony 7, Composer, PHPStan, Psalm, PHPUnit, Pest, Eloquent ORM, Doctrine, PSR standards, Swoole, ReactPHP, Redis, MySQL/PostgreSQL, REST/GraphQL APIs
207
+
208
+ [Documentation](https://jeffallan.github.io/claude-skills/skills/language/php-pro/)