maestro-bundle 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +125 -37
  2. package/package.json +1 -1
  3. package/src/cli.mjs +7 -4
  4. package/templates/bundle-ai-agents/skills/agent-orchestration/SKILL.md +107 -41
  5. package/templates/bundle-ai-agents/skills/agent-orchestration/references/graph-patterns.md +50 -0
  6. package/templates/bundle-ai-agents/skills/agent-orchestration/references/routing-strategies.md +47 -0
  7. package/templates/bundle-ai-agents/skills/api-design/SKILL.md +125 -16
  8. package/templates/bundle-ai-agents/skills/api-design/references/pydantic-patterns.md +72 -0
  9. package/templates/bundle-ai-agents/skills/api-design/references/rest-conventions.md +51 -0
  10. package/templates/bundle-ai-agents/skills/clean-architecture/SKILL.md +113 -21
  11. package/templates/bundle-ai-agents/skills/clean-architecture/references/dependency-injection.md +60 -0
  12. package/templates/bundle-ai-agents/skills/clean-architecture/references/layer-rules.md +56 -0
  13. package/templates/bundle-ai-agents/skills/context-engineering/SKILL.md +104 -36
  14. package/templates/bundle-ai-agents/skills/context-engineering/references/compression-techniques.md +76 -0
  15. package/templates/bundle-ai-agents/skills/context-engineering/references/context-budget-calculator.md +45 -0
  16. package/templates/bundle-ai-agents/skills/database-modeling/SKILL.md +146 -19
  17. package/templates/bundle-ai-agents/skills/database-modeling/references/index-strategies.md +48 -0
  18. package/templates/bundle-ai-agents/skills/database-modeling/references/naming-conventions.md +27 -0
  19. package/templates/bundle-ai-agents/skills/docker-containerization/SKILL.md +124 -15
  20. package/templates/bundle-ai-agents/skills/docker-containerization/references/compose-patterns.md +97 -0
  21. package/templates/bundle-ai-agents/skills/docker-containerization/references/dockerfile-checklist.md +37 -0
  22. package/templates/bundle-ai-agents/skills/eval-testing/SKILL.md +113 -25
  23. package/templates/bundle-ai-agents/skills/eval-testing/references/eval-types.md +52 -0
  24. package/templates/bundle-ai-agents/skills/eval-testing/references/golden-dataset-template.md +59 -0
  25. package/templates/bundle-ai-agents/skills/memory-management/SKILL.md +112 -28
  26. package/templates/bundle-ai-agents/skills/memory-management/references/memory-tiers.md +41 -0
  27. package/templates/bundle-ai-agents/skills/memory-management/references/namespace-conventions.md +41 -0
  28. package/templates/bundle-ai-agents/skills/prompt-engineering/SKILL.md +139 -47
  29. package/templates/bundle-ai-agents/skills/prompt-engineering/references/anti-patterns.md +59 -0
  30. package/templates/bundle-ai-agents/skills/prompt-engineering/references/prompt-templates.md +75 -0
  31. package/templates/bundle-ai-agents/skills/rag-pipeline/SKILL.md +104 -27
  32. package/templates/bundle-ai-agents/skills/rag-pipeline/references/chunking-strategies.md +27 -0
  33. package/templates/bundle-ai-agents/skills/rag-pipeline/references/embedding-models.md +31 -0
  34. package/templates/bundle-ai-agents/skills/rag-pipeline/references/rag-evaluation.md +39 -0
  35. package/templates/bundle-ai-agents/skills/testing-strategy/SKILL.md +127 -18
  36. package/templates/bundle-ai-agents/skills/testing-strategy/references/fixture-patterns.md +81 -0
  37. package/templates/bundle-ai-agents/skills/testing-strategy/references/naming-conventions.md +69 -0
  38. package/templates/bundle-base/skills/branch-strategy/SKILL.md +134 -21
  39. package/templates/bundle-base/skills/branch-strategy/references/branch-rules.md +40 -0
  40. package/templates/bundle-base/skills/code-review/SKILL.md +123 -38
  41. package/templates/bundle-base/skills/code-review/references/review-checklist.md +45 -0
  42. package/templates/bundle-base/skills/commit-pattern/SKILL.md +98 -39
  43. package/templates/bundle-base/skills/commit-pattern/references/conventional-commits.md +40 -0
  44. package/templates/bundle-data-pipeline/skills/data-preprocessing/SKILL.md +110 -19
  45. package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandas-cheatsheet.md +63 -0
  46. package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandera-schemas.md +44 -0
  47. package/templates/bundle-data-pipeline/skills/docker-containerization/SKILL.md +132 -16
  48. package/templates/bundle-data-pipeline/skills/docker-containerization/references/compose-patterns.md +82 -0
  49. package/templates/bundle-data-pipeline/skills/docker-containerization/references/dockerfile-best-practices.md +57 -0
  50. package/templates/bundle-data-pipeline/skills/feature-engineering/SKILL.md +143 -45
  51. package/templates/bundle-data-pipeline/skills/feature-engineering/references/encoding-guide.md +41 -0
  52. package/templates/bundle-data-pipeline/skills/feature-engineering/references/scaling-guide.md +38 -0
  53. package/templates/bundle-data-pipeline/skills/mlops-pipeline/SKILL.md +156 -37
  54. package/templates/bundle-data-pipeline/skills/mlops-pipeline/references/mlflow-commands.md +69 -0
  55. package/templates/bundle-data-pipeline/skills/model-training/SKILL.md +152 -33
  56. package/templates/bundle-data-pipeline/skills/model-training/references/evaluation-metrics.md +52 -0
  57. package/templates/bundle-data-pipeline/skills/model-training/references/model-selection-guide.md +41 -0
  58. package/templates/bundle-data-pipeline/skills/rag-pipeline/SKILL.md +127 -39
  59. package/templates/bundle-data-pipeline/skills/rag-pipeline/references/chunking-strategies.md +51 -0
  60. package/templates/bundle-data-pipeline/skills/rag-pipeline/references/embedding-models.md +49 -0
  61. package/templates/bundle-frontend-spa/skills/authentication/SKILL.md +196 -13
  62. package/templates/bundle-frontend-spa/skills/authentication/references/jwt-security.md +41 -0
  63. package/templates/bundle-frontend-spa/skills/component-design/SKILL.md +191 -41
  64. package/templates/bundle-frontend-spa/skills/component-design/references/accessibility-checklist.md +41 -0
  65. package/templates/bundle-frontend-spa/skills/component-design/references/tailwind-patterns.md +65 -0
  66. package/templates/bundle-frontend-spa/skills/e2e-testing/SKILL.md +241 -79
  67. package/templates/bundle-frontend-spa/skills/e2e-testing/references/playwright-selectors.md +66 -0
  68. package/templates/bundle-frontend-spa/skills/e2e-testing/references/test-patterns.md +82 -0
  69. package/templates/bundle-frontend-spa/skills/integration-api/SKILL.md +221 -31
  70. package/templates/bundle-frontend-spa/skills/integration-api/references/api-patterns.md +81 -0
  71. package/templates/bundle-frontend-spa/skills/react-patterns/SKILL.md +195 -70
  72. package/templates/bundle-frontend-spa/skills/react-patterns/references/component-checklist.md +22 -0
  73. package/templates/bundle-frontend-spa/skills/react-patterns/references/hook-patterns.md +63 -0
  74. package/templates/bundle-frontend-spa/skills/responsive-layout/SKILL.md +162 -22
  75. package/templates/bundle-frontend-spa/skills/responsive-layout/references/breakpoint-guide.md +63 -0
  76. package/templates/bundle-frontend-spa/skills/state-management/SKILL.md +158 -30
  77. package/templates/bundle-frontend-spa/skills/state-management/references/react-query-config.md +64 -0
  78. package/templates/bundle-frontend-spa/skills/state-management/references/state-patterns.md +78 -0
  79. package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/SKILL.md +135 -45
  80. package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/references/gitlab-ci-templates.md +93 -0
  81. package/templates/bundle-jhipster-microservices/skills/clean-architecture/SKILL.md +87 -21
  82. package/templates/bundle-jhipster-microservices/skills/clean-architecture/references/layer-rules.md +78 -0
  83. package/templates/bundle-jhipster-microservices/skills/ddd-tactical/SKILL.md +94 -25
  84. package/templates/bundle-jhipster-microservices/skills/ddd-tactical/references/ddd-patterns.md +48 -0
  85. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/SKILL.md +63 -21
  86. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-microservices.md +40 -0
  87. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-structure.md +59 -0
  88. package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/SKILL.md +125 -91
  89. package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/references/docker-k8s-commands.md +68 -0
  90. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/SKILL.md +72 -20
  91. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/cross-service-entities.md +36 -0
  92. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/jdl-types.md +56 -0
  93. package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/SKILL.md +80 -8
  94. package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/references/gateway-config.md +43 -0
  95. package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/SKILL.md +115 -22
  96. package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/references/kafka-events.md +39 -0
  97. package/templates/bundle-jhipster-microservices/skills/jhipster-registry/SKILL.md +92 -23
  98. package/templates/bundle-jhipster-microservices/skills/jhipster-registry/references/consul-config.md +61 -0
  99. package/templates/bundle-jhipster-microservices/skills/jhipster-service/SKILL.md +81 -18
  100. package/templates/bundle-jhipster-microservices/skills/jhipster-service/references/service-patterns.md +40 -0
  101. package/templates/bundle-jhipster-microservices/skills/testing-strategy/SKILL.md +101 -20
  102. package/templates/bundle-jhipster-microservices/skills/testing-strategy/references/test-naming.md +55 -0
  103. package/templates/bundle-jhipster-monorepo/skills/clean-architecture/SKILL.md +87 -21
  104. package/templates/bundle-jhipster-monorepo/skills/clean-architecture/references/layer-rules.md +78 -0
  105. package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/SKILL.md +94 -25
  106. package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/references/ddd-patterns.md +48 -0
  107. package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/SKILL.md +99 -52
  108. package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/references/angular-structure.md +59 -0
  109. package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/SKILL.md +89 -36
  110. package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/references/jdl-types.md +56 -0
  111. package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/SKILL.md +123 -23
  112. package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/references/liquibase-operations.md +95 -0
  113. package/templates/bundle-jhipster-monorepo/skills/jhipster-security/SKILL.md +106 -19
  114. package/templates/bundle-jhipster-monorepo/skills/jhipster-security/references/security-checklist.md +47 -0
  115. package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/SKILL.md +84 -16
  116. package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/references/spring-layers.md +41 -0
  117. package/templates/bundle-jhipster-monorepo/skills/testing-strategy/SKILL.md +101 -20
  118. package/templates/bundle-jhipster-monorepo/skills/testing-strategy/references/test-naming.md +55 -0
