One-click install
npx skills add https://github.com/roanbrasil/engineer-grade-agent-skills --skill ports-and-adapters
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ports-and-adapters
Source: https://github.com/roanbrasil/engineer-grade-agent-skills/tree/main/skills/ports-and-adapters
Command: npx skills add https://github.com/roanbrasil/engineer-grade-agent-skills --skill ports-and-adapters

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the common problem of application cores becoming tightly coupled to infrastructure details like databases, frameworks, and external services, which makes code hard to test, difficult to adapt to new delivery mechanisms, and expensive to modify when infrastructure needs change.

Core Features & Use Cases

  • Port Definition Patterns: Clear rules for defining primary (driving) and secondary (driven) ports using only domain types, with code examples in Java, Python, and Kotlin.
  • Adapter Implementation Guidance: Templates for thin primary adapters (REST, CLI, message consumers) and secondary adapters (database, email, payment gateways) that contain no business logic.
  • Testing & Enforcement Strategies: Built-in testing approaches for unit testing use cases without infrastructure, plus ArchUnit rules to enforce architectural boundaries and prevent coupling.
  • Use Case: Ideal for teams building long-lived applications with multiple delivery mechanisms, practicing TDD, or needing to swap infrastructure (e.g., switching from PostgreSQL to MongoDB) without modifying core business logic.

Quick Start

Use the ports-and-adapters skill to define primary and secondary ports for your new order processing use case, separating domain logic from REST API and database dependencies.

Frequently Asked Questions about ports-and-adapters

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I isolate business logic from infrastructure like databases and REST APIs?

Hexagonal Architecture isolates business logic by defining domain-focused interfaces called ports, implementing thin adapters for infrastructure like databases and REST APIs to prevent coupling and enable seamless swaps.

What is the best way to structure a domain-driven-design application for testable use cases?

Structuring a domain-driven-design application with ports and adapters separates core use cases from delivery mechanisms, allowing unit testing of business logic without infrastructure dependencies like databases or external services.

How do I swap databases from PostgreSQL to MongoDB without modifying core business logic?

Swapping databases without modifying core logic requires implementing secondary driven adapters for each database, connecting them to unchanged domain ports via dependency inversion to ensure infrastructure isolation.

Can I use ArchUnit to enforce hexagonal architecture boundaries and prevent coupling?

ArchUnit can enforce hexagonal architecture boundaries by applying architectural fitness functions that prevent coupling, verifying that adapters contain no business logic and domain ports use only domain types.

Does clean architecture work for applications with multiple delivery mechanisms like CLI and REST?

Clean architecture via ports and adapters supports multiple delivery mechanisms by defining primary driving adapters for CLI tools and REST APIs, ensuring the application core remains decoupled from delivery mechanisms.

When should I not use hexagonal architecture for software design?

Hexagonal architecture should be avoided for short-lived applications or simple scripts where the overhead of defining domain ports and implementing adapters outweighs the benefits of infrastructure isolation and testability.