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,15 +1,31 @@
1
1
  ---
2
2
  name: jhipster-security
3
- description: Configurar segurança no JHipster com JWT, OAuth2, roles e permissões. Use quando precisar implementar autenticação, autorização, roles, ou proteger endpoints.
3
+ description: Configure security in JHipster with JWT, OAuth2, roles, and permissions. Use when implementing authentication, authorization, roles, protecting endpoints, or configuring CORS/CSRF.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
8
  # JHipster Security
7
9
 
8
- ## JWT (padrão monorepo)
10
+ Configure and customize security in JHipster applications using JWT, OAuth2/Keycloak, role-based access control, and method-level security.
9
11
 
10
- O JHipster gera JWT automaticamente. Customizar:
12
+ ## When to Use
13
+ - When protecting REST endpoints by role
14
+ - When creating custom roles and authorities
15
+ - When configuring JWT or OAuth2/Keycloak
16
+ - When adding method-level security (@PreAuthorize)
17
+ - When setting up CORS, CSRF, or rate limiting
11
18
 
12
- ### Proteger endpoints por role
19
+ ## Available Operations
20
+ 1. Configure endpoint security by role
21
+ 2. Create custom roles and authorities
22
+ 3. Add method-level security annotations
23
+ 4. Configure OAuth2 with Keycloak
24
+ 5. Apply security checklist
25
+
26
+ ## Multi-Step Workflow
27
+
28
+ ### Step 1: Configure Endpoint Protection
13
29
 
14
30
  ```java
15
31
  @Configuration
@@ -31,18 +47,24 @@ public class SecurityConfiguration {
31
47
  }
32
48
  ```
33
49
 
34
- ### Criar roles customizadas
50
+ ### Step 2: Define Custom Roles
35
51
 
36
52
  ```java
37
53
  public final class AuthoritiesConstants {
38
54
  public static final String ADMIN = "ROLE_ADMIN";
39
55
  public static final String USER = "ROLE_USER";
40
- public static final String AGENT = "ROLE_AGENT"; // Agentes AI
41
- public static final String TECH_LEAD = "ROLE_TECH_LEAD"; // Aprovador de merge
56
+ public static final String AGENT = "ROLE_AGENT"; // AI Agents
57
+ public static final String TECH_LEAD = "ROLE_TECH_LEAD"; // Merge approver
42
58
  }
43
59
  ```
44
60
 
45
- ### Segurança no método
61
+ Add roles to Liquibase data:
62
+ ```bash
63
+ # Edit authority.csv to add new roles
64
+ cat src/main/resources/config/liquibase/data/authority.csv
65
+ ```
66
+
67
+ ### Step 3: Add Method-Level Security
46
68
 
47
69
  ```java
48
70
  @Service
@@ -50,17 +72,17 @@ public class DemandServiceImpl implements DemandService {
50
72
 
51
73
  @PreAuthorize("hasAuthority('ROLE_TECH_LEAD')")
52
74
  public void approveMerge(Long demandId) {
53
- // Somente tech lead pode aprovar merge
75
+ // Only tech lead can approve merge
54
76
  }
55
77
 
56
78
  @PreAuthorize("#login == authentication.name or hasAuthority('ROLE_ADMIN')")
57
79
  public DemandDTO findByUser(String login) {
58
- // Usuário suas demands, admin todas
80
+ // User sees only their demands, admin sees all
59
81
  }
60
82
  }
61
83
  ```
62
84
 
63
- ## OAuth2 + Keycloak (recomendado para microservices)
85
+ ### Step 4: Configure OAuth2 + Keycloak (for production)
64
86
 
65
87
  ```yaml
66
88
  # application.yml
@@ -78,12 +100,77 @@ spring:
78
100
  scope: openid,profile,email
79
101
  ```
80
102
 
