@h1dr0n/skill-pool 0.1.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/LICENSE +21 -0
- package/README.md +296 -0
- package/bin/cli.js +157 -0
- package/package.json +41 -0
- package/skills/api/agents/backend-specialist.md +69 -0
- package/skills/api/agents/database-optimizer.md +176 -0
- package/skills/api/manifest.yaml +20 -0
- package/skills/api/rules/auth-security.md +45 -0
- package/skills/api/skills/api-patterns/SKILL.md +81 -0
- package/skills/api/skills/api-patterns/api-style.md +42 -0
- package/skills/api/skills/api-patterns/auth.md +24 -0
- package/skills/api/skills/api-patterns/documentation.md +26 -0
- package/skills/api/skills/api-patterns/graphql.md +41 -0
- package/skills/api/skills/api-patterns/rate-limiting.md +31 -0
- package/skills/api/skills/api-patterns/response.md +37 -0
- package/skills/api/skills/api-patterns/rest.md +40 -0
- package/skills/api/skills/api-patterns/scripts/api_validator.py +211 -0
- package/skills/api/skills/api-patterns/security-testing.md +122 -0
- package/skills/api/skills/api-patterns/trpc.md +41 -0
- package/skills/api/skills/api-patterns/versioning.md +22 -0
- package/skills/api/skills/database-patterns.md +126 -0
- package/skills/api/skills/deployment-patterns.md +105 -0
- package/skills/api/skills/docker-patterns.md +135 -0
- package/skills/common/agents/code-reviewer.md +78 -0
- package/skills/common/agents/planner.md +80 -0
- package/skills/common/agents/security-reviewer.md +82 -0
- package/skills/common/agents/software-architect.md +81 -0
- package/skills/common/manifest.yaml +25 -0
- package/skills/common/rules/coding-style.md +39 -0
- package/skills/common/rules/git-workflow.md +33 -0
- package/skills/common/rules/security.md +25 -0
- package/skills/common/skills/architecture/SKILL.md +55 -0
- package/skills/common/skills/architecture/context-discovery.md +43 -0
- package/skills/common/skills/architecture/examples.md +94 -0
- package/skills/common/skills/architecture/pattern-selection.md +68 -0
- package/skills/common/skills/architecture/patterns-reference.md +50 -0
- package/skills/common/skills/architecture/trade-off-analysis.md +77 -0
- package/skills/common/skills/brainstorming/SKILL.md +163 -0
- package/skills/common/skills/brainstorming/dynamic-questioning.md +350 -0
- package/skills/common/skills/clean-code.md +99 -0
- package/skills/common/skills/code-review-checklist.md +86 -0
- package/skills/common/skills/plan-writing/SKILL.md +152 -0
- package/skills/common/skills/skill-feedback.md +94 -0
- package/skills/common/skills/tdd-workflow.md +130 -0
- package/skills/common/skills/verification-loop.md +112 -0
- package/skills/cpp/agents/cpp-build-resolver.md +90 -0
- package/skills/cpp/agents/cpp-reviewer.md +72 -0
- package/skills/cpp/manifest.yaml +15 -0
- package/skills/cpp/skills/cpp-coding-standards.md +722 -0
- package/skills/cpp/skills/cpp-testing.md +323 -0
- package/skills/devops/agents/devops-automator.md +376 -0
- package/skills/devops/agents/sre.md +90 -0
- package/skills/devops/manifest.yaml +20 -0
- package/skills/devops/skills/deployment-patterns.md +427 -0
- package/skills/devops/skills/deployment-procedures/SKILL.md +241 -0
- package/skills/devops/skills/docker-patterns.md +364 -0
- package/skills/devops/skills/e2e-testing.md +326 -0
- package/skills/devops/skills/github-ops.md +144 -0
- package/skills/django/manifest.yaml +16 -0
- package/skills/django/skills/django-patterns.md +734 -0
- package/skills/django/skills/django-security.md +593 -0
- package/skills/django/skills/django-tdd.md +729 -0
- package/skills/django/skills/django-verification.md +469 -0
- package/skills/dotnet/agents/csharp-reviewer.md +101 -0
- package/skills/dotnet/manifest.yaml +14 -0
- package/skills/dotnet/skills/csharp-testing.md +321 -0
- package/skills/dotnet/skills/dotnet-patterns.md +321 -0
- package/skills/go/agents/code-reviewer.md +76 -0
- package/skills/go/agents/go-build-resolver.md +94 -0
- package/skills/go/agents/go-reviewer.md +76 -0
- package/skills/go/manifest.yaml +17 -0
- package/skills/go/rules/go-style.md +55 -0
- package/skills/go/skills/golang-patterns.md +674 -0
- package/skills/go/skills/golang-testing.md +720 -0
- package/skills/java/agents/java-build-resolver.md +153 -0
- package/skills/java/agents/java-reviewer.md +92 -0
- package/skills/java/manifest.yaml +18 -0
- package/skills/java/skills/java-coding-standards.md +147 -0
- package/skills/java/skills/jpa-patterns.md +151 -0
- package/skills/java/skills/springboot-patterns.md +314 -0
- package/skills/java/skills/springboot-security.md +272 -0
- package/skills/kotlin/agents/kotlin-build-resolver.md +118 -0
- package/skills/kotlin/agents/kotlin-reviewer.md +159 -0
- package/skills/kotlin/manifest.yaml +17 -0
- package/skills/kotlin/skills/kotlin-coroutines-flows.md +284 -0
- package/skills/kotlin/skills/kotlin-patterns.md +711 -0
- package/skills/kotlin/skills/kotlin-testing.md +824 -0
- package/skills/laravel/manifest.yaml +15 -0
- package/skills/laravel/skills/laravel-patterns.md +409 -0
- package/skills/laravel/skills/laravel-security.md +279 -0
- package/skills/laravel/skills/laravel-tdd.md +277 -0
- package/skills/laravel/skills/laravel-verification.md +173 -0
- package/skills/mobile/agents/dart-build-resolver.md +201 -0
- package/skills/mobile/agents/flutter-reviewer.md +243 -0
- package/skills/mobile/manifest.yaml +19 -0
- package/skills/mobile/skills/android-clean-architecture.md +339 -0
- package/skills/mobile/skills/dart-flutter-patterns.md +563 -0
- package/skills/mobile/skills/swiftui-patterns.md +259 -0
- package/skills/nestjs/manifest.yaml +13 -0
- package/skills/nestjs/skills/nestjs-patterns.md +230 -0
- package/skills/perl/manifest.yaml +13 -0
- package/skills/perl/skills/perl-patterns.md +504 -0
- package/skills/perl/skills/perl-security.md +503 -0
- package/skills/perl/skills/perl-testing.md +475 -0
- package/skills/python/agents/python-reviewer.md +98 -0
- package/skills/python/manifest.yaml +18 -0
- package/skills/python/rules/python-style.md +69 -0
- package/skills/python/skills/python-patterns/SKILL.md +441 -0
- package/skills/python/skills/python-patterns.md +90 -0
- package/skills/python/skills/python-testing.md +81 -0
- package/skills/rust/agents/rust-build-resolver.md +148 -0
- package/skills/rust/agents/rust-reviewer.md +94 -0
- package/skills/rust/manifest.yaml +16 -0
- package/skills/rust/rules/rust-style.md +107 -0
- package/skills/rust/skills/rust-patterns.md +499 -0
- package/skills/rust/skills/rust-testing.md +500 -0
- package/skills/security/agents/accessibility-auditor.md +316 -0
- package/skills/security/agents/security-reviewer.md +108 -0
- package/skills/security/manifest.yaml +19 -0
- package/skills/security/skills/red-team-tactics/SKILL.md +199 -0
- package/skills/security/skills/security-bounty-hunter.md +99 -0
- package/skills/security/skills/security-review.md +495 -0
- package/skills/security/skills/security-scan.md +165 -0
- package/skills/security/skills/vulnerability-scanner/SKILL.md +276 -0
- package/skills/security/skills/vulnerability-scanner/checklists.md +121 -0
- package/skills/security/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/skills/swift/manifest.yaml +16 -0
- package/skills/swift/skills/swift-actor-persistence.md +142 -0
- package/skills/swift/skills/swift-concurrency.md +216 -0
- package/skills/swift/skills/swift-protocol-di-testing.md +190 -0
- package/skills/swift/skills/swiftui-patterns.md +259 -0
- package/skills/unity/agents/game-designer.md +167 -0
- package/skills/unity/agents/unity-architect.md +52 -0
- package/skills/unity/agents/unity-editor-tool-developer.md +310 -0
- package/skills/unity/agents/unity-multiplayer-engineer.md +321 -0
- package/skills/unity/agents/unity-shader-graph-artist.md +269 -0
- package/skills/unity/manifest.yaml +21 -0
- package/skills/unity/rules/csharp-patterns.md +48 -0
- package/skills/unity/rules/unity-specific.md +53 -0
- package/skills/unity/skills/systematic-debugging.md +92 -0
- package/skills/unity/skills/unity-architecture.md +173 -0
- package/skills/unreal/agents/level-designer.md +208 -0
- package/skills/unreal/agents/technical-artist.md +229 -0
- package/skills/unreal/agents/unreal-multiplayer-architect.md +313 -0
- package/skills/unreal/agents/unreal-systems-engineer.md +310 -0
- package/skills/unreal/agents/unreal-technical-artist.md +256 -0
- package/skills/unreal/agents/unreal-world-builder.md +273 -0
- package/skills/unreal/manifest.yaml +21 -0
- package/skills/unreal/skills/unreal-patterns.md +183 -0
- package/skills/web/agents/frontend-specialist.md +71 -0
- package/skills/web/agents/ui-designer.md +383 -0
- package/skills/web/agents/ux-architect.md +469 -0
- package/skills/web/manifest.yaml +22 -0
- package/skills/web/rules/accessibility.md +54 -0
- package/skills/web/rules/css-performance.md +52 -0
- package/skills/web/skills/e2e-testing.md +132 -0
- package/skills/web/skills/frontend-design/SKILL.md +452 -0
- package/skills/web/skills/frontend-design/animation-guide.md +331 -0
- package/skills/web/skills/frontend-design/color-system.md +311 -0
- package/skills/web/skills/frontend-design/decision-trees.md +418 -0
- package/skills/web/skills/frontend-design/motion-graphics.md +306 -0
- package/skills/web/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/skills/web/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/skills/web/skills/frontend-design/typography-system.md +345 -0
- package/skills/web/skills/frontend-design/ux-psychology.md +1116 -0
- package/skills/web/skills/frontend-design/visual-effects.md +383 -0
- package/skills/web/skills/react-nextjs.md +135 -0
- package/skills/web/skills/tailwind-patterns/SKILL.md +269 -0
- package/src/adapters/antigravity.js +164 -0
- package/src/adapters/claude.js +188 -0
- package/src/adapters/cursor.js +161 -0
- package/src/adapters/index.js +67 -0
- package/src/adapters/windsurf.js +158 -0
- package/src/commands/add.js +266 -0
- package/src/commands/create.js +127 -0
- package/src/commands/diff.js +78 -0
- package/src/commands/info.js +88 -0
- package/src/commands/init.js +224 -0
- package/src/commands/install.js +90 -0
- package/src/commands/list.js +54 -0
- package/src/commands/remove.js +101 -0
- package/src/commands/targets.js +32 -0
- package/src/commands/update.js +57 -0
- package/src/core/manifest.js +57 -0
- package/src/core/plugins.js +86 -0
- package/src/core/resolver.js +84 -0
- package/src/core/tracker.js +49 -0
- package/src/utils/fs.js +80 -0
- package/src/utils/git.js +52 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: java-build-resolver
|
|
3
|
+
description: Java/Maven/Gradle build, compilation, and dependency error resolution specialist. Fixes build errors, Java compiler errors, and Maven/Gradle issues with minimal changes. Use when Java or Spring Boot builds fail.
|
|
4
|
+
tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"]
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Java Build Error Resolver
|
|
9
|
+
|
|
10
|
+
You are an expert Java/Maven/Gradle build error resolution specialist. Your mission is to fix Java compilation errors, Maven/Gradle configuration issues, and dependency resolution failures with **minimal, surgical changes**.
|
|
11
|
+
|
|
12
|
+
You DO NOT refactor or rewrite code — you fix the build error only.
|
|
13
|
+
|
|
14
|
+
## Core Responsibilities
|
|
15
|
+
|
|
16
|
+
1. Diagnose Java compilation errors
|
|
17
|
+
2. Fix Maven and Gradle build configuration issues
|
|
18
|
+
3. Resolve dependency conflicts and version mismatches
|
|
19
|
+
4. Handle annotation processor errors (Lombok, MapStruct, Spring)
|
|
20
|
+
5. Fix Checkstyle and SpotBugs violations
|
|
21
|
+
|
|
22
|
+
## Diagnostic Commands
|
|
23
|
+
|
|
24
|
+
Run these in order:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
./mvnw compile -q 2>&1 || mvn compile -q 2>&1
|
|
28
|
+
./mvnw test -q 2>&1 || mvn test -q 2>&1
|
|
29
|
+
./gradlew build 2>&1
|
|
30
|
+
./mvnw dependency:tree 2>&1 | head -100
|
|
31
|
+
./gradlew dependencies --configuration runtimeClasspath 2>&1 | head -100
|
|
32
|
+
./mvnw checkstyle:check 2>&1 || echo "checkstyle not configured"
|
|
33
|
+
./mvnw spotbugs:check 2>&1 || echo "spotbugs not configured"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Resolution Workflow
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
1. ./mvnw compile OR ./gradlew build -> Parse error message
|
|
40
|
+
2. Read affected file -> Understand context
|
|
41
|
+
3. Apply minimal fix -> Only what's needed
|
|
42
|
+
4. ./mvnw compile OR ./gradlew build -> Verify fix
|
|
43
|
+
5. ./mvnw test OR ./gradlew test -> Ensure nothing broke
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Common Fix Patterns
|
|
47
|
+
|
|
48
|
+
| Error | Cause | Fix |
|
|
49
|
+
|-------|-------|-----|
|
|
50
|
+
| `cannot find symbol` | Missing import, typo, missing dependency | Add import or dependency |
|
|
51
|
+
| `incompatible types: X cannot be converted to Y` | Wrong type, missing cast | Add explicit cast or fix type |
|
|
52
|
+
| `method X in class Y cannot be applied to given types` | Wrong argument types or count | Fix arguments or check overloads |
|
|
53
|
+
| `variable X might not have been initialized` | Uninitialized local variable | Initialise variable before use |
|
|
54
|
+
| `non-static method X cannot be referenced from a static context` | Instance method called statically | Create instance or make method static |
|
|
55
|
+
| `reached end of file while parsing` | Missing closing brace | Add missing `}` |
|
|
56
|
+
| `package X does not exist` | Missing dependency or wrong import | Add dependency to `pom.xml`/`build.gradle` |
|
|
57
|
+
| `error: cannot access X, class file not found` | Missing transitive dependency | Add explicit dependency |
|
|
58
|
+
| `Annotation processor threw uncaught exception` | Lombok/MapStruct misconfiguration | Check annotation processor setup |
|
|
59
|
+
| `Could not resolve: group:artifact:version` | Missing repository or wrong version | Add repository or fix version in POM |
|
|
60
|
+
| `The following artifacts could not be resolved` | Private repo or network issue | Check repository credentials or `settings.xml` |
|
|
61
|
+
| `COMPILATION ERROR: Source option X is no longer supported` | Java version mismatch | Update `maven.compiler.source` / `targetCompatibility` |
|
|
62
|
+
|
|
63
|
+
## Maven Troubleshooting
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Check dependency tree for conflicts
|
|
67
|
+
./mvnw dependency:tree -Dverbose
|
|
68
|
+
|
|
69
|
+
# Force update snapshots and re-download
|
|
70
|
+
./mvnw clean install -U
|
|
71
|
+
|
|
72
|
+
# Analyse dependency conflicts
|
|
73
|
+
./mvnw dependency:analyze
|
|
74
|
+
|
|
75
|
+
# Check effective POM (resolved inheritance)
|
|
76
|
+
./mvnw help:effective-pom
|
|
77
|
+
|
|
78
|
+
# Debug annotation processors
|
|
79
|
+
./mvnw compile -X 2>&1 | grep -i "processor\|lombok\|mapstruct"
|
|
80
|
+
|
|
81
|
+
# Skip tests to isolate compile errors
|
|
82
|
+
./mvnw compile -DskipTests
|
|
83
|
+
|
|
84
|
+
# Check Java version in use
|
|
85
|
+
./mvnw --version
|
|
86
|
+
java -version
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Gradle Troubleshooting
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Check dependency tree for conflicts
|
|
93
|
+
./gradlew dependencies --configuration runtimeClasspath
|
|
94
|
+
|
|
95
|
+
# Force refresh dependencies
|
|
96
|
+
./gradlew build --refresh-dependencies
|
|
97
|
+
|
|
98
|
+
# Clear Gradle build cache
|
|
99
|
+
./gradlew clean && rm -rf .gradle/build-cache/
|
|
100
|
+
|
|
101
|
+
# Run with debug output
|
|
102
|
+
./gradlew build --debug 2>&1 | tail -50
|
|
103
|
+
|
|
104
|
+
# Check dependency insight
|
|
105
|
+
./gradlew dependencyInsight --dependency <name> --configuration runtimeClasspath
|
|
106
|
+
|
|
107
|
+
# Check Java toolchain
|
|
108
|
+
./gradlew -q javaToolchains
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Spring Boot Specific
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Verify Spring Boot application context loads
|
|
115
|
+
./mvnw spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=test"
|
|
116
|
+
|
|
117
|
+
# Check for missing beans or circular dependencies
|
|
118
|
+
./mvnw test -Dtest=*ContextLoads* -q
|
|
119
|
+
|
|
120
|
+
# Verify Lombok is configured as annotation processor (not just dependency)
|
|
121
|
+
grep -A5 "annotationProcessorPaths\|annotationProcessor" pom.xml build.gradle
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Key Principles
|
|
125
|
+
|
|
126
|
+
- **Surgical fixes only** — don't refactor, just fix the error
|
|
127
|
+
- **Never** suppress warnings with `@SuppressWarnings` without explicit approval
|
|
128
|
+
- **Never** change method signatures unless necessary
|
|
129
|
+
- **Always** run the build after each fix to verify
|
|
130
|
+
- Fix root cause over suppressing symptoms
|
|
131
|
+
- Prefer adding missing imports over changing logic
|
|
132
|
+
- Check `pom.xml`, `build.gradle`, or `build.gradle.kts` to confirm the build tool before running commands
|
|
133
|
+
|
|
134
|
+
## Stop Conditions
|
|
135
|
+
|
|
136
|
+
Stop and report if:
|
|
137
|
+
- Same error persists after 3 fix attempts
|
|
138
|
+
- Fix introduces more errors than it resolves
|
|
139
|
+
- Error requires architectural changes beyond scope
|
|
140
|
+
- Missing external dependencies that need user decision (private repos, licences)
|
|
141
|
+
|
|
142
|
+
## Output Format
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
[FIXED] src/main/java/com/example/service/PaymentService.java:87
|
|
146
|
+
Error: cannot find symbol — symbol: class IdempotencyKey
|
|
147
|
+
Fix: Added import com.example.domain.IdempotencyKey
|
|
148
|
+
Remaining errors: 1
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
152
|
+
|
|
153
|
+
For detailed Java and Spring Boot patterns, see `skill: springboot-patterns`.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: java-reviewer
|
|
3
|
+
description: Expert Java and Spring Boot code reviewer specializing in layered architecture, JPA patterns, security, and concurrency. Use for all Java code changes. MUST BE USED for Spring Boot projects.
|
|
4
|
+
tools: ["Read", "Grep", "Glob", "Bash"]
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
You are a senior Java engineer ensuring high standards of idiomatic Java and Spring Boot best practices.
|
|
8
|
+
When invoked:
|
|
9
|
+
1. Run `git diff -- '*.java'` to see recent Java file changes
|
|
10
|
+
2. Run `mvn verify -q` or `./gradlew check` if available
|
|
11
|
+
3. Focus on modified `.java` files
|
|
12
|
+
4. Begin review immediately
|
|
13
|
+
|
|
14
|
+
You DO NOT refactor or rewrite code — you report findings only.
|
|
15
|
+
|
|
16
|
+
## Review Priorities
|
|
17
|
+
|
|
18
|
+
### CRITICAL -- Security
|
|
19
|
+
- **SQL injection**: String concatenation in `@Query` or `JdbcTemplate` — use bind parameters (`:param` or `?`)
|
|
20
|
+
- **Command injection**: User-controlled input passed to `ProcessBuilder` or `Runtime.exec()` — validate and sanitise before invocation
|
|
21
|
+
- **Code injection**: User-controlled input passed to `ScriptEngine.eval(...)` — avoid executing untrusted scripts; prefer safe expression parsers or sandboxing
|
|
22
|
+
- **Path traversal**: User-controlled input passed to `new File(userInput)`, `Paths.get(userInput)`, or `FileInputStream(userInput)` without `getCanonicalPath()` validation
|
|
23
|
+
- **Hardcoded secrets**: API keys, passwords, tokens in source — must come from environment or secrets manager
|
|
24
|
+
- **PII/token logging**: `log.info(...)` calls near auth code that expose passwords or tokens
|
|
25
|
+
- **Missing `@Valid`**: Raw `@RequestBody` without Bean Validation — never trust unvalidated input
|
|
26
|
+
- **CSRF disabled without justification**: Stateless JWT APIs may disable it but must document why
|
|
27
|
+
|
|
28
|
+
If any CRITICAL security issue is found, stop and escalate to `security-reviewer`.
|
|
29
|
+
|
|
30
|
+
### CRITICAL -- Error Handling
|
|
31
|
+
- **Swallowed exceptions**: Empty catch blocks or `catch (Exception e) {}` with no action
|
|
32
|
+
- **`.get()` on Optional**: Calling `repository.findById(id).get()` without `.isPresent()` — use `.orElseThrow()`
|
|
33
|
+
- **Missing `@RestControllerAdvice`**: Exception handling scattered across controllers instead of centralised
|
|
34
|
+
- **Wrong HTTP status**: Returning `200 OK` with null body instead of `404`, or missing `201` on creation
|
|
35
|
+
|
|
36
|
+
### HIGH -- Spring Boot Architecture
|
|
37
|
+
- **Field injection**: `@Autowired` on fields is a code smell — constructor injection is required
|
|
38
|
+
- **Business logic in controllers**: Controllers must delegate to the service layer immediately
|
|
39
|
+
- **`@Transactional` on wrong layer**: Must be on service layer, not controller or repository
|
|
40
|
+
- **Missing `@Transactional(readOnly = true)`**: Read-only service methods must declare this
|
|
41
|
+
- **Entity exposed in response**: JPA entity returned directly from controller — use DTO or record projection
|
|
42
|
+
|
|
43
|
+
### HIGH -- JPA / Database
|
|
44
|
+
- **N+1 query problem**: `FetchType.EAGER` on collections — use `JOIN FETCH` or `@EntityGraph`
|
|
45
|
+
- **Unbounded list endpoints**: Returning `List<T>` from endpoints without `Pageable` and `Page<T>`
|
|
46
|
+
- **Missing `@Modifying`**: Any `@Query` that mutates data requires `@Modifying` + `@Transactional`
|
|
47
|
+
- **Dangerous cascade**: `CascadeType.ALL` with `orphanRemoval = true` — confirm intent is deliberate
|
|
48
|
+
|
|
49
|
+
### MEDIUM -- Concurrency and State
|
|
50
|
+
- **Mutable singleton fields**: Non-final instance fields in `@Service` / `@Component` are a race condition
|
|
51
|
+
- **Unbounded `@Async`**: `CompletableFuture` or `@Async` without a custom `Executor` — default creates unbounded threads
|
|
52
|
+
- **Blocking `@Scheduled`**: Long-running scheduled methods that block the scheduler thread
|
|
53
|
+
|
|
54
|
+
### MEDIUM -- Java Idioms and Performance
|
|
55
|
+
- **String concatenation in loops**: Use `StringBuilder` or `String.join`
|
|
56
|
+
- **Raw type usage**: Unparameterised generics (`List` instead of `List<T>`)
|
|
57
|
+
- **Missed pattern matching**: `instanceof` check followed by explicit cast — use pattern matching (Java 16+)
|
|
58
|
+
- **Null returns from service layer**: Prefer `Optional<T>` over returning null
|
|
59
|
+
|
|
60
|
+
### MEDIUM -- Testing
|
|
61
|
+
- **`@SpringBootTest` for unit tests**: Use `@WebMvcTest` for controllers, `@DataJpaTest` for repositories
|
|
62
|
+
- **Missing Mockito extension**: Service tests must use `@ExtendWith(MockitoExtension.class)`
|
|
63
|
+
- **`Thread.sleep()` in tests**: Use `Awaitility` for async assertions
|
|
64
|
+
- **Weak test names**: `testFindUser` gives no information — use `should_return_404_when_user_not_found`
|
|
65
|
+
|
|
66
|
+
### MEDIUM -- Workflow and State Machine (payment / event-driven code)
|
|
67
|
+
- **Idempotency key checked after processing**: Must be checked before any state mutation
|
|
68
|
+
- **Illegal state transitions**: No guard on transitions like `CANCELLED → PROCESSING`
|
|
69
|
+
- **Non-atomic compensation**: Rollback/compensation logic that can partially succeed
|
|
70
|
+
- **Missing jitter on retry**: Exponential backoff without jitter causes thundering herd
|
|
71
|
+
- **No dead-letter handling**: Failed async events with no fallback or alerting
|
|
72
|
+
|
|
73
|
+
## Diagnostic Commands
|
|
74
|
+
```bash
|
|
75
|
+
git diff -- '*.java'
|
|
76
|
+
mvn verify -q
|
|
77
|
+
./gradlew check # Gradle equivalent
|
|
78
|
+
./mvnw checkstyle:check # style
|
|
79
|
+
./mvnw spotbugs:check # static analysis
|
|
80
|
+
./mvnw test # unit tests
|
|
81
|
+
./mvnw dependency-check:check # CVE scan (OWASP plugin)
|
|
82
|
+
grep -rn "@Autowired" src/main/java --include="*.java"
|
|
83
|
+
grep -rn "FetchType.EAGER" src/main/java --include="*.java"
|
|
84
|
+
```
|
|
85
|
+
Read `pom.xml`, `build.gradle`, or `build.gradle.kts` to determine the build tool and Spring Boot version before reviewing.
|
|
86
|
+
|
|
87
|
+
## Approval Criteria
|
|
88
|
+
- **Approve**: No CRITICAL or HIGH issues
|
|
89
|
+
- **Warning**: MEDIUM issues only
|
|
90
|
+
- **Block**: CRITICAL or HIGH issues found
|
|
91
|
+
|
|
92
|
+
For detailed Spring Boot patterns and examples, see `skill: springboot-patterns`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: java
|
|
2
|
+
version: 0.1.0
|
|
3
|
+
description: Java coding standards, Spring Boot patterns, JPA/Hibernate, and security for production-grade Spring services
|
|
4
|
+
depends:
|
|
5
|
+
- common
|
|
6
|
+
tags:
|
|
7
|
+
- java
|
|
8
|
+
- spring
|
|
9
|
+
- jpa
|
|
10
|
+
rules: []
|
|
11
|
+
skills:
|
|
12
|
+
- skills/java-coding-standards.md
|
|
13
|
+
- skills/jpa-patterns.md
|
|
14
|
+
- skills/springboot-patterns.md
|
|
15
|
+
- skills/springboot-security.md
|
|
16
|
+
agents:
|
|
17
|
+
- agents/java-reviewer.md
|
|
18
|
+
- agents/java-build-resolver.md
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: java-coding-standards
|
|
3
|
+
description: "Java coding standards for Spring Boot services: naming, immutability, Optional usage, streams, exceptions, generics, and project layout."
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Java Coding Standards
|
|
8
|
+
|
|
9
|
+
Standards for readable, maintainable Java (17+) code in Spring Boot services.
|
|
10
|
+
|
|
11
|
+
## When to Activate
|
|
12
|
+
|
|
13
|
+
- Writing or reviewing Java code in Spring Boot projects
|
|
14
|
+
- Enforcing naming, immutability, or exception handling conventions
|
|
15
|
+
- Working with records, sealed classes, or pattern matching (Java 17+)
|
|
16
|
+
- Reviewing use of Optional, streams, or generics
|
|
17
|
+
- Structuring packages and project layout
|
|
18
|
+
|
|
19
|
+
## Core Principles
|
|
20
|
+
|
|
21
|
+
- Prefer clarity over cleverness
|
|
22
|
+
- Immutable by default; minimize shared mutable state
|
|
23
|
+
- Fail fast with meaningful exceptions
|
|
24
|
+
- Consistent naming and package structure
|
|
25
|
+
|
|
26
|
+
## Naming
|
|
27
|
+
|
|
28
|
+
```java
|
|
29
|
+
// PASS: Classes/Records: PascalCase
|
|
30
|
+
public class MarketService {}
|
|
31
|
+
public record Money(BigDecimal amount, Currency currency) {}
|
|
32
|
+
|
|
33
|
+
// PASS: Methods/fields: camelCase
|
|
34
|
+
private final MarketRepository marketRepository;
|
|
35
|
+
public Market findBySlug(String slug) {}
|
|
36
|
+
|
|
37
|
+
// PASS: Constants: UPPER_SNAKE_CASE
|
|
38
|
+
private static final int MAX_PAGE_SIZE = 100;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Immutability
|
|
42
|
+
|
|
43
|
+
```java
|
|
44
|
+
// PASS: Favor records and final fields
|
|
45
|
+
public record MarketDto(Long id, String name, MarketStatus status) {}
|
|
46
|
+
|
|
47
|
+
public class Market {
|
|
48
|
+
private final Long id;
|
|
49
|
+
private final String name;
|
|
50
|
+
// getters only, no setters
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Optional Usage
|
|
55
|
+
|
|
56
|
+
```java
|
|
57
|
+
// PASS: Return Optional from find* methods
|
|
58
|
+
Optional<Market> market = marketRepository.findBySlug(slug);
|
|
59
|
+
|
|
60
|
+
// PASS: Map/flatMap instead of get()
|
|
61
|
+
return market
|
|
62
|
+
.map(MarketResponse::from)
|
|
63
|
+
.orElseThrow(() -> new EntityNotFoundException("Market not found"));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Streams Best Practices
|
|
67
|
+
|
|
68
|
+
```java
|
|
69
|
+
// PASS: Use streams for transformations, keep pipelines short
|
|
70
|
+
List<String> names = markets.stream()
|
|
71
|
+
.map(Market::name)
|
|
72
|
+
.filter(Objects::nonNull)
|
|
73
|
+
.toList();
|
|
74
|
+
|
|
75
|
+
// FAIL: Avoid complex nested streams; prefer loops for clarity
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Exceptions
|
|
79
|
+
|
|
80
|
+
- Use unchecked exceptions for domain errors; wrap technical exceptions with context
|
|
81
|
+
- Create domain-specific exceptions (e.g., `MarketNotFoundException`)
|
|
82
|
+
- Avoid broad `catch (Exception ex)` unless rethrowing/logging centrally
|
|
83
|
+
|
|
84
|
+
```java
|
|
85
|
+
throw new MarketNotFoundException(slug);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Generics and Type Safety
|
|
89
|
+
|
|
90
|
+
- Avoid raw types; declare generic parameters
|
|
91
|
+
- Prefer bounded generics for reusable utilities
|
|
92
|
+
|
|
93
|
+
```java
|
|
94
|
+
public <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Project Structure (Maven/Gradle)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
src/main/java/com/example/app/
|
|
101
|
+
config/
|
|
102
|
+
controller/
|
|
103
|
+
service/
|
|
104
|
+
repository/
|
|
105
|
+
domain/
|
|
106
|
+
dto/
|
|
107
|
+
util/
|
|
108
|
+
src/main/resources/
|
|
109
|
+
application.yml
|
|
110
|
+
src/test/java/... (mirrors main)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Formatting and Style
|
|
114
|
+
|
|
115
|
+
- Use 2 or 4 spaces consistently (project standard)
|
|
116
|
+
- One public top-level type per file
|
|
117
|
+
- Keep methods short and focused; extract helpers
|
|
118
|
+
- Order members: constants, fields, constructors, public methods, protected, private
|
|
119
|
+
|
|
120
|
+
## Code Smells to Avoid
|
|
121
|
+
|
|
122
|
+
- Long parameter lists → use DTO/builders
|
|
123
|
+
- Deep nesting → early returns
|
|
124
|
+
- Magic numbers → named constants
|
|
125
|
+
- Static mutable state → prefer dependency injection
|
|
126
|
+
- Silent catch blocks → log and act or rethrow
|
|
127
|
+
|
|
128
|
+
## Logging
|
|
129
|
+
|
|
130
|
+
```java
|
|
131
|
+
private static final Logger log = LoggerFactory.getLogger(MarketService.class);
|
|
132
|
+
log.info("fetch_market slug={}", slug);
|
|
133
|
+
log.error("failed_fetch_market slug={}", slug, ex);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Null Handling
|
|
137
|
+
|
|
138
|
+
- Accept `@Nullable` only when unavoidable; otherwise use `@NonNull`
|
|
139
|
+
- Use Bean Validation (`@NotNull`, `@NotBlank`) on inputs
|
|
140
|
+
|
|
141
|
+
## Testing Expectations
|
|
142
|
+
|
|
143
|
+
- JUnit 5 + AssertJ for fluent assertions
|
|
144
|
+
- Mockito for mocking; avoid partial mocks where possible
|
|
145
|
+
- Favor deterministic tests; no hidden sleeps
|
|
146
|
+
|
|
147
|
+
**Remember**: Keep code intentional, typed, and observable. Optimize for maintainability over micro-optimizations unless proven necessary.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: jpa-patterns
|
|
3
|
+
description: JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# JPA/Hibernate Patterns
|
|
8
|
+
|
|
9
|
+
Use for data modeling, repositories, and performance tuning in Spring Boot.
|
|
10
|
+
|
|
11
|
+
## When to Activate
|
|
12
|
+
|
|
13
|
+
- Designing JPA entities and table mappings
|
|
14
|
+
- Defining relationships (@OneToMany, @ManyToOne, @ManyToMany)
|
|
15
|
+
- Optimizing queries (N+1 prevention, fetch strategies, projections)
|
|
16
|
+
- Configuring transactions, auditing, or soft deletes
|
|
17
|
+
- Setting up pagination, sorting, or custom repository methods
|
|
18
|
+
- Tuning connection pooling (HikariCP) or second-level caching
|
|
19
|
+
|
|
20
|
+
## Entity Design
|
|
21
|
+
|
|
22
|
+
```java
|
|
23
|
+
@Entity
|
|
24
|
+
@Table(name = "markets", indexes = {
|
|
25
|
+
@Index(name = "idx_markets_slug", columnList = "slug", unique = true)
|
|
26
|
+
})
|
|
27
|
+
@EntityListeners(AuditingEntityListener.class)
|
|
28
|
+
public class MarketEntity {
|
|
29
|
+
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
30
|
+
private Long id;
|
|
31
|
+
|
|
32
|
+
@Column(nullable = false, length = 200)
|
|
33
|
+
private String name;
|
|
34
|
+
|
|
35
|
+
@Column(nullable = false, unique = true, length = 120)
|
|
36
|
+
private String slug;
|
|
37
|
+
|
|
38
|
+
@Enumerated(EnumType.STRING)
|
|
39
|
+
private MarketStatus status = MarketStatus.ACTIVE;
|
|
40
|
+
|
|
41
|
+
@CreatedDate private Instant createdAt;
|
|
42
|
+
@LastModifiedDate private Instant updatedAt;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Enable auditing:
|
|
47
|
+
```java
|
|
48
|
+
@Configuration
|
|
49
|
+
@EnableJpaAuditing
|
|
50
|
+
class JpaConfig {}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Relationships and N+1 Prevention
|
|
54
|
+
|
|
55
|
+
```java
|
|
56
|
+
@OneToMany(mappedBy = "market", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
57
|
+
private List<PositionEntity> positions = new ArrayList<>();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Default to lazy loading; use `JOIN FETCH` in queries when needed
|
|
61
|
+
- Avoid `EAGER` on collections; use DTO projections for read paths
|
|
62
|
+
|
|
63
|
+
```java
|
|
64
|
+
@Query("select m from MarketEntity m left join fetch m.positions where m.id = :id")
|
|
65
|
+
Optional<MarketEntity> findWithPositions(@Param("id") Long id);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Repository Patterns
|
|
69
|
+
|
|
70
|
+
```java
|
|
71
|
+
public interface MarketRepository extends JpaRepository<MarketEntity, Long> {
|
|
72
|
+
Optional<MarketEntity> findBySlug(String slug);
|
|
73
|
+
|
|
74
|
+
@Query("select m from MarketEntity m where m.status = :status")
|
|
75
|
+
Page<MarketEntity> findByStatus(@Param("status") MarketStatus status, Pageable pageable);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Use projections for lightweight queries:
|
|
80
|
+
```java
|
|
81
|
+
public interface MarketSummary {
|
|
82
|
+
Long getId();
|
|
83
|
+
String getName();
|
|
84
|
+
MarketStatus getStatus();
|
|
85
|
+
}
|
|
86
|
+
Page<MarketSummary> findAllBy(Pageable pageable);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Transactions
|
|
90
|
+
|
|
91
|
+
- Annotate service methods with `@Transactional`
|
|
92
|
+
- Use `@Transactional(readOnly = true)` for read paths to optimize
|
|
93
|
+
- Choose propagation carefully; avoid long-running transactions
|
|
94
|
+
|
|
95
|
+
```java
|
|
96
|
+
@Transactional
|
|
97
|
+
public Market updateStatus(Long id, MarketStatus status) {
|
|
98
|
+
MarketEntity entity = repo.findById(id)
|
|
99
|
+
.orElseThrow(() -> new EntityNotFoundException("Market"));
|
|
100
|
+
entity.setStatus(status);
|
|
101
|
+
return Market.from(entity);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Pagination
|
|
106
|
+
|
|
107
|
+
```java
|
|
108
|
+
PageRequest page = PageRequest.of(pageNumber, pageSize, Sort.by("createdAt").descending());
|
|
109
|
+
Page<MarketEntity> markets = repo.findByStatus(MarketStatus.ACTIVE, page);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For cursor-like pagination, include `id > :lastId` in JPQL with ordering.
|
|
113
|
+
|
|
114
|
+
## Indexing and Performance
|
|
115
|
+
|
|
116
|
+
- Add indexes for common filters (`status`, `slug`, foreign keys)
|
|
117
|
+
- Use composite indexes matching query patterns (`status, created_at`)
|
|
118
|
+
- Avoid `select *`; project only needed columns
|
|
119
|
+
- Batch writes with `saveAll` and `hibernate.jdbc.batch_size`
|
|
120
|
+
|
|
121
|
+
## Connection Pooling (HikariCP)
|
|
122
|
+
|
|
123
|
+
Recommended properties:
|
|
124
|
+
```
|
|
125
|
+
spring.datasource.hikari.maximum-pool-size=20
|
|
126
|
+
spring.datasource.hikari.minimum-idle=5
|
|
127
|
+
spring.datasource.hikari.connection-timeout=30000
|
|
128
|
+
spring.datasource.hikari.validation-timeout=5000
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
For PostgreSQL LOB handling, add:
|
|
132
|
+
```
|
|
133
|
+
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Caching
|
|
137
|
+
|
|
138
|
+
- 1st-level cache is per EntityManager; avoid keeping entities across transactions
|
|
139
|
+
- For read-heavy entities, consider second-level cache cautiously; validate eviction strategy
|
|
140
|
+
|
|
141
|
+
## Migrations
|
|
142
|
+
|
|
143
|
+
- Use Flyway or Liquibase; never rely on Hibernate auto DDL in production
|
|
144
|
+
- Keep migrations idempotent and additive; avoid dropping columns without plan
|
|
145
|
+
|
|
146
|
+
## Testing Data Access
|
|
147
|
+
|
|
148
|
+
- Prefer `@DataJpaTest` with Testcontainers to mirror production
|
|
149
|
+
- Assert SQL efficiency using logs: set `logging.level.org.hibernate.SQL=DEBUG` and `logging.level.org.hibernate.orm.jdbc.bind=TRACE` for parameter values
|
|
150
|
+
|
|
151
|
+
**Remember**: Keep entities lean, queries intentional, and transactions short. Prevent N+1 with fetch strategies and projections, and index for your read/write paths.
|