# Mapstruct

> Mapstruct is an open-source agent skill for developer tools. Guides an agent to write and review MapStruct mappers for Sankhya DTO-entity conversion. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/snk-devcenter/addon-studio/tree/main/plugins/addon-studio/skills/mapstruct
- **Repository:** https://github.com/snk-devcenter/addon-studio
- **GitHub stars:** 7
- **License:** MIT
- **Skill name:** mapstruct
- **Collection:** https://github.com/snk-devcenter/addon-studio
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill sets the conventions an agent should follow when building or auditing MapStruct mappers in Sankhya Addon Studio 2.0 projects. It covers the project-wide Gradle compiler flags, the choice between plain interfaces, mappers with helper components, builder-disabled abstract classes, and create/merge mappers that use a repository for upsert logic. It also lists naming rules for mapper classes and conversion methods, and a checklist for new mappers and reviews of existing ones.

The guidance keeps the component model set once globally rather than on each mapper, requires constructor injection when helper classes or abstract mappers are used, and points to separate reference files for mapping patterns and injection examples. Its common-errors table lists frequent compilation and wiring problems with their fixes.

The content is written in Portuguese and targets Java 8, Gradle, Wildfly/EJB and the JAPE SDK, with Guice used for dependency injection. Working knowledge of Lombok and the Sankhya entity model is assumed.

## When your agent uses it

> Cria, revisa e refatora mappers MapStruct para Sankhya (`componentModel="jakarta"` global no `build.gradle`, nunca no `@Mapper`; `injectionStrategy=CONSTRUCTOR`, padrões create/merge, `@MappingTarget`, `@AfterMapping`, `@Named`) para conversão DTO↔Entidade campo a campo, sem escrever get/set à mão. Use ao criar, alterar, revisar, auditar ou padronizar mappers, ao trabalhar com arquivos `*Mapper.java`, ou ao tocar em código com `@Mapper`/`@Mapping`. Escopo: o mapper e as anotações de mapeamento; o DTO e a rota são `controller`. NÃO usar para controlar como um tipo serializa em JSON — isso é `@GlobalTypeAdapter`, skill `type-adapter`.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/mapstruct)
- [License: MIT](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/mapstruct)

## Features

- **Global compiler configuration:** Explains the Gradle annotation processor settings and what the component model and unmapped target policy flags do.
- **Mapper type selection:** Provides a decision flow for choosing between simple, helper-based, builder-disabled and create/merge mapper forms.
- **Create and merge upserts:** Describes an abstract mapper pattern that looks up an existing entity by external key and updates it or creates it.
- **Naming and method conventions:** Sets naming rules for REST and integration mappers and standard names for conversion methods.
- **Review checklist:** Lists verification steps for new mappers and for auditing existing mapper code.
- **Common error fixes:** Maps frequent MapStruct and Lombok compilation or injection problems to their corrections.

## Good for

- Create a MapStruct mapper converting a REST request DTO into a JAPE entity
- Review an existing mapper for missing injection strategy or component model overrides
- Build an integration mapper that updates or creates entities by external key
- Standardize mapper naming and method signatures across a Sankhya addon project
- Fix an ambiguous mapping method compilation error

## Install

### Claude Code

This skill ships in the `addon-studio` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add snk-devcenter/addon-studio
/plugin install addon-studio@snk-devcenter
```

Or copy only this skill to `~/.claude/skills/mapstruct`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/mapstruct &&
cp -R "$tmp/plugins/addon-studio/skills/mapstruct" ~/.claude/skills/mapstruct &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/mapstruct` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/mapstruct` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/mapstruct &&
cp -R "$tmp/plugins/addon-studio/skills/mapstruct" ~/.agents/skills/mapstruct &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/mapstruct` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/mapstruct` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/mapstruct &&
cp -R "$tmp/plugins/addon-studio/skills/mapstruct" ~/.cursor/skills/mapstruct &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/mapstruct` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/snk-devcenter/addon-studio.git --path plugins/addon-studio/skills/mapstruct
```

Or copy the folder to `~/.gemini/skills/mapstruct` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/mapstruct`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/mapstruct &&
cp -R "$tmp/plugins/addon-studio/skills/mapstruct" ~/.copilot/skills/mapstruct &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/mapstruct` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git
```

Then copy `addon-studio/plugins/addon-studio/skills/mapstruct` into your agent's skills folder as `mapstruct`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need to be effective?

It assumes a Sankhya Addon Studio 2.0 project with Java 8, Gradle, MapStruct 1.5.5 and Lombok, with the component model flag already set in build.gradle.

### Should the componentModel be set on each mapper?

No. The skill says the jakarta component model is declared globally in build.gradle and must not be repeated on @Mapper, since that overrides the global setting and breaks Guice injection.

### When is an abstract class mapper required?

When the mapper needs @AfterMapping, custom logic in concrete methods, or a repository for create/merge upsert behaviour.

### Does the skill cover JSON serialization?

No. It states that controlling how a type serializes to JSON belongs to a different skill, type-adapter.

### How do I install Mapstruct in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/mapstruct to use it in all your projects, or to .claude/skills/mapstruct in one project. Or install the addon-studio plugin, which includes it: /plugin marketplace add snk-devcenter/addon-studio, then /plugin install addon-studio@snk-devcenter.

### Does Mapstruct run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Mapstruct?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Mapstruct?

The closest alternatives to Mapstruct are Entity, Type adapter, Dependency injection, Test and Controller.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Entity](https://ai-powered.com/skills/entity): Entity is an open-source agent skill for developer tools.
- [Type adapter](https://ai-powered.com/skills/type-adapter): Type adapter is an open-source agent skill for developer tools.
- [Dependency injection](https://ai-powered.com/skills/dependency-injection): Dependency injection is an open-source agent skill for developer tools.
- [Test](https://ai-powered.com/skills/test-snk-devcenter): Test is an open-source agent skill for developer tools.
- [Controller](https://ai-powered.com/skills/controller): Controller is an open-source agent skill for developer tools.
- [Retrofit](https://ai-powered.com/skills/retrofit): Retrofit is an open-source agent skill for developer tools.
- [Map project](https://ai-powered.com/skills/map-project): Map project is an open-source agent skill for developer tools.
- [Repository](https://ai-powered.com/skills/repository): Repository is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/mapstruct
