cc-codeconductor 0.2.9 → 0.2.10

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 (90) hide show
  1. package/README.md +105 -25
  2. package/dist/index.js +165 -27
  3. package/package.json +1 -1
  4. package/presets/agy/AGENTS.md +354 -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 +13 -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/conductor-setup/SKILL.md +125 -0
  38. package/presets/claude/skills/find-skills/SKILL.md +142 -0
  39. package/presets/claude/skills/multi-agent-orchestration/README.md +144 -0
  40. package/presets/claude/skills/multi-agent-orchestration/SKILL.md +579 -0
  41. package/presets/claude/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  42. package/presets/claude/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  43. package/presets/claude/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  44. package/presets/claude/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  45. package/presets/claude/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  46. package/presets/claude/skills/pagespeed-insights/SKILL.md +443 -0
  47. package/presets/claude/skills/pagespeed-insights/reference.md +50 -0
  48. package/presets/claude/skills/pagespeed-perf/SKILL.md +279 -0
  49. package/presets/claude/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  50. package/presets/claude/skills/workflow-orchestration-patterns/references/details.md +223 -0
  51. package/presets/codex/AGENTS.md +19 -14
  52. package/presets/codex/skills/conductor-setup/SKILL.md +125 -0
  53. package/presets/codex/skills/find-skills/SKILL.md +142 -0
  54. package/presets/codex/skills/multi-agent-orchestration/README.md +144 -0
  55. package/presets/codex/skills/multi-agent-orchestration/SKILL.md +579 -0
  56. package/presets/codex/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  57. package/presets/codex/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  58. package/presets/codex/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  59. package/presets/codex/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  60. package/presets/codex/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  61. package/presets/codex/skills/pagespeed-insights/SKILL.md +443 -0
  62. package/presets/codex/skills/pagespeed-insights/reference.md +50 -0
  63. package/presets/codex/skills/pagespeed-perf/SKILL.md +279 -0
  64. package/presets/codex/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  65. package/presets/codex/skills/workflow-orchestration-patterns/references/details.md +223 -0
  66. package/presets/opencode/README.md +11 -10
  67. package/presets/opencode/commands/cc-pagespeed.md +100 -0
  68. package/presets/opencode/skills/conductor-setup/SKILL.md +125 -0
  69. package/presets/opencode/skills/find-skills/SKILL.md +142 -0
  70. package/presets/opencode/skills/multi-agent-orchestration/README.md +144 -0
  71. package/presets/opencode/skills/multi-agent-orchestration/SKILL.md +579 -0
  72. package/presets/opencode/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
  73. package/presets/opencode/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
  74. package/presets/opencode/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
  75. package/presets/opencode/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
  76. package/presets/opencode/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
  77. package/presets/opencode/skills/pagespeed-insights/SKILL.md +443 -0
  78. package/presets/opencode/skills/pagespeed-insights/reference.md +50 -0
  79. package/presets/opencode/skills/pagespeed-perf/SKILL.md +279 -0
  80. package/presets/opencode/skills/workflow-orchestration-patterns/SKILL.md +98 -0
  81. package/presets/opencode/skills/workflow-orchestration-patterns/references/details.md +223 -0
  82. package/presets/seo-hotel/commands/cc-seo-audit.md +17 -9
  83. package/presets/seo-hotel/settings.json +225 -0
  84. package/presets/seo-hotel/skills/find-skills/SKILL.md +142 -0
  85. package/presets/seo-hotel/skills/pagespeed-insights/SKILL.md +443 -0
  86. package/presets/seo-hotel/skills/pagespeed-insights/reference.md +50 -0
  87. package/src/presets/manifests/agy.yml +36 -2
  88. package/src/presets/manifests/claude.yml +5 -0
  89. package/src/presets/manifests/opencode.yml +4 -0
  90. package/src/presets/models/agy.yml +16 -0
