[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-jetbrains-kotlin-backend-jpa-entity-mapping":3,"mdc-wg1jjb-key":39,"related-repo-jetbrains-kotlin-backend-jpa-entity-mapping":1307,"related-org-jetbrains-kotlin-backend-jpa-entity-mapping":1429},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":28,"repoUrl":29,"updatedAt":30,"license":31,"forks":32,"topics":33,"repo":34,"sourceUrl":37,"mdContent":38},"kotlin-backend-jpa-entity-mapping","model Kotlin persistence with JPA and Hibernate","Model Kotlin persistence code correctly for Spring Data JPA and Hibernate. Covers entity design, identity and equality, uniqueness constraints, relationships, fetch plans, and common ORM (Object-Relational Mapping) traps  specific to Kotlin. Use when creating or reviewing JPA (Java Persistence API)  entities, diagnosing N+1 or LazyInitializationException, placing indexes and  uniqueness rules, or preventing Kotlin-specific bugs such as data class  entities and broken equals\u002FhashCode.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},"jetbrains","JetBrains","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fjetbrains.png",[12,16,19,22,25],{"name":13,"slug":14,"type":15},"Kotlin","kotlin","tag",{"name":17,"slug":18,"type":15},"Backend","backend",{"name":20,"slug":21,"type":15},"Spring","spring",{"name":23,"slug":24,"type":15},"Database","database",{"name":26,"slug":27,"type":15},"ORM","orm",252,"https:\u002F\u002Fgithub.com\u002FJetBrains\u002Fskills","2026-07-17T06:04:40.454635","Apache-2.0",17,[],{"repoUrl":29,"stars":28,"forks":32,"topics":35,"description":36},[],"Curated agent skills collection verified by JetBrains","https:\u002F\u002Fgithub.com\u002FJetBrains\u002Fskills\u002Ftree\u002FHEAD\u002Fkotlin-backend-jpa-entity-mapping","---\nname: kotlin-backend-jpa-entity-mapping\ndescription: >\n  Model Kotlin persistence code correctly for Spring Data JPA and Hibernate.\n  Covers entity design, identity and equality, uniqueness constraints,\n  relationships, fetch plans, and common ORM (Object-Relational Mapping) traps \n  specific to Kotlin. Use when creating or reviewing JPA (Java Persistence API) \n  entities, diagnosing N+1 or LazyInitializationException, placing indexes and \n  uniqueness rules, or preventing Kotlin-specific bugs such as data class \n  entities and broken equals\u002FhashCode.\nlicense: Apache-2.0\nmetadata:\n  short-description: \"Model Kotlin JPA entities correctly\"\n  author: JetBrains\n  version: \"1.0.0\"\n  source: https:\u002F\u002Fgithub.com\u002FKotlin\u002Fkotlin-agent-skills\u002Ftree\u002Fmain\u002Fskills\u002Fkotlin-backend-jpa-entity-mapping\n---\n\n# JPA Entity Mapping for Kotlin\n\nKotlin's `data class` is natural for DTOs but dangerous for JPA entities. Hibernate relies on\nidentity semantics that `data class` breaks: `equals`\u002F`hashCode` over all fields corrupts\n`Set`\u002F`Map` membership after state changes, and auto-generated `copy()` creates detached\nduplicates of managed entities.\n\nThis skill teaches correct entity design, identity strategies, and uniqueness constraints\nfor Kotlin + Spring Data JPA projects.\n\n## Entity Design Rules\n\n- **Never use `data class` for JPA entities.** Use a regular `class`. Keep `data class` for DTOs.\n- Keep transport DTOs and persistence entities separate unless the project clearly uses a shared model.\n- Model required columns as non-null only when object construction and persistence lifecycle make it safe.\n- Use `lateinit` only when the project already accepts that tradeoff and the lifecycle is safe.\n- Verify `kotlin(\"plugin.jpa\")` or equivalent no-arg support when JPA entities exist.\n- Verify classes and members are compatible with proxying where needed.\n\n## Identity and Equality\n\n- Never accept all-field `equals`\u002F`hashCode` generated by `data class` on an entity.\n- Follow project conventions when they already define an identity strategy.\n- If no convention exists, use ID-based equality with a stable `hashCode`.\n- Be explicit about mutable fields and lazy associations when discussing equality.\n\n### Broken: `data class` Entity\n\n```kotlin\n\u002F\u002F WRONG: data class generates equals\u002FhashCode from ALL fields\ndata class Order(\n    @Id @GeneratedValue val id: Long = 0,\n    var status: String,\n    var total: BigDecimal\n)\n\u002F\u002F BUG: order.status = \"SHIPPED\"; set.contains(order) → false (hash changed)\n\u002F\u002F BUG: Hibernate proxy.equals(entity) → false (proxy has lazy fields uninitialized)\n```\n\n### Correct: Regular Class with ID-Based Identity\n\n```kotlin\n@Entity\n@Table(name = \"orders\")\nclass Order(\n    @Column(nullable = false)\n    var status: String,\n\n    @Column(nullable = false)\n    var total: BigDecimal\n) {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    val id: Long = 0\n\n    override fun equals(other: Any?): Boolean {\n        if (this === other) return true\n        if (other !is Order) return false\n        return id != 0L && id == other.id\n    }\n\n    override fun hashCode(): Int = javaClass.hashCode()\n\n    \u002F\u002F toString must NOT reference lazy collections\n    override fun toString(): String = \"Order(id=$id, status=$status)\"\n}\n```\n\n**Key rules:**\n- `equals` compares by ID only — stable under dirty tracking and proxy unwrapping\n- `hashCode` returns class-based constant — avoids `Set`\u002F`Map` corruption after persist\n- `toString` excludes lazy-loaded relations — prevents `LazyInitializationException`\n- Constructor params are mutable entity fields; `id` is `val` with default\n\n## Uniqueness Constraints\n\nWhen an API must be idempotent (e.g., \"reserve stock for order X\"), enforce uniqueness\nat both layers: database constraint for correctness, application check for clean errors.\n\n### Broken: No Duplicate Guard\n\n```kotlin\n@Service\nclass ReservationService(private val repo: ReservationRepository) {\n    @Transactional\n    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {\n        \u002F\u002F BUG: no check — duplicates silently accumulate\n        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))\n    }\n}\n```\n\n### Correct: Database Constraint + Application Guard\n\n```kotlin\n@Entity\n@Table(\n    name = \"reservations\",\n    uniqueConstraints = [\n        UniqueConstraint(columnNames = [\"variant_id\", \"order_id\"])\n    ]\n)\nclass Reservation(\n    @Column(name = \"variant_id\", nullable = false)\n    val variantId: Long,\n\n    @Column(name = \"order_id\", nullable = false)\n    val orderId: String,\n\n    @Column(nullable = false)\n    var quantity: Int\n) {\n    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n    val id: Long = 0\n}\n\ninterface ReservationRepository : JpaRepository\u003CReservation, Long> {\n    fun findByVariantIdAndOrderId(variantId: Long, orderId: String): Reservation?\n}\n\n@Service\nclass ReservationService(private val repo: ReservationRepository) {\n    @Transactional\n    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {\n        repo.findByVariantIdAndOrderId(variantId, orderId)?.let {\n            throw IllegalStateException(\n                \"Reservation already exists for variant=$variantId, order=$orderId\"\n            )\n        }\n        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))\n    }\n}\n```\n\n**Key rules:**\n- Database constraint is mandatory — application checks alone have race conditions\n- Application check provides clean error messages — without it, users get raw `DataIntegrityViolationException`\n- Both layers together: application catches the common case, database catches the race\n- Spring Data derives `findByXAndY` queries automatically\n\n## Query and Fetch Rules\n\n- Diagnose N+1 by looking at actual query count or SQL logs, not by guessing from annotations.\n- Prefer targeted fetch solutions: `@EntityGraph`, `JOIN FETCH`, batch fetching, or DTO projection.\n- Be careful with collection fetch joins plus pagination — call out the tradeoff.\n- Use indexes and uniqueness constraints to support real query patterns.\n\n## Common ORM Traps\n\n- **Bidirectional associations:** maintain both sides in domain methods. Half-updated graphs cause subtle bugs.\n- **`orphanRemoval` vs cascade remove:** not interchangeable. Explain lifecycle semantics before choosing.\n- **Lazy load triggers:** `toString`, debug logging, JSON serialization, and IDE inspection can all trigger lazy loads.\n- **Bulk updates\u002Fdeletes:** bypass persistence context and lifecycle callbacks. Subsequent reads may be stale.\n- **Multiple bag fetches:** can cause Cartesian explosion. Verify the ORM can execute collection-heavy fetch plans safely.\n- **`Set` + mutable equality:** collection membership can break after entity state changes.\n- **`@Version`:** the clearest optimistic concurrency mechanism when concurrent updates matter.\n- **`open-in-view` disabled:** DTO mapping touching lazy fields must happen inside a transaction boundary.\n\n## Guardrails\n\n- Do not use `data class` for JPA entities.\n- Do not recommend `FetchType.EAGER` everywhere to silence lazy loading symptoms.\n- Do not expose entities directly through API responses by default.\n- Do not claim an N+1 fix without explaining how the fetch plan changes query behavior.\n",{"data":40,"body":45},{"name":4,"description":6,"license":31,"metadata":41},{"short-description":42,"author":9,"version":43,"source":44},"Model Kotlin JPA entities correctly","1.0.0","https:\u002F\u002Fgithub.com\u002FKotlin\u002Fkotlin-agent-skills\u002Ftree\u002Fmain\u002Fskills\u002Fkotlin-backend-jpa-entity-mapping",{"type":46,"children":47},"root",[48,57,118,123,130,209,215,265,279,363,369,578,586,660,666,671,677,746,752,1050,1057,1094,1100,1139,1145,1258,1264,1301],{"type":49,"tag":50,"props":51,"children":53},"element","h1",{"id":52},"jpa-entity-mapping-for-kotlin",[54],{"type":55,"value":56},"text","JPA Entity Mapping for Kotlin",{"type":49,"tag":58,"props":59,"children":60},"p",{},[61,63,70,72,77,79,85,87,93,95,101,102,108,110,116],{"type":55,"value":62},"Kotlin's ",{"type":49,"tag":64,"props":65,"children":67},"code",{"className":66},[],[68],{"type":55,"value":69},"data class",{"type":55,"value":71}," is natural for DTOs but dangerous for JPA entities. Hibernate relies on\nidentity semantics that ",{"type":49,"tag":64,"props":73,"children":75},{"className":74},[],[76],{"type":55,"value":69},{"type":55,"value":78}," breaks: ",{"type":49,"tag":64,"props":80,"children":82},{"className":81},[],[83],{"type":55,"value":84},"equals",{"type":55,"value":86},"\u002F",{"type":49,"tag":64,"props":88,"children":90},{"className":89},[],[91],{"type":55,"value":92},"hashCode",{"type":55,"value":94}," over all fields corrupts\n",{"type":49,"tag":64,"props":96,"children":98},{"className":97},[],[99],{"type":55,"value":100},"Set",{"type":55,"value":86},{"type":49,"tag":64,"props":103,"children":105},{"className":104},[],[106],{"type":55,"value":107},"Map",{"type":55,"value":109}," membership after state changes, and auto-generated ",{"type":49,"tag":64,"props":111,"children":113},{"className":112},[],[114],{"type":55,"value":115},"copy()",{"type":55,"value":117}," creates detached\nduplicates of managed entities.",{"type":49,"tag":58,"props":119,"children":120},{},[121],{"type":55,"value":122},"This skill teaches correct entity design, identity strategies, and uniqueness constraints\nfor Kotlin + Spring Data JPA projects.",{"type":49,"tag":124,"props":125,"children":127},"h2",{"id":126},"entity-design-rules",[128],{"type":55,"value":129},"Entity Design Rules",{"type":49,"tag":131,"props":132,"children":133},"ul",{},[134,168,173,178,191,204],{"type":49,"tag":135,"props":136,"children":137},"li",{},[138,151,153,159,161,166],{"type":49,"tag":139,"props":140,"children":141},"strong",{},[142,144,149],{"type":55,"value":143},"Never use ",{"type":49,"tag":64,"props":145,"children":147},{"className":146},[],[148],{"type":55,"value":69},{"type":55,"value":150}," for JPA entities.",{"type":55,"value":152}," Use a regular ",{"type":49,"tag":64,"props":154,"children":156},{"className":155},[],[157],{"type":55,"value":158},"class",{"type":55,"value":160},". Keep ",{"type":49,"tag":64,"props":162,"children":164},{"className":163},[],[165],{"type":55,"value":69},{"type":55,"value":167}," for DTOs.",{"type":49,"tag":135,"props":169,"children":170},{},[171],{"type":55,"value":172},"Keep transport DTOs and persistence entities separate unless the project clearly uses a shared model.",{"type":49,"tag":135,"props":174,"children":175},{},[176],{"type":55,"value":177},"Model required columns as non-null only when object construction and persistence lifecycle make it safe.",{"type":49,"tag":135,"props":179,"children":180},{},[181,183,189],{"type":55,"value":182},"Use ",{"type":49,"tag":64,"props":184,"children":186},{"className":185},[],[187],{"type":55,"value":188},"lateinit",{"type":55,"value":190}," only when the project already accepts that tradeoff and the lifecycle is safe.",{"type":49,"tag":135,"props":192,"children":193},{},[194,196,202],{"type":55,"value":195},"Verify ",{"type":49,"tag":64,"props":197,"children":199},{"className":198},[],[200],{"type":55,"value":201},"kotlin(\"plugin.jpa\")",{"type":55,"value":203}," or equivalent no-arg support when JPA entities exist.",{"type":49,"tag":135,"props":205,"children":206},{},[207],{"type":55,"value":208},"Verify classes and members are compatible with proxying where needed.",{"type":49,"tag":124,"props":210,"children":212},{"id":211},"identity-and-equality",[213],{"type":55,"value":214},"Identity and Equality",{"type":49,"tag":131,"props":216,"children":217},{},[218,243,248,260],{"type":49,"tag":135,"props":219,"children":220},{},[221,223,228,229,234,236,241],{"type":55,"value":222},"Never accept all-field ",{"type":49,"tag":64,"props":224,"children":226},{"className":225},[],[227],{"type":55,"value":84},{"type":55,"value":86},{"type":49,"tag":64,"props":230,"children":232},{"className":231},[],[233],{"type":55,"value":92},{"type":55,"value":235}," generated by ",{"type":49,"tag":64,"props":237,"children":239},{"className":238},[],[240],{"type":55,"value":69},{"type":55,"value":242}," on an entity.",{"type":49,"tag":135,"props":244,"children":245},{},[246],{"type":55,"value":247},"Follow project conventions when they already define an identity strategy.",{"type":49,"tag":135,"props":249,"children":250},{},[251,253,258],{"type":55,"value":252},"If no convention exists, use ID-based equality with a stable ",{"type":49,"tag":64,"props":254,"children":256},{"className":255},[],[257],{"type":55,"value":92},{"type":55,"value":259},".",{"type":49,"tag":135,"props":261,"children":262},{},[263],{"type":55,"value":264},"Be explicit about mutable fields and lazy associations when discussing equality.",{"type":49,"tag":266,"props":267,"children":269},"h3",{"id":268},"broken-data-class-entity",[270,272,277],{"type":55,"value":271},"Broken: ",{"type":49,"tag":64,"props":273,"children":275},{"className":274},[],[276],{"type":55,"value":69},{"type":55,"value":278}," Entity",{"type":49,"tag":280,"props":281,"children":285},"pre",{"className":282,"code":283,"language":14,"meta":284,"style":284},"language-kotlin shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F WRONG: data class generates equals\u002FhashCode from ALL fields\ndata class Order(\n    @Id @GeneratedValue val id: Long = 0,\n    var status: String,\n    var total: BigDecimal\n)\n\u002F\u002F BUG: order.status = \"SHIPPED\"; set.contains(order) → false (hash changed)\n\u002F\u002F BUG: Hibernate proxy.equals(entity) → false (proxy has lazy fields uninitialized)\n","",[286],{"type":49,"tag":64,"props":287,"children":288},{"__ignoreMap":284},[289,300,309,318,327,336,345,354],{"type":49,"tag":290,"props":291,"children":294},"span",{"class":292,"line":293},"line",1,[295],{"type":49,"tag":290,"props":296,"children":297},{},[298],{"type":55,"value":299},"\u002F\u002F WRONG: data class generates equals\u002FhashCode from ALL fields\n",{"type":49,"tag":290,"props":301,"children":303},{"class":292,"line":302},2,[304],{"type":49,"tag":290,"props":305,"children":306},{},[307],{"type":55,"value":308},"data class Order(\n",{"type":49,"tag":290,"props":310,"children":312},{"class":292,"line":311},3,[313],{"type":49,"tag":290,"props":314,"children":315},{},[316],{"type":55,"value":317},"    @Id @GeneratedValue val id: Long = 0,\n",{"type":49,"tag":290,"props":319,"children":321},{"class":292,"line":320},4,[322],{"type":49,"tag":290,"props":323,"children":324},{},[325],{"type":55,"value":326},"    var status: String,\n",{"type":49,"tag":290,"props":328,"children":330},{"class":292,"line":329},5,[331],{"type":49,"tag":290,"props":332,"children":333},{},[334],{"type":55,"value":335},"    var total: BigDecimal\n",{"type":49,"tag":290,"props":337,"children":339},{"class":292,"line":338},6,[340],{"type":49,"tag":290,"props":341,"children":342},{},[343],{"type":55,"value":344},")\n",{"type":49,"tag":290,"props":346,"children":348},{"class":292,"line":347},7,[349],{"type":49,"tag":290,"props":350,"children":351},{},[352],{"type":55,"value":353},"\u002F\u002F BUG: order.status = \"SHIPPED\"; set.contains(order) → false (hash changed)\n",{"type":49,"tag":290,"props":355,"children":357},{"class":292,"line":356},8,[358],{"type":49,"tag":290,"props":359,"children":360},{},[361],{"type":55,"value":362},"\u002F\u002F BUG: Hibernate proxy.equals(entity) → false (proxy has lazy fields uninitialized)\n",{"type":49,"tag":266,"props":364,"children":366},{"id":365},"correct-regular-class-with-id-based-identity",[367],{"type":55,"value":368},"Correct: Regular Class with ID-Based Identity",{"type":49,"tag":280,"props":370,"children":372},{"className":282,"code":371,"language":14,"meta":284,"style":284},"@Entity\n@Table(name = \"orders\")\nclass Order(\n    @Column(nullable = false)\n    var status: String,\n\n    @Column(nullable = false)\n    var total: BigDecimal\n) {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    val id: Long = 0\n\n    override fun equals(other: Any?): Boolean {\n        if (this === other) return true\n        if (other !is Order) return false\n        return id != 0L && id == other.id\n    }\n\n    override fun hashCode(): Int = javaClass.hashCode()\n\n    \u002F\u002F toString must NOT reference lazy collections\n    override fun toString(): String = \"Order(id=$id, status=$status)\"\n}\n",[373],{"type":49,"tag":64,"props":374,"children":375},{"__ignoreMap":284},[376,384,392,400,408,415,424,431,438,447,456,465,474,482,491,500,509,517,526,534,543,551,560,569],{"type":49,"tag":290,"props":377,"children":378},{"class":292,"line":293},[379],{"type":49,"tag":290,"props":380,"children":381},{},[382],{"type":55,"value":383},"@Entity\n",{"type":49,"tag":290,"props":385,"children":386},{"class":292,"line":302},[387],{"type":49,"tag":290,"props":388,"children":389},{},[390],{"type":55,"value":391},"@Table(name = \"orders\")\n",{"type":49,"tag":290,"props":393,"children":394},{"class":292,"line":311},[395],{"type":49,"tag":290,"props":396,"children":397},{},[398],{"type":55,"value":399},"class Order(\n",{"type":49,"tag":290,"props":401,"children":402},{"class":292,"line":320},[403],{"type":49,"tag":290,"props":404,"children":405},{},[406],{"type":55,"value":407},"    @Column(nullable = false)\n",{"type":49,"tag":290,"props":409,"children":410},{"class":292,"line":329},[411],{"type":49,"tag":290,"props":412,"children":413},{},[414],{"type":55,"value":326},{"type":49,"tag":290,"props":416,"children":417},{"class":292,"line":338},[418],{"type":49,"tag":290,"props":419,"children":421},{"emptyLinePlaceholder":420},true,[422],{"type":55,"value":423},"\n",{"type":49,"tag":290,"props":425,"children":426},{"class":292,"line":347},[427],{"type":49,"tag":290,"props":428,"children":429},{},[430],{"type":55,"value":407},{"type":49,"tag":290,"props":432,"children":433},{"class":292,"line":356},[434],{"type":49,"tag":290,"props":435,"children":436},{},[437],{"type":55,"value":335},{"type":49,"tag":290,"props":439,"children":441},{"class":292,"line":440},9,[442],{"type":49,"tag":290,"props":443,"children":444},{},[445],{"type":55,"value":446},") {\n",{"type":49,"tag":290,"props":448,"children":450},{"class":292,"line":449},10,[451],{"type":49,"tag":290,"props":452,"children":453},{},[454],{"type":55,"value":455},"    @Id\n",{"type":49,"tag":290,"props":457,"children":459},{"class":292,"line":458},11,[460],{"type":49,"tag":290,"props":461,"children":462},{},[463],{"type":55,"value":464},"    @GeneratedValue(strategy = GenerationType.IDENTITY)\n",{"type":49,"tag":290,"props":466,"children":468},{"class":292,"line":467},12,[469],{"type":49,"tag":290,"props":470,"children":471},{},[472],{"type":55,"value":473},"    val id: Long = 0\n",{"type":49,"tag":290,"props":475,"children":477},{"class":292,"line":476},13,[478],{"type":49,"tag":290,"props":479,"children":480},{"emptyLinePlaceholder":420},[481],{"type":55,"value":423},{"type":49,"tag":290,"props":483,"children":485},{"class":292,"line":484},14,[486],{"type":49,"tag":290,"props":487,"children":488},{},[489],{"type":55,"value":490},"    override fun equals(other: Any?): Boolean {\n",{"type":49,"tag":290,"props":492,"children":494},{"class":292,"line":493},15,[495],{"type":49,"tag":290,"props":496,"children":497},{},[498],{"type":55,"value":499},"        if (this === other) return true\n",{"type":49,"tag":290,"props":501,"children":503},{"class":292,"line":502},16,[504],{"type":49,"tag":290,"props":505,"children":506},{},[507],{"type":55,"value":508},"        if (other !is Order) return false\n",{"type":49,"tag":290,"props":510,"children":511},{"class":292,"line":32},[512],{"type":49,"tag":290,"props":513,"children":514},{},[515],{"type":55,"value":516},"        return id != 0L && id == other.id\n",{"type":49,"tag":290,"props":518,"children":520},{"class":292,"line":519},18,[521],{"type":49,"tag":290,"props":522,"children":523},{},[524],{"type":55,"value":525},"    }\n",{"type":49,"tag":290,"props":527,"children":529},{"class":292,"line":528},19,[530],{"type":49,"tag":290,"props":531,"children":532},{"emptyLinePlaceholder":420},[533],{"type":55,"value":423},{"type":49,"tag":290,"props":535,"children":537},{"class":292,"line":536},20,[538],{"type":49,"tag":290,"props":539,"children":540},{},[541],{"type":55,"value":542},"    override fun hashCode(): Int = javaClass.hashCode()\n",{"type":49,"tag":290,"props":544,"children":546},{"class":292,"line":545},21,[547],{"type":49,"tag":290,"props":548,"children":549},{"emptyLinePlaceholder":420},[550],{"type":55,"value":423},{"type":49,"tag":290,"props":552,"children":554},{"class":292,"line":553},22,[555],{"type":49,"tag":290,"props":556,"children":557},{},[558],{"type":55,"value":559},"    \u002F\u002F toString must NOT reference lazy collections\n",{"type":49,"tag":290,"props":561,"children":563},{"class":292,"line":562},23,[564],{"type":49,"tag":290,"props":565,"children":566},{},[567],{"type":55,"value":568},"    override fun toString(): String = \"Order(id=$id, status=$status)\"\n",{"type":49,"tag":290,"props":570,"children":572},{"class":292,"line":571},24,[573],{"type":49,"tag":290,"props":574,"children":575},{},[576],{"type":55,"value":577},"}\n",{"type":49,"tag":58,"props":579,"children":580},{},[581],{"type":49,"tag":139,"props":582,"children":583},{},[584],{"type":55,"value":585},"Key rules:",{"type":49,"tag":131,"props":587,"children":588},{},[589,599,622,639],{"type":49,"tag":135,"props":590,"children":591},{},[592,597],{"type":49,"tag":64,"props":593,"children":595},{"className":594},[],[596],{"type":55,"value":84},{"type":55,"value":598}," compares by ID only — stable under dirty tracking and proxy unwrapping",{"type":49,"tag":135,"props":600,"children":601},{},[602,607,609,614,615,620],{"type":49,"tag":64,"props":603,"children":605},{"className":604},[],[606],{"type":55,"value":92},{"type":55,"value":608}," returns class-based constant — avoids ",{"type":49,"tag":64,"props":610,"children":612},{"className":611},[],[613],{"type":55,"value":100},{"type":55,"value":86},{"type":49,"tag":64,"props":616,"children":618},{"className":617},[],[619],{"type":55,"value":107},{"type":55,"value":621}," corruption after persist",{"type":49,"tag":135,"props":623,"children":624},{},[625,631,633],{"type":49,"tag":64,"props":626,"children":628},{"className":627},[],[629],{"type":55,"value":630},"toString",{"type":55,"value":632}," excludes lazy-loaded relations — prevents ",{"type":49,"tag":64,"props":634,"children":636},{"className":635},[],[637],{"type":55,"value":638},"LazyInitializationException",{"type":49,"tag":135,"props":640,"children":641},{},[642,644,650,652,658],{"type":55,"value":643},"Constructor params are mutable entity fields; ",{"type":49,"tag":64,"props":645,"children":647},{"className":646},[],[648],{"type":55,"value":649},"id",{"type":55,"value":651}," is ",{"type":49,"tag":64,"props":653,"children":655},{"className":654},[],[656],{"type":55,"value":657},"val",{"type":55,"value":659}," with default",{"type":49,"tag":124,"props":661,"children":663},{"id":662},"uniqueness-constraints",[664],{"type":55,"value":665},"Uniqueness Constraints",{"type":49,"tag":58,"props":667,"children":668},{},[669],{"type":55,"value":670},"When an API must be idempotent (e.g., \"reserve stock for order X\"), enforce uniqueness\nat both layers: database constraint for correctness, application check for clean errors.",{"type":49,"tag":266,"props":672,"children":674},{"id":673},"broken-no-duplicate-guard",[675],{"type":55,"value":676},"Broken: No Duplicate Guard",{"type":49,"tag":280,"props":678,"children":680},{"className":282,"code":679,"language":14,"meta":284,"style":284},"@Service\nclass ReservationService(private val repo: ReservationRepository) {\n    @Transactional\n    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {\n        \u002F\u002F BUG: no check — duplicates silently accumulate\n        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))\n    }\n}\n",[681],{"type":49,"tag":64,"props":682,"children":683},{"__ignoreMap":284},[684,692,700,708,716,724,732,739],{"type":49,"tag":290,"props":685,"children":686},{"class":292,"line":293},[687],{"type":49,"tag":290,"props":688,"children":689},{},[690],{"type":55,"value":691},"@Service\n",{"type":49,"tag":290,"props":693,"children":694},{"class":292,"line":302},[695],{"type":49,"tag":290,"props":696,"children":697},{},[698],{"type":55,"value":699},"class ReservationService(private val repo: ReservationRepository) {\n",{"type":49,"tag":290,"props":701,"children":702},{"class":292,"line":311},[703],{"type":49,"tag":290,"props":704,"children":705},{},[706],{"type":55,"value":707},"    @Transactional\n",{"type":49,"tag":290,"props":709,"children":710},{"class":292,"line":320},[711],{"type":49,"tag":290,"props":712,"children":713},{},[714],{"type":55,"value":715},"    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {\n",{"type":49,"tag":290,"props":717,"children":718},{"class":292,"line":329},[719],{"type":49,"tag":290,"props":720,"children":721},{},[722],{"type":55,"value":723},"        \u002F\u002F BUG: no check — duplicates silently accumulate\n",{"type":49,"tag":290,"props":725,"children":726},{"class":292,"line":338},[727],{"type":49,"tag":290,"props":728,"children":729},{},[730],{"type":55,"value":731},"        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))\n",{"type":49,"tag":290,"props":733,"children":734},{"class":292,"line":347},[735],{"type":49,"tag":290,"props":736,"children":737},{},[738],{"type":55,"value":525},{"type":49,"tag":290,"props":740,"children":741},{"class":292,"line":356},[742],{"type":49,"tag":290,"props":743,"children":744},{},[745],{"type":55,"value":577},{"type":49,"tag":266,"props":747,"children":749},{"id":748},"correct-database-constraint-application-guard",[750],{"type":55,"value":751},"Correct: Database Constraint + Application Guard",{"type":49,"tag":280,"props":753,"children":755},{"className":282,"code":754,"language":14,"meta":284,"style":284},"@Entity\n@Table(\n    name = \"reservations\",\n    uniqueConstraints = [\n        UniqueConstraint(columnNames = [\"variant_id\", \"order_id\"])\n    ]\n)\nclass Reservation(\n    @Column(name = \"variant_id\", nullable = false)\n    val variantId: Long,\n\n    @Column(name = \"order_id\", nullable = false)\n    val orderId: String,\n\n    @Column(nullable = false)\n    var quantity: Int\n) {\n    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n    val id: Long = 0\n}\n\ninterface ReservationRepository : JpaRepository\u003CReservation, Long> {\n    fun findByVariantIdAndOrderId(variantId: Long, orderId: String): Reservation?\n}\n\n@Service\nclass ReservationService(private val repo: ReservationRepository) {\n    @Transactional\n    fun createReservation(variantId: Long, orderId: String, qty: Int): Reservation {\n        repo.findByVariantIdAndOrderId(variantId, orderId)?.let {\n            throw IllegalStateException(\n                \"Reservation already exists for variant=$variantId, order=$orderId\"\n            )\n        }\n        return repo.save(Reservation(variantId = variantId, orderId = orderId, quantity = qty))\n    }\n}\n",[756],{"type":49,"tag":64,"props":757,"children":758},{"__ignoreMap":284},[759,766,774,782,790,798,806,813,821,829,837,844,852,860,867,874,882,889,897,904,911,918,926,934,941,949,957,965,973,981,990,999,1008,1017,1026,1034,1042],{"type":49,"tag":290,"props":760,"children":761},{"class":292,"line":293},[762],{"type":49,"tag":290,"props":763,"children":764},{},[765],{"type":55,"value":383},{"type":49,"tag":290,"props":767,"children":768},{"class":292,"line":302},[769],{"type":49,"tag":290,"props":770,"children":771},{},[772],{"type":55,"value":773},"@Table(\n",{"type":49,"tag":290,"props":775,"children":776},{"class":292,"line":311},[777],{"type":49,"tag":290,"props":778,"children":779},{},[780],{"type":55,"value":781},"    name = \"reservations\",\n",{"type":49,"tag":290,"props":783,"children":784},{"class":292,"line":320},[785],{"type":49,"tag":290,"props":786,"children":787},{},[788],{"type":55,"value":789},"    uniqueConstraints = [\n",{"type":49,"tag":290,"props":791,"children":792},{"class":292,"line":329},[793],{"type":49,"tag":290,"props":794,"children":795},{},[796],{"type":55,"value":797},"        UniqueConstraint(columnNames = [\"variant_id\", \"order_id\"])\n",{"type":49,"tag":290,"props":799,"children":800},{"class":292,"line":338},[801],{"type":49,"tag":290,"props":802,"children":803},{},[804],{"type":55,"value":805},"    ]\n",{"type":49,"tag":290,"props":807,"children":808},{"class":292,"line":347},[809],{"type":49,"tag":290,"props":810,"children":811},{},[812],{"type":55,"value":344},{"type":49,"tag":290,"props":814,"children":815},{"class":292,"line":356},[816],{"type":49,"tag":290,"props":817,"children":818},{},[819],{"type":55,"value":820},"class Reservation(\n",{"type":49,"tag":290,"props":822,"children":823},{"class":292,"line":440},[824],{"type":49,"tag":290,"props":825,"children":826},{},[827],{"type":55,"value":828},"    @Column(name = \"variant_id\", nullable = false)\n",{"type":49,"tag":290,"props":830,"children":831},{"class":292,"line":449},[832],{"type":49,"tag":290,"props":833,"children":834},{},[835],{"type":55,"value":836},"    val variantId: Long,\n",{"type":49,"tag":290,"props":838,"children":839},{"class":292,"line":458},[840],{"type":49,"tag":290,"props":841,"children":842},{"emptyLinePlaceholder":420},[843],{"type":55,"value":423},{"type":49,"tag":290,"props":845,"children":846},{"class":292,"line":467},[847],{"type":49,"tag":290,"props":848,"children":849},{},[850],{"type":55,"value":851},"    @Column(name = \"order_id\", nullable = false)\n",{"type":49,"tag":290,"props":853,"children":854},{"class":292,"line":476},[855],{"type":49,"tag":290,"props":856,"children":857},{},[858],{"type":55,"value":859},"    val orderId: String,\n",{"type":49,"tag":290,"props":861,"children":862},{"class":292,"line":484},[863],{"type":49,"tag":290,"props":864,"children":865},{"emptyLinePlaceholder":420},[866],{"type":55,"value":423},{"type":49,"tag":290,"props":868,"children":869},{"class":292,"line":493},[870],{"type":49,"tag":290,"props":871,"children":872},{},[873],{"type":55,"value":407},{"type":49,"tag":290,"props":875,"children":876},{"class":292,"line":502},[877],{"type":49,"tag":290,"props":878,"children":879},{},[880],{"type":55,"value":881},"    var quantity: Int\n",{"type":49,"tag":290,"props":883,"children":884},{"class":292,"line":32},[885],{"type":49,"tag":290,"props":886,"children":887},{},[888],{"type":55,"value":446},{"type":49,"tag":290,"props":890,"children":891},{"class":292,"line":519},[892],{"type":49,"tag":290,"props":893,"children":894},{},[895],{"type":55,"value":896},"    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n",{"type":49,"tag":290,"props":898,"children":899},{"class":292,"line":528},[900],{"type":49,"tag":290,"props":901,"children":902},{},[903],{"type":55,"value":473},{"type":49,"tag":290,"props":905,"children":906},{"class":292,"line":536},[907],{"type":49,"tag":290,"props":908,"children":909},{},[910],{"type":55,"value":577},{"type":49,"tag":290,"props":912,"children":913},{"class":292,"line":545},[914],{"type":49,"tag":290,"props":915,"children":916},{"emptyLinePlaceholder":420},[917],{"type":55,"value":423},{"type":49,"tag":290,"props":919,"children":920},{"class":292,"line":553},[921],{"type":49,"tag":290,"props":922,"children":923},{},[924],{"type":55,"value":925},"interface ReservationRepository : JpaRepository\u003CReservation, Long> {\n",{"type":49,"tag":290,"props":927,"children":928},{"class":292,"line":562},[929],{"type":49,"tag":290,"props":930,"children":931},{},[932],{"type":55,"value":933},"    fun findByVariantIdAndOrderId(variantId: Long, orderId: String): Reservation?\n",{"type":49,"tag":290,"props":935,"children":936},{"class":292,"line":571},[937],{"type":49,"tag":290,"props":938,"children":939},{},[940],{"type":55,"value":577},{"type":49,"tag":290,"props":942,"children":944},{"class":292,"line":943},25,[945],{"type":49,"tag":290,"props":946,"children":947},{"emptyLinePlaceholder":420},[948],{"type":55,"value":423},{"type":49,"tag":290,"props":950,"children":952},{"class":292,"line":951},26,[953],{"type":49,"tag":290,"props":954,"children":955},{},[956],{"type":55,"value":691},{"type":49,"tag":290,"props":958,"children":960},{"class":292,"line":959},27,[961],{"type":49,"tag":290,"props":962,"children":963},{},[964],{"type":55,"value":699},{"type":49,"tag":290,"props":966,"children":968},{"class":292,"line":967},28,[969],{"type":49,"tag":290,"props":970,"children":971},{},[972],{"type":55,"value":707},{"type":49,"tag":290,"props":974,"children":976},{"class":292,"line":975},29,[977],{"type":49,"tag":290,"props":978,"children":979},{},[980],{"type":55,"value":715},{"type":49,"tag":290,"props":982,"children":984},{"class":292,"line":983},30,[985],{"type":49,"tag":290,"props":986,"children":987},{},[988],{"type":55,"value":989},"        repo.findByVariantIdAndOrderId(variantId, orderId)?.let {\n",{"type":49,"tag":290,"props":991,"children":993},{"class":292,"line":992},31,[994],{"type":49,"tag":290,"props":995,"children":996},{},[997],{"type":55,"value":998},"            throw IllegalStateException(\n",{"type":49,"tag":290,"props":1000,"children":1002},{"class":292,"line":1001},32,[1003],{"type":49,"tag":290,"props":1004,"children":1005},{},[1006],{"type":55,"value":1007},"                \"Reservation already exists for variant=$variantId, order=$orderId\"\n",{"type":49,"tag":290,"props":1009,"children":1011},{"class":292,"line":1010},33,[1012],{"type":49,"tag":290,"props":1013,"children":1014},{},[1015],{"type":55,"value":1016},"            )\n",{"type":49,"tag":290,"props":1018,"children":1020},{"class":292,"line":1019},34,[1021],{"type":49,"tag":290,"props":1022,"children":1023},{},[1024],{"type":55,"value":1025},"        }\n",{"type":49,"tag":290,"props":1027,"children":1029},{"class":292,"line":1028},35,[1030],{"type":49,"tag":290,"props":1031,"children":1032},{},[1033],{"type":55,"value":731},{"type":49,"tag":290,"props":1035,"children":1037},{"class":292,"line":1036},36,[1038],{"type":49,"tag":290,"props":1039,"children":1040},{},[1041],{"type":55,"value":525},{"type":49,"tag":290,"props":1043,"children":1045},{"class":292,"line":1044},37,[1046],{"type":49,"tag":290,"props":1047,"children":1048},{},[1049],{"type":55,"value":577},{"type":49,"tag":58,"props":1051,"children":1052},{},[1053],{"type":49,"tag":139,"props":1054,"children":1055},{},[1056],{"type":55,"value":585},{"type":49,"tag":131,"props":1058,"children":1059},{},[1060,1065,1076,1081],{"type":49,"tag":135,"props":1061,"children":1062},{},[1063],{"type":55,"value":1064},"Database constraint is mandatory — application checks alone have race conditions",{"type":49,"tag":135,"props":1066,"children":1067},{},[1068,1070],{"type":55,"value":1069},"Application check provides clean error messages — without it, users get raw ",{"type":49,"tag":64,"props":1071,"children":1073},{"className":1072},[],[1074],{"type":55,"value":1075},"DataIntegrityViolationException",{"type":49,"tag":135,"props":1077,"children":1078},{},[1079],{"type":55,"value":1080},"Both layers together: application catches the common case, database catches the race",{"type":49,"tag":135,"props":1082,"children":1083},{},[1084,1086,1092],{"type":55,"value":1085},"Spring Data derives ",{"type":49,"tag":64,"props":1087,"children":1089},{"className":1088},[],[1090],{"type":55,"value":1091},"findByXAndY",{"type":55,"value":1093}," queries automatically",{"type":49,"tag":124,"props":1095,"children":1097},{"id":1096},"query-and-fetch-rules",[1098],{"type":55,"value":1099},"Query and Fetch Rules",{"type":49,"tag":131,"props":1101,"children":1102},{},[1103,1108,1129,1134],{"type":49,"tag":135,"props":1104,"children":1105},{},[1106],{"type":55,"value":1107},"Diagnose N+1 by looking at actual query count or SQL logs, not by guessing from annotations.",{"type":49,"tag":135,"props":1109,"children":1110},{},[1111,1113,1119,1121,1127],{"type":55,"value":1112},"Prefer targeted fetch solutions: ",{"type":49,"tag":64,"props":1114,"children":1116},{"className":1115},[],[1117],{"type":55,"value":1118},"@EntityGraph",{"type":55,"value":1120},", ",{"type":49,"tag":64,"props":1122,"children":1124},{"className":1123},[],[1125],{"type":55,"value":1126},"JOIN FETCH",{"type":55,"value":1128},", batch fetching, or DTO projection.",{"type":49,"tag":135,"props":1130,"children":1131},{},[1132],{"type":55,"value":1133},"Be careful with collection fetch joins plus pagination — call out the tradeoff.",{"type":49,"tag":135,"props":1135,"children":1136},{},[1137],{"type":55,"value":1138},"Use indexes and uniqueness constraints to support real query patterns.",{"type":49,"tag":124,"props":1140,"children":1142},{"id":1141},"common-orm-traps",[1143],{"type":55,"value":1144},"Common ORM Traps",{"type":49,"tag":131,"props":1146,"children":1147},{},[1148,1158,1174,1191,1201,1211,1226,1242],{"type":49,"tag":135,"props":1149,"children":1150},{},[1151,1156],{"type":49,"tag":139,"props":1152,"children":1153},{},[1154],{"type":55,"value":1155},"Bidirectional associations:",{"type":55,"value":1157}," maintain both sides in domain methods. Half-updated graphs cause subtle bugs.",{"type":49,"tag":135,"props":1159,"children":1160},{},[1161,1172],{"type":49,"tag":139,"props":1162,"children":1163},{},[1164,1170],{"type":49,"tag":64,"props":1165,"children":1167},{"className":1166},[],[1168],{"type":55,"value":1169},"orphanRemoval",{"type":55,"value":1171}," vs cascade remove:",{"type":55,"value":1173}," not interchangeable. Explain lifecycle semantics before choosing.",{"type":49,"tag":135,"props":1175,"children":1176},{},[1177,1182,1184,1189],{"type":49,"tag":139,"props":1178,"children":1179},{},[1180],{"type":55,"value":1181},"Lazy load triggers:",{"type":55,"value":1183}," ",{"type":49,"tag":64,"props":1185,"children":1187},{"className":1186},[],[1188],{"type":55,"value":630},{"type":55,"value":1190},", debug logging, JSON serialization, and IDE inspection can all trigger lazy loads.",{"type":49,"tag":135,"props":1192,"children":1193},{},[1194,1199],{"type":49,"tag":139,"props":1195,"children":1196},{},[1197],{"type":55,"value":1198},"Bulk updates\u002Fdeletes:",{"type":55,"value":1200}," bypass persistence context and lifecycle callbacks. Subsequent reads may be stale.",{"type":49,"tag":135,"props":1202,"children":1203},{},[1204,1209],{"type":49,"tag":139,"props":1205,"children":1206},{},[1207],{"type":55,"value":1208},"Multiple bag fetches:",{"type":55,"value":1210}," can cause Cartesian explosion. Verify the ORM can execute collection-heavy fetch plans safely.",{"type":49,"tag":135,"props":1212,"children":1213},{},[1214,1224],{"type":49,"tag":139,"props":1215,"children":1216},{},[1217,1222],{"type":49,"tag":64,"props":1218,"children":1220},{"className":1219},[],[1221],{"type":55,"value":100},{"type":55,"value":1223}," + mutable equality:",{"type":55,"value":1225}," collection membership can break after entity state changes.",{"type":49,"tag":135,"props":1227,"children":1228},{},[1229,1240],{"type":49,"tag":139,"props":1230,"children":1231},{},[1232,1238],{"type":49,"tag":64,"props":1233,"children":1235},{"className":1234},[],[1236],{"type":55,"value":1237},"@Version",{"type":55,"value":1239},":",{"type":55,"value":1241}," the clearest optimistic concurrency mechanism when concurrent updates matter.",{"type":49,"tag":135,"props":1243,"children":1244},{},[1245,1256],{"type":49,"tag":139,"props":1246,"children":1247},{},[1248,1254],{"type":49,"tag":64,"props":1249,"children":1251},{"className":1250},[],[1252],{"type":55,"value":1253},"open-in-view",{"type":55,"value":1255}," disabled:",{"type":55,"value":1257}," DTO mapping touching lazy fields must happen inside a transaction boundary.",{"type":49,"tag":124,"props":1259,"children":1261},{"id":1260},"guardrails",[1262],{"type":55,"value":1263},"Guardrails",{"type":49,"tag":131,"props":1265,"children":1266},{},[1267,1278,1291,1296],{"type":49,"tag":135,"props":1268,"children":1269},{},[1270,1272,1277],{"type":55,"value":1271},"Do not use ",{"type":49,"tag":64,"props":1273,"children":1275},{"className":1274},[],[1276],{"type":55,"value":69},{"type":55,"value":150},{"type":49,"tag":135,"props":1279,"children":1280},{},[1281,1283,1289],{"type":55,"value":1282},"Do not recommend ",{"type":49,"tag":64,"props":1284,"children":1286},{"className":1285},[],[1287],{"type":55,"value":1288},"FetchType.EAGER",{"type":55,"value":1290}," everywhere to silence lazy loading symptoms.",{"type":49,"tag":135,"props":1292,"children":1293},{},[1294],{"type":55,"value":1295},"Do not expose entities directly through API responses by default.",{"type":49,"tag":135,"props":1297,"children":1298},{},[1299],{"type":55,"value":1300},"Do not claim an N+1 fix without explaining how the fetch plan changes query behavior.",{"type":49,"tag":1302,"props":1303,"children":1304},"style",{},[1305],{"type":55,"value":1306},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":1308,"total":1428},[1309,1328,1345,1361,1376,1395,1412],{"slug":1310,"name":1310,"fn":1311,"description":1312,"org":1313,"tags":1314,"stars":28,"repoUrl":29,"updatedAt":1327},"algorithmic-art","create generative art with p5.js","Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1315,1318,1321,1324],{"name":1316,"slug":1317,"type":15},"Creative","creative",{"name":1319,"slug":1320,"type":15},"Generative Art","generative-art",{"name":1322,"slug":1323,"type":15},"Graphics","graphics",{"name":1325,"slug":1326,"type":15},"JavaScript","javascript","2026-07-13T06:41:35.540127",{"slug":1329,"name":1329,"fn":1330,"description":1331,"org":1332,"tags":1333,"stars":28,"repoUrl":29,"updatedAt":1344},"antfu","configure JavaScript projects with Anthony Fu's tools","Anthony Fu's opinionated tooling and conventions for JavaScript\u002FTypeScript projects. Use when setting up new projects, configuring ESLint\u002FPrettier alternatives, monorepos, library publishing, or when the user mentions Anthony Fu's preferences.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1334,1337,1340,1341],{"name":1335,"slug":1336,"type":15},"Best Practices","best-practices",{"name":1338,"slug":1339,"type":15},"Engineering","engineering",{"name":1325,"slug":1326,"type":15},{"name":1342,"slug":1343,"type":15},"TypeScript","typescript","2026-07-13T06:43:13.153309",{"slug":1346,"name":1346,"fn":1347,"description":1348,"org":1349,"tags":1350,"stars":28,"repoUrl":29,"updatedAt":1360},"brand-guidelines","apply Anthropic brand guidelines","Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1351,1354,1357],{"name":1352,"slug":1353,"type":15},"Branding","branding",{"name":1355,"slug":1356,"type":15},"Design","design",{"name":1358,"slug":1359,"type":15},"Typography","typography","2026-07-13T06:43:06.077629",{"slug":1362,"name":1362,"fn":1363,"description":1364,"org":1365,"tags":1366,"stars":28,"repoUrl":29,"updatedAt":1375},"canvas-design","create visual art and design assets","Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1367,1368,1369,1372],{"name":1316,"slug":1317,"type":15},{"name":1355,"slug":1356,"type":15},{"name":1370,"slug":1371,"type":15},"Images","images",{"name":1373,"slug":1374,"type":15},"PDF","pdf","2026-07-13T06:39:58.803113",{"slug":1377,"name":1377,"fn":1378,"description":1379,"org":1380,"tags":1381,"stars":28,"repoUrl":29,"updatedAt":1394},"ci-cd-containerization-advisor","design CI\u002FCD pipelines for Kotlin applications","Design reproducible build, image, and deployment pipelines for Kotlin plus Spring applications, including CI verification, layered containers, rollout safety, and deployment-time migration coordination. Use when creating or improving Dockerfiles, CI workflows, image hardening, Kubernetes manifests, release gates, or deployment strategies for Spring Boot services, especially where build reproducibility and operational safety matter.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1382,1385,1388,1391,1392,1393],{"name":1383,"slug":1384,"type":15},"CI\u002FCD","ci-cd",{"name":1386,"slug":1387,"type":15},"Containers","containers",{"name":1389,"slug":1390,"type":15},"Deployment","deployment",{"name":1338,"slug":1339,"type":15},{"name":13,"slug":14,"type":15},{"name":20,"slug":21,"type":15},"2026-07-13T06:41:47.83899",{"slug":1396,"name":1396,"fn":1397,"description":1398,"org":1399,"tags":1400,"stars":28,"repoUrl":29,"updatedAt":1411},"cloudflare-deploy","deploy applications to Cloudflare","Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1401,1404,1407,1410],{"name":1402,"slug":1403,"type":15},"Cloudflare","cloudflare",{"name":1405,"slug":1406,"type":15},"Cloudflare Pages","cloudflare-pages",{"name":1408,"slug":1409,"type":15},"Cloudflare Workers","cloudflare-workers",{"name":1389,"slug":1390,"type":15},"2026-07-17T06:04:42.853896",{"slug":1413,"name":1413,"fn":1414,"description":1415,"org":1416,"tags":1417,"stars":28,"repoUrl":29,"updatedAt":1427},"compose-ui-control","interact with Compose Desktop applications","Control a running Compose Desktop application via HTTP. Use when you need to interact with UI elements, click buttons, enter text, wait for elements to appear, or capture screenshots in a Compose Desktop app that has compose-ui-test-server enabled.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1418,1421,1424],{"name":1419,"slug":1420,"type":15},"Automation","automation",{"name":1422,"slug":1423,"type":15},"Desktop","desktop",{"name":1425,"slug":1426,"type":15},"UI Components","ui-components","2026-07-13T06:40:38.798626",128,{"items":1430,"total":1555},[1431,1447,1456,1465,1476,1486,1495,1504,1513,1523,1532,1545],{"slug":1432,"name":1432,"fn":1433,"description":1434,"org":1435,"tags":1436,"stars":1444,"repoUrl":1445,"updatedAt":1446},"mps-aspect-accessories","configure JetBrains MPS module dependencies","Wire MPS module and model dependencies, used languages, used devkits, extended languages, runtime solutions, accessory models, and language\u002Fdependency versions. Use when adding\u002Fremoving module dependencies, importing languages or devkits into a model, declaring runtime solutions, or shipping accessory content visible to consumers without explicit import.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1437,1440,1443],{"name":1438,"slug":1439,"type":15},"Architecture","architecture",{"name":1441,"slug":1442,"type":15},"Configuration","configuration",{"name":1338,"slug":1339,"type":15},1650,"https:\u002F\u002Fgithub.com\u002FJetBrains\u002FMPS","2026-07-17T06:06:57.311661",{"slug":1448,"name":1448,"fn":1449,"description":1450,"org":1451,"tags":1452,"stars":1444,"repoUrl":1445,"updatedAt":1455},"mps-aspect-actions","define and edit MPS node factories","Use when defining or editing MPS node factories (the \"actions\" aspect) — `NodeFactories` roots, per-concept `NodeFactory` setup functions that initialize a freshly created node and optionally copy data from a replaced `sampleNode`, plus the actions aspect's `CopyPasteHandlers` and `PasteWrappers` roots. Reach for this skill when a substitution, side transform, completion replacement, or `add new initialized(...)` should preserve fields from the node it is replacing, or when defaults set in a constructor are not enough.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1453,1454],{"name":1438,"slug":1439,"type":15},{"name":1338,"slug":1339,"type":15},"2026-07-17T06:04:48.066901",{"slug":1457,"name":1457,"fn":1458,"description":1459,"org":1460,"tags":1461,"stars":1444,"repoUrl":1445,"updatedAt":1464},"mps-aspect-behavior","define and edit MPS concept behavior","Use when defining or editing MPS `ConceptBehavior` — per-concept methods (non-virtual \u002F virtual \u002F abstract \u002F static \u002F virtual static), constructors, virtual dispatch (MRO), super and interface-default calls (`super\u003CInterface>.method`), overriding methods from `lang.core.behavior` interfaces such as `ScopeProvider.getScope` \u002F `INamedConcept.getName` \u002F `BaseConcept.getPresentation`, calling sibling methods (`LocalBehaviorMethodCall`) and behavior methods from other aspects via `node.method(...)`. Reach for this skill whenever the task involves authoring or modifying `\u003Clang>\u002FlanguageModels\u002Fbehavior.mps`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1462,1463],{"name":1438,"slug":1439,"type":15},{"name":1338,"slug":1339,"type":15},"2026-07-13T06:45:21.757084",{"slug":1466,"name":1466,"fn":1467,"description":1468,"org":1469,"tags":1470,"stars":1444,"repoUrl":1445,"updatedAt":1475},"mps-aspect-constraints","define JetBrains MPS language constraints","Use when defining or editing MPS language constraints — property validators \u002F setters \u002F getters, referent search scopes (imperative or inherited via `ScopeProvider.getScope`), `referentSetHandler` side effects, default-scope blocks, `canBeChild` \u002F `canBeParent` \u002F `canBeAncestor` \u002F `canBeRoot` placement rules, `defaultConcreteConcept` for abstract concepts, `set \u003Cread-only>` and `{name}` aliasing, and scope helpers (`SimpleRoleScope`, `ListScope`, `CompositeScope`, `HidingByNameScope`). Reach for this skill whenever the task involves authoring or modifying `\u003Clang>\u002FlanguageModels\u002Fconstraints.mps`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1471,1472],{"name":1438,"slug":1439,"type":15},{"name":1473,"slug":1474,"type":15},"Code Analysis","code-analysis","2026-07-23T05:41:33.639365",{"slug":1477,"name":1477,"fn":1478,"description":1479,"org":1480,"tags":1481,"stars":1444,"repoUrl":1445,"updatedAt":1485},"mps-aspect-dataflow","define and debug MPS dataflow builders","Use when defining or debugging MPS dataflow builders for a concept — control\u002Fdata flow declarations that drive reachability analysis and variable-use checking. Covers DataFlowBuilderDeclaration, BuilderBlock, emit instructions (code for, jump, ifjump, label, read, write, ret, mayBeUnreachable), positions (AfterPosition, BeforePosition, LabelPosition), the jetbrains.mps.lang.dataFlow language, the NodeParameter implicit, BL+smodel usage inside builder bodies, and IBuilderMode for advanced analyses such as nullable\u002Fnon-null tracking.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1482],{"name":1483,"slug":1484,"type":15},"Data Analysis","data-analysis","2026-07-13T06:45:19.114674",{"slug":1487,"name":1487,"fn":1488,"description":1489,"org":1490,"tags":1491,"stars":1444,"repoUrl":1445,"updatedAt":1494},"mps-aspect-editor","define MPS editor layouts","Use when creating or changing MPS editor definitions — the overall workflow from scaffolding a `ConceptEditorDeclaration` through componentizing reusable `EditorComponentDeclaration`s, refining cell models and cell layouts, applying style sheets and indent-layout style items, wiring smart references, leveraging inheritance via super-concepts and interfaces, inspecting (`print_node_json`, `show_node_representation`) and validating (`check_root_node_problems`). Covers `jetbrains.mps.lang.editor` cell models (`CellModel_RefNode`\u002F`CellModel_RefNodeList`\u002F`CellModel_RefCell`\u002F`CellModel_Property`\u002F`CellModel_Constant`), layout choices, and JSON blueprints for common editor shapes. For the non-layout side (action maps, keymaps, transformation\u002Fsubstitute menus) use `mps-aspect-editor-menus-and-keymaps`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1492,1493],{"name":1355,"slug":1356,"type":15},{"name":1425,"slug":1426,"type":15},"2026-07-23T05:41:56.638151",{"slug":1496,"name":1496,"fn":1497,"description":1498,"org":1499,"tags":1500,"stars":1444,"repoUrl":1445,"updatedAt":1503},"mps-aspect-editor-menus-and-keymaps","author MPS editor menus and keymaps","Use when authoring the **non-layout** parts of the MPS editor aspect — what happens when the user types, presses a key, triggers completion, pastes, or invokes a context action. Covers action maps (`CellActionMapDeclaration`), cell keymaps (`CellKeyMapDeclaration`), transformation menus (`TransformationMenu_Default` \u002F `_Named` \u002F `_Contribution`), substitute menus (`SubstituteMenu_Default` \u002F `SubstituteMenu` \u002F contributions), side transforms (LEFT\u002FRIGHT), legacy cell menus, paste wrappers and copy-paste handlers (in the actions language), completion styling, reference presentation, two-step deletion, and the editor selection API. Trigger terms: `actionMap`, `keyMap`, `delete_action_id`, `transformationMenu`, `substituteMenu`, `Ctrl+Space`, `Ctrl+Alt+B`, side transform, paste wrapper, completion styling, `PasteWrappers`, `CopyPasteHandlers`. For the **layout** side (cells, layouts, style sheets) use `mps-aspect-editor` instead.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1501,1502],{"name":1338,"slug":1339,"type":15},{"name":1425,"slug":1426,"type":15},"2026-07-23T05:41:49.666535",{"slug":1505,"name":1505,"fn":1506,"description":1507,"org":1508,"tags":1509,"stars":1444,"repoUrl":1445,"updatedAt":1512},"mps-aspect-generation-plan","modify MPS generation plans","Use when defining or modifying an MPS generation plan — explicit ordering of generators, checkpoints for cross-model reference resolution, forks for parallel branches, IncludePlan composition, conditional PlanContribution activation, ParameterEquals\u002FConceptListSelector fork selectors, and InitModelAttributes for targetFacet routing. Apply when working with @genplan models, the jetbrains.mps.lang.generator.plan language, attaching plans via DevKits or the Custom generation facet, or debugging cross-model mapping label resolution.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1510,1511],{"name":1438,"slug":1439,"type":15},{"name":1338,"slug":1339,"type":15},"2026-07-13T06:44:59.507855",{"slug":1514,"name":1514,"fn":1515,"description":1516,"org":1517,"tags":1518,"stars":1444,"repoUrl":1445,"updatedAt":1522},"mps-aspect-generator","define JetBrains MPS generator rules","Use when defining or modifying MPS generators — author a generator module, add or edit root\u002Freduction\u002Fweaving\u002Fpattern mapping rules, attach template macros ($COPY_SRC, $LOOP, $IF, $PROPERTY, $REF, $SWITCH, $MAP_SRC, $WEAVE, $INSERT, $LABEL, $TRACE, $VAR), wire mapping labels, build template switches, write pre\u002Fpost mapping scripts, navigate `genContext`, or debug \"rule didn't fire\", missing references, empty output, infinite reduction loops, and generated-Java compile failures.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1519,1520,1521],{"name":1438,"slug":1439,"type":15},{"name":1473,"slug":1474,"type":15},{"name":1338,"slug":1339,"type":15},"2026-07-17T06:06:58.042999",{"slug":1524,"name":1524,"fn":1525,"description":1526,"org":1527,"tags":1528,"stars":1444,"repoUrl":1445,"updatedAt":1531},"mps-aspect-intentions","define and edit MPS intentions","Use when defining or editing MPS intentions (the Alt+Enter context-action aspect) — adding `IntentionDeclaration` roots, parameterized or surround-with variants, description\u002FisApplicable\u002Fexecute blocks, child-filter functions, factory-initialized AST splicing, or debugging why an intention is not offered. Lives in the language's `intentions` model and uses `jetbrains.mps.lang.intentions`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1529,1530],{"name":1438,"slug":1439,"type":15},{"name":1338,"slug":1339,"type":15},"2026-07-23T05:41:48.692899",{"slug":1533,"name":1533,"fn":1534,"description":1535,"org":1536,"tags":1537,"stars":1444,"repoUrl":1445,"updatedAt":1544},"mps-aspect-migrations","author and debug MPS migration scripts","Use when authoring or debugging MPS migration scripts that upgrade user models after a language definition changes — covers jetbrains.mps.lang.migration (MigrationScript class-based, PureMigrationScript declarative, MoveConcept\u002FMoveContainmentLink\u002FMoveReferenceLink\u002FMoveProperty, ordering via OrderDependency, data exchange via putData\u002FgetData, RefactoringLog, ConceptMigrationReference) and jetbrains.mps.lang.script Enhancement Scripts (MigrationScript with MigrationScriptPart_Instance, ExtractInterfaceMigration, FactoryMigrationScriptPart, CommentMigrationScriptPart) — when a model needs version-gated upgrade, concept rename or removal, link or property rename, instance-level transformation, or composition of migration steps.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1538,1541],{"name":1539,"slug":1540,"type":15},"Debugging","debugging",{"name":1542,"slug":1543,"type":15},"Migration","migration","2026-07-13T06:45:20.372122",{"slug":1546,"name":1546,"fn":1547,"description":1548,"org":1549,"tags":1550,"stars":1444,"repoUrl":1445,"updatedAt":1554},"mps-aspect-structure-concepts","define concepts in MPS structure aspect","Define concepts, interface concepts, enumerations, and constrained data types in an MPS language's `structure` aspect. Covers smart-reference detection, alias rules, cardinality, INamedConcept usage, bulk creation, and the full `mps_mcp_alter_structure` \u002F `mps_mcp_query_structure` reference. Use when authoring or modifying a language's structure model.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[1551],{"name":1552,"slug":1553,"type":15},"Data Modeling","data-modeling","2026-07-23T05:41:30.705975",188]