@polymorphism-tech/morph-spec 2.3.0 → 3.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.
- package/CLAUDE.md +446 -1730
- package/README.md +515 -516
- package/bin/morph-spec.js +366 -294
- package/bin/task-manager.js +429 -368
- package/bin/validate.js +369 -268
- package/content/.claude/commands/morph-apply.md +221 -158
- package/content/.claude/commands/morph-deploy.md +529 -0
- package/content/.claude/commands/morph-preflight.md +227 -0
- package/content/.claude/commands/morph-proposal.md +122 -101
- package/content/.claude/commands/morph-status.md +86 -86
- package/content/.claude/commands/morph-troubleshoot.md +122 -0
- package/content/.claude/skills/infra/azure-deploy-specialist.md +699 -0
- package/content/.claude/skills/level-0-meta/README.md +7 -0
- package/content/.claude/skills/level-0-meta/code-review.md +226 -0
- package/content/.claude/skills/level-0-meta/morph-checklist.md +117 -0
- package/content/.claude/skills/level-0-meta/simulation-checklist.md +77 -0
- package/content/.claude/skills/level-1-workflows/README.md +7 -0
- package/content/.claude/skills/level-1-workflows/morph-replicate.md +213 -0
- package/content/.claude/{commands/morph-clarify.md → skills/level-1-workflows/phase-clarify.md} +131 -184
- package/content/.claude/{commands/morph-design.md → skills/level-1-workflows/phase-design.md} +213 -275
- package/content/.claude/skills/level-1-workflows/phase-setup.md +106 -0
- package/content/.claude/skills/level-1-workflows/phase-tasks.md +164 -0
- package/content/.claude/{commands/morph-uiux.md → skills/level-1-workflows/phase-uiux.md} +169 -211
- package/content/.claude/skills/level-2-domains/README.md +14 -0
- package/content/.claude/skills/level-2-domains/ai-agents/ai-system-architect.md +192 -0
- package/content/.claude/skills/{specialists → level-2-domains/architecture}/po-pm-advisor.md +197 -197
- package/content/.claude/skills/level-2-domains/architecture/standards-architect.md +156 -0
- package/content/.claude/skills/level-2-domains/backend/dotnet-senior.md +287 -0
- package/content/.claude/skills/level-2-domains/backend/ef-modeler.md +113 -0
- package/content/.claude/skills/level-2-domains/backend/hangfire-orchestrator.md +126 -0
- package/content/.claude/skills/level-2-domains/backend/ms-agent-expert.md +109 -0
- package/content/.claude/skills/level-2-domains/frontend/blazor-builder.md +210 -0
- package/content/.claude/skills/level-2-domains/frontend/nextjs-expert.md +154 -0
- package/content/.claude/skills/level-2-domains/frontend/ui-ux-designer.md +191 -0
- package/content/.claude/skills/{specialists → level-2-domains/infrastructure}/azure-architect.md +142 -142
- package/content/.claude/skills/level-2-domains/infrastructure/bicep-architect.md +126 -0
- package/content/.claude/skills/level-2-domains/infrastructure/container-specialist.md +131 -0
- package/content/.claude/skills/level-2-domains/infrastructure/devops-engineer.md +119 -0
- package/content/.claude/skills/level-2-domains/integrations/asaas-financial.md +130 -0
- package/content/.claude/skills/level-2-domains/integrations/azure-identity.md +142 -0
- package/content/.claude/skills/level-2-domains/integrations/clerk-auth.md +108 -0
- package/content/.claude/skills/level-2-domains/integrations/resend-email.md +119 -0
- package/content/.claude/skills/level-2-domains/quality/code-analyzer.md +235 -0
- package/content/.claude/skills/level-2-domains/quality/testing-specialist.md +126 -0
- package/content/.claude/skills/level-3-technologies/README.md +7 -0
- package/content/.claude/skills/level-4-patterns/README.md +7 -0
- package/content/.claude/skills/specialists/prompt-engineer.md +189 -0
- package/content/.claude/skills/specialists/seo-growth-hacker.md +320 -0
- package/content/.morph/config/agents.json +762 -242
- package/content/.morph/config/config.template.json +122 -108
- package/content/.morph/docs/workflows/design-impl.md +37 -0
- package/content/.morph/docs/workflows/enforcement-pipeline.md +668 -0
- package/content/.morph/docs/workflows/fast-track.md +29 -0
- package/content/.morph/docs/workflows/full-morph.md +76 -0
- package/content/.morph/docs/workflows/standard.md +44 -0
- package/content/.morph/docs/workflows/ui-refresh.md +39 -0
- package/content/.morph/examples/scheduled-reports/decisions.md +158 -0
- package/content/.morph/examples/scheduled-reports/proposal.md +95 -0
- package/content/.morph/examples/scheduled-reports/spec.md +267 -0
- package/content/.morph/hooks/README.md +348 -239
- package/content/.morph/hooks/pre-commit-agents.sh +24 -24
- package/content/.morph/hooks/task-completed.js +73 -0
- package/content/.morph/hooks/teammate-idle.js +68 -0
- package/content/.morph/schemas/tasks.schema.json +220 -0
- package/content/.morph/standards/agent-framework-blazor-ui.md +359 -0
- package/content/.morph/standards/agent-framework-production.md +410 -0
- package/content/.morph/standards/agent-framework-setup.md +413 -453
- package/content/.morph/standards/agent-framework-workflows.md +349 -0
- package/content/.morph/standards/agent-teams-workflow.md +474 -0
- package/content/.morph/standards/architecture.md +325 -325
- package/content/.morph/standards/azure.md +605 -379
- package/content/.morph/standards/dotnet10-migration.md +520 -494
- package/content/.morph/templates/CONTEXT-FEATURE.md +276 -0
- package/content/.morph/templates/CONTEXT.md +170 -0
- package/content/.morph/templates/agent.cs +163 -172
- package/content/.morph/templates/clarify-questions.md +159 -0
- package/content/.morph/templates/contracts/Commands.cs +74 -0
- package/content/.morph/templates/contracts/Entities.cs +25 -0
- package/content/.morph/templates/contracts/Queries.cs +74 -0
- package/content/.morph/templates/contracts/README.md +74 -0
- package/content/.morph/templates/decisions.md +123 -106
- package/content/.morph/templates/infra/azure-pipelines-deploy.yml +480 -0
- package/content/.morph/templates/infra/deploy-checklist.md +426 -0
- package/content/.morph/templates/proposal.md +141 -155
- package/content/.morph/templates/recap.md +94 -105
- package/content/.morph/templates/simulation.md +353 -0
- package/content/.morph/templates/spec.md +149 -148
- package/content/.morph/templates/state.template.json +222 -222
- package/content/.morph/templates/tasks.md +257 -235
- package/content/.morph/templates/ui-components.md +362 -276
- package/content/CLAUDE.md +150 -442
- package/detectors/structure-detector.js +245 -250
- package/docs/README.md +144 -149
- package/docs/getting-started.md +301 -302
- package/docs/installation.md +361 -361
- package/docs/validation-checklist.md +265 -266
- package/package.json +80 -80
- package/src/commands/advance-phase.js +266 -0
- package/src/commands/analyze-blazor-concurrency.js +193 -0
- package/src/commands/deploy.js +780 -0
- package/src/commands/detect-agents.js +167 -0
- package/src/commands/doctor.js +356 -280
- package/src/commands/generate-context.js +40 -0
- package/src/commands/init.js +258 -245
- package/src/commands/lint-fluent.js +352 -0
- package/src/commands/rollback-phase.js +185 -0
- package/src/commands/session-summary.js +291 -0
- package/src/commands/task.js +78 -75
- package/src/commands/troubleshoot.js +222 -0
- package/src/commands/update.js +192 -159
- package/src/commands/validate-blazor-state.js +210 -0
- package/src/commands/validate-blazor.js +156 -0
- package/src/commands/validate-css.js +84 -0
- package/src/commands/validate-phase.js +221 -0
- package/src/lib/blazor-concurrency-analyzer.js +288 -0
- package/src/lib/blazor-state-validator.js +291 -0
- package/src/lib/blazor-validator.js +374 -0
- package/src/lib/complexity-analyzer.js +441 -292
- package/src/lib/context-generator.js +513 -0
- package/src/lib/continuous-validator.js +421 -440
- package/src/lib/css-validator.js +352 -0
- package/src/lib/decision-constraint-loader.js +109 -0
- package/src/lib/design-system-detector.js +187 -0
- package/src/lib/design-system-scaffolder.js +299 -0
- package/src/lib/hook-executor.js +256 -0
- package/src/lib/recap-generator.js +205 -0
- package/src/lib/spec-validator.js +258 -0
- package/src/lib/standards-context-injector.js +287 -0
- package/src/lib/state-manager.js +397 -340
- package/src/lib/team-orchestrator.js +322 -0
- package/src/lib/troubleshoot-grep.js +194 -0
- package/src/lib/troubleshoot-index.js +144 -0
- package/src/lib/validation-runner.js +283 -0
- package/src/lib/validators/contract-compliance-validator.js +273 -0
- package/src/lib/validators/design-system-validator.js +231 -0
- package/src/utils/file-copier.js +187 -139
- package/content/.claude/commands/morph-costs.md +0 -206
- package/content/.claude/commands/morph-setup.md +0 -100
- package/content/.claude/commands/morph-tasks.md +0 -319
- package/content/.claude/skills/infra/bicep-architect.md +0 -419
- package/content/.claude/skills/infra/container-specialist.md +0 -437
- package/content/.claude/skills/infra/devops-engineer.md +0 -405
- package/content/.claude/skills/integrations/asaas-financial.md +0 -333
- package/content/.claude/skills/integrations/azure-identity.md +0 -309
- package/content/.claude/skills/integrations/clerk-auth.md +0 -290
- package/content/.claude/skills/specialists/ai-system-architect.md +0 -604
- package/content/.claude/skills/specialists/cost-guardian.md +0 -110
- package/content/.claude/skills/specialists/ef-modeler.md +0 -211
- package/content/.claude/skills/specialists/hangfire-orchestrator.md +0 -255
- package/content/.claude/skills/specialists/ms-agent-expert.md +0 -263
- package/content/.claude/skills/specialists/standards-architect.md +0 -78
- package/content/.claude/skills/specialists/ui-ux-designer.md +0 -1100
- package/content/.claude/skills/stacks/dotnet-blazor.md +0 -606
- package/content/.claude/skills/stacks/dotnet-nextjs.md +0 -402
- package/content/.claude/skills/stacks/shopify.md +0 -445
- package/content/.morph/config/azure-pricing.json +0 -70
- package/content/.morph/config/azure-pricing.schema.json +0 -50
- package/content/.morph/hooks/pre-commit-costs.sh +0 -91
- package/docs/api/cost-calculator.js.html +0 -513
- package/docs/api/design-system-generator.js.html +0 -382
- package/docs/api/global.html +0 -5263
- package/docs/api/index.html +0 -96
- package/docs/api/state-manager.js.html +0 -423
- package/src/commands/cost.js +0 -181
- package/src/commands/update-pricing.js +0 -206
- package/src/lib/cost-calculator.js +0 -429
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Code Analyzer
|
|
2
|
+
|
|
3
|
+
> **Layer:** 2 | **Load:** on-keyword | **Keywords:** analyze, review, refactor, clean, smell, duplicate, architecture, quality, debt, unused, dead code, code review, code quality
|
|
4
|
+
|
|
5
|
+
Deep code analysis specialist. Automates architecture review, clean code checks, and duplication detection.
|
|
6
|
+
|
|
7
|
+
> **Ref:** `framework/standards/coding.md` for naming conventions.
|
|
8
|
+
> **Ref:** `framework/standards/architecture.md` for architectural patterns.
|
|
9
|
+
> **Ref:** `.claude/skills/checklists/code-review.md` for runtime pattern checks.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to Run
|
|
14
|
+
|
|
15
|
+
| Trigger | Automatic? | Scope |
|
|
16
|
+
|---------|-----------|-------|
|
|
17
|
+
| FASE 5 completion (`/morph-apply` done) | Yes | Full feature code |
|
|
18
|
+
| Checkpoint (every 3 tasks) | Yes | Code since last checkpoint |
|
|
19
|
+
| Manual: `analyze`, `review code`, `code quality` | No | Specified scope |
|
|
20
|
+
| Pre-merge review | Recommended | All changed files |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 3 Analysis Modes
|
|
25
|
+
|
|
26
|
+
Run all 3 modes by default. Use `--mode architecture`, `--mode clean`, or `--mode duplication` for targeted analysis.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### Mode 1: Architecture Analysis
|
|
31
|
+
|
|
32
|
+
Analyze the codebase for structural and architectural issues.
|
|
33
|
+
|
|
34
|
+
#### Checklist
|
|
35
|
+
|
|
36
|
+
**Layer Integrity:**
|
|
37
|
+
- [ ] `[CRITICAL]` Domain project has zero references to Infrastructure or Web
|
|
38
|
+
- [ ] `[CRITICAL]` Application does NOT reference Web project
|
|
39
|
+
- [ ] `[HIGH]` No circular dependencies between projects
|
|
40
|
+
- [ ] `[HIGH]` Infrastructure details don't leak into Application (no EF types in DTOs)
|
|
41
|
+
|
|
42
|
+
**Responsibility Separation:**
|
|
43
|
+
- [ ] `[HIGH]` Each class has a single, clear responsibility (< 300 lines)
|
|
44
|
+
- [ ] `[HIGH]` Controllers/pages are thin (< 50 lines logic, delegate to services)
|
|
45
|
+
- [ ] `[MEDIUM]` Interfaces are focused (< 7 methods per interface)
|
|
46
|
+
- [ ] `[MEDIUM]` No "God classes" (classes with 10+ dependencies)
|
|
47
|
+
|
|
48
|
+
**Abstractions:**
|
|
49
|
+
- [ ] `[MEDIUM]` External services accessed through interfaces (testable)
|
|
50
|
+
- [ ] `[LOW]` No over-abstraction (interfaces with exactly 1 implementation that's never mocked)
|
|
51
|
+
- [ ] `[MEDIUM]` Missing abstractions: direct HTTP calls, file I/O, or DB access without interface
|
|
52
|
+
|
|
53
|
+
**File Organization:**
|
|
54
|
+
- [ ] `[MEDIUM]` One class per file (file name matches class name)
|
|
55
|
+
- [ ] `[MEDIUM]` Files in correct project/folder per architecture.md
|
|
56
|
+
- [ ] `[LOW]` Consistent folder structure across all layers
|
|
57
|
+
|
|
58
|
+
**Configuration:**
|
|
59
|
+
- [ ] `[HIGH]` No hardcoded connection strings, URLs, or secrets
|
|
60
|
+
- [ ] `[MEDIUM]` Configuration via Options pattern (`IOptions<T>`)
|
|
61
|
+
- [ ] `[LOW]` No duplicate configuration across projects
|
|
62
|
+
|
|
63
|
+
**Unused Code:**
|
|
64
|
+
- [ ] `[MEDIUM]` No unused classes or interfaces (search for zero references)
|
|
65
|
+
- [ ] `[MEDIUM]` No dead code paths (unreachable branches)
|
|
66
|
+
- [ ] `[LOW]` No commented-out code blocks (> 3 lines)
|
|
67
|
+
- [ ] `[LOW]` No empty or near-empty files (< 10 lines of actual code)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Mode 2: Clean Code Analysis
|
|
72
|
+
|
|
73
|
+
Analyze for code smells, style violations, and improvement opportunities.
|
|
74
|
+
|
|
75
|
+
#### Checklist
|
|
76
|
+
|
|
77
|
+
**Naming (ref: coding.md):**
|
|
78
|
+
- [ ] `[HIGH]` All naming follows coding.md conventions (PascalCase constants, _camelCase fields, etc.)
|
|
79
|
+
- [ ] `[HIGH]` No Hungarian notation (`strName`, `iCount`, `btnSubmit`)
|
|
80
|
+
- [ ] `[HIGH]` No ALL_CAPS constants (`MAX_RETRY` -> `MaxRetry`)
|
|
81
|
+
- [ ] `[MEDIUM]` Descriptive names (no `data`, `info`, `item`, `result` without context)
|
|
82
|
+
- [ ] `[MEDIUM]` No abbreviations in public APIs (`repo` -> `repository`)
|
|
83
|
+
|
|
84
|
+
**Method Quality:**
|
|
85
|
+
- [ ] `[HIGH]` No methods > 30 lines (extract sub-methods)
|
|
86
|
+
- [ ] `[HIGH]` No methods with > 4 parameters (use request object)
|
|
87
|
+
- [ ] `[MEDIUM]` No nested conditionals > 3 levels (extract or use early return)
|
|
88
|
+
- [ ] `[MEDIUM]` No complex conditionals (> 3 conditions in one `if` — extract to named bool or method)
|
|
89
|
+
|
|
90
|
+
**Class Quality:**
|
|
91
|
+
- [ ] `[HIGH]` No classes > 300 lines (SRP violation — split)
|
|
92
|
+
- [ ] `[HIGH]` No classes with > 7 constructor dependencies (God class — split)
|
|
93
|
+
- [ ] `[MEDIUM]` Classes are `sealed` unless designed for inheritance
|
|
94
|
+
|
|
95
|
+
**Magic Values:**
|
|
96
|
+
- [ ] `[HIGH]` No magic strings in comparisons (`if (status == "active")` -> use enum or constant)
|
|
97
|
+
- [ ] `[HIGH]` No magic numbers (`if (items.Count > 50)` -> extract `const int MaxItemsPerPage = 50`)
|
|
98
|
+
- [ ] `[MEDIUM]` No hardcoded URLs, file paths, or configuration values
|
|
99
|
+
|
|
100
|
+
**Dead Code:**
|
|
101
|
+
- [ ] `[MEDIUM]` No unused private methods (zero callers)
|
|
102
|
+
- [ ] `[MEDIUM]` No unused parameters in methods
|
|
103
|
+
- [ ] `[LOW]` No TODO/FIXME/HACK comments older than 2 sprints
|
|
104
|
+
- [ ] `[LOW]` No `#if DEBUG` blocks with substantial logic
|
|
105
|
+
|
|
106
|
+
**Error Handling:**
|
|
107
|
+
- [ ] `[CRITICAL]` No empty catch blocks
|
|
108
|
+
- [ ] `[HIGH]` No generic `catch (Exception)` without re-throw
|
|
109
|
+
- [ ] `[HIGH]` Result pattern used for business errors (not exceptions)
|
|
110
|
+
- [ ] `[MEDIUM]` Consistent error handling pattern across all services
|
|
111
|
+
|
|
112
|
+
**Logging:**
|
|
113
|
+
- [ ] `[HIGH]` No `$""` string interpolation in log methods (use message templates)
|
|
114
|
+
- [ ] `[HIGH]` Critical operations have entry/exit/error logging
|
|
115
|
+
- [ ] `[MEDIUM]` Log messages include correlation IDs (OrderId, UserId)
|
|
116
|
+
- [ ] `[MEDIUM]` Consistent log levels across similar operations
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### Mode 3: Duplication Detection
|
|
121
|
+
|
|
122
|
+
Find redundant, duplicate, and unnecessary code.
|
|
123
|
+
|
|
124
|
+
#### Targets
|
|
125
|
+
|
|
126
|
+
**Exact/Near-Exact Duplicates:**
|
|
127
|
+
- [ ] `[HIGH]` Methods with identical or near-identical logic in different classes
|
|
128
|
+
- Same method body, different class -> extract to shared service or extension
|
|
129
|
+
- Same logic with different types -> extract to generic method
|
|
130
|
+
- [ ] `[HIGH]` Repeated code blocks (> 5 lines identical in 2+ locations)
|
|
131
|
+
|
|
132
|
+
**Thin Wrappers:**
|
|
133
|
+
- [ ] `[MEDIUM]` Methods that only delegate to another method with same parameters
|
|
134
|
+
```csharp
|
|
135
|
+
// SMELL: Thin wrapper with no added value
|
|
136
|
+
public Task<Order> GetOrderAsync(int id, CancellationToken ct)
|
|
137
|
+
=> _innerService.GetOrderAsync(id, ct);
|
|
138
|
+
```
|
|
139
|
+
- [ ] `[MEDIUM]` Service methods that only call a repository method (no logic added)
|
|
140
|
+
|
|
141
|
+
**Interface Redundancy:**
|
|
142
|
+
- [ ] `[MEDIUM]` Same method signature appearing in multiple interfaces (extract base interface)
|
|
143
|
+
- [ ] `[LOW]` Interface that exactly mirrors another interface (merge or inherit)
|
|
144
|
+
|
|
145
|
+
**Passthrough Delegates:**
|
|
146
|
+
- [ ] `[MEDIUM]` Controller/page methods that only call one service method and return result
|
|
147
|
+
- If no validation, auth, or mapping: consider simplifying the layer
|
|
148
|
+
|
|
149
|
+
**DTO/Model Duplication:**
|
|
150
|
+
- [ ] `[HIGH]` Duplicate model definitions (same properties in different classes)
|
|
151
|
+
- [ ] `[MEDIUM]` Request/Response DTOs that are identical (merge or use shared base)
|
|
152
|
+
- [ ] `[MEDIUM]` Enums defined in multiple projects (centralize in Domain)
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Output Format
|
|
157
|
+
|
|
158
|
+
For each finding, report:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
### [{SEVERITY}] {Category}: {Short Description}
|
|
162
|
+
|
|
163
|
+
**File:** `path/to/file.cs:42`
|
|
164
|
+
**Rule:** {rule reference from checklist above}
|
|
165
|
+
|
|
166
|
+
**Current code:**
|
|
167
|
+
```csharp
|
|
168
|
+
// problematic code snippet
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Suggested fix:**
|
|
172
|
+
```csharp
|
|
173
|
+
// corrected code snippet
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Why:** {brief explanation of the problem and impact}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Summary Template
|
|
182
|
+
|
|
183
|
+
After analysis, generate a summary:
|
|
184
|
+
|
|
185
|
+
```markdown
|
|
186
|
+
## Code Analysis Summary
|
|
187
|
+
|
|
188
|
+
**Scope:** {files/feature analyzed}
|
|
189
|
+
**Date:** {date}
|
|
190
|
+
**Modes:** Architecture | Clean Code | Duplication
|
|
191
|
+
|
|
192
|
+
### Findings by Severity
|
|
193
|
+
|
|
194
|
+
| Severity | Count |
|
|
195
|
+
|----------|-------|
|
|
196
|
+
| CRITICAL | {n} |
|
|
197
|
+
| HIGH | {n} |
|
|
198
|
+
| MEDIUM | {n} |
|
|
199
|
+
| LOW | {n} |
|
|
200
|
+
|
|
201
|
+
### Top 5 Priorities
|
|
202
|
+
|
|
203
|
+
1. {Most critical finding with file:line}
|
|
204
|
+
2. {Second most critical}
|
|
205
|
+
3. ...
|
|
206
|
+
|
|
207
|
+
### Estimated Effort
|
|
208
|
+
|
|
209
|
+
| Category | Findings | Effort |
|
|
210
|
+
|----------|----------|--------|
|
|
211
|
+
| Quick fixes (naming, style) | {n} | ~{h}h |
|
|
212
|
+
| Refactoring (extraction, splitting) | {n} | ~{h}h |
|
|
213
|
+
| Architecture (layer changes) | {n} | ~{h}h |
|
|
214
|
+
|
|
215
|
+
### Recommendations
|
|
216
|
+
|
|
217
|
+
- {Key recommendation 1}
|
|
218
|
+
- {Key recommendation 2}
|
|
219
|
+
- {Key recommendation 3}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Integration with Other Specialists
|
|
225
|
+
|
|
226
|
+
| Specialist | Handoff |
|
|
227
|
+
|------------|---------|
|
|
228
|
+
| **Standards Architect** | Code Analyzer validates naming rules defined by Standards Architect |
|
|
229
|
+
| **.NET Senior Engineer** | Code Analyzer reviews code produced by dotnet-senior |
|
|
230
|
+
| **Code Review Checklist** | Code Analyzer runs architecture/clean code checks; code-review.md covers runtime patterns |
|
|
231
|
+
| **Testing Specialist** | Findings may generate new test requirements |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Testing Specialist
|
|
2
|
+
|
|
3
|
+
> **Layer:** 2 | **Load:** on-keyword | **Keywords:** test, testing, mock, fake, simulation, unit test, integration test
|
|
4
|
+
|
|
5
|
+
Especialista em testes, mocking e simulação para projetos .NET.
|
|
6
|
+
|
|
7
|
+
## Strategy
|
|
8
|
+
|
|
9
|
+
| Level | What | Tools |
|
|
10
|
+
|-------|------|-------|
|
|
11
|
+
| **Unit** | Business logic, domain, handlers | xUnit + Moq + FluentAssertions |
|
|
12
|
+
| **Integration** | API flows, DB operations | WebApplicationFactory + TestContainers |
|
|
13
|
+
| **Component** | Blazor rendering, events | bUnit |
|
|
14
|
+
| **E2E** | Critical user journeys | Playwright (if needed) |
|
|
15
|
+
|
|
16
|
+
**Focus:** Critical/complex code. Don't aim for 100%, aim for value. Cover edge cases and error paths.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Core Patterns
|
|
21
|
+
|
|
22
|
+
### AAA (Arrange-Act-Assert)
|
|
23
|
+
|
|
24
|
+
```csharp
|
|
25
|
+
[Fact]
|
|
26
|
+
public async Task CreateOrder_Should_ReturnSuccess_When_ValidInput()
|
|
27
|
+
{
|
|
28
|
+
// Arrange
|
|
29
|
+
var command = new CreateOrderCommand { CustomerId = 1, Items = [...] };
|
|
30
|
+
var handler = new CreateOrderHandler(_mockRepo.Object);
|
|
31
|
+
// Act
|
|
32
|
+
var result = await handler.Handle(command, CancellationToken.None);
|
|
33
|
+
// Assert
|
|
34
|
+
result.IsSuccess.Should().BeTrue();
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Naming Convention
|
|
39
|
+
```
|
|
40
|
+
[Method]_Should_[ExpectedResult]_When_[Condition]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Test Data Builders
|
|
44
|
+
Use builder pattern for complex test entities: `new OrderBuilder().WithCustomer(123).WithStatus(Completed).Build()`
|
|
45
|
+
|
|
46
|
+
### Mocking (Moq)
|
|
47
|
+
```csharp
|
|
48
|
+
var mockRepo = new Mock<IOrderRepository>();
|
|
49
|
+
mockRepo.Setup(r => r.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(new Order { Id = 1 });
|
|
50
|
+
mockRepo.Verify(r => r.SaveAsync(It.IsAny<Order>()), Times.Once);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Integration Tests (WebApplicationFactory)
|
|
54
|
+
Replace real DB with in-memory in `ConfigureServices`, use `CreateClient()` for HTTP calls.
|
|
55
|
+
|
|
56
|
+
### bUnit (Blazor)
|
|
57
|
+
`RenderComponent<Counter>()` → `Find("button").Click()` → assert `TextContent`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Libraries
|
|
62
|
+
|
|
63
|
+
| Library | Purpose | NuGet |
|
|
64
|
+
|---------|---------|-------|
|
|
65
|
+
| xUnit | Test framework | `xunit` |
|
|
66
|
+
| Moq | Mocking | `Moq` |
|
|
67
|
+
| FluentAssertions | Readable assertions | `FluentAssertions` |
|
|
68
|
+
| Bogus | Fake data | `Bogus` |
|
|
69
|
+
| TestContainers | DB containers | `Testcontainers` |
|
|
70
|
+
| Respawn | DB reset | `Respawn` |
|
|
71
|
+
| WireMock | HTTP mocking | `WireMock.Net` |
|
|
72
|
+
| bUnit | Blazor testing | `bunit` |
|
|
73
|
+
|
|
74
|
+
## Folder Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
tests/
|
|
78
|
+
├── Unit/{Domain,Application,Builders}/
|
|
79
|
+
├── Integration/{Api,Fixtures}/
|
|
80
|
+
└── E2E/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Anti-Patterns
|
|
84
|
+
1. **Fragile tests** — test behavior, not implementation
|
|
85
|
+
2. **Slow tests** — use mocks, not real DB for unit tests
|
|
86
|
+
3. **Coupled tests** — each test independent
|
|
87
|
+
4. **Vague assertions** — use specific FluentAssertions
|
|
88
|
+
5. **Giant setup** — extract to builders/fixtures
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Simulation of External Services
|
|
93
|
+
|
|
94
|
+
> **Ref:** `.claude/skills/checklists/simulation-checklist.md` for complete checklist
|
|
95
|
+
|
|
96
|
+
### Key Rules
|
|
97
|
+
|
|
98
|
+
| Mock Type | Characteristic | DI Lifetime |
|
|
99
|
+
|-----------|---------------|-------------|
|
|
100
|
+
| **Stateful** (Dictionary, List) | Keeps data between calls | `Singleton` |
|
|
101
|
+
| **Stateless** | No state | `Scoped` |
|
|
102
|
+
|
|
103
|
+
```csharp
|
|
104
|
+
// ❌ Stateful with Scoped = loses state between requests
|
|
105
|
+
services.AddScoped<IReplicateClient, FakeReplicateClient>();
|
|
106
|
+
// ✅ Stateful with Singleton
|
|
107
|
+
services.AddSingleton<IReplicateClient, FakeReplicateClient>();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Before implementing mocks:** Map ALL dependencies (interfaces, transitive deps, lifetimes).
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Checklists
|
|
115
|
+
|
|
116
|
+
### Per Test Type
|
|
117
|
+
| Target | Test |
|
|
118
|
+
|--------|------|
|
|
119
|
+
| Entity/Domain | Creation validation, state transitions (valid + invalid), invariants |
|
|
120
|
+
| Handler/Service | Happy path, invalid input, not found (404), auth error, timeout |
|
|
121
|
+
| API | Status codes, response body, request validation, auth |
|
|
122
|
+
| Blazor Component | Initial render, user events, states (loading/error/empty), form validation |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Prompt Engineer
|
|
2
|
+
|
|
3
|
+
Especialista em engenharia de prompts para LLMs e sistemas de IA. Use PROATIVAMENTE ao construir features de IA, melhorar performance de agentes ou criar system prompts.
|
|
4
|
+
|
|
5
|
+
## Responsabilidades
|
|
6
|
+
|
|
7
|
+
1. Criar prompts otimizados para LLMs
|
|
8
|
+
2. Aplicar técnicas avançadas de prompting
|
|
9
|
+
3. Definir formatos de output estruturados
|
|
10
|
+
4. Otimizar prompts existentes
|
|
11
|
+
5. Adaptar prompts para diferentes modelos
|
|
12
|
+
|
|
13
|
+
## Triggers
|
|
14
|
+
|
|
15
|
+
Keywords: `prompt`, `prompting`, `system prompt`, `few-shot`, `chain-of-thought`, `llm prompt`, `agent prompt`, `engenharia de prompt`
|
|
16
|
+
|
|
17
|
+
## Áreas de Expertise
|
|
18
|
+
|
|
19
|
+
### Otimização de Prompts
|
|
20
|
+
|
|
21
|
+
- Seleção few-shot vs zero-shot
|
|
22
|
+
- Raciocínio chain-of-thought
|
|
23
|
+
- Role-playing e definição de perspectiva
|
|
24
|
+
- Especificação de formato de output
|
|
25
|
+
- Definição de constraints e limites
|
|
26
|
+
|
|
27
|
+
### Arsenal de Técnicas
|
|
28
|
+
|
|
29
|
+
- Constitutional AI principles
|
|
30
|
+
- Recursive prompting
|
|
31
|
+
- Tree of thoughts
|
|
32
|
+
- Self-consistency checking
|
|
33
|
+
- Prompt chaining e pipelines
|
|
34
|
+
|
|
35
|
+
### Otimização por Modelo
|
|
36
|
+
|
|
37
|
+
- **Claude**: Ênfase em helpful, harmless, honest
|
|
38
|
+
- **GPT**: Estrutura clara e exemplos
|
|
39
|
+
- **Open models**: Necessidades específicas de formatação
|
|
40
|
+
- **Modelos especializados**: Adaptação de domínio
|
|
41
|
+
|
|
42
|
+
## Processo de Otimização
|
|
43
|
+
|
|
44
|
+
1. Analisar caso de uso pretendido
|
|
45
|
+
2. Identificar requisitos e constraints chave
|
|
46
|
+
3. Selecionar técnicas de prompting apropriadas
|
|
47
|
+
4. Criar prompt inicial com estrutura clara
|
|
48
|
+
5. Testar e iterar baseado em outputs
|
|
49
|
+
6. Documentar padrões efetivos
|
|
50
|
+
|
|
51
|
+
## Formato de Output Obrigatório
|
|
52
|
+
|
|
53
|
+
**IMPORTANTE:** SEMPRE que criar qualquer prompt, DEVE exibir o texto completo. NUNCA apenas descreva um prompt.
|
|
54
|
+
|
|
55
|
+
### O Prompt
|
|
56
|
+
```
|
|
57
|
+
[Exibir texto completo do prompt aqui]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Notas de Implementação
|
|
61
|
+
- Técnicas chave usadas
|
|
62
|
+
- Por que essas escolhas foram feitas
|
|
63
|
+
- Outcomes esperados
|
|
64
|
+
|
|
65
|
+
## Deliverables
|
|
66
|
+
|
|
67
|
+
- **O texto do prompt** (exibido completo, formatado)
|
|
68
|
+
- Explicação das escolhas de design
|
|
69
|
+
- Guidelines de uso
|
|
70
|
+
- Exemplos de outputs esperados
|
|
71
|
+
- Benchmarks de performance
|
|
72
|
+
- Estratégias de tratamento de erro
|
|
73
|
+
|
|
74
|
+
## Padrões Comuns
|
|
75
|
+
|
|
76
|
+
### Estrutura System/User/Assistant
|
|
77
|
+
```
|
|
78
|
+
<system>
|
|
79
|
+
[Contexto e personalidade]
|
|
80
|
+
</system>
|
|
81
|
+
|
|
82
|
+
<user>
|
|
83
|
+
[Input do usuário]
|
|
84
|
+
</user>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Tags XML para Seções Claras
|
|
88
|
+
```xml
|
|
89
|
+
<context>
|
|
90
|
+
[Background information]
|
|
91
|
+
</context>
|
|
92
|
+
|
|
93
|
+
<instructions>
|
|
94
|
+
[What to do]
|
|
95
|
+
</instructions>
|
|
96
|
+
|
|
97
|
+
<output_format>
|
|
98
|
+
[Expected format]
|
|
99
|
+
</output_format>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Outros Padrões
|
|
103
|
+
- Formatos de output explícitos
|
|
104
|
+
- Raciocínio passo-a-passo
|
|
105
|
+
- Critérios de auto-avaliação
|
|
106
|
+
|
|
107
|
+
## Exemplo de Output
|
|
108
|
+
|
|
109
|
+
Quando solicitado a criar prompt para code review:
|
|
110
|
+
|
|
111
|
+
### O Prompt
|
|
112
|
+
```
|
|
113
|
+
You are an expert code reviewer with 10+ years of experience. Review the provided code focusing on:
|
|
114
|
+
1. Security vulnerabilities
|
|
115
|
+
2. Performance optimizations
|
|
116
|
+
3. Code maintainability
|
|
117
|
+
4. Best practices
|
|
118
|
+
|
|
119
|
+
For each issue found, provide:
|
|
120
|
+
- Severity level (Critical/High/Medium/Low)
|
|
121
|
+
- Specific line numbers
|
|
122
|
+
- Explanation of the issue
|
|
123
|
+
- Suggested fix with code example
|
|
124
|
+
|
|
125
|
+
Format your response as a structured report with clear sections.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Notas de Implementação
|
|
129
|
+
- Usa role-playing para estabelecer expertise
|
|
130
|
+
- Fornece critérios de avaliação claros
|
|
131
|
+
- Especifica formato de output para consistência
|
|
132
|
+
- Inclui requisitos de feedback acionável
|
|
133
|
+
|
|
134
|
+
## Técnicas Avançadas
|
|
135
|
+
|
|
136
|
+
### Few-Shot Prompting
|
|
137
|
+
```
|
|
138
|
+
Here are examples of good responses:
|
|
139
|
+
|
|
140
|
+
Example 1:
|
|
141
|
+
Input: [example input]
|
|
142
|
+
Output: [example output]
|
|
143
|
+
|
|
144
|
+
Example 2:
|
|
145
|
+
Input: [example input]
|
|
146
|
+
Output: [example output]
|
|
147
|
+
|
|
148
|
+
Now process this:
|
|
149
|
+
Input: [actual input]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Chain-of-Thought
|
|
153
|
+
```
|
|
154
|
+
Think through this step by step:
|
|
155
|
+
1. First, identify...
|
|
156
|
+
2. Then, analyze...
|
|
157
|
+
3. Finally, conclude...
|
|
158
|
+
|
|
159
|
+
Show your reasoning before giving the final answer.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Self-Consistency
|
|
163
|
+
```
|
|
164
|
+
Generate 3 different approaches to solve this problem.
|
|
165
|
+
Compare the approaches and select the most robust one.
|
|
166
|
+
Explain why this approach is best.
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Checklist Antes de Completar
|
|
170
|
+
|
|
171
|
+
- [ ] Exibiu texto completo do prompt (não apenas descreveu)
|
|
172
|
+
- [ ] Marcou claramente com headers ou code blocks
|
|
173
|
+
- [ ] Forneceu instruções de uso
|
|
174
|
+
- [ ] Explicou escolhas de design
|
|
175
|
+
- [ ] Incluiu exemplos de outputs esperados
|
|
176
|
+
|
|
177
|
+
## Documentação de Referência
|
|
178
|
+
|
|
179
|
+
- [Anthropic Prompt Engineering Guide](https://docs.anthropic.com/claude/docs/prompt-engineering)
|
|
180
|
+
- [OpenAI Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
|
|
181
|
+
- [Prompt Engineering Patterns](https://www.promptingguide.ai/)
|
|
182
|
+
|
|
183
|
+
## Anti-Patterns a Evitar
|
|
184
|
+
|
|
185
|
+
1. **Prompts vagos**: "Faça algo bom" → Especifique critérios claros
|
|
186
|
+
2. **Sem formato de output**: Sempre definir estrutura esperada
|
|
187
|
+
3. **Instruções contraditórias**: Revisar consistência antes de usar
|
|
188
|
+
4. **Overloading**: Muitas instruções = confusão. Priorize as essenciais
|
|
189
|
+
5. **Falta de exemplos**: Few-shot geralmente supera zero-shot
|