@booklib/skills 1.0.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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -0
  3. package/animation-at-work/SKILL.md +246 -0
  4. package/animation-at-work/assets/example_asset.txt +1 -0
  5. package/animation-at-work/references/api_reference.md +369 -0
  6. package/animation-at-work/references/review-checklist.md +79 -0
  7. package/animation-at-work/scripts/example.py +1 -0
  8. package/bin/skills.js +85 -0
  9. package/clean-code-reviewer/SKILL.md +292 -0
  10. package/clean-code-reviewer/evals/evals.json +67 -0
  11. package/data-intensive-patterns/SKILL.md +204 -0
  12. package/data-intensive-patterns/assets/example_asset.txt +1 -0
  13. package/data-intensive-patterns/references/api_reference.md +34 -0
  14. package/data-intensive-patterns/references/patterns-catalog.md +551 -0
  15. package/data-intensive-patterns/references/review-checklist.md +193 -0
  16. package/data-intensive-patterns/scripts/example.py +1 -0
  17. package/data-pipelines/SKILL.md +252 -0
  18. package/data-pipelines/assets/example_asset.txt +1 -0
  19. package/data-pipelines/references/api_reference.md +301 -0
  20. package/data-pipelines/references/review-checklist.md +181 -0
  21. package/data-pipelines/scripts/example.py +1 -0
  22. package/design-patterns/SKILL.md +245 -0
  23. package/design-patterns/assets/example_asset.txt +1 -0
  24. package/design-patterns/references/api_reference.md +1 -0
  25. package/design-patterns/references/patterns-catalog.md +726 -0
  26. package/design-patterns/references/review-checklist.md +173 -0
  27. package/design-patterns/scripts/example.py +1 -0
  28. package/domain-driven-design/SKILL.md +221 -0
  29. package/domain-driven-design/assets/example_asset.txt +1 -0
  30. package/domain-driven-design/references/api_reference.md +1 -0
  31. package/domain-driven-design/references/patterns-catalog.md +545 -0
  32. package/domain-driven-design/references/review-checklist.md +158 -0
  33. package/domain-driven-design/scripts/example.py +1 -0
  34. package/effective-java/SKILL.md +195 -0
  35. package/effective-java/assets/example_asset.txt +1 -0
  36. package/effective-java/references/api_reference.md +1 -0
  37. package/effective-java/references/items-catalog.md +955 -0
  38. package/effective-java/references/review-checklist.md +216 -0
  39. package/effective-java/scripts/example.py +1 -0
  40. package/effective-kotlin/SKILL.md +225 -0
  41. package/effective-kotlin/assets/example_asset.txt +1 -0
  42. package/effective-kotlin/references/api_reference.md +1 -0
  43. package/effective-kotlin/references/practices-catalog.md +1228 -0
  44. package/effective-kotlin/references/review-checklist.md +126 -0
  45. package/effective-kotlin/scripts/example.py +1 -0
  46. package/kotlin-in-action/SKILL.md +251 -0
  47. package/kotlin-in-action/assets/example_asset.txt +1 -0
  48. package/kotlin-in-action/references/api_reference.md +1 -0
  49. package/kotlin-in-action/references/practices-catalog.md +436 -0
  50. package/kotlin-in-action/references/review-checklist.md +204 -0
  51. package/kotlin-in-action/scripts/example.py +1 -0
  52. package/lean-startup/SKILL.md +250 -0
  53. package/lean-startup/assets/example_asset.txt +1 -0
  54. package/lean-startup/references/api_reference.md +319 -0
  55. package/lean-startup/references/review-checklist.md +137 -0
  56. package/lean-startup/scripts/example.py +1 -0
  57. package/microservices-patterns/SKILL.md +179 -0
  58. package/microservices-patterns/references/patterns-catalog.md +391 -0
  59. package/microservices-patterns/references/review-checklist.md +169 -0
  60. package/package.json +17 -0
  61. package/refactoring-ui/SKILL.md +236 -0
  62. package/refactoring-ui/assets/example_asset.txt +1 -0
  63. package/refactoring-ui/references/api_reference.md +355 -0
  64. package/refactoring-ui/references/review-checklist.md +114 -0
  65. package/refactoring-ui/scripts/example.py +1 -0
  66. package/storytelling-with-data/SKILL.md +238 -0
  67. package/storytelling-with-data/assets/example_asset.txt +1 -0
  68. package/storytelling-with-data/references/api_reference.md +379 -0
  69. package/storytelling-with-data/references/review-checklist.md +111 -0
  70. package/storytelling-with-data/scripts/example.py +1 -0
  71. package/system-design-interview/SKILL.md +213 -0
  72. package/system-design-interview/assets/example_asset.txt +1 -0
  73. package/system-design-interview/references/api_reference.md +582 -0
  74. package/system-design-interview/references/review-checklist.md +201 -0
  75. package/system-design-interview/scripts/example.py +1 -0
  76. package/using-asyncio-python/SKILL.md +242 -0
  77. package/using-asyncio-python/assets/example_asset.txt +1 -0
  78. package/using-asyncio-python/references/api_reference.md +267 -0
  79. package/using-asyncio-python/references/review-checklist.md +149 -0
  80. package/using-asyncio-python/scripts/example.py +1 -0
  81. package/web-scraping-python/SKILL.md +259 -0
  82. package/web-scraping-python/assets/example_asset.txt +1 -0
  83. package/web-scraping-python/references/api_reference.md +393 -0
  84. package/web-scraping-python/references/review-checklist.md +163 -0
  85. package/web-scraping-python/scripts/example.py +1 -0
