[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M722YXEYDTR1QGVMVHC9TKZQ":3,"skill-same:01M722YXEYDTR1QGVMVHC9TKZQ":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":65,"commitSha":66,"skillDirectory":67,"forksCount":14,"repositoryHtmlUrl":68,"repositoryHomepageUrl":69,"ownerHtmlUrl":70,"ownerBlogUrl":71,"ownerDescription":72,"updatedAt":73,"install":74,"resources":86},"01M722YXEYDTR1QGVMVHC9TKZQ","spring-boot-feature",null,"Guides the creation of complete Spring Boot features following a structured, layer-by-layer workflow: entity, repository, service, controller, and tests. Applies Kotlin idioms, Bean Validation, and MockK test patterns throughout.","lgzarturo\u002Fcodeconductor","lgzarturo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128883?v=4","01M720TSS2BWM10Y93J765VZ8E","algforge","01M720TSSPQ1K51R83213SN6NZ",0,"MIT","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Fspring-boot-feature\u002FSKILL.md",[],[],"2026-11-10 18:39:20",false,"---\nid: spring-boot-feature\nname: spring-boot-feature\ndescription: >\n  Guides the creation of complete Spring Boot features following a structured,\n  layer-by-layer workflow: entity, repository, service, controller, and tests.\n  Applies Kotlin idioms, Bean Validation, and MockK test patterns throughout.\n\nuser-invokable: true\nlicense: MIT\nmetadata:\n  author: lgzarturo\n  category: spring\n\ncompatibility:\n  tools: [claude, codex, gemini, agy, opencode]\n  stacks:\n    languages: [kotlin]\n    frameworks: [spring-boot, spring-mvc, spring-data-jpa, mockk, junit5]\n    databases: [postgresql, h2]\n\nrisk:\n  level: medium\n  can_execute_shell: false\n  can_modify_files: true\n  requires_network: false\n\ninputs:\n  - feature description\n  - existing domain context (if any)\n  - build.gradle.kts\n  - application.yml\n\noutputs:\n  - domain entity\n  - JPA repository interface\n  - service class with business logic\n  - REST controller with validations\n  - request\u002Fresponse DTOs\n  - unit tests (MockK)\n  - controller integration tests (MockMvc)\n\nquality:\n  reviewed_by: codeconductor-core\n  version: 0.1.0\n---\n\n# Spring Boot Feature Creation\n\nWhen asked to create a feature, follow these steps **in order**. Do not skip\nsteps or combine layers. Each layer has a single responsibility.\n\n**When to ask questions:** Only ask when there is genuine ambiguity in business\nlogic — for example, what happens when a duplicate is found, or whether soft\ndelete is required. Do not ask about technical choices (naming, package\nstructure, framework configuration) — apply the conventions in this skill.\n\n---\n\n## Step 1 — Entity + Repository\n\nCreate the JPA entity and its repository before any other layer.\n\n### Entity\n\n```kotlin\n@Entity\n@Table(\n    name = \"orders\",\n    indexes = [Index(columnList = \"customer_id\")]\n)\nclass Order(\n    @Id\n    @GeneratedValue(strategy = GenerationType.UUID)\n    val id: UUID = UUID.randomUUID(),\n\n    @Column(name = \"customer_id\", nullable = false)\n    val customerId: UUID,\n\n    @Column(name = \"status\", nullable = false)\n    @Enumerated(EnumType.STRING)\n    var status: OrderStatus = OrderStatus.PENDING,\n\n    @Column(name = \"total_amount\", nullable = false)\n    var totalAmount: BigDecimal,\n\n    @Column(name = \"created_at\", nullable = false, updatable = false)\n    @CreatedDate\n    val createdAt: Instant = Instant.now(),\n\n    @Column(name = \"updated_at\", nullable = false)\n    @LastModifiedDate\n    var updatedAt: Instant = Instant.now()\n)\n\nenum class OrderStatus { PENDING, CONFIRMED, CANCELLED }\n```\n\nRules:\n\n- `@Table` with explicit `name` — never rely on inferred table names\n- `@Column(nullable = false)` always explicit for non-nullable fields\n- UUID primary keys with `GenerationType.UUID`\n- Enums stored as `STRING`, not `ORDINAL`\n- Include `createdAt` and `updatedAt` on every entity\n- Never use `data class` for JPA entities — Hibernate requires a no-arg\n  constructor and mutable state; use `class`\n- `equals`\u002F`hashCode` based on `id` only, or omit (reference equality is safe\n  for JPA entities when managed by the same `EntityManager`)\n\n### Repository\n\n```kotlin\n@Repository\ninterface OrderRepository : JpaRepository\u003COrder, UUID> {\n    fun findByCustomerId(customerId: UUID): List\u003COrder>\n    fun findByCustomerIdAndStatus(customerId: UUID, status: OrderStatus): List\u003COrder>\n    fun existsByCustomerIdAndStatus(customerId: UUID, status: OrderStatus): Boolean\n\n    @Query(\"SELECT o FROM Order o WHERE o.status = :status AND o.createdAt \u003C :before\")\n    fun findExpiredPending(\n        @Param(\"status\") status: OrderStatus,\n        @Param(\"before\") before: Instant\n    ): List\u003COrder>\n}\n```\n\nRules:\n\n- Extend `JpaRepository\u003CEntity, IdType>`\n- Use derived query method names for simple conditions\n- Use `@Query` with JPQL for joins, multi-condition queries, or aggregations\n- Use native SQL only when JPQL cannot express it — add `nativeQuery = true`\n- Never add `@Transactional` to repository methods — Spring Data handles it\n\n---\n\n## Step 2 — Service\n\nThe service is the single owner of all business logic. No logic in controllers,\nno logic in repositories.\n\n```kotlin\n@Service\n@Transactional\nclass OrderService(\n    private val orderRepository: OrderRepository,\n    private val customerRepository: CustomerRepository\n) {\n\n    @Transactional(readOnly = true)\n    fun getById(id: UUID): Order =\n        orderRepository.findById(id).orElseThrow { OrderNotFoundException(id) }\n\n    @Transactional(readOnly = true)\n    fun listByCustomer(customerId: UUID): List\u003COrder> =\n        orderRepository.findByCustomerId(customerId)\n\n    fun create(customerId: UUID, request: CreateOrderRequest): Order {\n        if (!customerRepository.existsById(customerId)) {\n            throw CustomerNotFoundException(customerId)\n        }\n        val order = Order(\n            customerId = customerId,\n            totalAmount = request.totalAmount\n        )\n        return orderRepository.save(order)\n    }\n\n    fun cancel(id: UUID): Order {\n        val order = getById(id)\n        if (order.status == OrderStatus.CANCELLED) {\n            throw OrderAlreadyCancelledException(id)\n        }\n        order.status = OrderStatus.CANCELLED\n        return orderRepository.save(order)\n    }\n}\n```\n\nRules:\n\n- `@Transactional` at class level — applies to all public methods\n- `readOnly = true` on read-only methods — prevents dirty checking, faster\n- Never put `@Transactional` on private methods — Spring proxies cannot\n  intercept them\n- Throw typed domain exceptions — never `RuntimeException` or `Exception`\n  directly\n- Never inject repositories into controllers — only services cross that boundary\n\n### Domain Exceptions\n\nDefine typed exceptions per feature:\n\n```kotlin\nclass OrderNotFoundException(id: UUID) :\n    RuntimeException(\"Order not found: $id\")\n\nclass OrderAlreadyCancelledException(id: UUID) :\n    RuntimeException(\"Order already cancelled: $id\")\n\nclass CustomerNotFoundException(id: UUID) :\n    RuntimeException(\"Customer not found: $id\")\n```\n\n---\n\n## Step 3 — Controller + DTOs\n\nThe controller translates HTTP into service calls. No business logic here.\n\n### DTOs\n\nDefine request and response data classes with Bean Validation annotations:\n\n```kotlin\ndata class CreateOrderRequest(\n    @field:NotNull(message = \"totalAmount is required\")\n    @field:DecimalMin(value = \"0.01\", message = \"totalAmount must be greater than zero\")\n    val totalAmount: BigDecimal\n)\n\ndata class OrderResponse(\n    val id: UUID,\n    val customerId: UUID,\n    val status: String,\n    val totalAmount: BigDecimal,\n    val createdAt: Instant\n)\n\nfun Order.toResponse(): OrderResponse = OrderResponse(\n    id = id,\n    customerId = customerId,\n    status = status.name,\n    totalAmount = totalAmount,\n    createdAt = createdAt\n)\n```\n\nRules for DTOs:\n\n- Use `data class` — immutable, no `@Entity`\n- Use `@field:` prefix on validation annotations — Kotlin applies annotations to\n  the property by default, not the backing field; Spring reads the field\n- Define a `toResponse()` extension function on the entity — do not expose\n  entities directly in responses\n- Never return `@Entity` from a controller method\n\n### Controller\n\n```kotlin\n@RestController\n@RequestMapping(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F{customerId}\u002Forders\")\nclass OrderController(private val orderService: OrderService) {\n\n    @GetMapping\n    fun list(@PathVariable customerId: UUID): ResponseEntity\u003CList\u003COrderResponse>> =\n        ResponseEntity.ok(orderService.listByCustomer(customerId).map { it.toResponse() })\n\n    @GetMapping(\"\u002F{id}\")\n    fun get(\n        @PathVariable customerId: UUID,\n        @PathVariable id: UUID\n    ): ResponseEntity\u003COrderResponse> =\n        ResponseEntity.ok(orderService.getById(id).toResponse())\n\n    @PostMapping\n    fun create(\n        @PathVariable customerId: UUID,\n        @Valid @RequestBody request: CreateOrderRequest\n    ): ResponseEntity\u003COrderResponse> {\n        val order = orderService.create(customerId, request)\n        return ResponseEntity.status(HttpStatus.CREATED).body(order.toResponse())\n    }\n\n    @DeleteMapping(\"\u002F{id}\u002Fcancel\")\n    fun cancel(\n        @PathVariable customerId: UUID,\n        @PathVariable id: UUID\n    ): ResponseEntity\u003COrderResponse> =\n        ResponseEntity.ok(orderService.cancel(id).toResponse())\n}\n```\n\nRules:\n\n- One controller per feature\n- `@Valid` on every `@RequestBody` parameter\n- Return `ResponseEntity\u003CT>` — explicit HTTP status control\n- No try\u002Fcatch in controllers — use `GlobalExceptionHandler`\n- Map entities to DTOs before returning — never return the entity itself\n\n### Global Exception Handler\n\nAdd new exception mappings to the existing `GlobalExceptionHandler`. Do not\ncreate a second one.\n\n```kotlin\n@ControllerAdvice\nclass GlobalExceptionHandler {\n\n    @ExceptionHandler(OrderNotFoundException::class)\n    fun handleOrderNotFound(ex: OrderNotFoundException): ResponseEntity\u003CErrorResponse> =\n        ResponseEntity.status(HttpStatus.NOT_FOUND)\n            .body(ErrorResponse(error = ex.message ?: \"Order not found\", code = \"ORDER_NOT_FOUND\"))\n\n    @ExceptionHandler(OrderAlreadyCancelledException::class)\n    fun handleAlreadyCancelled(ex: OrderAlreadyCancelledException): ResponseEntity\u003CErrorResponse> =\n        ResponseEntity.status(HttpStatus.CONFLICT)\n            .body(ErrorResponse(error = ex.message ?: \"Order already cancelled\", code = \"ORDER_ALREADY_CANCELLED\"))\n\n    @ExceptionHandler(MethodArgumentNotValidException::class)\n    fun handleValidation(ex: MethodArgumentNotValidException): ResponseEntity\u003CErrorResponse> {\n        val message = ex.bindingResult.fieldErrors\n            .joinToString(\", \") { \"${it.field}: ${it.defaultMessage}\" }\n        return ResponseEntity.badRequest()\n            .body(ErrorResponse(error = message, code = \"VALIDATION_ERROR\"))\n    }\n}\n\ndata class ErrorResponse(val error: String, val code: String)\n```\n\n---\n\n## Step 4 — Tests with MockK\n\nWrite three test classes per feature: unit tests for the service, controller\ntests with MockMvc, and repository tests with `@DataJpaTest`.\n\n### Service Unit Tests (MockK)\n\n```kotlin\n@ExtendWith(MockKExtension::class)\nclass OrderServiceTest {\n\n    @MockK\n    private lateinit var orderRepository: OrderRepository\n\n    @MockK\n    private lateinit var customerRepository: CustomerRepository\n\n    private lateinit var orderService: OrderService\n\n    @BeforeEach\n    fun setUp() {\n        orderService = OrderService(orderRepository, customerRepository)\n    }\n\n    @Nested\n    inner class Create {\n\n        @Test\n        fun `should create order when customer exists`() {\n            \u002F\u002F Arrange\n            val customerId = UUID.randomUUID()\n            val request = CreateOrderRequest(totalAmount = BigDecimal(\"99.99\"))\n            val savedOrder = Order(customerId = customerId, totalAmount = request.totalAmount)\n            every { customerRepository.existsById(customerId) } returns true\n            every { orderRepository.save(any()) } returns savedOrder\n\n            \u002F\u002F Act\n            val result = orderService.create(customerId, request)\n\n            \u002F\u002F Assert\n            assertThat(result.customerId).isEqualTo(customerId)\n            assertThat(result.totalAmount).isEqualByComparingTo(BigDecimal(\"99.99\"))\n            verify(exactly = 1) { orderRepository.save(any()) }\n        }\n\n        @Test\n        fun `should throw CustomerNotFoundException when customer does not exist`() {\n            \u002F\u002F Arrange\n            val customerId = UUID.randomUUID()\n            every { customerRepository.existsById(customerId) } returns false\n\n            \u002F\u002F Act + Assert\n            assertThrows\u003CCustomerNotFoundException> {\n                orderService.create(customerId, CreateOrderRequest(totalAmount = BigDecimal(\"10.00\")))\n            }\n            verify(exactly = 0) { orderRepository.save(any()) }\n        }\n    }\n\n    @Nested\n    inner class Cancel {\n\n        @Test\n        fun `should cancel order when status is PENDING`() {\n            \u002F\u002F Arrange\n            val order = Order(customerId = UUID.randomUUID(), totalAmount = BigDecimal(\"50.00\"))\n            every { orderRepository.findById(order.id) } returns Optional.of(order)\n            every { orderRepository.save(any()) } answers { firstArg() }\n\n            \u002F\u002F Act\n            val result = orderService.cancel(order.id)\n\n            \u002F\u002F Assert\n            assertThat(result.status).isEqualTo(OrderStatus.CANCELLED)\n        }\n\n        @Test\n        fun `should throw OrderAlreadyCancelledException when order is already cancelled`() {\n            \u002F\u002F Arrange\n            val order = Order(\n                customerId = UUID.randomUUID(),\n                totalAmount = BigDecimal(\"50.00\"),\n                status = OrderStatus.CANCELLED\n            )\n            every { orderRepository.findById(order.id) } returns Optional.of(order)\n\n            \u002F\u002F Act + Assert\n            assertThrows\u003COrderAlreadyCancelledException> {\n                orderService.cancel(order.id)\n            }\n        }\n    }\n}\n```\n\n### Controller Tests (MockMvc)\n\n```kotlin\n@SpringBootTest\n@AutoConfigureMockMvc\nclass OrderControllerTest {\n\n    @Autowired\n    private lateinit var mockMvc: MockMvc\n\n    @Autowired\n    private lateinit var objectMapper: ObjectMapper\n\n    @MockkBean\n    private lateinit var orderService: OrderService\n\n    @Test\n    fun `should return 201 and created order when request is valid`() {\n        \u002F\u002F Arrange\n        val customerId = UUID.randomUUID()\n        val order = Order(customerId = customerId, totalAmount = BigDecimal(\"99.99\"))\n        every { orderService.create(customerId, any()) } returns order\n\n        val body = mapOf(\"totalAmount\" to \"99.99\")\n\n        \u002F\u002F Act + Assert\n        mockMvc.perform(\n            post(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F$customerId\u002Forders\")\n                .contentType(MediaType.APPLICATION_JSON)\n                .content(objectMapper.writeValueAsString(body))\n        )\n            .andExpect(status().isCreated)\n            .andExpect(jsonPath(\"$.customerId\").value(customerId.toString()))\n            .andExpect(jsonPath(\"$.status\").value(\"PENDING\"))\n    }\n\n    @Test\n    fun `should return 400 when totalAmount is missing`() {\n        mockMvc.perform(\n            post(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F${UUID.randomUUID()}\u002Forders\")\n                .contentType(MediaType.APPLICATION_JSON)\n                .content(\"{}\")\n        )\n            .andExpect(status().isBadRequest)\n            .andExpect(jsonPath(\"$.code\").value(\"VALIDATION_ERROR\"))\n    }\n\n    @Test\n    fun `should return 404 when order is not found`() {\n        val customerId = UUID.randomUUID()\n        val orderId = UUID.randomUUID()\n        every { orderService.getById(orderId) } throws OrderNotFoundException(orderId)\n\n        mockMvc.perform(get(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F$customerId\u002Forders\u002F$orderId\"))\n            .andExpect(status().isNotFound)\n            .andExpect(jsonPath(\"$.code\").value(\"ORDER_NOT_FOUND\"))\n    }\n}\n```\n\n### Repository Tests\n\n```kotlin\n@DataJpaTest\nclass OrderRepositoryTest {\n\n    @Autowired\n    private lateinit var orderRepository: OrderRepository\n\n    @Test\n    fun `should find orders by customer id`() {\n        \u002F\u002F Arrange\n        val customerId = UUID.randomUUID()\n        orderRepository.save(Order(customerId = customerId, totalAmount = BigDecimal(\"10.00\")))\n        orderRepository.save(Order(customerId = UUID.randomUUID(), totalAmount = BigDecimal(\"20.00\")))\n\n        \u002F\u002F Act\n        val result = orderRepository.findByCustomerId(customerId)\n\n        \u002F\u002F Assert\n        assertThat(result).hasSize(1)\n        assertThat(result.first().customerId).isEqualTo(customerId)\n    }\n}\n```\n\nMockK rules:\n\n- Use `@ExtendWith(MockKExtension::class)` — not `@MockBean` for unit tests\n- Use `@MockkBean` (MockK Spring integration) only in `@SpringBootTest` context\n- `every { }` for stubbing, `verify { }` for verification\n- `answers { firstArg() }` to return the argument passed to `save()`\n- `verify(exactly = 0) { }` to assert a method was never called\n- Never use `relaxed = true` unless you genuinely do not care about any return\n  value\n- Test names: `should [expected outcome] when [condition]`\n- Test structure: Arrange \u002F Act \u002F Assert, separated by blank lines\n\n---\n\n## Step 5 — When to Ask\n\nOnly pause to ask when there is genuine ambiguity in business logic. Do not ask\nabout technical choices — apply the conventions in this skill.\n\n**Ask when:**\n\n- The feature description does not specify what happens on conflict (duplicate,\n  constraint violation, concurrent modification)\n- It is unclear whether delete means hard delete or soft delete\n- Authorization rules are not specified and cannot be inferred from context\n- A domain invariant is referenced but not defined (e.g., \"validate the order\"\n  without specifying which fields or rules)\n\n**Do not ask about:**\n\n- Package structure — always feature-oriented MVC\n- Naming conventions — follow the existing codebase\n- Whether to use MockK or Mockito — always MockK\n- Whether to add `@Transactional` — always at the service class level\n- Whether to validate at controller or service — always at DTO layer\n\n---\n\n## Package Structure\n\nAlways feature-oriented. One package per feature, not one package per layer.\n\n```\nsrc\u002Fmain\u002Fkotlin\u002F{base-package}\u002F{feature}\u002F\n  controller\u002F     # HTTP only — OrderController, DTOs, toResponse() extensions\n  service\u002F        # Business logic — OrderService, domain exceptions\n  repository\u002F     # Data access — OrderRepository\n  domain\u002F         # JPA entities — Order, OrderStatus\n\nsrc\u002Ftest\u002Fkotlin\u002F{base-package}\u002F{feature}\u002F\n  controller\u002F     # OrderControllerTest (MockMvc)\n  service\u002F        # OrderServiceTest (MockK)\n  repository\u002F     # OrderRepositoryTest (@DataJpaTest)\n```\n\nNever create `src\u002Fmain\u002Fkotlin\u002Fcontrollers\u002F`, `src\u002Fmain\u002Fkotlin\u002Fservices\u002F`, etc.\nLayer-first structure does not scale and breaks feature cohesion.\n","# Spring Boot Feature Creation\n\nWhen asked to create a feature, follow these steps **in order**. Do not skip\nsteps or combine layers. Each layer has a single responsibility.\n\n**When to ask questions:** Only ask when there is genuine ambiguity in business\nlogic — for example, what happens when a duplicate is found, or whether soft\ndelete is required. Do not ask about technical choices (naming, package\nstructure, framework configuration) — apply the conventions in this skill.\n\n---\n\n## Step 1 — Entity + Repository\n\nCreate the JPA entity and its repository before any other layer.\n\n### Entity\n\n```kotlin\n@Entity\n@Table(\n    name = \"orders\",\n    indexes = [Index(columnList = \"customer_id\")]\n)\nclass Order(\n    @Id\n    @GeneratedValue(strategy = GenerationType.UUID)\n    val id: UUID = UUID.randomUUID(),\n\n    @Column(name = \"customer_id\", nullable = false)\n    val customerId: UUID,\n\n    @Column(name = \"status\", nullable = false)\n    @Enumerated(EnumType.STRING)\n    var status: OrderStatus = OrderStatus.PENDING,\n\n    @Column(name = \"total_amount\", nullable = false)\n    var totalAmount: BigDecimal,\n\n    @Column(name = \"created_at\", nullable = false, updatable = false)\n    @CreatedDate\n    val createdAt: Instant = Instant.now(),\n\n    @Column(name = \"updated_at\", nullable = false)\n    @LastModifiedDate\n    var updatedAt: Instant = Instant.now()\n)\n\nenum class OrderStatus { PENDING, CONFIRMED, CANCELLED }\n```\n\nRules:\n\n- `@Table` with explicit `name` — never rely on inferred table names\n- `@Column(nullable = false)` always explicit for non-nullable fields\n- UUID primary keys with `GenerationType.UUID`\n- Enums stored as `STRING`, not `ORDINAL`\n- Include `createdAt` and `updatedAt` on every entity\n- Never use `data class` for JPA entities — Hibernate requires a no-arg\n  constructor and mutable state; use `class`\n- `equals`\u002F`hashCode` based on `id` only, or omit (reference equality is safe\n  for JPA entities when managed by the same `EntityManager`)\n\n### Repository\n\n```kotlin\n@Repository\ninterface OrderRepository : JpaRepository\u003COrder, UUID> {\n    fun findByCustomerId(customerId: UUID): List\u003COrder>\n    fun findByCustomerIdAndStatus(customerId: UUID, status: OrderStatus): List\u003COrder>\n    fun existsByCustomerIdAndStatus(customerId: UUID, status: OrderStatus): Boolean\n\n    @Query(\"SELECT o FROM Order o WHERE o.status = :status AND o.createdAt \u003C :before\")\n    fun findExpiredPending(\n        @Param(\"status\") status: OrderStatus,\n        @Param(\"before\") before: Instant\n    ): List\u003COrder>\n}\n```\n\nRules:\n\n- Extend `JpaRepository\u003CEntity, IdType>`\n- Use derived query method names for simple conditions\n- Use `@Query` with JPQL for joins, multi-condition queries, or aggregations\n- Use native SQL only when JPQL cannot express it — add `nativeQuery = true`\n- Never add `@Transactional` to repository methods — Spring Data handles it\n\n---\n\n## Step 2 — Service\n\nThe service is the single owner of all business logic. No logic in controllers,\nno logic in repositories.\n\n```kotlin\n@Service\n@Transactional\nclass OrderService(\n    private val orderRepository: OrderRepository,\n    private val customerRepository: CustomerRepository\n) {\n\n    @Transactional(readOnly = true)\n    fun getById(id: UUID): Order =\n        orderRepository.findById(id).orElseThrow { OrderNotFoundException(id) }\n\n    @Transactional(readOnly = true)\n    fun listByCustomer(customerId: UUID): List\u003COrder> =\n        orderRepository.findByCustomerId(customerId)\n\n    fun create(customerId: UUID, request: CreateOrderRequest): Order {\n        if (!customerRepository.existsById(customerId)) {\n            throw CustomerNotFoundException(customerId)\n        }\n        val order = Order(\n            customerId = customerId,\n            totalAmount = request.totalAmount\n        )\n        return orderRepository.save(order)\n    }\n\n    fun cancel(id: UUID): Order {\n        val order = getById(id)\n        if (order.status == OrderStatus.CANCELLED) {\n            throw OrderAlreadyCancelledException(id)\n        }\n        order.status = OrderStatus.CANCELLED\n        return orderRepository.save(order)\n    }\n}\n```\n\nRules:\n\n- `@Transactional` at class level — applies to all public methods\n- `readOnly = true` on read-only methods — prevents dirty checking, faster\n- Never put `@Transactional` on private methods — Spring proxies cannot\n  intercept them\n- Throw typed domain exceptions — never `RuntimeException` or `Exception`\n  directly\n- Never inject repositories into controllers — only services cross that boundary\n\n### Domain Exceptions\n\nDefine typed exceptions per feature:\n\n```kotlin\nclass OrderNotFoundException(id: UUID) :\n    RuntimeException(\"Order not found: $id\")\n\nclass OrderAlreadyCancelledException(id: UUID) :\n    RuntimeException(\"Order already cancelled: $id\")\n\nclass CustomerNotFoundException(id: UUID) :\n    RuntimeException(\"Customer not found: $id\")\n```\n\n---\n\n## Step 3 — Controller + DTOs\n\nThe controller translates HTTP into service calls. No business logic here.\n\n### DTOs\n\nDefine request and response data classes with Bean Validation annotations:\n\n```kotlin\ndata class CreateOrderRequest(\n    @field:NotNull(message = \"totalAmount is required\")\n    @field:DecimalMin(value = \"0.01\", message = \"totalAmount must be greater than zero\")\n    val totalAmount: BigDecimal\n)\n\ndata class OrderResponse(\n    val id: UUID,\n    val customerId: UUID,\n    val status: String,\n    val totalAmount: BigDecimal,\n    val createdAt: Instant\n)\n\nfun Order.toResponse(): OrderResponse = OrderResponse(\n    id = id,\n    customerId = customerId,\n    status = status.name,\n    totalAmount = totalAmount,\n    createdAt = createdAt\n)\n```\n\nRules for DTOs:\n\n- Use `data class` — immutable, no `@Entity`\n- Use `@field:` prefix on validation annotations — Kotlin applies annotations to\n  the property by default, not the backing field; Spring reads the field\n- Define a `toResponse()` extension function on the entity — do not expose\n  entities directly in responses\n- Never return `@Entity` from a controller method\n\n### Controller\n\n```kotlin\n@RestController\n@RequestMapping(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F{customerId}\u002Forders\")\nclass OrderController(private val orderService: OrderService) {\n\n    @GetMapping\n    fun list(@PathVariable customerId: UUID): ResponseEntity\u003CList\u003COrderResponse>> =\n        ResponseEntity.ok(orderService.listByCustomer(customerId).map { it.toResponse() })\n\n    @GetMapping(\"\u002F{id}\")\n    fun get(\n        @PathVariable customerId: UUID,\n        @PathVariable id: UUID\n    ): ResponseEntity\u003COrderResponse> =\n        ResponseEntity.ok(orderService.getById(id).toResponse())\n\n    @PostMapping\n    fun create(\n        @PathVariable customerId: UUID,\n        @Valid @RequestBody request: CreateOrderRequest\n    ): ResponseEntity\u003COrderResponse> {\n        val order = orderService.create(customerId, request)\n        return ResponseEntity.status(HttpStatus.CREATED).body(order.toResponse())\n    }\n\n    @DeleteMapping(\"\u002F{id}\u002Fcancel\")\n    fun cancel(\n        @PathVariable customerId: UUID,\n        @PathVariable id: UUID\n    ): ResponseEntity\u003COrderResponse> =\n        ResponseEntity.ok(orderService.cancel(id).toResponse())\n}\n```\n\nRules:\n\n- One controller per feature\n- `@Valid` on every `@RequestBody` parameter\n- Return `ResponseEntity\u003CT>` — explicit HTTP status control\n- No try\u002Fcatch in controllers — use `GlobalExceptionHandler`\n- Map entities to DTOs before returning — never return the entity itself\n\n### Global Exception Handler\n\nAdd new exception mappings to the existing `GlobalExceptionHandler`. Do not\ncreate a second one.\n\n```kotlin\n@ControllerAdvice\nclass GlobalExceptionHandler {\n\n    @ExceptionHandler(OrderNotFoundException::class)\n    fun handleOrderNotFound(ex: OrderNotFoundException): ResponseEntity\u003CErrorResponse> =\n        ResponseEntity.status(HttpStatus.NOT_FOUND)\n            .body(ErrorResponse(error = ex.message ?: \"Order not found\", code = \"ORDER_NOT_FOUND\"))\n\n    @ExceptionHandler(OrderAlreadyCancelledException::class)\n    fun handleAlreadyCancelled(ex: OrderAlreadyCancelledException): ResponseEntity\u003CErrorResponse> =\n        ResponseEntity.status(HttpStatus.CONFLICT)\n            .body(ErrorResponse(error = ex.message ?: \"Order already cancelled\", code = \"ORDER_ALREADY_CANCELLED\"))\n\n    @ExceptionHandler(MethodArgumentNotValidException::class)\n    fun handleValidation(ex: MethodArgumentNotValidException): ResponseEntity\u003CErrorResponse> {\n        val message = ex.bindingResult.fieldErrors\n            .joinToString(\", \") { \"${it.field}: ${it.defaultMessage}\" }\n        return ResponseEntity.badRequest()\n            .body(ErrorResponse(error = message, code = \"VALIDATION_ERROR\"))\n    }\n}\n\ndata class ErrorResponse(val error: String, val code: String)\n```\n\n---\n\n## Step 4 — Tests with MockK\n\nWrite three test classes per feature: unit tests for the service, controller\ntests with MockMvc, and repository tests with `@DataJpaTest`.\n\n### Service Unit Tests (MockK)\n\n```kotlin\n@ExtendWith(MockKExtension::class)\nclass OrderServiceTest {\n\n    @MockK\n    private lateinit var orderRepository: OrderRepository\n\n    @MockK\n    private lateinit var customerRepository: CustomerRepository\n\n    private lateinit var orderService: OrderService\n\n    @BeforeEach\n    fun setUp() {\n        orderService = OrderService(orderRepository, customerRepository)\n    }\n\n    @Nested\n    inner class Create {\n\n        @Test\n        fun `should create order when customer exists`() {\n            \u002F\u002F Arrange\n            val customerId = UUID.randomUUID()\n            val request = CreateOrderRequest(totalAmount = BigDecimal(\"99.99\"))\n            val savedOrder = Order(customerId = customerId, totalAmount = request.totalAmount)\n            every { customerRepository.existsById(customerId) } returns true\n            every { orderRepository.save(any()) } returns savedOrder\n\n            \u002F\u002F Act\n            val result = orderService.create(customerId, request)\n\n            \u002F\u002F Assert\n            assertThat(result.customerId).isEqualTo(customerId)\n            assertThat(result.totalAmount).isEqualByComparingTo(BigDecimal(\"99.99\"))\n            verify(exactly = 1) { orderRepository.save(any()) }\n        }\n\n        @Test\n        fun `should throw CustomerNotFoundException when customer does not exist`() {\n            \u002F\u002F Arrange\n            val customerId = UUID.randomUUID()\n            every { customerRepository.existsById(customerId) } returns false\n\n            \u002F\u002F Act + Assert\n            assertThrows\u003CCustomerNotFoundException> {\n                orderService.create(customerId, CreateOrderRequest(totalAmount = BigDecimal(\"10.00\")))\n            }\n            verify(exactly = 0) { orderRepository.save(any()) }\n        }\n    }\n\n    @Nested\n    inner class Cancel {\n\n        @Test\n        fun `should cancel order when status is PENDING`() {\n            \u002F\u002F Arrange\n            val order = Order(customerId = UUID.randomUUID(), totalAmount = BigDecimal(\"50.00\"))\n            every { orderRepository.findById(order.id) } returns Optional.of(order)\n            every { orderRepository.save(any()) } answers { firstArg() }\n\n            \u002F\u002F Act\n            val result = orderService.cancel(order.id)\n\n            \u002F\u002F Assert\n            assertThat(result.status).isEqualTo(OrderStatus.CANCELLED)\n        }\n\n        @Test\n        fun `should throw OrderAlreadyCancelledException when order is already cancelled`() {\n            \u002F\u002F Arrange\n            val order = Order(\n                customerId = UUID.randomUUID(),\n                totalAmount = BigDecimal(\"50.00\"),\n                status = OrderStatus.CANCELLED\n            )\n            every { orderRepository.findById(order.id) } returns Optional.of(order)\n\n            \u002F\u002F Act + Assert\n            assertThrows\u003COrderAlreadyCancelledException> {\n                orderService.cancel(order.id)\n            }\n        }\n    }\n}\n```\n\n### Controller Tests (MockMvc)\n\n```kotlin\n@SpringBootTest\n@AutoConfigureMockMvc\nclass OrderControllerTest {\n\n    @Autowired\n    private lateinit var mockMvc: MockMvc\n\n    @Autowired\n    private lateinit var objectMapper: ObjectMapper\n\n    @MockkBean\n    private lateinit var orderService: OrderService\n\n    @Test\n    fun `should return 201 and created order when request is valid`() {\n        \u002F\u002F Arrange\n        val customerId = UUID.randomUUID()\n        val order = Order(customerId = customerId, totalAmount = BigDecimal(\"99.99\"))\n        every { orderService.create(customerId, any()) } returns order\n\n        val body = mapOf(\"totalAmount\" to \"99.99\")\n\n        \u002F\u002F Act + Assert\n        mockMvc.perform(\n            post(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F$customerId\u002Forders\")\n                .contentType(MediaType.APPLICATION_JSON)\n                .content(objectMapper.writeValueAsString(body))\n        )\n            .andExpect(status().isCreated)\n            .andExpect(jsonPath(\"$.customerId\").value(customerId.toString()))\n            .andExpect(jsonPath(\"$.status\").value(\"PENDING\"))\n    }\n\n    @Test\n    fun `should return 400 when totalAmount is missing`() {\n        mockMvc.perform(\n            post(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F${UUID.randomUUID()}\u002Forders\")\n                .contentType(MediaType.APPLICATION_JSON)\n                .content(\"{}\")\n        )\n            .andExpect(status().isBadRequest)\n            .andExpect(jsonPath(\"$.code\").value(\"VALIDATION_ERROR\"))\n    }\n\n    @Test\n    fun `should return 404 when order is not found`() {\n        val customerId = UUID.randomUUID()\n        val orderId = UUID.randomUUID()\n        every { orderService.getById(orderId) } throws OrderNotFoundException(orderId)\n\n        mockMvc.perform(get(\"\u002Fapi\u002Fv1\u002Fcustomers\u002F$customerId\u002Forders\u002F$orderId\"))\n            .andExpect(status().isNotFound)\n            .andExpect(jsonPath(\"$.code\").value(\"ORDER_NOT_FOUND\"))\n    }\n}\n```\n\n### Repository Tests\n\n```kotlin\n@DataJpaTest\nclass OrderRepositoryTest {\n\n    @Autowired\n    private lateinit var orderRepository: OrderRepository\n\n    @Test\n    fun `should find orders by customer id`() {\n        \u002F\u002F Arrange\n        val customerId = UUID.randomUUID()\n        orderRepository.save(Order(customerId = customerId, totalAmount = BigDecimal(\"10.00\")))\n        orderRepository.save(Order(customerId = UUID.randomUUID(), totalAmount = BigDecimal(\"20.00\")))\n\n        \u002F\u002F Act\n        val result = orderRepository.findByCustomerId(customerId)\n\n        \u002F\u002F Assert\n        assertThat(result).hasSize(1)\n        assertThat(result.first().customerId).isEqualTo(customerId)\n    }\n}\n```\n\nMockK rules:\n\n- Use `@ExtendWith(MockKExtension::class)` — not `@MockBean` for unit tests\n- Use `@MockkBean` (MockK Spring integration) only in `@SpringBootTest` context\n- `every { }` for stubbing, `verify { }` for verification\n- `answers { firstArg() }` to return the argument passed to `save()`\n- `verify(exactly = 0) { }` to assert a method was never called\n- Never use `relaxed = true` unless you genuinely do not care about any return\n  value\n- Test names: `should [expected outcome] when [condition]`\n- Test structure: Arrange \u002F Act \u002F Assert, separated by blank lines\n\n---\n\n## Step 5 — When to Ask\n\nOnly pause to ask when there is genuine ambiguity in business logic. Do not ask\nabout technical choices — apply the conventions in this skill.\n\n**Ask when:**\n\n- The feature description does not specify what happens on conflict (duplicate,\n  constraint violation, concurrent modification)\n- It is unclear whether delete means hard delete or soft delete\n- Authorization rules are not specified and cannot be inferred from context\n- A domain invariant is referenced but not defined (e.g., \"validate the order\"\n  without specifying which fields or rules)\n\n**Do not ask about:**\n\n- Package structure — always feature-oriented MVC\n- Naming conventions — follow the existing codebase\n- Whether to use MockK or Mockito — always MockK\n- Whether to add `@Transactional` — always at the service class level\n- Whether to validate at controller or service — always at DTO layer\n\n---\n\n## Package Structure\n\nAlways feature-oriented. One package per feature, not one package per layer.\n\n```\nsrc\u002Fmain\u002Fkotlin\u002F{base-package}\u002F{feature}\u002F\n  controller\u002F     # HTTP only — OrderController, DTOs, toResponse() extensions\n  service\u002F        # Business logic — OrderService, domain exceptions\n  repository\u002F     # Data access — OrderRepository\n  domain\u002F         # JPA entities — Order, OrderStatus\n\nsrc\u002Ftest\u002Fkotlin\u002F{base-package}\u002F{feature}\u002F\n  controller\u002F     # OrderControllerTest (MockMvc)\n  service\u002F        # OrderServiceTest (MockK)\n  repository\u002F     # OrderRepositoryTest (@DataJpaTest)\n```\n\nNever create `src\u002Fmain\u002Fkotlin\u002Fcontrollers\u002F`, `src\u002Fmain\u002Fkotlin\u002Fservices\u002F`, etc.\nLayer-first structure does not scale and breaks feature cohesion.\n",{"id":5,"name":5,"risk":24,"inputs":27,"license":15,"outputs":32,"quality":40,"metadata":43,"description":45,"compatibility":46,"user-invokable":26},{"level":25,"can_modify_files":26,"requires_network":20,"can_execute_shell":20},"medium",true,[28,29,30,31],"feature description","existing domain context (if any)","build.gradle.kts","application.yml",[33,34,35,36,37,38,39],"domain entity","JPA repository interface","service class with business logic","REST controller with validations","request\u002Fresponse DTOs","unit tests (MockK)","controller integration tests (MockMvc)",{"version":41,"reviewed_by":42},"0.1.0","codeconductor-core",{"author":9,"category":44},"spring","Guides the creation of complete Spring Boot features following a structured, layer-by-layer workflow: entity, repository, service, controller, and tests. Applies Kotlin idioms, Bean Validation, and MockK test patterns throughout.\n",{"tools":47,"stacks":53},[48,49,50,51,52],"claude","codex","gemini","agy","opencode",{"databases":54,"languages":57,"frameworks":59},[55,56],"postgresql","h2",[58],"kotlin",[60,61,62,63,64],"spring-boot","spring-mvc","spring-data-jpa","mockk","junit5","main","f598d2e6b22828efb97e54ef48ff9b6b813d0dd5","skills\u002Fspring-boot-feature","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor","https:\u002F\u002Fcodeconductor.appsutiles.dev\u002F","https:\u002F\u002Fgithub.com\u002Flgzarturo","https:\u002F\u002Fwww.lgzarturo.com","Building products, not just software.\r\n\r\nTechnical Leadership • Software Architecture • AI","2026-10-31 21:24:13",{"source":8,"skillName":5,"commands":75,"prompt":85,"zipAvailable":26},[76,79,82],{"tool":77,"command":78},"npx","npx skills add lgzarturo\u002Fcodeconductor --skill spring-boot-feature",{"tool":80,"command":81},"bunx","bunx skills add lgzarturo\u002Fcodeconductor --skill spring-boot-feature",{"tool":83,"command":84},"pnpm","pnpm dlx skills add lgzarturo\u002Fcodeconductor --skill spring-boot-feature","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Fspring-boot-feature\u002FSKILL.md",[],[88,95,102,109,116,123],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7231GC8G8CX0AQJ0GB86T3Y","workflow-orchestration-patterns","Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow-orchestration-patterns\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7230S6HGTQH4YCQ9BYEA42G","web-design-engineering","Design, implement, and review web interface layout, component states, feedback, and motion within the current CodeConductor workflow. Use for concrete web UI work or requested UI audits, not backend-only tasks or native mobile apps.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Fweb-design-engineering\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M7230Q191BNFJT4ANF9F8F8X","using-cc-skills","Maps incoming work to the CodeConductor slash command and workflow skill. Use when starting a session or deciding which \u002Fcc-* command applies.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Fusing-cc-skills\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":19},"01M7230MVAGEAGCD33W7RV3FMH","testing-tdd","Guides agents through Red-Green-Refactor with runner-captured evidence. Use when running \u002Fcc-tdd-cycle, writing tests before implementation, or Global TDD required is yes.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-tdd\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":19},"01M7230J6BNQQYSXGAHA1BH429","testing-strategy","Provides expert knowledge of the testing pyramid, test design principles, MockK patterns, and integration testing conventions for Spring Boot + Kotlin projects.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-strategy\u002FSKILL.md",[],[],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":19},"01M7230GDPTB28J3TDPMR2HF7M","tdd-mutation-tester","Performs simple mutation testing to verify test coverage and assertions.","https:\u002F\u002Fgithub.com\u002Flgzarturo\u002Fcodeconductor\u002Fblob\u002Fmain\u002Fskills\u002Ftdd-mutation-tester\u002FSKILL.md",[],[]]