agentleFS
ch4570ch4570/vulpora/skills/mapper/SKILL.md

mapper

Skill1 starsChanged 56 days agoApache-2.0View on GitHub

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.

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep mapping unidirectional and explicit: toModel and toEntity are separate functions.

    line 44
  2. Distinctive:

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

    line 54

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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)

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).
  • 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 objects — 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 and the knowledge base at reference/kb/INDEX.md. KB takes precedence on conflicts.

Related

[[entity]] · [[repository]] · [[enum]]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.