@@ -1,22 +1,42 @@
1
1
  ---
2
2
  name: jhipster-service
3
- description: Criar e configurar um microsserviço JHipster com Spring Boot, incluindo API, banco próprio e comunicação inter-serviço. Use quando precisar criar um novo microsserviço, configurar Feign clients, ou definir APIs internas.
3
+ description: Create and configure JHipster microservices with Spring Boot, including API, own database, Feign clients, and Kafka communication. Use when creating a new microservice, configuring inter-service communication, or defining internal APIs.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
8
  # JHipster Microservice
7
9
 
8
- ## Criar novo serviço
10
+ Create and configure JHipster microservices with their own database, Feign clients for synchronous communication, and Kafka for asynchronous messaging.
11
+
12
+ ## When to Use
13
+ - When creating a new microservice
14
+ - When configuring Feign clients for service-to-service calls
15
+ - When setting up Kafka producers/consumers
16
+ - When defining internal API contracts
17
+ - When implementing circuit breakers and fallbacks
18
+
19
+ ## Available Operations
20
+ 1. Generate a new microservice with JHipster
21
+ 2. Configure database and service properties
22
+ 3. Create Feign clients with fallbacks
23
+ 4. Set up Kafka producers and consumers
24
+ 5. Define internal API contracts with DTOs
25
+
26
+ ## Multi-Step Workflow
27
+
28
+ ### Step 1: Generate the Microservice
9
29
 