@@ -0,0 +1,216 @@
1
+ # Effective Java Code Review Checklist
2
+
3
+ Use this checklist when reviewing Java code. Work through each section and flag any
4
+ violations. Not every section applies to every review — skip sections that aren't
5
+ relevant to the code under review.
6
+
7
+ ---
8
+
9
+ ## 1. Object Creation
10
+
11
+ - [ ] Static factory methods used where beneficial (named construction, caching, return subtypes)
12
+ - [ ] Builder pattern used for classes with many optional parameters
13
+ - [ ] Singleton enforcement is correct (enum type or private constructor with static field)
14
+ - [ ] Utility classes have private constructor to prevent instantiation
15
+ - [ ] Dependencies are injected, not hardwired to concrete implementations
16
+ - [ ] No unnecessary object creation (cached patterns, primitive vs boxed in loops)
17
+ - [ ] Obsolete object references are nulled out (custom collections, caches, listeners)
18
+ - [ ] try-with-resources used for all AutoCloseable objects
19
+ - [ ] No finalizers or cleaners (except as safety nets for native resources)
20
+
21
+ **Red flags**: Telescoping constructors with 4+ parameters. `new String("literal")`.
22
+ `Long sum = 0L` in a loop. Resources closed in finally blocks instead of
23
+ try-with-resources. Finalizer or cleaner used for non-native resource cleanup.
24
+
25
+ ---
26
+
27
+ ## 2. Methods Common to All Objects
28
+
29
+ - [ ] `equals` override obeys the contract (reflexive, symmetric, transitive, consistent)
30
+ - [ ] `hashCode` is overridden whenever `equals` is overridden
31
+ - [ ] `toString` provides useful diagnostic information
32
+ - [ ] `clone` is avoided in favor of copy constructors or copy factories
33
+ - [ ] `Comparable` is implemented where natural ordering exists
34
+ - [ ] Comparators don't use subtraction (overflow risk)
35
+
36
+ **Red flags**: `equals` that breaks symmetry (subclass vs superclass). Missing `hashCode`
37
+ override causing HashMap failures. `Cloneable` implemented on new classes. Comparator
38
+ using `return o1.val - o2.val` (integer overflow).
39
+
40
+ ---
41
+
42
+ ## 3. Class Design
43
+
44
+ - [ ] Classes and members have minimal accessibility (private > package-private > protected > public)
45
+ - [ ] Instance fields are never public (use accessors)
46
+ - [ ] Classes are immutable where possible (final fields, no setters, final class or private constructor)
47
+ - [ ] Composition is used instead of inheritance across package boundaries
48
+ - [ ] Classes designed for inheritance document self-use of overridable methods
49
+ - [ ] Classes not designed for inheritance are final or have private constructors
50
+ - [ ] Interfaces are used to define types, not for constants
51
+ - [ ] Tagged classes are refactored into class hierarchies
52
+ - [ ] Inner classes are static unless they need an enclosing instance reference
53
+ - [ ] One top-level class per source file
54
+
55
+ **Red flags**: Public mutable fields. Concrete class extended across package boundary
56
+ without documentation of overridable method self-use. Non-static inner class in a
57
+ long-lived object (hidden reference causes memory leak). Constant interface
58
+ (`interface Constants { int FOO = 1; }`).
59
+
60
+ ---
61
+
62
+ ## 4. Generics
63
+
64
+ - [ ] No raw types anywhere in the codebase
65
+ - [ ] All unchecked warnings are eliminated or suppressed with justification
66
+ - [ ] Lists preferred over arrays for generic collections
67
+ - [ ] Types and methods are generic where appropriate
68
+ - [ ] Bounded wildcards used per PECS (Producer-Extends, Consumer-Super)
69
+ - [ ] `@SafeVarargs` used correctly on generic varargs methods
70
+ - [ ] No wildcards on return types
71
+
72
+ **Red flags**: `List` instead of `List<String>`. `@SuppressWarnings("unchecked")` on a
73
+ large scope without comment. `E[]` used where `List<E>` would be safer. Missing
74
+ wildcards on API parameters that accept subtypes.
75
+
76
+ ---
77
+
78
+ ## 5. Enums and Annotations
79
+
80
+ - [ ] Enums used instead of `int` or `String` constants
81
+ - [ ] Enum values don't derive from `ordinal()` — instance fields used instead
82
+ - [ ] `EnumSet` used instead of bit fields
83
+ - [ ] `EnumMap` used instead of ordinal-indexed arrays
84
+ - [ ] `@Override` annotation present on all overriding methods
85
+ - [ ] Annotations used instead of naming patterns
86
+
87
+ **Red flags**: `public static final int SEASON_WINTER = 0`. Calling `ordinal()` to
88
+ derive a value. `int` flags combined with bitwise OR instead of `EnumSet`. Array
89
+ indexed by `enum.ordinal()`.
90
+
91
+ ---
92
+
93
+ ## 6. Lambdas and Streams
94
+
95
+ - [ ] Lambdas used instead of anonymous classes for functional interfaces
96
+ - [ ] Method references used where clearer than lambdas
97
+ - [ ] Standard functional interfaces from `java.util.function` used before custom ones
98
+ - [ ] Streams used judiciously (not forced where loops are clearer)
99
+ - [ ] Stream operations are side-effect-free (no mutation in `forEach` used for computation)
100
+ - [ ] `Collection` returned from APIs instead of `Stream`
101
+ - [ ] Parallel streams used only with appropriate data structures and verified speedup
102
+
103
+ **Red flags**: Long, complex lambdas (should be extracted to methods). `forEach` used
104
+ for computation instead of collect/reduce. `Stream.parallel()` on `LinkedList` or
105
+ `Stream.iterate`. Stream pipeline with side effects on shared mutable state.
106
+
107
+ ---
108
+
109
+ ## 7. Method Design
110
+
111
+ - [ ] Parameters validated at method entry (`Objects.requireNonNull`, bounds checks)
112
+ - [ ] Defensive copies made of mutable input parameters (copy before validation)
113
+ - [ ] Method signatures have ≤4 parameters (or use helper classes / Builder)
114
+ - [ ] No confusing overloads (same number of parameters with different behavior)
115
+ - [ ] Varargs methods require at least one argument where needed
116
+ - [ ] Empty collections/arrays returned instead of null
117
+ - [ ] `Optional` used appropriately for absent return values (not for fields/parameters/collections)
118
+ - [ ] All exported API elements have doc comments
119
+
120
+ **Red flags**: Missing null check that leads to NPE deep in call stack. Mutable
121
+ `Date`/`Calendar` parameter stored directly without copy. Method returning `null`
122
+ instead of `Collections.emptyList()`. `Optional.get()` without presence check.
123
+ Overloaded methods with same arity causing dispatch surprises.
124
+
125
+ ---
126
+
127
+ ## 8. General Programming
128
+
129
+ - [ ] Local variables declared at point of first use with minimal scope
130
+ - [ ] For-each loops used wherever applicable
131
+ - [ ] Standard library methods used instead of hand-rolled equivalents
132
+ - [ ] `BigDecimal` or `int`/`long` used for monetary calculations (not `float`/`double`)
133
+ - [ ] Primitive types preferred over boxed primitives
134
+ - [ ] Strings not used as substitutes for other types (enums, aggregates, capabilities)
135
+ - [ ] `StringBuilder` used for string concatenation in loops
136
+ - [ ] Objects referred to by interface types where appropriate
137
+ - [ ] Reflection avoided except for class instantiation via interfaces
138
+ - [ ] Naming conventions followed (camelCase methods, UPPER_SNAKE constants, etc.)
139
+
140
+ **Red flags**: `double` used for currency. `String` concatenation with `+` inside a loop
141
+ building large output. `==` applied to boxed primitives. Hand-rolled sorting or data
142
+ structure instead of using `java.util` classes. Variable declared far from use with
143
+ wide scope.
144
+
145
+ ---
146
+
147
+ ## 9. Exceptions
148
+
149
+ - [ ] Exceptions used only for exceptional conditions (not control flow)
150
+ - [ ] Checked exceptions for recoverable conditions, runtime for programming errors
151
+ - [ ] Unnecessary checked exceptions eliminated (consider Optional or method splitting)
152
+ - [ ] Standard exceptions reused (`IllegalArgumentException`, `NullPointerException`, etc.)
153
+ - [ ] Exceptions translated at abstraction boundaries (with chaining)
154
+ - [ ] All exceptions documented with `@throws`
155
+ - [ ] Exception detail messages include failure-capture information
156
+ - [ ] Methods are failure-atomic (object state unchanged on failure)
157
+ - [ ] No empty catch blocks (if intentionally ignored, document why and use `ignored` variable name)
158
+
159
+ **Red flags**: `try { ... } catch (Exception e) { }` (swallowed exception). Exception
160
+ used for flow control (`try { array[i++] } catch (AIOOBE)`). Method declares
161
+ `throws Exception`. Low-level `SQLException` propagated through business logic instead
162
+ of translated.
163
+
164
+ ---
165
+
166
+ ## 10. Concurrency
167
+
168
+ - [ ] Shared mutable data is properly synchronized or volatile
169
+ - [ ] Minimal work done inside synchronized regions
170
+ - [ ] No alien method calls within synchronized blocks
171
+ - [ ] `ExecutorService` used instead of raw `Thread` management
172
+ - [ ] `java.util.concurrent` utilities preferred over `wait`/`notify`
173
+ - [ ] Thread safety level documented on every class
174
+ - [ ] Lazy initialization used only when necessary, with correct idiom
175
+ - [ ] No dependence on thread scheduler behavior (`Thread.yield`, priorities)
176
+
177
+ **Red flags**: Non-volatile field used as stop flag across threads. Long computation
178
+ inside synchronized block. `wait()` without loop. `new Thread(runnable).start()` instead
179
+ of executor. Missing thread safety documentation. Single-check idiom used where
180
+ double-check is required.
181
+
182
+ ---
183
+
184
+ ## 11. Serialization
185
+
186
+ - [ ] Java serialization avoided (JSON, protobuf, or other formats preferred)
187
+ - [ ] If Serializable: considered impact on flexibility and security
188
+ - [ ] If Serializable: custom serialized form used where default is inappropriate
189
+ - [ ] If Serializable: `readObject` validates defensively like a constructor
190
+ - [ ] If Serializable: enum types preferred for instance-controlled classes
191
+ - [ ] If Serializable: serialization proxy pattern considered
192
+ - [ ] No deserialization of untrusted data
193
+
194
+ **Red flags**: `ObjectInputStream.readObject()` on untrusted input. Default serialized
195
+ form exposing internal representation. `readObject` that doesn't validate or make
196
+ defensive copies. Non-enum singleton implementing `Serializable` without `readResolve`
197
+ or serialization proxy.
198
+
199
+ ---
200
+
201
+ ## Severity Classification
202
+
203
+ When reporting issues, classify them:
204
+
205
+ - **Critical**: Bug, security vulnerability, or data corruption risk
206
+ (e.g., missing synchronization on shared mutable data, deserializing untrusted data,
207
+ broken equals/hashCode contract, empty catch block hiding failures)
208
+ - **Major**: Significant design debt or maintenance burden
209
+ (e.g., concrete class inheritance, raw types, mutable class that should be immutable,
210
+ telescoping constructors, checked exceptions that should be unchecked)
211
+ - **Minor**: Best practice deviation with limited immediate impact
212
+ (e.g., missing @Override, toString not implemented, unnecessary object creation,
213
+ for-loop instead of for-each)
214
+ - **Suggestion**: Improvement that would be nice but isn't urgent
215
+ (e.g., consider Builder for future extensibility, evaluate switching to Optional
216
+ return type, document thread safety level)
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,225 @@
1
+ ---
2
+ name: effective-kotlin
3
+ description: >
4
+ Apply Effective Kotlin best practices (Marcin Moskała, 2nd Ed). Covers Safety
5
+ (Items 1-10: mutability, scope, nulls, types, expectations, errors, resources,
6
+ tests), Readability (Items 11-18: operators, receivers, properties, naming),
7
+ Reusability (Items 19-25: DRY, generics, delegation, variance), Abstraction
8
+ (Items 26-32: levels, stability, visibility, contracts), Object Creation
9
+ (Items 33-35: factories, constructors, DSLs), Class Design (Items 36-44:
10
+ composition, data classes, sealed hierarchies, equals/hashCode/compareTo,
11
+ extensions), Efficiency (Items 45-52: object creation, inline, sequences,
12
+ collections). Trigger on "Effective Kotlin", "Kotlin best practice",
13
+ "Kotlin idiom", "Kotlin style", "Kotlin review", "Kotlin safety",
14
+ "Kotlin performance", "Kotlin readability", or "Kotlin design".
15
+ ---
16
+
17
+ # Effective Kotlin Skill
18
+
19
+ You are an expert Kotlin developer grounded in the 52 best-practice items from
20
+ *Effective Kotlin* (2nd Edition) by Marcin Moskała. You help developers in two modes:
21
+
22
+ 1. **Code Generation** — Write idiomatic, safe, readable, and efficient Kotlin code
23
+ 2. **Code Review** — Analyze existing Kotlin code against the 52 items and recommend improvements
24
+
25
+ ## How to Decide Which Mode
26
+
27
+ - If the user asks you to *build*, *create*, *generate*, *implement*, *write*, or *refactor* Kotlin code → **Code Generation**
28
+ - If the user asks you to *review*, *check*, *improve*, *audit*, *critique*, or *analyze* Kotlin code → **Code Review**
29
+ - If ambiguous, ask briefly which mode they'd prefer
30
+
31
+ ---
32
+
33
+ ## Mode 1: Code Generation
34
+
35
+ When generating Kotlin code, follow this decision flow:
36
+
37
+ ### Step 1 — Understand the Requirements
38
+
39
+ Ask (or infer from context):
40
+
41
+ - **What domain?** — Data model, API, UI, concurrency, DSL?
42
+ - **What constraints?** — Kotlin/JVM, Kotlin Multiplatform, Android, server-side?
43
+ - **What quality attributes?** — Safety, readability, performance, extensibility?
44
+
45
+ ### Step 2 — Apply the Right Practices
46
+
47
+ Read `references/practices-catalog.md` for the full 52-item catalog. Quick decision guide by concern:
48
+
49
+ | Concern | Items to Apply |
50
+ |---------|---------------|
51
+ | Preventing null / type errors | Items 3-8: Eliminate platform types, don't expose inferred types, prefer null/Failure, handle nulls properly |
52
+ | Limiting mutability and scope | Items 1-2: Limit mutability (val, immutable collections, data class copy), minimize variable scope |
53
+ | Error handling and validation | Items 5-7: Use require/check/assert, prefer standard errors, prefer null or Failure result type |
54
+ | Resource management | Item 9: Close resources with use() |
55
+ | Readable and maintainable code | Items 11-18: Design for readability, meaningful operators, explicit types when unclear, named arguments, coding conventions |
56
+ | Avoiding duplication | Items 19-22: DRY, use stdlib algorithms, property delegation, generics for common algorithms |
57
+ | API and abstraction design | Items 26-32: Single abstraction level, protect against changes, API stability, wrap external APIs, minimize visibility, document contracts |
58
+ | Object creation | Items 33-35: Factory functions, primary constructor with named optional args, DSL for complex creation |
59
+ | Class and type design | Items 36-44: Composition over inheritance, data modifier, function types, sealed hierarchies, equals/hashCode/compareTo contracts, extensions |
60
+ | Performance | Items 45-52: Avoid unnecessary object creation, inline functions, inline value classes, eliminate obsolete references, Sequence, limit operations, primitive arrays, mutable collections |
61
+ | Testing | Item 10: Write unit tests |
62
+
63
+ ### Step 3 — Follow Kotlin Idioms
64
+
65
+ Every code generation should honor these principles:
66
+
67
+ 1. **Limit mutability** — Use val, immutable collections, data class copy() instead of mutable state
68
+ 2. **Minimize scope** — Declare variables in the narrowest scope; prefer local over property, private over public
69
+ 3. **Favor composition over inheritance** — Use delegation, interface composition, and HAS-A relationships
70
+ 4. **Program to interfaces** — Depend on abstractions; return interface types from functions
71
+ 5. **Use Kotlin's type system** — Sealed classes for restricted hierarchies, value classes for type-safe wrappers, nullability for optional values
72
+ 6. **Be explicit when clarity demands it** — Explicit types for public APIs, named arguments for boolean/numeric params, explicit receivers in scoping functions
73
+ 7. **Leverage the stdlib** — Use standard library functions (let, run, apply, also, with, use, map, filter, fold, etc.) idiomatically
74
+ 8. **Design for extension** — Use sealed interfaces, function types as parameters, and extension functions for non-essential API parts
75
+
76
+ ### Step 4 — Generate the Code
77
+
78
+ Follow these guidelines:
79
+
80
+ - **Idiomatic Kotlin** — Use Kotlin features naturally: data classes, sealed hierarchies, extension functions, scope functions, destructuring, delegation
81
+ - **Safe by default** — Non-null types by default, require/check for preconditions, use() for resources, proper error handling
82
+ - **Readable** — Clear naming, named arguments for ambiguous params, single-level-of-abstraction functions, respect coding conventions
83
+ - **Efficient where it matters** — Sequence for multi-step collection processing, inline for lambdas, value classes for wrappers, primitive arrays for hot paths
84
+ - **Well-structured** — Small focused functions, clear API boundaries, minimal visibility, documented contracts
85
+
86
+ When generating code, produce:
87
+
88
+ 1. **Practice identification** — Which items apply and why
89
+ 2. **Interface/contract definitions** — The abstractions
90
+ 3. **Implementation** — Idiomatic Kotlin code
91
+ 4. **Usage example** — How client code uses it
92
+ 5. **Extension points** — How the design accommodates change
93
+
94
+ ### Code Generation Examples
95
+
96
+ **Example 1 — Safe API Design:**
97
+ ```
98
+ User: "Create a user repository with proper error handling"
99
+
100
+ Apply: Items 1 (limit mutability), 5 (require/check), 6 (standard errors),
101
+ 7 (Result type), 9 (use for resources), 30 (minimize visibility),
102
+ 33 (factory function), 34 (named optional args)
103
+
104
+ Generate:
105
+ - Sealed interface for UserError (NotFound, Duplicate, ValidationFailed)
106
+ - User data class with validated construction via companion factory
107
+ - UserRepository interface returning Result types
108
+ - Implementation with require() preconditions, use() for resources
109
+ - Private mutable state, public immutable view
110
+ ```
111
+
112
+ **Example 2 — Collection Processing Pipeline:**
113
+ ```
114
+ User: "Process a large CSV of transactions for reporting"
115
+
116
+ Apply: Items 49 (Sequence for big collections), 50 (limit operations),
117
+ 51 (primitive arrays for numeric), 20 (stdlib algorithms),
118
+ 37 (data class for records)
119
+
120
+ Generate:
121
+ - Transaction data class with proper parsing
122
+ - Sequence-based pipeline for lazy processing
123
+ - Efficient aggregation using fold/groupBy
124
+ - Primitive arrays for numeric accumulation in hot path
125
+ ```
126
+
127
+ **Example 3 — DSL Builder:**
128
+ ```
129
+ User: "Create a type-safe HTML DSL"
130
+
131
+ Apply: Items 35 (DSL for complex creation), 15 (explicit receivers),
132
+ 22 (generics), 46 (inline for lambda params)
133
+
134
+ Generate:
135
+ - @DslMarker annotation for scope control
136
+ - Inline builder functions with receiver lambdas
137
+ - Type-safe tag hierarchy using sealed classes
138
+ - Extension functions for tag creation
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Mode 2: Code Review
144
+
145
+ When reviewing Kotlin code, read `references/review-checklist.md` for the full checklist.
146
+
147
+ ### Review Process
148
+
149
+ 1. **Safety scan** — Check Items 1-10: mutability, null handling, platform types, error handling, resource management, testing
150
+ 2. **Readability scan** — Check Items 11-18: operator overloading, type clarity, receiver usage, property vs function, naming, conventions
151
+ 3. **Design scan** — Check Items 19-44: duplication, abstraction levels, API design, visibility, class design, inheritance vs composition
152
+ 4. **Efficiency scan** — Check Items 45-52: unnecessary allocations, inline opportunities, collection processing efficiency
153
+ 5. **Cross-cutting concerns** — Testability, API stability, contract documentation
154
+
155
+ ### Review Output Format
156
+
157
+ Structure your review as:
158
+
159
+ ```
160
+ ## Summary
161
+ One paragraph: overall code quality, key Kotlin idiom adherence, main concerns.
162
+
163
+ ## Safety Issues
164
+ For each issue found (Items 1-10):
165
+ - **Item**: number and name
166
+ - **Location**: where in the code
167
+ - **Problem**: what's wrong
168
+ - **Fix**: recommended change with code snippet
169
+
170
+ ## Readability Issues
171
+ For each issue found (Items 11-18):
172
+ - Same structure as above
173
+
174
+ ## Design Issues
175
+ For each issue found (Items 19-44):
176
+ - Same structure as above
177
+
178
+ ## Efficiency Issues
179
+ For each issue found (Items 45-52):
180
+ - Same structure as above
181
+
182
+ ## Recommendations
183
+ Priority-ordered list from most critical to nice-to-have.
184
+ Each recommendation references the specific Item number.
185
+ ```
186
+
187
+ ### Common Kotlin Anti-Patterns to Flag
188
+
189
+ - **Mutable where immutable works** → Item 1: Use val, immutable collections, copy()
190
+ - **Overly broad variable scope** → Item 2: Move declarations closer to usage
191
+ - **Platform types leaking** → Item 3: Add explicit nullability annotations at Java boundaries
192
+ - **Exposed inferred types** → Item 4: Declare explicit return types on public functions
193
+ - **Missing precondition checks** → Item 5: Add require() for arguments, check() for state
194
+ - **Custom exception hierarchies** → Item 6: Prefer IllegalArgumentException, IllegalStateException, etc.
195
+ - **Throwing on expected failures** → Item 7: Return null or Result instead
196
+ - **Force-unwrapping nulls (!!)** → Item 8: Use safe calls, Elvis, smart casting, lateinit
197
+ - **Unclosed resources** → Item 9: Use use() or useLines()
198
+ - **No tests** → Item 10: Add unit tests
199
+ - **Clever but unreadable code** → Item 11: Simplify, prefer clarity
200
+ - **Meaningless operator overloading** → Item 12: Operator meaning must match function name convention
201
+ - **Properties with side effects** → Item 16: Properties for state, functions for behavior
202
+ - **Magic numbers / unnamed booleans** → Item 17: Use named arguments
203
+ - **Copy-pasted logic** → Item 19: Extract shared logic, respect DRY
204
+ - **Hand-rolled stdlib algorithms** → Item 20: Use existing stdlib functions
205
+ - **Deep inheritance for code reuse** → Item 36: Prefer composition and delegation
206
+ - **Tagged class with type enum** → Item 39: Replace with sealed class hierarchy
207
+ - **Broken equals/hashCode** → Items 40-41: Ensure contract compliance
208
+ - **Member extensions** → Item 44: Avoid; use top-level or local extensions
209
+ - **Unnecessary object creation in loops** → Item 45: Cache, reuse, use primitives
210
+ - **Lambda overhead in hot paths** → Item 46: Use inline modifier
211
+ - **Eager collection processing on large data** → Item 49: Switch to Sequence
212
+ - **Redundant collection operations** → Item 50: Combine or use specialized functions (any vs filter+isEmpty)
213
+
214
+ ---
215
+
216
+ ## General Guidelines
217
+
218
+ - Be practical — Kotlin is designed for pragmatic developers. Don't over-abstract or over-engineer.
219
+ - **Safety first** — Kotlin's type system prevents many bugs. Use it fully: non-null by default, sealed hierarchies for state, require/check for contracts.
220
+ - **Readability is king** — Code is read far more than written. Prefer clarity over cleverness.
221
+ - **Idiomatic Kotlin > Java-in-Kotlin** — Use data classes, extension functions, scope functions, destructuring, delegation, sequences. Don't write Java with Kotlin syntax.
222
+ - **Know the stdlib** — The standard library is rich. Before writing utilities, check if a stdlib function already exists.
223
+ - **Efficiency where it matters** — Don't optimize prematurely, but know the tools: inline, Sequence, value classes, primitive arrays.
224
+ - For deeper practice details, read `references/practices-catalog.md` before generating code.
225
+ - For review checklists, read `references/review-checklist.md` before reviewing code.