Agent skill

spring-boot-modulith

Spring Modulith 2.0 implementation for bounded contexts in Spring Boot 4. Use when structuring application modules, implementing @ApplicationModuleListener for event-driven communication, testing with Scenario API, enforcing module boundaries, externalizing events to Kafka/AMQP, building a modular monolith, defining module dependencies, managing inter-module events, or organizing DDD modules as packages. Covers package-based module boundaries, named interfaces, event publication, and Scenario API testing. For architecture decisions, see domain-driven-design skill.

Stars 9
Forks 1

Install this agent skill to your Project

npx add-skill https://github.com/joaquimscosta/arkhe-claude-plugins/tree/main/plugins/spring-boot/skills/spring-boot-modulith

SKILL.md

Spring Modulith for Bounded Contexts

Implements DDD bounded contexts as application modules with enforced boundaries and event-driven communication.

Core Concepts

Concept Description
Application Module Package-based boundary = bounded context
Module API Types in base package (public)
Internal Types in sub-packages (encapsulated)
Events Cross-module communication mechanism

Module Structure

src/main/java/
├── com.example/
│   └── Application.java              ← @SpringBootApplication
├── com.example.order/                ← Module: order
│   ├── OrderService.java             ← Public API
│   ├── OrderCreated.java             ← Public event
│   ├── package-info.java             ← @ApplicationModule config
│   └── internal/                     ← Encapsulated
│       ├── OrderRepository.java
│       └── OrderEntity.java
├── com.example.inventory/            ← Module: inventory
│   ├── InventoryService.java
│   └── internal/
└── com.example.shipping/             ← Module: shipping

Types in com.example.order = public API Types in com.example.order.internal = hidden from other modules

Quick Patterns

See EXAMPLES.md for complete working examples including:

  • Module Configuration with @ApplicationModule
  • Event Publishing with domain event records
  • Event Handling with @ApplicationModuleListener (Java + Kotlin)
  • Module Verification Test with PlantUML generation
  • Event Externalization for Kafka/AMQP

Spring Boot 4 / Modulith 2.0 Specifics

  • @ApplicationModuleListener combines @Async + @Transactional(REQUIRES_NEW) + @TransactionalEventListener(AFTER_COMMIT)
  • Event Externalization with @Externalized annotation for Kafka/AMQP
  • JDBC event log ensures at-least-once delivery

Detailed References

  • Examples: See EXAMPLES.md for complete working code examples
  • Troubleshooting: See TROUBLESHOOTING.md for common issues and Boot 4 migration
  • Workflow: See WORKFLOW.md for detailed step-by-step Modulith setup
  • Module Structure: See references/MODULE-STRUCTURE.md for package conventions, named interfaces, dependency rules
  • Event Patterns: See references/EVENTS.md for publishing, handling, externalization, testing with Scenario API

Related Skills

Need Skill
DDD concepts domain-driven-design
Data layer per module spring-boot-data-ddd
Module event testing spring-boot-testing
REST APIs for modules spring-boot-web-api

Anti-Pattern Checklist

Anti-Pattern Fix
Direct bean injection across modules Use events or expose API
Synchronous cross-module calls Use @ApplicationModuleListener
Module dependencies not declared Add allowedDependencies in @ApplicationModule
Missing verification test Add ApplicationModules.verify() test
Internal types in public API Move to .internal sub-package
Events without data Include all data handlers need

Critical Reminders

  1. One module = one bounded context — Mirror DDD boundaries
  2. Events are the integration mechanism — Not direct method calls
  3. Verify in CIApplicationModules.verify() catches boundary violations
  4. Reference by ID — Never direct object references across modules
  5. Transaction per module@ApplicationModuleListener ensures isolation

Expand your agent's capabilities with these related and highly-rated skills.

joaquimscosta/arkhe-claude-plugins

Skill Name

What this skill does. Use when user mentions "keyword1", "keyword2", or "keyword3". Keep under 1,024 characters and include specific trigger keywords.

9 1
Explore
joaquimscosta/arkhe-claude-plugins

plugin-release-checker

9 1
Explore
joaquimscosta/arkhe-claude-plugins

skill-validator

Validate skills against Anthropic best practices for frontmatter, structure, content, file organization, hooks, MCP, and security (62 rules in 8 categories). Use when creating new skills, updating existing skills, before publishing skills, reviewing skill quality, or when user mentions "validate skill", "check skill", "skill best practices", "skill review", or "lint skill".

9 1
Explore
joaquimscosta/arkhe-claude-plugins

sync-docs

Sync official Anthropic documentation and analyze impact on project components. Runs docs/reference/update-claude-docs.sh, computes diffs, and reports impacts on the skill validator, plugins, and project documentation. Use when user mentions "sync docs", "update reference docs", "refresh docs", or "check doc changes".

9 1
Explore
joaquimscosta/arkhe-claude-plugins

research-frontmatter

Enforce standard YAML frontmatter on research documents in docs/research/. Use when creating, editing, or promoting research files, when user mentions "research metadata", "research frontmatter", or "research staleness".

9 1
Explore
joaquimscosta/arkhe-claude-plugins

deep-research

Deep research on technical topics using EXA tools with intelligent two-tier caching. Use when user asks to research a topic, investigate best practices, look up information, find patterns, or explore architectures. Also invoked by /research command. Triggers: "research", "look up", "investigate", "deep dive", "find information about", "what are best practices for", "how do others implement".

9 1
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results