10
30
  ```bash
11
- # Gerar via JDL (recomendado)
31
+ # Generate via JDL (recommended)
12
32
  jhipster import-jdl jhipster-jdl.jdl
13
33
 
14
- # Ou gerar manualmente
34
+ # Or generate manually
15
35
  mkdir bundle-service && cd bundle-service
16
36
  jhipster --blueprints="" --skip-client
17
37
  ```
18
38
 
19
- ## Configuração do serviço
39
+ ### Step 2: Configure the Service
20
40
 
21
41
  ```yaml
22
42
  # application.yml
@@ -26,14 +46,14 @@ spring:
26
46
  server:
27
47
  port: 8084
28
48
 
29
- # Banco próprio (database per service)
49
+ # Own database (database per service)
30
50
  spring:
31
51
  datasource:
32
52
  url: jdbc:postgresql://localhost:5432/bundle_service
33
53
  username: bundle
34
54
  password: bundle
35
55
 
36
- # Kafka
56
+ # Kafka bindings
37
57
  spring:
38
58
  cloud:
39
59
  stream:
@@ -48,7 +68,7 @@ spring:
48
68
  group: bundle-service
49
69
  ```
50
70
 
51
- ## Comunicação Síncrona Feign
71
+ ### Step 3: Create Feign Clients (Synchronous Communication)
52
72
 
53
73
  ```java
54
74
  @FeignClient(name = "demand-service", fallback = DemandServiceFallback.class)
@@ -78,7 +98,7 @@ public class DemandServiceFallback implements DemandServiceClient {
78
98
  }
79
99
  ```
80
100
 
81
- ## Comunicação Assíncrona Kafka
101
+ ### Step 4: Set Up Kafka (Asynchronous Communication)
82
102
 
83
103
  ```java
84
104
  // Producer
@@ -104,12 +124,10 @@ public Consumer<DemandCreatedEvent> demandEvents() {
104
124
  }
105
125
  ```
