Skip to content
Back to skills

Mapper

ASecurity

Scaffold a manual `object` mapper between a domain model and JPA entity. This project maps by hand, not MapStruct, because entities are immutable. Use when adding model-to-entity or entity-to-model conversion.

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 19, 2026
developmentgokotlinspringapi

Works with

  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned November 19, 2026

npx -y skills add ch4570/vulpora --skill mapper --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mapper?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mapper
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ch4570-mapper/badge)](https://www.skillsdirectory.com/skills/ch4570-mapper)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mapper
description: Scaffold a manual `object` mapper between a domain model and JPA entity. This project maps by hand, not MapStruct, because entities are immutable. Use when adding model-to-entity or entity-to-model conversion.
---

# mapper — manual object mapper

Generate a hand-written `object` mapper between a domain **model** and its **entity**. This project
maps **by hand**, not with MapStruct, because entities/models are immutable (`val`). This skill encodes
that decision so new mappers don't reintroduce MapStruct by accident.

> **Authority**: project conventions (e.g. `AGENTS.md`) are binding. Review with `kotlin-spring-review`.

## Where it goes
- Domain module (`<domain-module>`), package `com.example.<domain>.mapper`. No `public` keyword.
- `object <Name>Mapper` — a stateless singleton, **not** a Spring bean (callers reference it statically).

## Skeleton (see `order/mapper/OrderMapper.kt`, `member/mapper/MemberMapper.kt`)
```kotlin
object <Name>Mapper {
    fun toModel(entity: <Name>Entity): <Name> =
        <Name>(
            id = entity.id,
            status = entity.status,
            // ...one line per field
        )

    fun toEntity(model: <Name>): <Name>Entity =
        <Name>Entity(
            id = model.id,
            status = model.status,
            // ...
        )

    fun toModels(entities: List<<Name>Entity>): List<<Name>> = entities.map(::toModel)
}
```

## Rules (MUST)
- Hand-written `object`. Map via **constructor** (entities/models are immutable `val`, so MapStruct setter injection cannot work). Do **not** add `@Mapper` / `org.mapstruct.*`.
- Convert enum↔String only where the stored representation differs from the model representation; preserve unknown-enum fallbacks (see [`enum`](../enum/SKILL.md)).
- Nested values map with `entity.x?.let(::toX)`. KDoc in Korean noting why MapStruct is avoided (immutable `val`).
- The mapper lives at the persistence boundary: services hold models, repositories hold entities, the mapper crosses between them.
- Keep mapping unidirectional and explicit: `toModel` and `toEntity` are separate functions; do not collapse them.
- For single-parameter Kotlin lambdas, use `it` when the lambda is not nested. Only name an inner parameter when nested scopes would otherwise make the value ambiguous; keep API-required parameters for multi-parameter lambdas.

## Note (project convention)
This project deliberately chooses **manual mappers**: entities and models are immutable `val`, so
constructor-based mapping is the only safe option and MapStruct's setter/builder injection adds no value.
New mappers MUST be manual `object`s — do not wire `componentModel`. (MapStruct itself is a fine tool in
projects with mutable models; see the reference KB for a fair comparison.)

## Verify
Run the project's Kotlin compile task via the detected build system (gradle/maven 등 빌드시스템 자동감지).

## reference
Deeper rationale, trade-offs, and per-task rules: see [`reference/principles.md`](reference/principles.md)
and the knowledge base at [`reference/kb/INDEX.md`](reference/kb/INDEX.md). KB takes precedence on conflicts.

## Related
[[entity]] · [[repository]] · [[enum]]

Files in this skill

  • SKILL.md3.1 KB
  • reference/kb/INDEX.md2.5 KB
  • reference/kb/manual-mapping.md2.6 KB
  • reference/kb/mapping-boundaries.md2.6 KB
  • reference/kb/mapstruct-basics.md2.8 KB
  • reference/kb/null-immutability.md3.2 KB
  • reference/principles.md3.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.