@@ -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,98 @@
1
+ ---
2
+ name: workflow-orchestration-patterns
3
+ description: Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.
4
+ ---
5
+
6
+ # Workflow Orchestration Patterns
7
+
8
+ Master workflow orchestration architecture with Temporal, covering fundamental design decisions, resilience patterns, and best practices for building reliable distributed systems.
9
+
10
+ ## When to Use Workflow Orchestration
11
+
12
+ ### Ideal Use Cases (Source: docs.temporal.io)
13
+
14
+ - **Multi-step processes** spanning machines/services/databases
15
+ - **Distributed transactions** requiring all-or-nothing semantics
16
+ - **Long-running workflows** (hours to years) with automatic state persistence
17
+ - **Failure recovery** that must resume from last successful step
18
+ - **Business processes**: bookings, orders, campaigns, approvals
19
+ - **Entity lifecycle management**: inventory tracking, account management, cart workflows
20
+ - **Infrastructure automation**: CI/CD pipelines, provisioning, deployments
21
+ - **Human-in-the-loop** systems requiring timeouts and escalations
22
+
23
+ ### When NOT to Use
24
+
25
+ - Simple CRUD operations (use direct API calls)
26
+ - Pure data processing pipelines (use Airflow, batch processing)
27
+ - Stateless request/response (use standard APIs)
28
+ - Real-time streaming (use Kafka, event processors)
29
+
30
+ ## Detailed patterns and worked examples
31
+
32
+ Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
33
+
34
+ ## Best Practices
35
+
36
+ ### Workflow Design
37
+
38
+ 1. **Keep workflows focused** - Single responsibility per workflow
39
+ 2. **Small workflows** - Use child workflows for scalability
40
+ 3. **Clear boundaries** - Workflow orchestrates, activities execute
41
+ 4. **Test locally** - Use time-skipping test environment
42
+
43
+ ### Activity Design
44
+
45
+ 1. **Idempotent operations** - Safe to retry
46
+ 2. **Short-lived** - Seconds to minutes, not hours
47
+ 3. **Timeout configuration** - Always set timeouts
48
+ 4. **Heartbeat for long tasks** - Report progress
49
+ 5. **Error handling** - Distinguish retryable vs non-retryable
50
+
51
+ ### Common Pitfalls
52
+
53
+ **Workflow Violations**:
54
+
55
+ - Using `datetime.now()` instead of `workflow.now()`
56
+ - Threading or async operations in workflow code
57
+ - Calling external APIs directly from workflow
58
+ - Non-deterministic logic in workflows
59
+
60
+ **Activity Mistakes**:
61
+
62
+ - Non-idempotent operations (can't handle retries)
63
+ - Missing timeouts (activities run forever)
64
+ - No error classification (retry validation errors)
65
+ - Ignoring payload limits (2MB per argument)
66
+
67
+ ### Operational Considerations
68
+
69
+ **Monitoring**:
70
+
71
+ - Workflow execution duration
72
+ - Activity failure rates
73
+ - Retry attempts and backoff
74
+ - Pending workflow counts
75
+
76
+ **Scalability**:
77
+
78
+ - Horizontal scaling with workers
79
+ - Task queue partitioning
80
+ - Child workflow decomposition
81
+ - Activity batching when appropriate
82
+
83
+ ## Additional Resources
84
+
85
+ **Official Documentation**:
86
+
87
+ - Temporal Core Concepts: docs.temporal.io/workflows
88
+ - Workflow Patterns: docs.temporal.io/evaluate/use-cases-design-patterns
89
+ - Best Practices: docs.temporal.io/develop/best-practices
90
+ - Saga Pattern: temporal.io/blog/saga-pattern-made-easy
91
+
92
+ **Key Principles**:
93
+
94
+ 1. Workflows = orchestration, Activities = external calls
95
+ 2. Determinism is non-negotiable for workflows
96
+ 3. Idempotency is critical for activities
97
+ 4. State preservation is automatic
98
+ 5. Design for failure and recovery
@@ -0,0 +1,223 @@
1
+ # workflow-orchestration-patterns — detailed patterns and worked examples
2
+
3
+ ## Critical Design Decision: Workflows vs Activities
4
+
5
+ **The Fundamental Rule** (Source: temporal.io/blog/workflow-engine-principles):
6
+
7
+ - **Workflows** = Orchestration logic and decision-making
8
+ - **Activities** = External interactions (APIs, databases, network calls)
9
+
10
+ ### Workflows (Orchestration)
11
+
12
+ **Characteristics:**
13
+
14
+ - Contain business logic and coordination
15
+ - **MUST be deterministic** (same inputs → same outputs)
16
+ - **Cannot** perform direct external calls
17
+ - State automatically preserved across failures
18
+ - Can run for years despite infrastructure failures
19
+
20
+ **Example workflow tasks:**
21
+
22
+ - Decide which steps to execute
23
+ - Handle compensation logic
24
+ - Manage timeouts and retries
25
+ - Coordinate child workflows
26
+
27
+ ### Activities (External Interactions)
28
+
29
+ **Characteristics:**
30
+
31
+ - Handle all external system interactions
32
+ - Can be non-deterministic (API calls, DB writes)
33
+ - Include built-in timeouts and retry logic
34
+ - **Must be idempotent** (calling N times = calling once)
35
+ - Short-lived (seconds to minutes typically)
36
+
37
+ **Example activity tasks:**
38
+
39
+ - Call payment gateway API
40
+ - Write to database
41
+ - Send emails or notifications
42
+ - Query external services
43
+
44
+ ### Design Decision Framework
45
+
46
+ ```
47
+ Does it touch external systems? → Activity
48
+ Is it orchestration/decision logic? → Workflow
49
+ ```
50
+
51
+ ## Core Workflow Patterns
52
+
53
+ ### 1. Saga Pattern with Compensation
54
+
55
+ **Purpose**: Implement distributed transactions with rollback capability
56
+
57
+ **Pattern** (Source: temporal.io/blog/compensating-actions-part-of-a-complete-breakfast-with-sagas):
58
+
59
+ ```
60
+ For each step:
61
+ 1. Register compensation BEFORE executing
62
+ 2. Execute the step (via activity)
63
+ 3. On failure, run all compensations in reverse order (LIFO)
64
+ ```
65
+
66
+ **Example: Payment Workflow**
67
+
68
+ 1. Reserve inventory (compensation: release inventory)
69
+ 2. Charge payment (compensation: refund payment)
70
+ 3. Fulfill order (compensation: cancel fulfillment)
71
+
72
+ **Critical Requirements:**
73
+
74
+ - Compensations must be idempotent
75
+ - Register compensation BEFORE executing step
76
+ - Run compensations in reverse order
77
+ - Handle partial failures gracefully
78
+
79
+ ### 2. Entity Workflows (Actor Model)
80
+
81
+ **Purpose**: Long-lived workflow representing single entity instance
82
+
83
+ **Pattern** (Source: docs.temporal.io/evaluate/use-cases-design-patterns):
84
+
85
+ - One workflow execution = one entity (cart, account, inventory item)
86
+ - Workflow persists for entity lifetime
87
+ - Receives signals for state changes
88
+ - Supports queries for current state
89
+
90
+ **Example Use Cases:**
91
+
92
+ - Shopping cart (add items, checkout, expiration)
93
+ - Bank account (deposits, withdrawals, balance checks)
94
+ - Product inventory (stock updates, reservations)
95
+
96
+ **Benefits:**
97
+
98
+ - Encapsulates entity behavior
99
+ - Guarantees consistency per entity
100
+ - Natural event sourcing
101
+
102
+ ### 3. Fan-Out/Fan-In (Parallel Execution)
103
+
104
+ **Purpose**: Execute multiple tasks in parallel, aggregate results
105
+
106
+ **Pattern:**
107
+
108
+ - Spawn child workflows or parallel activities
109
+ - Wait for all to complete
110
+ - Aggregate results
111
+ - Handle partial failures
112
+
113
+ **Scaling Rule** (Source: temporal.io/blog/workflow-engine-principles):
114
+
115
+ - Don't scale individual workflows
116
+ - For 1M tasks: spawn 1K child workflows × 1K tasks each
117
+ - Keep each workflow bounded
118
+
119
+ ### 4. Async Callback Pattern
120
+
121
+ **Purpose**: Wait for external event or human approval
122
+
123
+ **Pattern:**
124
+
125
+ - Workflow sends request and waits for signal
126
+ - External system processes asynchronously
127
+ - Sends signal to resume workflow
128
+ - Workflow continues with response
129
+
130
+ **Use Cases:**
131
+
132
+ - Human approval workflows
133
+ - Webhook callbacks
134
+ - Long-running external processes
135
+
136
+ ## State Management and Determinism
137
+
138
+ ### Automatic State Preservation
139
+
140
+ **How Temporal Works** (Source: docs.temporal.io/workflows):
141
+
142
+ - Complete program state preserved automatically
143
+ - Event History records every command and event
144
+ - Seamless recovery from crashes
145
+ - Applications restore pre-failure state
146
+
147
+ ### Determinism Constraints
148
+
149
+ **Workflows Execute as State Machines**:
150
+
151
+ - Replay behavior must be consistent
152
+ - Same inputs → identical outputs every time
153
+
154
+ **Prohibited in Workflows** (Source: docs.temporal.io/workflows):
155
+
156
+ - ❌ Threading, locks, synchronization primitives
157
+ - ❌ Random number generation (`random()`)
158
+ - ❌ Global state or static variables
159
+ - ❌ System time (`datetime.now()`)
160
+ - ❌ Direct file I/O or network calls
161
+ - ❌ Non-deterministic libraries
162
+
163
+ **Allowed in Workflows**:
164
+
165
+ - ✅ `workflow.now()` (deterministic time)
166
+ - ✅ `workflow.random()` (deterministic random)
167
+ - ✅ Pure functions and calculations
168
+ - ✅ Calling activities (non-deterministic operations)
169
+
170
+ ### Versioning Strategies
171
+
172
+ **Challenge**: Changing workflow code while old executions still running
173
+
174
+ **Solutions**:
175
+
176
+ 1. **Versioning API**: Use `workflow.get_version()` for safe changes
177
+ 2. **New Workflow Type**: Create new workflow, route new executions to it
178
+ 3. **Backward Compatibility**: Ensure old events replay correctly
179
+
180
+ ## Resilience and Error Handling
181
+
182
+ ### Retry Policies
183
+
184
+ **Default Behavior**: Temporal retries activities forever
185
+
186
+ **Configure Retry**:
187
+
188
+ - Initial retry interval
189
+ - Backoff coefficient (exponential backoff)
190
+ - Maximum interval (cap retry delay)
191
+ - Maximum attempts (eventually fail)
192
+
193
+ **Non-Retryable Errors**:
194
+
195
+ - Invalid input (validation failures)
196
+ - Business rule violations
197
+ - Permanent failures (resource not found)
198
+
199
+ ### Idempotency Requirements
200
+
201
+ **Why Critical** (Source: docs.temporal.io/activities):
202
+
203
+ - Activities may execute multiple times
204
+ - Network failures trigger retries
205
+ - Duplicate execution must be safe
206
+
207
+ **Implementation Strategies**:
208
+
209
+ - Idempotency keys (deduplication)
210
+ - Check-then-act with unique constraints
211
+ - Upsert operations instead of insert
212
+ - Track processed request IDs
213
+
214
+ ### Activity Heartbeats
215
+
216
+ **Purpose**: Detect stalled long-running activities
217
+
218
+ **Pattern**:
219
+
220
+ - Activity sends periodic heartbeat
221
+ - Includes progress information
222
+ - Timeout if no heartbeat received
223
+ - Enables progress-based retry
@@ -2,6 +2,10 @@
2
2
 
3
3
  Run a comprehensive SEO and GEO audit on hotel and hospitality websites.
4
4
 
5
+ > Spanish prose/docs/reports/Markdown: preserve natural Spanish orthography,
6
+ > including accents, `ñ`, `¿`, `¡`, and normal Unicode. The ASCII-only editing
7
+ > preference does not apply to these artifacts.
8
+
5
9
  ## Usage
6
10
 
7
11
  ```
@@ -12,15 +16,15 @@ Run a comprehensive SEO and GEO audit on hotel and hospitality websites.
12
16
 
13
17
  ## Parameters
14
18
 
15
- | Parameter | Required | Description |
16
- |-----------|----------|-------------|
17
- | `--url` | One of `--url` or `--sitemap` | Single URL to audit |
19
+ | Parameter | Required | Description |
20
+ | ----------- | ----------------------------- | -------------------------------------------------------------- |
21
+ | `--url` | One of `--url` or `--sitemap` | Single URL to audit |
18
22
  | `--sitemap` | One of `--url` or `--sitemap` | Remote sitemap XML URL. Only URLs listed here will be audited. |
19
- | `--format` | No | Output format: `cli` (default) or `json` |
20
- | `--fail-on` | No | Exit code trigger: `error` (default) or `warning` |
21
- | `--astro` | No | Run Astro-specific SEO validation on source code |
22
- | `--path` | With `--astro` | Path to Astro source directory |
23
- | `--delay` | No | Delay between requests in ms (default: 500) |
23
+ | `--format` | No | Output format: `cli` (default) or `json` |
24
+ | `--fail-on` | No | Exit code trigger: `error` (default) or `warning` |
25
+ | `--astro` | No | Run Astro-specific SEO validation on source code |
26
+ | `--path` | With `--astro` | Path to Astro source directory |
27
+ | `--delay` | No | Delay between requests in ms (default: 500) |
24
28
 
25
29
  ## Workflow
26
30
 
@@ -55,7 +59,8 @@ Run a comprehensive SEO and GEO audit on hotel and hospitality websites.
55
59
 
56
60
  ## Hard Rules
57
61
 
58
- - **Sitemap-scoped only.** When `--sitemap` is provided, only audit URLs from the sitemap.
62
+ - **Sitemap-scoped only.** When `--sitemap` is provided, only audit URLs from
63
+ the sitemap.
59
64
  - **No external crawling.** Never follow hyperlinks found on pages.
60
65
  - **GET only.** No POST, PUT, DELETE requests.
61
66
  - **No auth.** Never send cookies, tokens, or API keys.
@@ -85,3 +90,6 @@ Run a comprehensive SEO and GEO audit on hotel and hospitality websites.
85
90
  - `geo-readiness` — AI-search readiness (GEO)
86
91
  - `astro-seo` — Astro framework SEO validation
87
92
  - `off-page` — Off-page SEO strategy guidance
93
+ - `pagespeed-insights` — Audit web pages for performance optimization following
94
+ PageSpeed Insights guidelines
95
+ - `find-skills` — Discover and install agent skills