106
126
 
107
- ## Padrão de API interna
108
-
109
- APIs entre serviços usam DTOs compartilhados (nunca entities):
127
+ ### Step 5: Define Internal API DTOs
110
128
 
111
129
  ```java
112
- // Shared DTO package separado ou duplicado (não compartilhar JARs)
130
+ // Shared DTO -- package separado or duplicated (never share JARs)
113
131
  public record AgentAllocationRequest(
114
132
  Long taskId,
115
133
  AgentType requiredType,
@@ -123,9 +141,54 @@ public record AgentAllocationResponse(
123
141
  ) {}
124
142
  ```
125
143
 
126
- ## Regras
144
+ ### Step 6: Build and Run
145
+
146
+ ```bash
147
+ # Build the service
148
+ ./mvnw compile
149
+
150
+ # Run tests
151
+ ./mvnw test
152
+
153
+ # Start the service
154
+ ./mvnw spring-boot:run
155
+
156
+ # Verify registration in Consul
157
+ curl http://localhost:8500/v1/health/service/bundle-service
158
+ ```
127
159
 
128
- - Cada serviço tem seu próprio banco — NUNCA acessar banco de outro
129
- - Falha de um serviço NÃO pode derrubar outros (circuit breaker)
130
- - Eventos Kafka para notificação, Feign para query
131
- - Idempotência em consumers Kafka (mesmo evento pode chegar 2x)
160
+ ## Resources
161
+ - `references/service-patterns.md` - Microservice communication patterns and best practices
162
+
163
+ ## Examples
164
+ ### Example 1: Create a New Microservice
165
+ User asks: "Create a new notification-service"
166
+ Response approach:
167
+ 1. Generate with `jhipster --skip-client` in a new directory
168
+ 2. Configure `spring.application.name: notification-service`
169
+ 3. Set up its own PostgreSQL database
170
+ 4. Register with Consul
171
+ 5. Add Kafka consumer for events it needs
172
+
173
+ ### Example 2: Add Inter-Service Communication
174
+ User asks: "The demand-service needs to call agent-service to allocate an agent"
175
+ Response approach:
176
+ 1. Create `AgentServiceClient` Feign interface in demand-service
177
+ 2. Add fallback class for circuit breaker
178
+ 3. Call Feign client from service layer
179
+ 4. Test with agent-service running
180
+
181
+ ### Example 3: Handle Service Unavailability
182
+ User asks: "What happens if agent-service is down?"
183
+ Response approach:
184
+ 1. Verify Feign fallback is implemented
185
+ 2. Add circuit breaker configuration
186
+ 3. Log warnings when fallback is triggered
187
+ 4. Consider using Kafka for non-critical operations
188
+
189
+ ## Notes
190
+ - Each service has its own database -- NEVER access another service's database
191
+ - One service failing MUST NOT bring down others (circuit breaker)
192
+ - Kafka for notifications, Feign for queries
193
+ - Kafka consumers MUST be idempotent (same event can arrive twice)
194
+ - Duplicate DTOs between services rather than sharing JARs
@@ -0,0 +1,40 @@
1
+ # Microservice Communication Patterns
2
+
3
+ ## Synchronous (Feign)
4
+ - Use for: queries, real-time data needs
5
+ - Pattern: Request/Response
6
+ - Failure: Circuit breaker + fallback
7
+ - Discovery: Resolved via Consul/Eureka
8
+
9
+ ```java
10
+ @FeignClient(name = "service-name", fallback = Fallback.class)
11
+ public interface ServiceClient {
12
+ @GetMapping("/api/resource/{id}")
13
+ ResourceDTO get(@PathVariable Long id);
14
+ }
15
+ ```
16
+
17
+ ## Asynchronous (Kafka)
18
+ - Use for: notifications, event-driven flows
19
+ - Pattern: Publish/Subscribe
20
+ - Failure: DLQ (Dead Letter Queue)
21
+ - Guarantee: At-least-once delivery
22
+
23
+ ```java
24
+ // Producer
25
+ streamBridge.send("topic-out-0", event);
26
+
27
+ // Consumer
28
+ @Bean
29
+ public Consumer<EventType> topicName() {
30
+ return event -> { /* handle */ };
31
+ }
32
+ ```
33
+
34
+ ## Rules
35
+ 1. Database per service -- never share databases
36
+ 2. Feign for queries, Kafka for events
37
+ 3. Fallbacks for all Feign clients
38
+ 4. Idempotent Kafka consumers
39
+ 5. Duplicate DTOs, never share JARs
40
+ 6. One topic per bounded context
@@ -1,27 +1,46 @@
1
1
  ---
2
2
  name: testing-strategy