81
- ## Checklist de segurança
103
+ ```bash
104
+ # Start Keycloak with Docker
105
+ docker-compose -f src/main/docker/keycloak.yml up -d
106
+
107
+ # Access Keycloak admin console
108
+ # URL: http://localhost:9080
109
+ # User: admin / Password: admin
110
+ ```
111
+
112
+ ### Step 5: Apply Security Checklist
113
+
114
+ ```bash
115
+ # Verify no hardcoded secrets
116
+ grep -r "password\|secret\|api.key" src/main/resources/ --include="*.yml" --include="*.properties"
117
+
118
+ # Check CORS configuration
119
+ grep -r "cors" src/main/java/ --include="*.java"
120
+
121
+ # Verify HTTPS configuration for prod profile
122
+ grep -r "ssl\|https" src/main/resources/config/application-prod.yml
123
+ ```
124
+
125
+ Checklist:
126
+ - [ ] Rate limiting on public endpoints
127
+ - [ ] CORS properly configured (not `*` in production)
128
+ - [ ] CSRF enabled for browser, disabled for API
129
+ - [ ] Secrets in environment variables, never in code
130
+ - [ ] Passwords with BCrypt (JHipster default)
131
+ - [ ] Audit trail for critical operations
132
+ - [ ] HTTPS in production
133
+
134
+ ### Step 6: Test Security
135
+
136
+ ```bash
137
+ # Run security-related tests
138
+ ./mvnw test -Dtest="*Security*,*Auth*"
139
+
140
+ # Test endpoint protection manually
141
+ curl -v http://localhost:8080/api/demands # Should return 401
142
+ curl -v -H "Authorization: Bearer <token>" http://localhost:8080/api/demands # Should return 200
143
+ ```
82
144
 
83
- - [ ] Rate limiting nos endpoints públicos
84
- - [ ] CORS configurado corretamente (não `*` em prod)
85
- - [ ] CSRF habilitado para browser, desabilitado para API
86
- - [ ] Secrets em variáveis de ambiente, nunca no código
87
- - [ ] Senhas com BCrypt (padrão JHipster)
88
- - [ ] Audit trail para operações críticas
89
- - [ ] HTTPS em produção
145
+ ## Resources
146
+ - `references/security-checklist.md` - Complete security checklist for JHipster applications
147
+
148
+ ## Examples
149
+ ### Example 1: Protect an Endpoint by Role
150
+ User asks: "Only admins should access the /api/admin/reports endpoint"
151
+ Response approach:
152
+ 1. Add `.requestMatchers("/api/admin/reports/**").hasAuthority(AuthoritiesConstants.ADMIN)` to SecurityConfiguration
153
+ 2. Run `./mvnw test -Dtest="*Security*"` to verify
154
+ 3. Test manually with curl
155
+
156
+ ### Example 2: Add a Custom Role
157
+ User asks: "Create a TECH_LEAD role that can approve merges"
158
+ Response approach:
159
+ 1. Add `ROLE_TECH_LEAD` to `AuthoritiesConstants`
160
+ 2. Add to `authority.csv` in Liquibase data
161
+ 3. Add `@PreAuthorize("hasAuthority('ROLE_TECH_LEAD')")` to the approval method
162
+ 4. Run `./mvnw test`
163
+
164
+ ### Example 3: Setup Keycloak
165
+ User asks: "Configure OAuth2 with Keycloak for this project"
166
+ Response approach:
167
+ 1. Add OAuth2 configuration to `application.yml`
168
+ 2. Start Keycloak with `docker-compose -f src/main/docker/keycloak.yml up -d`
169
+ 3. Configure realm and client in Keycloak admin console
170
+ 4. Test login flow
171
+
172
+ ## Notes
173
+ - JWT is the default for monorepo; OAuth2/Keycloak recommended for microservices
174
+ - Always use `@PreAuthorize` for fine-grained access control in services
175
+ - Never expose security configuration details in API responses
176
+ - Test both authenticated and unauthenticated access in integration tests
@@ -0,0 +1,47 @@
1
+ # JHipster Security Checklist
2
+
3
+ ## Authentication
4
+ - [ ] JWT or OAuth2/OIDC properly configured
5
+ - [ ] Token expiration set appropriately
6
+ - [ ] Refresh token mechanism in place
7
+ - [ ] Password policy enforced (BCrypt, min length)
8
+
9
+ ## Authorization
10
+ - [ ] Endpoints protected with proper roles
11
+ - [ ] Method-level security with @PreAuthorize where needed
12
+ - [ ] User can only access their own resources (data isolation)
13
+ - [ ] Admin endpoints separated under /api/admin/
14
+
15
+ ## API Security
16
+ - [ ] Rate limiting on public endpoints
17
+ - [ ] Input validation on all request bodies (@Valid)
18
+ - [ ] CORS configured (not wildcard in production)
19
+ - [ ] CSRF enabled for browser clients
20
+ - [ ] Content-Type validation
21
+ - [ ] Response does not leak internal details
22
+
23
+ ## Data Security
24
+ - [ ] No hardcoded secrets in source code
25
+ - [ ] Secrets stored in environment variables or vault
26
+ - [ ] Parameterized queries (no SQL injection)
27
+ - [ ] Sensitive data encrypted at rest
28
+ - [ ] Passwords hashed with BCrypt
29
+
30
+ ## Infrastructure
31
+ - [ ] HTTPS enforced in production
32
+ - [ ] Security headers configured (X-Frame-Options, CSP, etc.)
33
+ - [ ] Audit trail for critical operations
34
+ - [ ] Logging does not contain sensitive data
35
+ - [ ] Dependencies scanned for vulnerabilities
36
+
37
+ ## Commands for Verification
38
+ ```bash
39
+ # Check for hardcoded secrets
40
+ grep -rn "password\|secret\|api.key" src/ --include="*.java" --include="*.yml"
41
+
42
+ # Run security tests
43
+ ./mvnw test -Dtest="*Security*,*Auth*"
44
+
45
+ # Check dependencies for vulnerabilities
46
+ ./mvnw dependency-check:check
47
+ ```
@@ -1,19 +1,39 @@
1
1
  ---
