oh-my-customcode 0.32.0 → 0.33.1
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/README.md +13 -10
- package/dist/cli/index.js +197 -76
- package/dist/index.js +52 -6
- package/package.json +1 -1
- package/templates/.claude/rules/MUST-agent-design.md +11 -0
- package/templates/.claude/rules/MUST-agent-identification.md +4 -4
- package/templates/.claude/rules/MUST-agent-teams.md +17 -18
- package/templates/.claude/rules/MUST-continuous-improvement.md +3 -3
- package/templates/.claude/rules/MUST-orchestrator-coordination.md +24 -42
- package/templates/.claude/rules/MUST-parallel-execution.md +18 -40
- package/templates/.claude/rules/MUST-sync-verification.md +6 -6
- package/templates/.claude/rules/MUST-tool-identification.md +39 -10
- package/templates/.claude/rules/SHOULD-ontology-rag-routing.md +49 -0
- package/templates/.claude/skills/airflow-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/analysis/SKILL.md +2 -1
- package/templates/.claude/skills/audit-agents/SKILL.md +4 -3
- package/templates/.claude/skills/aws-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/claude-code-bible/SKILL.md +1 -0
- package/templates/.claude/skills/codex-exec/SKILL.md +5 -4
- package/templates/.claude/skills/create-agent/SKILL.md +1 -0
- package/templates/.claude/skills/cve-triage/SKILL.md +1 -0
- package/templates/.claude/skills/dag-orchestration/SKILL.md +1 -0
- package/templates/.claude/skills/dbt-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/de-lead-routing/SKILL.md +1 -0
- package/templates/.claude/skills/deep-plan/SKILL.md +292 -0
- package/templates/.claude/skills/dev-lead-routing/SKILL.md +1 -0
- package/templates/.claude/skills/dev-refactor/SKILL.md +1 -0
- package/templates/.claude/skills/dev-review/SKILL.md +1 -0
- package/templates/.claude/skills/django-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/docker-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/fastapi-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/fix-refs/SKILL.md +1 -0
- package/templates/.claude/skills/flutter-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/go-backend-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/go-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/help/SKILL.md +1 -0
- package/templates/.claude/skills/intent-detection/SKILL.md +1 -0
- package/templates/.claude/skills/java21-best-practices/SKILL.md +305 -0
- package/templates/.claude/skills/jinja2-prompts/SKILL.md +1 -0
- package/templates/.claude/skills/kafka-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/kotlin-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/lists/SKILL.md +1 -0
- package/templates/.claude/skills/memory-management/SKILL.md +1 -0
- package/templates/.claude/skills/memory-recall/SKILL.md +1 -0
- package/templates/.claude/skills/memory-save/SKILL.md +1 -0
- package/templates/.claude/skills/model-escalation/SKILL.md +1 -0
- package/templates/.claude/skills/monitoring-setup/SKILL.md +1 -0
- package/templates/.claude/skills/multi-model-verification/SKILL.md +1 -0
- package/templates/.claude/skills/npm-audit/SKILL.md +1 -0
- package/templates/.claude/skills/npm-publish/SKILL.md +1 -0
- package/templates/.claude/skills/npm-version/SKILL.md +1 -0
- package/templates/.claude/skills/optimize-analyze/SKILL.md +1 -0
- package/templates/.claude/skills/optimize-bundle/SKILL.md +1 -0
- package/templates/.claude/skills/optimize-report/SKILL.md +1 -0
- package/templates/.claude/skills/pipeline-architecture-patterns/SKILL.md +1 -0
- package/templates/.claude/skills/pipeline-guards/SKILL.md +2 -0
- package/templates/.claude/skills/postgres-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/pr-auto-improve/SKILL.md +1 -0
- package/templates/.claude/skills/python-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/qa-lead-routing/SKILL.md +1 -0
- package/templates/.claude/skills/react-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/redis-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/research/SKILL.md +1 -0
- package/templates/.claude/skills/result-aggregation/SKILL.md +1 -0
- package/templates/.claude/skills/rust-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/sauron-watch/SKILL.md +1 -0
- package/templates/.claude/skills/secretary-routing/SKILL.md +1 -0
- package/templates/.claude/skills/skills-sh-search/SKILL.md +1 -0
- package/templates/.claude/skills/snowflake-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/spark-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/springboot-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/status/SKILL.md +1 -0
- package/templates/.claude/skills/structured-dev-cycle/SKILL.md +1 -0
- package/templates/.claude/skills/stuck-recovery/SKILL.md +1 -0
- package/templates/.claude/skills/supabase-postgres-best-practices/SKILL.md +2 -1
- package/templates/.claude/skills/task-decomposition/SKILL.md +2 -0
- package/templates/.claude/skills/typescript-best-practices/SKILL.md +1 -0
- package/templates/.claude/skills/update-docs/SKILL.md +4 -3
- package/templates/.claude/skills/update-external/SKILL.md +1 -0
- package/templates/.claude/skills/vercel-deploy/SKILL.md +1 -0
- package/templates/.claude/skills/web-design-guidelines/SKILL.md +1 -0
- package/templates/.claude/skills/worker-reviewer-pipeline/SKILL.md +2 -0
- package/templates/.claude/skills/writing-clearly-and-concisely/SKILL.md +3 -2
- package/templates/CLAUDE.md.en +7 -5
- package/templates/CLAUDE.md.ko +7 -5
- package/templates/manifest.json +4 -4
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: java21-best-practices
|
|
3
|
+
description: Modern Java 21 patterns from Virtual Threads, Pattern Matching, Records, and Sealed Classes
|
|
4
|
+
scope: core
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Apply modern Java 21 patterns and best practices leveraging the latest language features for clean, performant, and maintainable Java code.
|
|
11
|
+
|
|
12
|
+
## Core Principles
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Embrace modern Java features over legacy patterns
|
|
16
|
+
Prefer immutability and data-centric design
|
|
17
|
+
Leverage Virtual Threads for scalable concurrency
|
|
18
|
+
Use Pattern Matching for expressive type handling
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
### 1. Naming Conventions (Google Java Style)
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
packages:
|
|
27
|
+
style: lowercase, no underscores
|
|
28
|
+
example: com.example.project
|
|
29
|
+
|
|
30
|
+
classes:
|
|
31
|
+
style: UpperCamelCase
|
|
32
|
+
example: OrderProcessor, UserRecord
|
|
33
|
+
|
|
34
|
+
methods_variables:
|
|
35
|
+
style: lowerCamelCase
|
|
36
|
+
example: processOrder(), itemCount
|
|
37
|
+
|
|
38
|
+
constants:
|
|
39
|
+
style: UPPER_SNAKE_CASE
|
|
40
|
+
example: static final int MAX_RETRIES = 3
|
|
41
|
+
|
|
42
|
+
records:
|
|
43
|
+
style: UpperCamelCase (same as class)
|
|
44
|
+
example: record Point(int x, int y) {}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Virtual Threads (JEP 444)
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
principles:
|
|
51
|
+
- Use Virtual Threads for I/O-bound tasks
|
|
52
|
+
- Avoid pooling Virtual Threads (they are lightweight)
|
|
53
|
+
- Replace thread pools for blocking I/O with Virtual Thread executors
|
|
54
|
+
|
|
55
|
+
patterns: |
|
|
56
|
+
// Preferred: Virtual Thread executor
|
|
57
|
+
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
|
|
58
|
+
Future<String> result = executor.submit(() -> fetchFromDB());
|
|
59
|
+
System.out.println(result.get());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Direct creation
|
|
63
|
+
Thread vThread = Thread.ofVirtual().start(() -> {
|
|
64
|
+
// blocking I/O is fine here
|
|
65
|
+
String data = callExternalApi();
|
|
66
|
+
process(data);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// With structured concurrency (JEP 453, preview)
|
|
70
|
+
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
|
|
71
|
+
Future<String> user = scope.fork(() -> fetchUser(id));
|
|
72
|
+
Future<List<Order>> orders = scope.fork(() -> fetchOrders(id));
|
|
73
|
+
scope.join().throwIfFailed();
|
|
74
|
+
return new UserProfile(user.get(), orders.get());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
antipatterns:
|
|
78
|
+
- "Executors.newFixedThreadPool() for I/O tasks — use Virtual Threads instead"
|
|
79
|
+
- "Thread.sleep() on platform threads for rate limiting — use Virtual Threads"
|
|
80
|
+
- "synchronized blocks in Virtual Thread code — use ReentrantLock instead"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Pattern Matching
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
instanceof_patterns: |
|
|
87
|
+
// Old style (avoid)
|
|
88
|
+
if (obj instanceof String) {
|
|
89
|
+
String s = (String) obj;
|
|
90
|
+
System.out.println(s.length());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// New style (prefer)
|
|
94
|
+
if (obj instanceof String s) {
|
|
95
|
+
System.out.println(s.length());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// With guard
|
|
99
|
+
if (obj instanceof String s && s.length() > 5) {
|
|
100
|
+
System.out.println("Long string: " + s);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
switch_patterns: |
|
|
104
|
+
// Pattern matching for switch (JEP 441)
|
|
105
|
+
String result = switch (obj) {
|
|
106
|
+
case Integer i -> "int " + i;
|
|
107
|
+
case String s -> "str " + s;
|
|
108
|
+
case null -> "null";
|
|
109
|
+
default -> "other " + obj;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// With guards (when clause)
|
|
113
|
+
String label = switch (shape) {
|
|
114
|
+
case Circle c when c.radius() > 10 -> "large circle";
|
|
115
|
+
case Circle c -> "small circle";
|
|
116
|
+
case Rectangle r -> "rectangle";
|
|
117
|
+
default -> "unknown";
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 4. Records (JEP 395)
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
principles:
|
|
125
|
+
- Use Records for immutable data carriers
|
|
126
|
+
- Prefer Records over POJOs with getters/setters for pure data
|
|
127
|
+
- Compact constructors for validation
|
|
128
|
+
|
|
129
|
+
patterns: |
|
|
130
|
+
// Basic record
|
|
131
|
+
record Point(int x, int y) {}
|
|
132
|
+
|
|
133
|
+
// With validation (compact constructor)
|
|
134
|
+
record Range(int min, int max) {
|
|
135
|
+
Range {
|
|
136
|
+
if (min > max) throw new IllegalArgumentException(
|
|
137
|
+
"min %d > max %d".formatted(min, max));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// With custom methods
|
|
142
|
+
record Circle(double radius) {
|
|
143
|
+
double area() {
|
|
144
|
+
return Math.PI * radius * radius;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Implementing interface
|
|
149
|
+
interface Shape { double area(); }
|
|
150
|
+
record Square(double side) implements Shape {
|
|
151
|
+
public double area() { return side * side; }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
antipatterns:
|
|
155
|
+
- "Mutable state in records — records are inherently immutable"
|
|
156
|
+
- "Using records for entities with behavior — prefer classes"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 5. Record Patterns (JEP 440)
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
patterns: |
|
|
163
|
+
// Deconstruct record in instanceof
|
|
164
|
+
if (obj instanceof Point(int x, int y)) {
|
|
165
|
+
System.out.println("x=" + x + ", y=" + y);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// In switch
|
|
169
|
+
String describe = switch (shape) {
|
|
170
|
+
case Circle(double r) -> "circle r=" + r;
|
|
171
|
+
case Rectangle(double w, double h) -> "rect " + w + "x" + h;
|
|
172
|
+
default -> "unknown";
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Nested record patterns
|
|
176
|
+
record ColoredPoint(Point point, Color color) {}
|
|
177
|
+
if (obj instanceof ColoredPoint(Point(int x, int y), Color c)) {
|
|
178
|
+
System.out.println("colored point at " + x + "," + y);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 6. Sealed Classes (JEP 409)
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
principles:
|
|
186
|
+
- Use Sealed Classes for closed type hierarchies
|
|
187
|
+
- Combine with Pattern Matching switch for exhaustive handling
|
|
188
|
+
- Prefer sealed interfaces for behavior-focused hierarchies
|
|
189
|
+
|
|
190
|
+
patterns: |
|
|
191
|
+
// Sealed interface with records
|
|
192
|
+
sealed interface Shape permits Circle, Rectangle, Triangle {}
|
|
193
|
+
record Circle(double radius) implements Shape {}
|
|
194
|
+
record Rectangle(double width, double height) implements Shape {}
|
|
195
|
+
record Triangle(double base, double height) implements Shape {}
|
|
196
|
+
|
|
197
|
+
// Exhaustive switch (no default needed)
|
|
198
|
+
double area = switch (shape) {
|
|
199
|
+
case Circle(double r) -> Math.PI * r * r;
|
|
200
|
+
case Rectangle(double w, double h) -> w * h;
|
|
201
|
+
case Triangle(double b, double h) -> 0.5 * b * h;
|
|
202
|
+
};
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 7. Sequenced Collections (JEP 431)
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
principles:
|
|
209
|
+
- Use SequencedCollection for ordered access
|
|
210
|
+
- getFirst()/getLast() replace get(0) and get(size-1)
|
|
211
|
+
|
|
212
|
+
patterns: |
|
|
213
|
+
// SequencedCollection methods
|
|
214
|
+
List<String> list = new ArrayList<>(List.of("a", "b", "c"));
|
|
215
|
+
String first = list.getFirst(); // "a"
|
|
216
|
+
String last = list.getLast(); // "c"
|
|
217
|
+
list.addFirst("z"); // ["z", "a", "b", "c"]
|
|
218
|
+
list.addLast("end"); // ["z", "a", "b", "c", "end"]
|
|
219
|
+
|
|
220
|
+
// Reversed view
|
|
221
|
+
List<String> reversed = list.reversed();
|
|
222
|
+
|
|
223
|
+
// SequencedMap
|
|
224
|
+
SequencedMap<String, Integer> map = new LinkedHashMap<>();
|
|
225
|
+
map.put("one", 1);
|
|
226
|
+
map.put("two", 2);
|
|
227
|
+
Map.Entry<String, Integer> firstEntry = map.firstEntry(); // "one"=1
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 8. Text Blocks and String Features
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
patterns: |
|
|
234
|
+
// Text blocks (since Java 15)
|
|
235
|
+
String json = """
|
|
236
|
+
{
|
|
237
|
+
"name": "Alice",
|
|
238
|
+
"age": 30
|
|
239
|
+
}
|
|
240
|
+
""";
|
|
241
|
+
|
|
242
|
+
// String.formatted() (since Java 15)
|
|
243
|
+
String msg = "Hello, %s! You are %d years old.".formatted(name, age);
|
|
244
|
+
|
|
245
|
+
// String templates (JEP 430, preview in Java 21)
|
|
246
|
+
// Prefer String.formatted() or MessageFormat for now
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 9. Error Handling
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
principles:
|
|
253
|
+
- Prefer checked exceptions for recoverable conditions
|
|
254
|
+
- Use unchecked exceptions for programming errors
|
|
255
|
+
- Never swallow exceptions silently
|
|
256
|
+
- Use specific exception types
|
|
257
|
+
|
|
258
|
+
patterns: |
|
|
259
|
+
// Specific exception type
|
|
260
|
+
public User findUser(long id) {
|
|
261
|
+
return userRepository.findById(id)
|
|
262
|
+
.orElseThrow(() -> new UserNotFoundException("User not found: " + id));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Multi-catch
|
|
266
|
+
try {
|
|
267
|
+
process();
|
|
268
|
+
} catch (IOException | SQLException e) {
|
|
269
|
+
log.error("Data access failed", e);
|
|
270
|
+
throw new ServiceException("Processing failed", e);
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 10. Documentation
|
|
275
|
+
|
|
276
|
+
```yaml
|
|
277
|
+
format: |
|
|
278
|
+
/**
|
|
279
|
+
* Processes the given {@link Order} and returns a {@link Receipt}.
|
|
280
|
+
*
|
|
281
|
+
* @param order the order to process (must not be null)
|
|
282
|
+
* @return the generated receipt
|
|
283
|
+
* @throws OrderException if the order cannot be fulfilled
|
|
284
|
+
*/
|
|
285
|
+
public Receipt processOrder(Order order) { }
|
|
286
|
+
|
|
287
|
+
best_practices:
|
|
288
|
+
- Use @param and @return for public API
|
|
289
|
+
- Link related types with {@link}
|
|
290
|
+
- Document checked exceptions with @throws
|
|
291
|
+
- Keep Javadoc focused on "what", not "how"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Application
|
|
295
|
+
|
|
296
|
+
When writing or reviewing Java 21 code:
|
|
297
|
+
|
|
298
|
+
1. **Use** Records for pure data classes over verbose POJOs
|
|
299
|
+
2. **Use** Sealed Classes + Pattern Matching for type hierarchies
|
|
300
|
+
3. **Use** Virtual Threads for I/O-bound concurrency
|
|
301
|
+
4. **Use** `instanceof` pattern matching over explicit casts
|
|
302
|
+
5. **Prefer** switch expressions over switch statements
|
|
303
|
+
6. **Use** `getFirst()`/`getLast()` for sequenced collections
|
|
304
|
+
7. **Write** exhaustive switch for sealed types (no default)
|
|
305
|
+
8. **Document** public APIs with proper Javadoc
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: supabase-postgres-best-practices
|
|
3
3
|
description: PostgreSQL performance optimization guidelines from Supabase. Apply when writing SQL, designing schemas, configuring RLS, or optimizing database performance.
|
|
4
|
+
scope: core
|
|
4
5
|
user-invocable: false
|
|
5
6
|
---
|
|
6
7
|
|
|
@@ -96,4 +97,4 @@ user-invocable: false
|
|
|
96
97
|
- PostgreSQL Official Docs: https://www.postgresql.org/docs/
|
|
97
98
|
- Supabase Agent Skills: https://github.com/supabase/agent-skills
|
|
98
99
|
|
|
99
|
-
For detailed rule files with specific examples, see guides/supabase-postgres/.
|
|
100
|
+
For detailed rule files with specific examples, see templates/guides/supabase-postgres/.
|