3
- description: Implementar estratégia de testes com unitários, integração e e2e usando Pytest ou JUnit. Use quando for escrever testes, definir estratégia de testes, ou melhorar cobertura.
3
+ description: Implement testing strategy with unit, integration, and e2e tests using Pytest or JUnit. Use when writing tests, defining test strategy, improving coverage, or setting up test infrastructure.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
- # Estratégia de Testes
8
+ # Testing Strategy
7
9
 
8
- ## Pirâmide
10
+ Implement a comprehensive testing strategy following the test pyramid with unit tests for domain logic, integration tests for infrastructure, and e2e tests for critical flows.
11
+
12
+ ## When to Use
13
+ - When writing tests for new features
14
+ - When defining the test strategy for a module
15
+ - When improving test coverage
16
+ - When setting up test infrastructure (fixtures, factories)
17
+ - When reviewing test quality
18
+
19
+ ## Available Operations
20
+ 1. Write unit tests for domain entities and value objects
21
+ 2. Write integration tests for repositories
22
+ 3. Write API integration tests for controllers
23
+ 4. Set up test fixtures and factories
24
+ 5. Run tests with coverage reporting
25
+
26
+ ## Multi-Step Workflow
27
+
28
+ ### Step 1: Understand the Test Pyramid
9
29
 
10
30
  ```
11
- / E2E \ Poucos, lentos, caros
12
- / Integr. \ Moderados
13
- / Unitários \ Muitos, rápidos, baratos
31
+ / E2E \ Few, slow, expensive
32
+ / Integr. \ Moderate
33
+ / Unit Tests \ Many, fast, cheap
14
34
  ```
15
35
 
16
- ## Testes Unitários Domínio
17
-
18
- Testar regras de negócio sem infraestrutura.
36
+ ### Step 2: Write Unit Tests for Domain Logic
37
+ Test business rules without infrastructure dependencies.
19
38
 
20
39
  ```python
21
40
  # tests/domain/test_demand.py
22
41
  class TestDemand:
23
42
  def test_should_decompose_new_demand(self):
24
- demand = Demand(id=DemandId.generate(), description="Criar CRUD")
43
+ demand = Demand(id=DemandId.generate(), description="Create CRUD")
25
44
  planner = FakePlanner(tasks=[Task(...), Task(...)])
26
45
 
27
46
  tasks = demand.decompose(planner)
@@ -30,14 +49,14 @@ class TestDemand:
30
49
  assert demand.status == DemandStatus.PLANNED
31
50
 
32
51
  def test_should_reject_decompose_if_already_planned(self):
33
- demand = Demand(id=DemandId.generate(), description="Criar CRUD")
52
+ demand = Demand(id=DemandId.generate(), description="Create CRUD")
34
53
  demand.decompose(FakePlanner(tasks=[Task(...)]))
35
54
 
36
55
  with pytest.raises(DemandAlreadyDecomposedException):
37
56
  demand.decompose(FakePlanner(tasks=[]))
38
57
 
39
58
  def test_should_not_allow_more_than_20_tasks(self):
40
- demand = Demand(id=DemandId.generate(), description="Mega projeto")
59
+ demand = Demand(id=DemandId.generate(), description="Large project")
41
60
  for i in range(20):
42
61
  demand.add_task(Task(...))
43
62
 
@@ -45,7 +64,7 @@ class TestDemand:
45
64
  demand.add_task(Task(...))
46
65
  ```
47
66
 
48
- ## Testes Unitários Value Objects
67
+ ### Step 3: Write Unit Tests for Value Objects
49
68
 
50
69
  ```python
51
70
  class TestComplianceScore:
@@ -62,7 +81,7 @@ class TestComplianceScore:
62
81
  ComplianceScore(150.0)
63
82
  ```
64
83
 
65
- ## Testes de Integração Repositórios
84
+ ### Step 4: Write Integration Tests for Repositories
66
85
 
67
86
  ```python
68
87
  # tests/infrastructure/test_pg_demand_repository.py
@@ -84,12 +103,74 @@ class TestPgDemandRepository:
84
103
  assert found.description == "Test"
85
104
  ```
86
105
 
87
- ## Naming
88
-
106
+ ### Step 5: Run Tests with Coverage
107
+
108
+ ```bash
109
+ # Python with Pytest
110
+ pytest --cov=src --cov-report=html --cov-fail-under=80
111
+ pytest tests/domain/ -v # Unit tests only
112
+ pytest tests/infrastructure/ -v # Integration tests only
113
+
114
+ # Java with Maven
115
+ ./mvnw test # All tests
116
+ ./mvnw test -Dtest="*DomainTest" # Domain tests only
117
+ ./mvnw test -Dtest="*RepositoryIT" # Repository integration tests
118
+ ./mvnw test -Dtest="*ResourceIT" # API integration tests
119
+ ./mvnw verify -Pcoverage # With coverage report
120
+
121
+ # Angular
122
+ npm test # Unit tests
123
+ npm run test -- --code-coverage # With coverage
124
+ npm run e2e # End-to-end tests
89
125
  ```