2
2
  name: jhipster-spring
3
- description: Desenvolver backend Spring Boot no JHipster com services, repositories, DTOs, MapStruct e Spring Security. Use quando precisar criar endpoints, services, ou customizar o backend JHipster.
3
+ description: Develop Spring Boot backend in JHipster with controllers, services, repositories, DTOs, and MapStruct mappers. Use when creating endpoints, services, repositories, or customizing the JHipster backend.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
8
  # JHipster Spring Boot
7
9
 
8
- ## Camadas no JHipster
10
+ Develop and customize the Spring Boot backend generated by JHipster, following the layered architecture with Controllers, Services, Repositories, DTOs, and MapStruct Mappers.
11
+
12
+ ## When to Use
13
+ - When creating new REST endpoints
14
+ - When implementing service layer business logic
15
+ - When creating custom repository queries
16
+ - When defining DTOs and MapStruct mappers
17
+ - When customizing generated backend code
18
+
19
+ ## Available Operations
20
+ 1. Create REST controllers with pagination and filtering
21
+ 2. Implement service layer with transaction management
22
+ 3. Define DTOs using Java Records
23
+ 4. Create MapStruct mappers
24
+ 5. Add custom repository queries with Spring Data JPA
25
+
26
+ ## Multi-Step Workflow
27
+
28
+ ### Step 1: Understand the Layer Architecture
9
29
 
10
30
  ```
11
- Controller (web/rest/) Service (service/) Repository (repository/) Entity (domain/)
12
-
13
- DTO + Mapper (service/dto/ + service/mapper/)
31
+ Controller (web/rest/) --> Service (service/) --> Repository (repository/) --> Entity (domain/)
32
+ |
33
+ DTO + Mapper (service/dto/ + service/mapper/)
14
34
  ```
15
35
 
16
- ## Controller REST API
36
+ ### Step 2: Create the Controller
17
37
 
18
38
  ```java
19
39
  @RestController
@@ -61,7 +81,7 @@ public class DemandResource {
61
81
  }
62
82
  ```
63
83
 
64
- ## Service Lógica de aplicação
84
+ ### Step 3: Implement the Service
65
85
 
66
86
  ```java
67
87
  @Service
@@ -98,7 +118,7 @@ public class DemandServiceImpl implements DemandService {
98
118
  }
99
119
  ```
100
120
 
101
- ## DTO Records (Java 21)
121
+ ### Step 4: Define DTOs with Java Records
102
122
 
103
123
  ```java
104
124
  public record CreateDemandDTO(
@@ -116,7 +136,7 @@ public record DemandDTO(
116
136
  ) {}
117
137
  ```
118
138
 
119
- ## MapStruct Mapper
139
+ ### Step 5: Create MapStruct Mapper
120
140
 
121
141
  ```java
122
142
  @Mapper(componentModel = "spring", uses = {TaskMapper.class})
@@ -131,7 +151,7 @@ public interface DemandMapper extends EntityMapper<DemandDTO, Demand> {
131
151
  }
132
152
  ```
133
153
 
134
- ## Repository Spring Data JPA
154
+ ### Step 6: Add Repository Queries
135
155
 
136
156
  ```java
137
157
  @Repository
@@ -146,10 +166,58 @@ public interface DemandRepository extends JpaRepository<Demand, Long>, JpaSpecif
146
166
  }
147
167
  ```
148
168
 
