@polymorphism-tech/morph-spec 4.5.0 → 4.7.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 +77 -56
- package/README.md +394 -700
- package/docs/ARCHITECTURE.md +331 -0
- package/docs/CHEATSHEET.md +221 -0
- package/docs/COMMAND-FLOWS.md +368 -0
- package/docs/QUICKSTART.md +212 -0
- package/docs/examples/order-management/contracts.cs +84 -0
- package/docs/examples/order-management/proposal.md +24 -0
- package/docs/examples/order-management/spec.md +162 -0
- package/docs/plans/2026-02-23-ddd-architecture-refactor.md +1153 -0
- package/docs/plans/2026-02-23-ddd-nextsteps.md +682 -0
- package/docs/plans/2026-02-23-infra-architect-refactor.md +437 -0
- package/docs/plans/2026-02-23-nextjs-code-review-design.md +156 -0
- package/docs/plans/2026-02-23-nextjs-code-review-impl.md +1254 -0
- package/docs/plans/2026-02-23-nextjs-standards-design.md +149 -0
- package/docs/plans/2026-02-23-nextjs-standards-impl.md +1846 -0
- package/framework/{skills/level-2-domains → agents}/README.md +14 -14
- package/framework/{skills/level-2-domains → agents}/ai-agents/ai-system-architect.md +1 -4
- package/framework/{skills/level-2-domains → agents}/architecture/po-pm-advisor.md +1 -2
- package/framework/{skills/level-2-domains → agents}/architecture/prompt-engineer.md +1 -2
- package/framework/{skills/level-2-domains → agents}/architecture/seo-growth-hacker.md +1 -2
- package/framework/{skills/level-2-domains → agents}/architecture/standards-architect.md +159 -162
- package/framework/agents/backend/api-designer.md +103 -0
- package/framework/{skills/level-2-domains → agents}/backend/dotnet-senior.md +1 -2
- package/framework/agents/backend/ef-modeler.md +119 -0
- package/framework/{skills/level-2-domains → agents}/backend/hangfire-orchestrator.md +1 -4
- package/framework/{skills/level-2-domains → agents}/backend/ms-agent-expert.md +1 -4
- package/framework/{skills/level-2-domains → agents}/frontend/blazor-builder.md +1 -4
- package/framework/agents/frontend/nextjs-expert.md +118 -0
- package/framework/{skills/level-2-domains → agents}/frontend/ui-ux-designer.md +1 -2
- package/framework/{skills/level-2-domains → agents}/infrastructure/azure-architect.md +147 -148
- package/framework/{skills/level-2-domains → agents}/infrastructure/azure-deploy-specialist.md +1 -2
- package/framework/{skills/level-2-domains → agents}/infrastructure/bicep-architect.md +1 -4
- package/framework/{skills/level-2-domains → agents}/infrastructure/container-specialist.md +1 -4
- package/framework/{skills/level-2-domains → agents}/infrastructure/devops-engineer.md +1 -4
- package/framework/agents/infrastructure/infra-architect.md +45 -0
- package/framework/{skills/level-2-domains → agents}/integrations/asaas-financial.md +1 -4
- package/framework/{skills/level-2-domains → agents}/integrations/azure-identity.md +1 -4
- package/framework/{skills/level-2-domains → agents}/integrations/clerk-auth.md +1 -4
- package/framework/{skills/level-2-domains → agents}/integrations/hangfire-integration.md +1 -2
- package/framework/{skills/level-2-domains → agents}/integrations/resend-email.md +1 -4
- package/framework/{skills/level-2-domains → agents}/quality/code-analyzer.md +1 -4
- package/framework/{skills/level-2-domains → agents}/quality/testing-specialist.md +1 -4
- package/framework/agents.json +1145 -278
- package/framework/hooks/claude-code/statusline.py +384 -85
- package/framework/hooks/shared/phase-utils.js +129 -129
- package/framework/rules/frontend-standards.md +0 -3
- package/framework/rules/nextjs-standards.md +17 -0
- package/framework/skills/README.md +66 -0
- package/framework/skills/level-0-meta/{brainstorming.md → brainstorming/SKILL.md} +3 -1
- package/framework/skills/level-0-meta/brainstorming/references/proposal-example.md +138 -0
- package/framework/skills/level-0-meta/{code-review.md → code-review/SKILL.md} +3 -2
- package/framework/skills/level-0-meta/code-review/references/review-example.md +164 -0
- package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +121 -0
- package/framework/skills/level-0-meta/code-review-nextjs/SKILL.md +147 -0
- package/framework/skills/level-0-meta/code-review-nextjs/references/review-example-nextjs.md +254 -0
- package/framework/skills/level-0-meta/{morph-checklist.md → morph-checklist/SKILL.md} +2 -5
- package/framework/skills/{level-1-workflows/morph-replicate.md → level-0-meta/morph-replicate/SKILL.md} +6 -7
- package/framework/skills/level-0-meta/{simulation-checklist.md → simulation-checklist/SKILL.md} +3 -6
- package/framework/skills/level-0-meta/{tool-usage-guide.md → tool-usage-guide/SKILL.md} +4 -5
- package/framework/skills/level-0-meta/{verification-before-completion.md → verification-before-completion/SKILL.md} +3 -1
- package/framework/skills/level-0-meta/verification-before-completion/scripts/check-phase-outputs.mjs +110 -0
- package/framework/skills/level-1-workflows/{phase-clarify.md → phase-clarify/SKILL.md} +3 -3
- package/framework/skills/level-1-workflows/phase-clarify/references/clarifications-example.md +117 -0
- package/framework/skills/level-1-workflows/{phase-codebase-analysis.md → phase-codebase-analysis/SKILL.md} +2 -3
- package/framework/skills/level-1-workflows/{phase-design.md → phase-design/SKILL.md} +46 -182
- package/framework/skills/level-1-workflows/phase-design/references/spec-example.md +253 -0
- package/framework/skills/level-1-workflows/{phase-implement.md → phase-implement/SKILL.md} +3 -3
- package/framework/skills/level-1-workflows/phase-implement/references/recap-example.md +132 -0
- package/framework/skills/level-1-workflows/{phase-setup.md → phase-setup/SKILL.md} +2 -3
- package/framework/skills/level-1-workflows/{phase-tasks.md → phase-tasks/SKILL.md} +42 -3
- package/framework/skills/level-1-workflows/phase-tasks/references/tasks-example.md +231 -0
- package/framework/skills/level-1-workflows/phase-tasks/scripts/validate-tasks.mjs +112 -0
- package/framework/skills/level-1-workflows/{phase-uiux.md → phase-uiux/SKILL.md} +2 -3
- package/framework/standards/STANDARDS.json +121 -0
- package/framework/standards/architecture/ddd/bounded-contexts.md +105 -0
- package/framework/standards/architecture/ddd/complexity-levels.md +108 -0
- package/framework/standards/architecture/ddd/ubiquitous-language.md +58 -0
- package/framework/standards/frontend/nextjs/app-router.md +123 -0
- package/framework/standards/frontend/nextjs/components.md +132 -0
- package/framework/standards/frontend/nextjs/data-fetching.md +126 -0
- package/framework/standards/frontend/nextjs/forms.md +128 -0
- package/framework/standards/frontend/nextjs/naming-conventions.md +67 -0
- package/framework/standards/frontend/nextjs/project-structure.md +102 -0
- package/framework/standards/frontend/nextjs/state-management.md +72 -0
- package/framework/standards/frontend/nextjs/testing.md +111 -0
- package/framework/templates/REGISTRY.json +538 -142
- package/framework/templates/code/dotnet/contracts/contracts-level1.cs +69 -0
- package/framework/templates/code/dotnet/contracts/contracts-level2.cs +86 -0
- package/framework/templates/code/dotnet/contracts/contracts-level3.cs +41 -0
- package/framework/templates/docs/spec.md +49 -0
- package/framework/templates/frontend/nextjs/Dockerfile.nextjs.hbs +43 -0
- package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -0
- package/framework/templates/frontend/nextjs/env.mjs.hbs +32 -0
- package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -0
- package/framework/templates/frontend/nextjs/page.tsx.hbs +22 -0
- package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -0
- package/framework/templates/frontend/nextjs/use-feature.ts.hbs +54 -0
- package/framework/templates/project-structure/dotnet-ddd.md +70 -0
- package/framework/workflows/docs/enforcement-pipeline.md +2 -1
- package/package.json +1 -1
- package/scripts/scan-nextjs.mjs +169 -0
- package/src/commands/project/doctor.js +52 -1
- package/src/commands/project/init.js +19 -65
- package/src/commands/project/update.js +7 -63
- package/src/lib/detectors/claude-config-detector.js +1 -3
- package/src/lib/standards/standards-context-injector.js +5 -0
- package/src/lib/validators/nextjs/index.js +6 -0
- package/src/lib/validators/nextjs/next-component-validator.js +181 -0
- package/src/lib/validators/validation-runner.js +5 -0
- package/src/utils/agents-installer.js +16 -4
- package/src/utils/skills-installer.js +59 -15
- package/.morph/.morphversion +0 -5
- package/.morph/analytics/threads-log.jsonl +0 -44
- package/.morph/config/config.json +0 -8
- package/.morph/context/README.md +0 -17
- package/.morph/framework/agents.json +0 -948
- package/.morph/framework/standards/STANDARDS.json +0 -812
- package/.morph/framework/standards/ai-agents/blazor-ui.md +0 -364
- package/.morph/framework/standards/ai-agents/production.md +0 -415
- package/.morph/framework/standards/ai-agents/setup.md +0 -418
- package/.morph/framework/standards/ai-agents/team-orchestration.md +0 -479
- package/.morph/framework/standards/ai-agents/workflows.md +0 -354
- package/.morph/framework/standards/architecture/ddd/aggregates.md +0 -120
- package/.morph/framework/standards/architecture/ddd/entities.md +0 -99
- package/.morph/framework/standards/architecture/ddd/value-objects.md +0 -124
- package/.morph/framework/standards/backend/api/minimal-api.md +0 -494
- package/.morph/framework/standards/backend/api/rest.md +0 -492
- package/.morph/framework/standards/backend/api/validation.md +0 -88
- package/.morph/framework/standards/backend/authentication/passkeys.md +0 -428
- package/.morph/framework/standards/backend/database/ef-core.md +0 -199
- package/.morph/framework/standards/backend/database/migrations.md +0 -393
- package/.morph/framework/standards/backend/database/postgresql/database.md +0 -352
- package/.morph/framework/standards/backend/database/repository-patterns.md +0 -528
- package/.morph/framework/standards/backend/database/vector-search-rag.md +0 -541
- package/.morph/framework/standards/backend/dotnet/async.md +0 -366
- package/.morph/framework/standards/backend/dotnet/core.md +0 -117
- package/.morph/framework/standards/backend/dotnet/di.md +0 -439
- package/.morph/framework/standards/backend/dotnet/program-cs-checklist.md +0 -92
- package/.morph/framework/standards/backend/integrations/asaas/asaas-api.md +0 -216
- package/.morph/framework/standards/backend/integrations/clerk/clerk-auth.md +0 -290
- package/.morph/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +0 -350
- package/.morph/framework/standards/backend/integrations/resend/resend-email.md +0 -385
- package/.morph/framework/standards/context/analytics.md +0 -96
- package/.morph/framework/standards/context/bundles.md +0 -110
- package/.morph/framework/standards/context/priming.md +0 -78
- package/.morph/framework/standards/core/architecture.md +0 -185
- package/.morph/framework/standards/core/coding.md +0 -214
- package/.morph/framework/standards/core/git-branching-strategy.md +0 -403
- package/.morph/framework/standards/core/git.md +0 -185
- package/.morph/framework/standards/core/testing.md +0 -295
- package/.morph/framework/standards/data/nosql/blob-storage.md +0 -102
- package/.morph/framework/standards/data/nosql/cache/redis.md +0 -97
- package/.morph/framework/standards/data/nosql/cosmos-db.md +0 -118
- package/.morph/framework/standards/data/vector-search/azure-ai-search.md +0 -121
- package/.morph/framework/standards/data/vector-search/rag-chunking.md +0 -104
- package/.morph/framework/standards/frontend/blazor/design-checklist.md +0 -222
- package/.morph/framework/standards/frontend/blazor/fluent-ui-setup.md +0 -595
- package/.morph/framework/standards/frontend/blazor/fluent-ui.md +0 -137
- package/.morph/framework/standards/frontend/blazor/html-conversion.md +0 -184
- package/.morph/framework/standards/frontend/blazor/lifecycle.md +0 -195
- package/.morph/framework/standards/frontend/blazor/pitfalls.md +0 -198
- package/.morph/framework/standards/frontend/blazor/state.md +0 -191
- package/.morph/framework/standards/frontend/design-system/animations.md +0 -151
- package/.morph/framework/standards/frontend/design-system/naming.md +0 -64
- package/.morph/framework/standards/frontend/nextjs/nextjs-patterns.md +0 -198
- package/.morph/framework/standards/infrastructure/azure/azure.md +0 -624
- package/.morph/framework/standards/infrastructure/azure/bicep/bicep-patterns.md +0 -422
- package/.morph/framework/standards/infrastructure/azure/devops/azure-devops-setup.md +0 -516
- package/.morph/framework/standards/infrastructure/azure/devops/local-development.md +0 -520
- package/.morph/framework/standards/infrastructure/azure/services/functions.md +0 -486
- package/.morph/framework/standards/infrastructure/azure/services/service-bus.md +0 -459
- package/.morph/framework/standards/infrastructure/azure/services/storage.md +0 -407
- package/.morph/framework/standards/infrastructure/docker/easypanel-deploy.md +0 -196
- package/.morph/framework/standards/infrastructure/supabase/mcp-setup.md +0 -252
- package/.morph/framework/standards/infrastructure/supabase/supabase-auth.md +0 -176
- package/.morph/framework/standards/infrastructure/supabase/supabase-pgvector.md +0 -169
- package/.morph/framework/standards/infrastructure/supabase/supabase-rls.md +0 -184
- package/.morph/framework/standards/infrastructure/supabase/supabase-storage.md +0 -153
- package/.morph/framework/standards/integration/api/graphql.md +0 -91
- package/.morph/framework/standards/integration/api/grpc.md +0 -114
- package/.morph/framework/standards/integration/api/rest-design.md +0 -95
- package/.morph/framework/standards/integration/event-driven/cqrs.md +0 -101
- package/.morph/framework/standards/integration/event-driven/event-sourcing.md +0 -124
- package/.morph/framework/standards/integration/event-driven/service-bus.md +0 -95
- package/.morph/framework/standards/integration/mcp/mcp-tools.md +0 -384
- package/.morph/framework/standards/observability/logging.md +0 -131
- package/.morph/framework/standards/observability/metrics.md +0 -121
- package/.morph/framework/standards/observability/monitoring.md +0 -114
- package/.morph/framework/standards/observability/tracing.md +0 -132
- package/.morph/framework/standards/workflows/parallel-execution.md +0 -112
- package/.morph/framework/standards/workflows/thread-management.md +0 -113
- package/.morph/framework/templates/.idea/morph-templates.xml +0 -92
- package/.morph/framework/templates/.vscode/morph-templates.code-snippets +0 -186
- package/.morph/framework/templates/IDE-SNIPPETS.md +0 -266
- package/.morph/framework/templates/README.md +0 -814
- package/.morph/framework/templates/REGISTRY.json +0 -1492
- package/.morph/framework/templates/code/dotnet/backend/repository.cs +0 -141
- package/.morph/framework/templates/code/dotnet/backend/service.cs +0 -139
- package/.morph/framework/templates/code/dotnet/contracts/Commands.cs +0 -74
- package/.morph/framework/templates/code/dotnet/contracts/Entities.cs +0 -25
- package/.morph/framework/templates/code/dotnet/contracts/Queries.cs +0 -74
- package/.morph/framework/templates/code/dotnet/contracts/README.md +0 -74
- package/.morph/framework/templates/code/dotnet/contracts/api-contracts.cs +0 -173
- package/.morph/framework/templates/code/dotnet/contracts/contracts.cs +0 -217
- package/.morph/framework/templates/code/dotnet/contracts/contracts.cs.hbs +0 -172
- package/.morph/framework/templates/code/dotnet/database/migration.cs +0 -83
- package/.morph/framework/templates/code/dotnet/frontend/component.razor +0 -239
- package/.morph/framework/templates/code/dotnet/jobs/agent.cs +0 -163
- package/.morph/framework/templates/code/dotnet/jobs/job.cs +0 -171
- package/.morph/framework/templates/code/dotnet/test.cs +0 -239
- package/.morph/framework/templates/code/sql/rls-policy.sql +0 -57
- package/.morph/framework/templates/code/sql/supabase-migration.sql +0 -100
- package/.morph/framework/templates/code/sql/supabase-migration.template.sql +0 -113
- package/.morph/framework/templates/code/typescript/contracts.ts +0 -168
- package/.morph/framework/templates/context/CONTEXT-FEATURE.md +0 -276
- package/.morph/framework/templates/context/CONTEXT.md +0 -181
- package/.morph/framework/templates/docs/clarifications.md +0 -253
- package/.morph/framework/templates/docs/onboarding.md +0 -123
- package/.morph/framework/templates/docs/proposal.md +0 -182
- package/.morph/framework/templates/docs/schema-analysis.md +0 -119
- package/.morph/framework/templates/docs/spec.md +0 -149
- package/.morph/framework/templates/docs/ui-components.md +0 -124
- package/.morph/framework/templates/docs/ui-design-system.md +0 -76
- package/.morph/framework/templates/docs/ui-flows.md +0 -167
- package/.morph/framework/templates/docs/ui-mockups.md +0 -98
- package/.morph/framework/templates/examples/design-system-examples.md +0 -357
- package/.morph/framework/templates/examples/spec-examples.md +0 -90
- package/.morph/framework/templates/feature/decisions.md +0 -187
- package/.morph/framework/templates/feature/recap.md +0 -146
- package/.morph/framework/templates/feature/tasks.md +0 -199
- package/.morph/framework/templates/infrastructure/azure/Dockerfile.example +0 -82
- package/.morph/framework/templates/infrastructure/azure/README.md +0 -286
- package/.morph/framework/templates/infrastructure/azure/app-insights.bicep +0 -63
- package/.morph/framework/templates/infrastructure/azure/app-service.bicep +0 -164
- package/.morph/framework/templates/infrastructure/azure/container-app-env.bicep +0 -49
- package/.morph/framework/templates/infrastructure/azure/container-app.bicep +0 -156
- package/.morph/framework/templates/infrastructure/azure/deploy-checklist.md +0 -426
- package/.morph/framework/templates/infrastructure/azure/deploy.ps1 +0 -229
- package/.morph/framework/templates/infrastructure/azure/deploy.sh +0 -208
- package/.morph/framework/templates/infrastructure/azure/key-vault.bicep +0 -91
- package/.morph/framework/templates/infrastructure/azure/main.bicep +0 -189
- package/.morph/framework/templates/infrastructure/azure/parameters.dev.json +0 -29
- package/.morph/framework/templates/infrastructure/azure/parameters.prod.json +0 -29
- package/.morph/framework/templates/infrastructure/azure/parameters.staging.json +0 -29
- package/.morph/framework/templates/infrastructure/azure/sql-database.bicep +0 -103
- package/.morph/framework/templates/infrastructure/azure/storage.bicep +0 -106
- package/.morph/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
- package/.morph/framework/templates/infrastructure/docker/docker-compose.template.yml +0 -67
- package/.morph/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +0 -38
- package/.morph/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +0 -48
- package/.morph/framework/templates/infrastructure/docker/easypanel.template.json +0 -54
- package/.morph/framework/templates/infrastructure/github/README.md +0 -593
- package/.morph/framework/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -22
- package/.morph/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
- package/.morph/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
- package/.morph/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +0 -61
- package/.morph/framework/templates/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -31
- package/.morph/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +0 -59
- package/.morph/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +0 -39
- package/.morph/framework/templates/integrations/asaas-client.cs +0 -387
- package/.morph/framework/templates/integrations/asaas-webhook.cs +0 -351
- package/.morph/framework/templates/integrations/azure-identity-config.cs +0 -288
- package/.morph/framework/templates/integrations/clerk-config.cs +0 -258
- package/.morph/framework/templates/meta-prompts/fusion/fusion-agent.md +0 -76
- package/.morph/framework/templates/meta-prompts/fusion/fusion-aggregator.md +0 -100
- package/.morph/framework/templates/meta-prompts/hops/hop-retry.md +0 -78
- package/.morph/framework/templates/meta-prompts/hops/hop-validation.md +0 -97
- package/.morph/framework/templates/meta-prompts/hops/hop-wrapper.md +0 -36
- package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-coordinator.md +0 -113
- package/.morph/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +0 -80
- package/.morph/framework/templates/meta-prompts/squad-leaders/backend-squad.md +0 -90
- package/.morph/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +0 -126
- package/.morph/framework/templates/meta-prompts/squad-leaders/squad-leader.md +0 -43
- package/.morph/framework/templates/meta-prompts/validators/checkpoint-validator.md +0 -107
- package/.morph/framework/templates/meta-prompts/validators/pre-commit-validator.md +0 -95
- package/.morph/framework/templates/saas/subscription.cs +0 -347
- package/.morph/framework/templates/saas/tenant.cs +0 -338
- package/.morph/framework/templates/state.template.json +0 -17
- package/.morph/framework/templates/ui/FluentDesignTheme.cs +0 -149
- package/.morph/framework/templates/ui/MudTheme.cs +0 -281
- package/.morph/framework/templates/ui/design-system.css +0 -226
- package/.morph/logs/tool-failures.log +0 -51
- package/.morph/memory/pre-compact-2026-02-22T17-01-01-658Z.json +0 -16
- package/.morph/state.json +0 -48
- package/framework/skills/level-2-domains/backend/api-designer.md +0 -66
- package/framework/skills/level-2-domains/backend/ef-modeler.md +0 -65
- package/framework/skills/level-2-domains/frontend/nextjs-expert.md +0 -161
- package/framework/skills/level-3-technologies/README.md +0 -7
- package/framework/skills/level-4-patterns/README.md +0 -7
- package/framework/templates/code/dotnet/contracts/contracts.cs +0 -217
- package/framework/templates/code/dotnet/contracts/contracts.cs.hbs +0 -172
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Code Review Report — Photo Processing Pipeline
|
|
2
|
+
|
|
3
|
+
> Example of a well-structured code review output. Filled-in reference — not a template.
|
|
4
|
+
|
|
5
|
+
**Scope:** `src/Application/PhotoProcessing/` + `src/Web/Endpoints/PhotoProcessingEndpoints.cs`
|
|
6
|
+
**Date:** 2025-01-22
|
|
7
|
+
**Reviewer:** code-review skill
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Findings by Severity
|
|
12
|
+
|
|
13
|
+
| Severity | Count |
|
|
14
|
+
|----------|-------|
|
|
15
|
+
| CRITICAL | 1 |
|
|
16
|
+
| HIGH | 2 |
|
|
17
|
+
| MEDIUM | 2 |
|
|
18
|
+
| LOW | 1 |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### [CRITICAL] Naming: UPPER_SNAKE_CASE constant
|
|
23
|
+
|
|
24
|
+
**File:** `src/Application/PhotoProcessing/PhotoProcessingService.cs:14`
|
|
25
|
+
|
|
26
|
+
**Current code:**
|
|
27
|
+
```csharp
|
|
28
|
+
private const int MAX_RETRY_COUNT = 3;
|
|
29
|
+
private const int DEFAULT_TIMEOUT_SECONDS = 30;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Suggested fix:**
|
|
33
|
+
```csharp
|
|
34
|
+
private const int MaxRetryCount = 3;
|
|
35
|
+
private const int DefaultTimeoutSeconds = 30;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Why:** `ALL_CAPS` constants violate C# conventions (§ coding.md). Pascal case is the .NET standard.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### [HIGH] Async: Missing CancellationToken propagation
|
|
43
|
+
|
|
44
|
+
**File:** `src/Infrastructure/Storage/AzureBlobStorageService.cs:28`
|
|
45
|
+
|
|
46
|
+
**Current code:**
|
|
47
|
+
```csharp
|
|
48
|
+
public async Task<string> UploadAsync(Stream content, string blobName)
|
|
49
|
+
{
|
|
50
|
+
var blobClient = _containerClient.GetBlobClient(blobName);
|
|
51
|
+
await blobClient.UploadAsync(content); // no CT
|
|
52
|
+
return blobClient.Uri.ToString();
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Suggested fix:**
|
|
57
|
+
```csharp
|
|
58
|
+
public async Task<string> UploadAsync(Stream content, string blobName, CancellationToken ct = default)
|
|
59
|
+
{
|
|
60
|
+
var blobClient = _containerClient.GetBlobClient(blobName);
|
|
61
|
+
await blobClient.UploadAsync(content, cancellationToken: ct);
|
|
62
|
+
return blobClient.Uri.ToString();
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Why:** Cancellation cannot propagate into the Blob SDK call, meaning a cancelled HTTP request still holds the upload open.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### [HIGH] Logging: String interpolation in ILogger call
|
|
71
|
+
|
|
72
|
+
**File:** `src/Application/PhotoProcessing/PhotoProcessingJob.cs:52`
|
|
73
|
+
|
|
74
|
+
**Current code:**
|
|
75
|
+
```csharp
|
|
76
|
+
_logger.LogError($"Job {jobId} failed after {retryCount} retries: {ex.Message}");
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Suggested fix:**
|
|
80
|
+
```csharp
|
|
81
|
+
_logger.LogError("Job {JobId} failed after {RetryCount} retries: {ErrorMessage}",
|
|
82
|
+
jobId, retryCount, ex.Message);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Why:** String interpolation allocates eagerly even if the log level is filtered. Message templates are structured and queryable in Application Insights / Seq.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### [MEDIUM] Architecture: Controller logic exceeds 50 lines
|
|
90
|
+
|
|
91
|
+
**File:** `src/Web/Endpoints/PhotoProcessingEndpoints.cs`
|
|
92
|
+
|
|
93
|
+
**Issue:** The upload endpoint inline lambda is 60+ lines — includes validation, service call, response mapping, and error handling all inline.
|
|
94
|
+
|
|
95
|
+
**Suggested fix:** Extract a `UploadPhotoRequestHandler` or move validation to a FluentValidation `IValidator<UploadPhotoCommand>`. The endpoint lambda should be < 10 lines.
|
|
96
|
+
|
|
97
|
+
**Why:** Fat endpoints are hard to test and violate the "thin API layer" rule (§ architecture.md).
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### [MEDIUM] Error Handling: Generic catch without context
|
|
102
|
+
|
|
103
|
+
**File:** `src/Application/PhotoProcessing/PhotoProcessingService.cs:89`
|
|
104
|
+
|
|
105
|
+
**Current code:**
|
|
106
|
+
```csharp
|
|
107
|
+
catch (Exception ex)
|
|
108
|
+
{
|
|
109
|
+
_logger.LogError(ex, "Upload failed");
|
|
110
|
+
throw;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Suggested fix:**
|
|
115
|
+
```csharp
|
|
116
|
+
catch (Exception ex)
|
|
117
|
+
{
|
|
118
|
+
_logger.LogError(ex, "Upload failed for user {UserId}", userId);
|
|
119
|
+
throw;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Why:** Log entries without correlation IDs (UserId, JobId) are unqueryable in production. Always include the relevant entity ID.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### [LOW] Dead Code: Unused private method
|
|
128
|
+
|
|
129
|
+
**File:** `src/Application/PhotoProcessing/PhotoProcessingService.cs:110`
|
|
130
|
+
|
|
131
|
+
**Current code:**
|
|
132
|
+
```csharp
|
|
133
|
+
private string BuildBlobPath(Guid jobId, string suffix)
|
|
134
|
+
=> $"uploads/{jobId}/{suffix}";
|
|
135
|
+
// Called 0 times — path built inline everywhere
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Suggested fix:** Either use `BuildBlobPath` consistently or delete it.
|
|
139
|
+
|
|
140
|
+
**Why:** Dead code misleads future readers and increases maintenance surface.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Top Priorities
|
|
145
|
+
|
|
146
|
+
1. `PhotoProcessingService.cs:14` — CRITICAL naming violation (5 min fix)
|
|
147
|
+
2. `AzureBlobStorageService.cs:28` — HIGH missing CancellationToken (10 min fix)
|
|
148
|
+
3. `PhotoProcessingJob.cs:52` — HIGH structured logging (5 min fix)
|
|
149
|
+
4. `PhotoProcessingEndpoints.cs` — MEDIUM endpoint refactor (30 min)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Passed Checks ✅
|
|
154
|
+
|
|
155
|
+
- Layer integrity: Domain has no Infrastructure references
|
|
156
|
+
- All async methods have `Async` suffix
|
|
157
|
+
- Private fields use `_camelCase`
|
|
158
|
+
- No hardcoded connection strings or secrets
|
|
159
|
+
- External services accessed through interfaces (`IBlobStorageService`, `IPhotoProcessingJob`)
|
|
160
|
+
- `ProcessingJob` entity uses private setters + domain methods
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* scan-csharp.mjs
|
|
4
|
+
*
|
|
5
|
+
* Scans .cs files for MORPH-SPEC coding standard violations.
|
|
6
|
+
* Executed locally by Claude via Bash — output returned to Claude.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node scan-csharp.mjs [path] # scan directory or file
|
|
10
|
+
* node scan-csharp.mjs src/ # scan src/ recursively
|
|
11
|
+
* node scan-csharp.mjs --summary # counts only, no details
|
|
12
|
+
*
|
|
13
|
+
* Checks (ref: framework/standards/core/coding.md):
|
|
14
|
+
* - UPPER_SNAKE_CASE constants → should be PascalCase
|
|
15
|
+
* - Hungarian notation → strName, iCount, btnSubmit
|
|
16
|
+
* - Missing CancellationToken → async methods without CT param
|
|
17
|
+
* - String interpolation in logging → $"" in ILogger calls
|
|
18
|
+
* - Empty catch blocks → catch { } or catch (E) { }
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { readdirSync, readFileSync, statSync, existsSync } from 'fs';
|
|
22
|
+
import { join, extname, relative } from 'path';
|
|
23
|
+
|
|
24
|
+
const targetPath = process.argv[2] ?? '.';
|
|
25
|
+
const summaryOnly = process.argv.includes('--summary');
|
|
26
|
+
|
|
27
|
+
const CHECKS = [
|
|
28
|
+
{
|
|
29
|
+
id: 'UPPER_SNAKE_CASE',
|
|
30
|
+
severity: 'CRITICAL',
|
|
31
|
+
pattern: /\bconst\s+\w+\s+([A-Z][A-Z_]{2,})\s*=/g,
|
|
32
|
+
message: (m) => `Constant '${m[1]}' uses UPPER_SNAKE_CASE (anti-pattern in C#) → use PascalCase`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'HUNGARIAN_NOTATION',
|
|
36
|
+
severity: 'CRITICAL',
|
|
37
|
+
pattern: /\b(str|int|bool|btn|lbl|txt|dbl|flt|obj|arr|lst)([A-Z]\w*)\b/g,
|
|
38
|
+
message: (m) => `'${m[0]}' looks like Hungarian notation → rename to '${m[2].charAt(0).toLowerCase() + m[2].slice(1)}'`,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'MISSING_CANCELLATION_TOKEN',
|
|
42
|
+
severity: 'HIGH',
|
|
43
|
+
pattern: /public\s+async\s+Task(?:<[^>]+>)?\s+(\w+Async)\s*\(([^)]*)\)/g,
|
|
44
|
+
message: (m) => {
|
|
45
|
+
const params = m[2];
|
|
46
|
+
if (params.includes('CancellationToken') || params.includes('ct ') || params.includes('ct,') || params.includes('ct)')) return null;
|
|
47
|
+
return `Async method '${m[1]}' missing CancellationToken parameter`;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'LOG_STRING_INTERPOLATION',
|
|
52
|
+
severity: 'HIGH',
|
|
53
|
+
pattern: /\.(LogInformation|LogWarning|LogError|LogDebug|LogCritical)\s*\(\s*\$"/g,
|
|
54
|
+
message: () => 'String interpolation ($"") in log call → use message template with structured parameters',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'EMPTY_CATCH',
|
|
58
|
+
severity: 'CRITICAL',
|
|
59
|
+
pattern: /catch\s*(\([^)]*\))?\s*\{\s*\}/g,
|
|
60
|
+
message: () => 'Empty catch block — exceptions are silently swallowed',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
function collectCsFiles(dir) {
|
|
65
|
+
if (!existsSync(dir)) return [];
|
|
66
|
+
const stat = statSync(dir);
|
|
67
|
+
if (stat.isFile()) return dir.endsWith('.cs') ? [dir] : [];
|
|
68
|
+
const results = [];
|
|
69
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
70
|
+
if (entry.isDirectory() && entry.name !== 'bin' && entry.name !== 'obj' && entry.name !== '.git') {
|
|
71
|
+
results.push(...collectCsFiles(join(dir, entry.name)));
|
|
72
|
+
} else if (entry.isFile() && extname(entry.name) === '.cs') {
|
|
73
|
+
results.push(join(dir, entry.name));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return results;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const files = collectCsFiles(targetPath);
|
|
80
|
+
const findings = [];
|
|
81
|
+
|
|
82
|
+
for (const file of files) {
|
|
83
|
+
const content = readFileSync(file, 'utf-8');
|
|
84
|
+
const lines = content.split('\n');
|
|
85
|
+
|
|
86
|
+
for (const check of CHECKS) {
|
|
87
|
+
const regex = new RegExp(check.pattern.source, check.pattern.flags);
|
|
88
|
+
let match;
|
|
89
|
+
while ((match = regex.exec(content)) !== null) {
|
|
90
|
+
const msg = check.message(match);
|
|
91
|
+
if (!msg) continue;
|
|
92
|
+
const lineNum = content.slice(0, match.index).split('\n').length;
|
|
93
|
+
findings.push({
|
|
94
|
+
severity: check.severity,
|
|
95
|
+
id: check.id,
|
|
96
|
+
file: relative(process.cwd(), file).replace(/\\/g, '/'),
|
|
97
|
+
line: lineNum,
|
|
98
|
+
message: msg,
|
|
99
|
+
snippet: lines[lineNum - 1]?.trim().slice(0, 100),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const bySeverity = { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 };
|
|
106
|
+
for (const f of findings) bySeverity[f.severity] = (bySeverity[f.severity] ?? 0) + 1;
|
|
107
|
+
|
|
108
|
+
const summary = {
|
|
109
|
+
scanned: files.length,
|
|
110
|
+
findings: findings.length,
|
|
111
|
+
bySeverity,
|
|
112
|
+
clean: findings.length === 0,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (summaryOnly) {
|
|
116
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
117
|
+
} else {
|
|
118
|
+
console.log(JSON.stringify({ summary, findings }, null, 2));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
process.exit(findings.some(f => f.severity === 'CRITICAL') ? 1 : 0);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-nextjs
|
|
3
|
+
description: Next.js code review checklist covering naming conventions, component architecture (Server vs Client), data fetching patterns, form implementation, state management, TypeScript/Zod discipline, feature boundaries, and testing. Use after implementing Next.js code, before creating PRs, or when reviewing TSX/TS code for compliance with MORPH-SPEC Next.js standards.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Next.js Code Review Checklist
|
|
9
|
+
|
|
10
|
+
> Comprehensive checklist for Next.js code review: naming, component architecture, data fetching, forms, state, TypeScript, structure, and testing.
|
|
11
|
+
> **Ref:** `framework/standards/frontend/nextjs/naming-conventions.md`
|
|
12
|
+
> **Ref:** `framework/standards/frontend/nextjs/app-router.md`
|
|
13
|
+
> **Ref:** `framework/standards/frontend/nextjs/components.md`
|
|
14
|
+
> **Ref:** `framework/standards/frontend/nextjs/data-fetching.md`
|
|
15
|
+
> **Ref:** `framework/standards/frontend/nextjs/forms.md`
|
|
16
|
+
> **Ref:** `framework/standards/frontend/nextjs/state-management.md`
|
|
17
|
+
> **Ref:** `framework/standards/frontend/nextjs/testing.md`
|
|
18
|
+
> **Example:** `references/review-example-nextjs.md` — filled-in review showing expected finding format.
|
|
19
|
+
> **Script:** `scripts/scan-nextjs.mjs` — automated scan for CRITICAL/HIGH violations before manual review.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Step 1 — Run automated scan first
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
node scripts/scan-nextjs.mjs src/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Review and address CRITICAL findings before proceeding with the manual checklist below. Warnings can be addressed during review.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Naming & Style (ref: naming-conventions.md)
|
|
34
|
+
|
|
35
|
+
- [ ] `[CRITICAL]` File names use kebab-case (`user-card.tsx`, NOT `UserCard.tsx`)
|
|
36
|
+
- [ ] `[HIGH]` Components exported as named exports (`export function UserCard`, NOT `export default function UserCard`)
|
|
37
|
+
- [ ] `[HIGH]` Hook files named `use-{action}.ts` and export `use{Action}()`
|
|
38
|
+
- [ ] `[HIGH]` Schema files named `{feature}.schemas.ts` with Zod exports
|
|
39
|
+
- [ ] `[HIGH]` Type files named `{feature}.types.ts` with `z.infer<>` derived types
|
|
40
|
+
- [ ] `[MEDIUM]` No abbreviations in public API names (`repository` not `repo`)
|
|
41
|
+
- [ ] `[MEDIUM]` Feature folder uses kebab-case (`features/user-management/`, NOT `features/userManagement/`)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Component Architecture (ref: app-router.md, components.md)
|
|
46
|
+
|
|
47
|
+
### Server vs Client Discipline
|
|
48
|
+
- [ ] `[CRITICAL]` `'use client'` only on components that use hooks or event handlers
|
|
49
|
+
- [ ] `[CRITICAL]` No `useEffect(() => { fetch(...) }, [])` for data fetching — use Server Components or TanStack Query
|
|
50
|
+
- [ ] `[HIGH]` Server Components used for initial page data (no `'use client'` on page files)
|
|
51
|
+
- [ ] `[HIGH]` `loading.tsx`, `error.tsx` co-located with every `page.tsx`
|
|
52
|
+
- [ ] `[HIGH]` No business logic in `app/` route files — import from `features/`
|
|
53
|
+
|
|
54
|
+
### Three-Tier Hierarchy
|
|
55
|
+
- [ ] `[CRITICAL]` No edits to `components/ui/` files — shadcn primitives are never modified
|
|
56
|
+
- [ ] `[HIGH]` `components/` (Tier 2) has no imports from `features/` — no domain knowledge
|
|
57
|
+
- [ ] `[HIGH]` Feature components (`features/*/components/`) do not import from other features
|
|
58
|
+
- [ ] `[MEDIUM]` Feature cross-dependencies extracted to `components/` or `lib/`
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Data Fetching (ref: data-fetching.md)
|
|
63
|
+
|
|
64
|
+
- [ ] `[CRITICAL]` No `useEffect` + `useState` pattern for API data — use `useQuery`
|
|
65
|
+
- [ ] `[HIGH]` TanStack Query v5 syntax: `useQuery({ queryKey: [...], queryFn: async () => {} })`
|
|
66
|
+
- [ ] `[HIGH]` Query key factory pattern used (`userKeys.lists()`, NOT hardcoded `['users']`)
|
|
67
|
+
- [ ] `[HIGH]` `useMutation` used for POST/PUT/DELETE — not inline `fetch` in handlers
|
|
68
|
+
- [ ] `[HIGH]` API responses validated with Zod before use
|
|
69
|
+
- [ ] `[MEDIUM]` `onSuccess` in `useMutation` invalidates relevant query keys
|
|
70
|
+
- [ ] `[MEDIUM]` `QueryClientProvider` wraps app in `app/layout.tsx`, not per-component
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Forms (ref: forms.md)
|
|
75
|
+
|
|
76
|
+
- [ ] `[CRITICAL]` Zod schema defined BEFORE TypeScript type — type derived with `z.infer<>`
|
|
77
|
+
- [ ] `[HIGH]` `useForm` uses `zodResolver(schema)` — NOT manual validation
|
|
78
|
+
- [ ] `[HIGH]` shadcn `<Form>`, `<FormField>`, `<FormItem>`, `<FormLabel>`, `<FormControl>`, `<FormMessage>` used
|
|
79
|
+
- [ ] `[HIGH]` Form submission uses `useMutation` — NOT direct `fetch` in `onSubmit`
|
|
80
|
+
- [ ] `[MEDIUM]` `isPending` used for loading state — NOT `isLoading` (v5 renamed)
|
|
81
|
+
- [ ] `[MEDIUM]` Root-level errors displayed: `form.formState.errors.root`
|
|
82
|
+
- [ ] `[MEDIUM]` No `useState` for individual form fields — react-hook-form handles this
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## State Management (ref: state-management.md)
|
|
87
|
+
|
|
88
|
+
- [ ] `[HIGH]` No Zustand/Redux installed without documented justification
|
|
89
|
+
- [ ] `[HIGH]` No React Context used for server state (API data) — use TanStack Query
|
|
90
|
+
- [ ] `[MEDIUM]` Local UI state (open/closed, selected) in `useState` — not global store
|
|
91
|
+
- [ ] `[MEDIUM]` Context only for truly global UI: theme, auth user, locale
|
|
92
|
+
- [ ] `[LOW]` No prop drilling beyond 3 levels — consider Context or co-location
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## TypeScript Discipline
|
|
97
|
+
|
|
98
|
+
- [ ] `[CRITICAL]` No `any` type — use `unknown` and narrow, or fix the actual type
|
|
99
|
+
- [ ] `[HIGH]` Types derived from Zod schemas (`type User = z.infer<typeof userSchema>`)
|
|
100
|
+
- [ ] `[HIGH]` No duplicate type definitions — if the server returns it, define it once with Zod
|
|
101
|
+
- [ ] `[MEDIUM]` API response types come from the shared schema, not manually written
|
|
102
|
+
- [ ] `[MEDIUM]` `noUncheckedIndexedAccess` respected — array accesses use optional chaining
|
|
103
|
+
- [ ] `[LOW]` No type assertions (`as User`) without validation
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Feature Structure (ref: project-structure.md)
|
|
108
|
+
|
|
109
|
+
- [ ] `[HIGH]` Feature exposes public API via `features/{name}/index.ts` — no deep path imports
|
|
110
|
+
- [ ] `[HIGH]` Consumers import from index: `from '@/features/users'` NOT `from '@/features/users/components/user-list'`
|
|
111
|
+
- [ ] `[MEDIUM]` New features create: `components/`, `hooks/`, `types/` subdirectories
|
|
112
|
+
- [ ] `[MEDIUM]` TanStack Query hooks in `features/{name}/hooks/` — NOT co-located with components
|
|
113
|
+
- [ ] `[MEDIUM]` Zod schemas in `features/{name}/types/{name}.schemas.ts`
|
|
114
|
+
- [ ] `[LOW]` Feature index only exports what external consumers actually need (no over-exposure)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Testing (ref: testing.md)
|
|
119
|
+
|
|
120
|
+
- [ ] `[HIGH]` Test files co-located with source (`user-card.test.tsx` next to `user-card.tsx`)
|
|
121
|
+
- [ ] `[HIGH]` `@testing-library/user-event` used — NOT `fireEvent`
|
|
122
|
+
- [ ] `[HIGH]` API calls mocked with MSW — NOT `jest.mock('fetch')` or `global.fetch = jest.fn()`
|
|
123
|
+
- [ ] `[MEDIUM]` Hook tests use `QueryClientWrapper` helper with `retry: false`
|
|
124
|
+
- [ ] `[MEDIUM]` Tests cover happy path + one error path per component
|
|
125
|
+
- [ ] `[LOW]` No snapshot tests — use `expect(screen.getByText(...))`
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Quick Pre-Merge Checklist
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
[ ] node scripts/scan-nextjs.mjs src/ — 0 CRITICAL findings
|
|
133
|
+
[ ] File names are kebab-case (UserCard.tsx → user-card.tsx)
|
|
134
|
+
[ ] 'use client' only on interactive components (hooks or event handlers)
|
|
135
|
+
[ ] No useEffect for data fetching — Server Component or useQuery
|
|
136
|
+
[ ] Zod schema defined first, type derived with z.infer<>
|
|
137
|
+
[ ] zodResolver connected to useForm, useMutation for submit
|
|
138
|
+
[ ] Query key factory used (userKeys.lists() not ['users'])
|
|
139
|
+
[ ] Feature public API via features/{name}/index.ts
|
|
140
|
+
[ ] components/ui/ files untouched (shadcn CLI only)
|
|
141
|
+
[ ] Tests: userEvent not fireEvent, MSW not mock fetch
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
*Covers: naming-conventions.md + app-router.md + components.md + data-fetching.md + forms.md + state-management.md + testing.md + project-structure.md*
|
|
147
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Code Review Report — User Management Feature
|
|
2
|
+
|
|
3
|
+
> Example of a well-structured Next.js code review output. Filled-in reference — not a template.
|
|
4
|
+
|
|
5
|
+
**Scope:** `src/features/users/` + `src/app/(dashboard)/users/page.tsx`
|
|
6
|
+
**Date:** 2026-02-23
|
|
7
|
+
**Reviewer:** code-review-nextjs skill
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Automated Scan Results
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
$ node scripts/scan-nextjs.mjs src/features/users/
|
|
15
|
+
|
|
16
|
+
CRITICAL (1)
|
|
17
|
+
features/users/components/UserList.tsx:1 — React hooks used (useState) without 'use client'
|
|
18
|
+
|
|
19
|
+
HIGH/MEDIUM (2)
|
|
20
|
+
features/users/components/UserList.tsx — PascalCase filename (should be user-list.tsx)
|
|
21
|
+
features/users/components/user-form.tsx — 'use client' directive present but no interactivity detected
|
|
22
|
+
|
|
23
|
+
Summary: 8 files scanned | 3 issues (1 critical, 2 high/medium)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Findings by Severity
|
|
29
|
+
|
|
30
|
+
| Severity | Count |
|
|
31
|
+
|----------|-------|
|
|
32
|
+
| CRITICAL | 2 |
|
|
33
|
+
| HIGH | 3 |
|
|
34
|
+
| MEDIUM | 2 |
|
|
35
|
+
| LOW | 1 |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### [CRITICAL] Missing 'use client' on interactive component
|
|
40
|
+
|
|
41
|
+
**File:** `src/features/users/components/UserList.tsx:1`
|
|
42
|
+
|
|
43
|
+
**Current code:**
|
|
44
|
+
```tsx
|
|
45
|
+
import { useState } from 'react';
|
|
46
|
+
|
|
47
|
+
export function UserList() {
|
|
48
|
+
const [selected, setSelected] = useState<string | null>(null);
|
|
49
|
+
return <div onClick={() => setSelected('test')}>...</div>;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Suggested fix:**
|
|
54
|
+
```tsx
|
|
55
|
+
'use client';
|
|
56
|
+
|
|
57
|
+
import { useState } from 'react';
|
|
58
|
+
// ... rest unchanged
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Why:** React hooks (`useState`) require `'use client'`. Without it, Next.js treats this as a Server Component and the `useState` call fails at runtime.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### [CRITICAL] useEffect for data fetching
|
|
66
|
+
|
|
67
|
+
**File:** `src/features/users/components/user-list.tsx:8`
|
|
68
|
+
|
|
69
|
+
**Current code:**
|
|
70
|
+
```tsx
|
|
71
|
+
'use client';
|
|
72
|
+
import { useEffect, useState } from 'react';
|
|
73
|
+
|
|
74
|
+
export function UserList() {
|
|
75
|
+
const [users, setUsers] = useState([]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
fetch('/api/users').then(r => r.json()).then(setUsers);
|
|
78
|
+
}, []);
|
|
79
|
+
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Suggested fix:**
|
|
84
|
+
```tsx
|
|
85
|
+
// Option A — Server Component (no 'use client' needed)
|
|
86
|
+
// app/(dashboard)/users/page.tsx
|
|
87
|
+
async function getUsers() {
|
|
88
|
+
const res = await fetch(`${process.env.API_URL}/api/users`, { next: { revalidate: 30 } });
|
|
89
|
+
return res.json();
|
|
90
|
+
}
|
|
91
|
+
export default async function UsersPage() {
|
|
92
|
+
const users = await getUsers();
|
|
93
|
+
return <UserList initialData={users} />;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Option B — TanStack Query (when client interactivity needed)
|
|
97
|
+
'use client';
|
|
98
|
+
import { useUsers } from '@/features/users/hooks/use-users';
|
|
99
|
+
export function UserList() {
|
|
100
|
+
const { data: users = [], isLoading } = useUsers();
|
|
101
|
+
if (isLoading) return <div>Loading...</div>;
|
|
102
|
+
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Why:** `useEffect` + `useState` for fetching: (1) doubles renders, (2) no caching, (3) no SSR, (4) no error/loading states, (5) can't be cancelled. TanStack Query or Server Components solve all five.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### [HIGH] PascalCase file name
|
|
111
|
+
|
|
112
|
+
**File:** `src/features/users/components/UserList.tsx`
|
|
113
|
+
|
|
114
|
+
**Suggested fix:** Rename to `user-list.tsx`
|
|
115
|
+
|
|
116
|
+
**Why:** Linux servers are case-sensitive. `UserList.tsx` and `user-list.tsx` are different files on the server but the same on macOS/Windows, causing import failures in production.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### [HIGH] Default export on non-page component
|
|
121
|
+
|
|
122
|
+
**File:** `src/features/users/components/user-card.tsx:3`
|
|
123
|
+
|
|
124
|
+
**Current code:**
|
|
125
|
+
```tsx
|
|
126
|
+
export default function UserCard({ user }: { user: User }) {
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Suggested fix:**
|
|
130
|
+
```tsx
|
|
131
|
+
export function UserCard({ user }: { user: User }) {
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Why:** Named exports are refactor-safe — IDEs track renames automatically. Default exports are anonymous in imports (`import X from './user-card'` allows `X` to be anything).
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### [HIGH] Type defined manually instead of deriving from Zod schema
|
|
139
|
+
|
|
140
|
+
**File:** `src/features/users/types/user.types.ts:1`
|
|
141
|
+
|
|
142
|
+
**Current code:**
|
|
143
|
+
```ts
|
|
144
|
+
export type User = {
|
|
145
|
+
id: string;
|
|
146
|
+
name: string;
|
|
147
|
+
email: string;
|
|
148
|
+
role: 'admin' | 'user';
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Suggested fix:**
|
|
153
|
+
```ts
|
|
154
|
+
// user.schemas.ts — single source of truth
|
|
155
|
+
export const userSchema = z.object({
|
|
156
|
+
id: z.string(),
|
|
157
|
+
name: z.string(),
|
|
158
|
+
email: z.string().email(),
|
|
159
|
+
role: z.enum(['admin', 'user']),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// user.types.ts — derived, never written manually
|
|
163
|
+
export type User = z.infer<typeof userSchema>;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Why:** Manually written types drift from API responses. `z.infer<>` ensures the TypeScript type is always in sync with the runtime validation.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### [MEDIUM] Deep path import instead of feature index
|
|
171
|
+
|
|
172
|
+
**File:** `src/app/(dashboard)/users/page.tsx:2`
|
|
173
|
+
|
|
174
|
+
**Current code:**
|
|
175
|
+
```tsx
|
|
176
|
+
import { UserList } from '@/features/users/components/user-list';
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Suggested fix:**
|
|
180
|
+
```tsx
|
|
181
|
+
import { UserList } from '@/features/users';
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Why:** Deep path imports expose internal structure. When `user-list.tsx` moves or is renamed, every consumer breaks. The feature index is the stable public API.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### [MEDIUM] Query key not using factory pattern
|
|
189
|
+
|
|
190
|
+
**File:** `src/features/users/hooks/use-users.ts:8`
|
|
191
|
+
|
|
192
|
+
**Current code:**
|
|
193
|
+
```ts
|
|
194
|
+
return useQuery({
|
|
195
|
+
queryKey: ['users'],
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Suggested fix:**
|
|
199
|
+
```ts
|
|
200
|
+
// query-keys.ts
|
|
201
|
+
export const userKeys = {
|
|
202
|
+
all: ['users'] as const,
|
|
203
|
+
lists: () => [...userKeys.all, 'list'] as const,
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// use-users.ts
|
|
207
|
+
return useQuery({
|
|
208
|
+
queryKey: userKeys.lists(),
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Why:** Hardcoded `['users']` cannot be selectively invalidated. `queryClient.invalidateQueries({ queryKey: userKeys.lists() })` correctly invalidates only list queries, not detail queries with the same prefix.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### [LOW] Test uses fireEvent instead of userEvent
|
|
216
|
+
|
|
217
|
+
**File:** `src/features/users/components/user-card.test.tsx:14`
|
|
218
|
+
|
|
219
|
+
**Current code:**
|
|
220
|
+
```tsx
|
|
221
|
+
fireEvent.click(screen.getByRole('button', { name: /edit/i }));
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Suggested fix:**
|
|
225
|
+
```tsx
|
|
226
|
+
await userEvent.click(screen.getByRole('button', { name: /edit/i }));
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Why:** `fireEvent.click` dispatches a synthetic event. `userEvent.click` simulates the full browser interaction sequence (pointerdown, mousedown, focus, click, etc.) — closer to real user behaviour.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Top Priorities
|
|
234
|
+
|
|
235
|
+
1. `UserList.tsx:1` — CRITICAL missing `'use client'` (2 min fix)
|
|
236
|
+
2. `user-list.tsx:8` — CRITICAL useEffect fetch → useQuery (15 min)
|
|
237
|
+
3. `UserList.tsx` — HIGH rename to `user-list.tsx` (2 min)
|
|
238
|
+
4. `user-card.tsx:3` — HIGH named export (2 min)
|
|
239
|
+
5. `user.types.ts:1` — HIGH derive from Zod (10 min)
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Passed Checks ✅
|
|
244
|
+
|
|
245
|
+
- `components/ui/` files untouched
|
|
246
|
+
- `zodResolver` correctly wired in `user-form.tsx`
|
|
247
|
+
- `isPending` used (v5 correct — not `isLoading`)
|
|
248
|
+
- `loading.tsx` and `error.tsx` present in `app/(dashboard)/users/`
|
|
249
|
+
- Feature has `index.ts` re-exporting public API
|
|
250
|
+
- Test file co-located with component
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: morph-checklist
|
|
3
|
-
description:
|
|
4
|
-
Pre-implementation checklist verifying that all MORPH-SPEC phases are complete and outputs exist before starting code. Use before any implementation work begins.
|
|
3
|
+
description: Pre-deploy, security, SEO, performance, accessibility, and LGPD compliance checklists for MORPH-SPEC projects. Use before deploying to production, during security audits, when optimizing for SEO or performance, or when validating Brazilian LGPD data protection compliance.
|
|
5
4
|
user-invocable: true
|
|
6
5
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
6
|
---
|
|
8
7
|
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
> **Layer:** 2 | **Load:** on-keyword | **Keywords:** checklist, deploy, security, seo, performance, accessibility, lgpd, legal
|
|
8
|
+
# MORPH Checklists
|
|
12
9
|
|
|
13
10
|
Types: `deploy`, `security`, `seo`, `performance`, `accessibility`, `legal-brazil`, `simulation` (see [simulation-checklist.md](simulation-checklist.md))
|
|
14
11
|
|