90
- test_should_<resultado>_when_<condição>
91
126
 
92
- test_should_return_error_when_email_is_invalid
93
- test_should_decompose_demand_when_status_is_created
94
- test_should_reject_merge_when_conflicts_exist
127
+ ### Step 6: Review Coverage Report
128
+
129
+ ```bash
130
+ # Python
131
+ open htmlcov/index.html
132
+
133
+ # Java (JaCoCo)
134
+ open target/site/jacoco/index.html
135
+
136
+ # Angular
137
+ open coverage/index.html
95
138
  ```
139
+
140
+ ## Resources
141
+ - `references/test-naming.md` - Test naming conventions and patterns
142
+
143
+ ## Examples
144
+ ### Example 1: Test a New Entity
145
+ User asks: "Write tests for the Demand entity"
146
+ Response approach:
147
+ 1. Test happy path: create, decompose, complete
148
+ 2. Test invariants: max tasks, status transitions
149
+ 3. Test edge cases: empty description, null values
150
+ 4. Use `test_should_<result>_when_<condition>` naming
151
+ 5. Run `pytest tests/domain/test_demand.py -v`
152
+
153
+ ### Example 2: Test a Repository
154
+ User asks: "Write integration tests for the DemandRepository"
155
+ Response approach:
156
+ 1. Set up test database fixture with rollback
157
+ 2. Test save and find operations
158
+ 3. Test query methods (findByStatus, etc.)
159
+ 4. Test not-found scenarios
160
+ 5. Run `pytest tests/infrastructure/ -v`
161
+
162
+ ### Example 3: Improve Test Coverage
163
+ User asks: "Our coverage is at 60%, we need 80%"
164
+ Response approach:
165
+ 1. Run `pytest --cov=src --cov-report=html` to see uncovered lines
166
+ 2. Identify untested domain logic (highest priority)
167
+ 3. Write tests for uncovered business rules first
168
+ 4. Then cover integration points
169
+ 5. Verify with `pytest --cov-fail-under=80`
170
+
171
+ ## Notes
172
+ - Test naming convention: `test_should_<result>_when_<condition>`
173
+ - Domain tests should have ZERO infrastructure dependencies
174
+ - Integration tests should use rollback to avoid polluting the database
175
+ - Minimum coverage target: 80% for business logic
176
+ - Use fakes/stubs for domain tests, real implementations for integration tests
@@ -0,0 +1,55 @@
1
+ # Test Naming Conventions
2
+
3
+ ## Pattern
4
+ ```
5
+ test_should_<expected_result>_when_<condition>
6
+ ```
7
+
8
+ ## Examples
9
+ ```
10
+ test_should_return_error_when_email_is_invalid
11
+ test_should_decompose_demand_when_status_is_created
12
+ test_should_reject_merge_when_conflicts_exist
13
+ test_should_allocate_agent_when_team_has_capacity
14
+ test_should_raise_exception_when_score_exceeds_100
15
+ test_should_complete_demand_when_all_tasks_done
16
+ ```
17
+
18
+ ## Java/JUnit Equivalent
19
+ ```java
20
+ @Test
21
+ void shouldReturnErrorWhenEmailIsInvalid() { ... }
22
+
23
+ @Test
24
+ void shouldDecomposeDemandWhenStatusIsCreated() { ... }
25
+ ```
26
+
27
+ ## Test Structure (AAA Pattern)
28
+ ```python
29
+ def test_should_decompose_new_demand(self):
30
+ # Arrange
31
+ demand = Demand(id=DemandId.generate(), description="Create CRUD")
32
+ planner = FakePlanner(tasks=[Task(...), Task(...)])
33
+
34
+ # Act
35
+ tasks = demand.decompose(planner)
36
+
37
+ # Assert
38
+ assert len(tasks) == 2
39
+ assert demand.status == DemandStatus.PLANNED
40
+ ```
41
+
42
+ ## Test Categories
43
+ | Category | Location | Dependencies | Speed |
44
+ |---|---|---|---|
45
+ | Unit (Domain) | tests/domain/ | None | Fast |
46
+ | Unit (Application) | tests/application/ | Mocked | Fast |
47
+ | Integration | tests/infrastructure/ | DB, Kafka | Medium |
48
+ | API/Controller | tests/api/ | Full stack | Medium |
49
+ | E2E | tests/e2e/ | Full system | Slow |
50
+
51
+ ## Coverage Targets
52
+ - Domain logic: 90%+
53
+ - Application layer: 80%+
54
+ - Infrastructure: 70%+
55
+ - Overall minimum: 80%
@@ -1,28 +1,49 @@
1
1
  ---