149
- ## Regras
169
+ ### Step 7: Build and Test
170
+
171
+ ```bash
172
+ # Compile
173
+ ./mvnw compile
174
+
175
+ # Run tests
176
+ ./mvnw test
177
+
178
+ # Run specific test class
179
+ ./mvnw test -Dtest="DemandResourceIT"
180
+
181
+ # Run the application
182
+ ./mvnw spring-boot:run
183
+
184
+ # Test endpoint
185
+ curl http://localhost:8080/api/v1/demands
186
+ ```
150
187
 
151
- - Constructor injection sempre (nunca `@Autowired` em campo)
152
- - `@Transactional(readOnly = true)` em queries
153
- - `@Transactional` apenas no Service, nunca no Controller
154
- - DTOs na API, Entities no domínio — nunca misturar
155
- - Validação com Bean Validation (`@Valid`) no Controller
188
+ ## Resources
189
+ - `references/spring-layers.md` - Spring Boot layer conventions and patterns
190
+
191
+ ## Examples
192
+ ### Example 1: Create a New REST Endpoint
193
+ User asks: "Create an endpoint to list demands filtered by status"
194
+ Response approach:
195
+ 1. Add `@GetMapping` to controller with `@RequestParam` for status
196
+ 2. Implement service method with status filter
197
+ 3. Add `findByStatus()` to repository
198
+ 4. Create DTO if needed
199
+ 5. Run `./mvnw test`
200
+
201
+ ### Example 2: Add a Custom Query
202
+ User asks: "I need to fetch a demand with all its tasks eagerly loaded"
203
+ Response approach:
204
+ 1. Add `@Query` method to `DemandRepository` with `LEFT JOIN FETCH`
205
+ 2. Call from service layer
206
+ 3. Map to DTO including tasks
207
+ 4. Run `./mvnw test`
208
+
209
+ ### Example 3: Create DTOs for a New Feature
210
+ User asks: "Create request/response DTOs for the demand creation endpoint"
211
+ Response approach:
212
+ 1. Create `CreateDemandDTO` record with validation annotations
213
+ 2. Create `DemandDTO` record for the response
214
+ 3. Create MapStruct mapper
215
+ 4. Use in controller with `@Valid @RequestBody`
216
+ 5. Run `./mvnw test`
217
+
218
+ ## Notes
219
+ - Always use constructor injection (never `@Autowired` on fields)
220
+ - Use `@Transactional(readOnly = true)` on query methods
221
+ - `@Transactional` only in Service layer, never in Controller
222
+ - DTOs at the API boundary, Entities in the domain -- never mix
223
+ - Validation with Bean Validation (`@Valid`) in the Controller
@@ -0,0 +1,41 @@
1
+ # Spring Boot Layer Conventions
2
+
3
+ ## Architecture
4
+ ```
5
+ Controller (web/rest/) --> Service (service/) --> Repository (repository/) --> Entity (domain/)
6
+ |
7
+ DTO + Mapper (service/dto/ + service/mapper/)
8
+ ```
9
+
10
+ ## Controller Rules
11
+ - `@RestController` + `@RequestMapping`
12
+ - Constructor injection for dependencies
13
+ - `@Valid @RequestBody` for input validation
14
+ - Return `ResponseEntity` for proper HTTP semantics
15
+ - Use `PaginationUtil` for paginated responses
16
+ - No business logic -- delegate to service
17
+
18
+ ## Service Rules
19
+ - `@Service` + `@Transactional`
20
+ - `@Transactional(readOnly = true)` for read operations
21
+ - Business logic and orchestration live here
22
+ - Work with Entities internally, return DTOs externally
23
+ - Constructor injection for repositories and mappers
24
+
25
+ ## Repository Rules
26
+ - Extend `JpaRepository` and optionally `JpaSpecificationExecutor`
27
+ - Use Spring Data derived query methods
28
+ - Use `@Query` with JPQL for complex queries
29
+ - `LEFT JOIN FETCH` for eager loading relationships
30
+
31
+ ## DTO Rules
32
+ - Use Java Records (Java 21)
33
+ - Validation annotations on request DTOs
34
+ - Separate Create/Update/Response DTOs
35
+ - Never expose Entity directly in API
36
+
37
+ ## Mapper Rules
38
+ - Use MapStruct with `@Mapper(componentModel = "spring")`
39
+ - Extend `EntityMapper<DTO, Entity>` from JHipster
40
+ - Use `@Mapping` for field-level customization
41
+ - `uses = {OtherMapper.class}` for nested mappings
@@ -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%