2
2
  name: clean-architecture
3
- description: Implementar Clean Architecture com camadas de domínio, aplicação e infraestrutura. Use quando for criar módulos, organizar código em camadas, separar regras de negócio de infraestrutura, ou estruturar um projeto novo.
3
+ description: Implement Clean Architecture with domain, application, and infrastructure layers. Use when creating modules, organizing code in layers, separating business rules from infrastructure, or structuring a new project.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
8
  # Clean Architecture
7
9
 
8
- ## Camadas
10
+ Implement Clean Architecture with properly separated layers, dependency inversion, and domain-centric design.
11
+
12
+ ## When to Use
13
+ - When creating a new module or bounded context
14
+ - When organizing code into proper layers
15
+ - When separating business rules from infrastructure
16
+ - When reviewing architecture compliance
17
+ - When refactoring a monolithic service class
18
+
19
+ ## Available Operations
20
+ 1. Create domain layer with entities and repository interfaces
21
+ 2. Create application layer with use cases
22
+ 3. Create infrastructure layer with adapters
23
+ 4. Verify dependency direction compliance
24
+ 5. Refactor code to follow Clean Architecture
25
+
26
+ ## Multi-Step Workflow
27
+
28
+ ### Step 1: Understand the Layer Structure
9
29
 
10
30
  ```
11
- ┌──────────────────────────────┐
12
- API / CLI Controllers, Routers
13
- ├──────────────────────────────┤
14
- APPLICATION Use Cases, DTOs
15
- ├──────────────────────────────┤
16
- DOMAIN Entities, VOs, Events, Repos (interface)
17
- ├──────────────────────────────┤
18
- INFRASTRUCTURE DB, HTTP clients, Frameworks
19
- └──────────────────────────────┘
20
-
21
- Dependency Rule: setas apontam para DENTRO (infra domain)
22
- Domain NUNCA importa de infrastructure
31
+ +------------------------------+
32
+ | API / CLI | <-- Controllers, Routers
33
+ +------------------------------+
34
+ | APPLICATION | <-- Use Cases, DTOs
35
+ +------------------------------+
36
+ | DOMAIN | <-- Entities, VOs, Events, Repos (interface)
37
+ +------------------------------+
38
+ | INFRASTRUCTURE | <-- DB, HTTP clients, Frameworks
39
+ +------------------------------+
40
+
41
+ Dependency Rule: arrows point INWARD (infra -> domain)
42
+ Domain NEVER imports from infrastructure
23
43
  ```
24
44
 
25
- ## Domain Layer
45
+ ### Step 2: Implement the Domain Layer
46
+ The domain layer contains entities, value objects, domain events, and repository interfaces (ports).
26
47
 
27
48
  ```python
28
49
  # domain/entities/demand.py
@@ -45,7 +66,7 @@ class Demand:
45
66
  def pending_events(self) -> list[DomainEvent]:
46
67
  return list(self._events)
47
68
 
48
- # domain/repositories/demand_repository.py (PORT - apenas interface)
69
+ # domain/repositories/demand_repository.py (PORT - interface only)
49
70
  class DemandRepository(ABC):
50
71
  @abstractmethod
51
72
  def find_by_id(self, id: DemandId) -> Demand: ...
@@ -53,7 +74,8 @@ class DemandRepository(ABC):
53
74
  def save(self, demand: Demand) -> None: ...
54
75
  ```
55
76
 
56
- ## Application Layer
77
+ ### Step 3: Implement the Application Layer
78
+ Use cases orchestrate domain operations. They contain NO business rules.
57
79
 
58
80
  ```python
59
81
  # application/use_cases/decompose_demand.py
@@ -72,7 +94,8 @@ class DecomposeDemand:
72
94
  return DecomposeDemandOutput(tasks=[TaskDTO.from_entity(t) for t in tasks])
73
95
  ```
74
96
 
75
- ## Infrastructure Layer
97
+ ### Step 4: Implement the Infrastructure Layer
98
+ Adapters implement the ports defined in the domain layer.
76
99
 
77
100
  ```python
78
101
  # infrastructure/persistence/pg_demand_repository.py (ADAPTER)
@@ -92,8 +115,51 @@ class PgDemandRepository(DemandRepository):
92
115
  self._session.commit()
93
116
  ```
94
117
 
95
- ## Regra de ouro
118
+ ### Step 5: Verify Architecture Compliance
119
+
120
+ ```bash
121
+ # Check for dependency violations: domain should not import infrastructure
122
+ grep -rn "from infrastructure" src/domain/ --include="*.py"
123
+ grep -rn "from.*infrastructure" src/domain/ --include="*.java"
96
124
 
97
- Use Case orquestra Entity contém regra → Repository persiste
125
+ # Run tests per layer
126
+ pytest tests/domain/ # Unit tests (no infra deps)
127
+ pytest tests/application/ # Use case tests (mocked deps)
128
+ pytest tests/infrastructure/ # Integration tests
129
+ ```
98
130
 
99
- Nunca colocar regra de negócio no Controller, Repository ou "Service" genérico.
131
+ ## Resources
132
+ - `references/layer-rules.md` - Layer dependency rules and package organization
133
+
134
+ ## Examples
135
+ ### Example 1: Create a New Domain Module
136
+ User asks: "Create the demand management module with Clean Architecture"
137
+ Response approach:
138
+ 1. Create `domain/entities/demand.py` with entity and behavior
139
+ 2. Create `domain/repositories/demand_repository.py` as interface (port)
140
+ 3. Create `application/use_cases/create_demand.py` as orchestrator
141
+ 4. Create `infrastructure/persistence/pg_demand_repository.py` as adapter
142
+ 5. Wire dependencies via DI container
143
+
144
+ ### Example 2: Refactor a Fat Service
145
+ User asks: "This service has 500 lines and mixes business logic with database calls"
146
+ Response approach:
147
+ 1. Extract business rules into domain entities
148
+ 2. Extract repository interface from data access code
149
+ 3. Create use case class for orchestration
150
+ 4. Move database code to infrastructure adapter
151
+ 5. Verify no domain imports from infrastructure
152
+
153
+ ### Example 3: Verify Architecture
154
+ User asks: "Check if our code follows Clean Architecture"
155
+ Response approach:
156
+ 1. Search for dependency violations with grep
157
+ 2. Check that domain layer has no framework imports
158
+ 3. Verify use cases only orchestrate, not contain logic
159
+ 4. Check that entities have behavior, not just data
160
+
161
+ ## Notes
162
+ - Golden Rule: Use Case orchestrates -> Entity contains rules -> Repository persists
163
+ - Never put business logic in Controller, Repository, or generic "Service"
164
+ - Domain layer must be testable without any infrastructure
165
+ - Use dependency injection to wire adapters to ports
@@ -0,0 +1,78 @@
1
+ # Clean Architecture Layer Rules
2
+
3
+ ## Dependency Direction
4
+ ```
5
+ API/CLI --> APPLICATION --> DOMAIN <-- INFRASTRUCTURE
6
+ ```
7
+ - All dependencies point toward DOMAIN
8
+ - Domain NEVER imports from Application, Infrastructure, or API
9
+ - Infrastructure implements Domain interfaces (Dependency Inversion)
10
+
11
+ ## Layer Contents
12
+
13
+ ### Domain Layer
14
+ - Entities (with behavior, not anemic)
15
+ - Value Objects (immutable, validated)
16
+ - Domain Events
17
+ - Repository Interfaces (Ports)
18
+ - Domain Services (cross-entity logic)
19
+ - Exceptions (business exceptions)
20
+
21
+ ### Application Layer
22
+ - Use Cases (one per operation)
23
+ - Input/Output DTOs
24
+ - Application Services (orchestration only)
25
+ - NO business rules here
26
+
27
+ ### Infrastructure Layer
28
+ - Repository Implementations (Adapters)
29
+ - Database Models/Mappings
30
+ - HTTP Clients
31
+ - Message Queue Producers/Consumers
32
+ - Framework Configuration
33
+
34
+ ### API Layer
35
+ - REST Controllers
36
+ - GraphQL Resolvers
37
+ - CLI Commands
38
+ - Request/Response mapping
39
+
40
+ ## Package Organization (Java)
41
+ ```
42
+ com.myapp/
43
+ domain/
44
+ model/ # Entities, VOs
45
+ event/ # Domain Events
46
+ repository/ # Repository interfaces
47
+ service/ # Domain Services
48
+ exception/ # Business exceptions
49
+ application/
50
+ usecase/ # Use Cases
51
+ dto/ # Input/Output DTOs
52
+ infrastructure/
53
+ persistence/ # JPA Repositories
54
+ messaging/ # Kafka/RabbitMQ
55
+ http/ # REST clients
56
+ web/
57
+ rest/ # Controllers
58
+ ```
59
+
60
+ ## Package Organization (Python)
61
+ ```
62
+ src/
63
+ domain/
64
+ entities/
65
+ value_objects/
66
+ events/
67
+ repositories/ # ABC interfaces
68
+ services/
69
+ application/
70
+ use_cases/
71
+ dto/
72
+ infrastructure/
73
+ persistence/
74
+ messaging/
75
+ http_clients/
76
+ api/
77
+ routes/
78
+ ```