Back to Skills

port-adapter-designer

verified

Helps design port traits and adapter implementations for external dependencies. Activates when users need to abstract away databases, APIs, or other external systems.

View on GitHub

Marketplace

lf-marketplace

EmilLindfors/claude-marketplace

Plugin

rust-hexagonal

development

Repository

EmilLindfors/claude-marketplace
2stars

plugins/rust-hexagonal/skills/port-adapter-designer/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/EmilLindfors/claude-marketplace/blob/main/plugins/rust-hexagonal/skills/port-adapter-designer/SKILL.md -a claude-code --skill port-adapter-designer

Installation paths:

Claude
.claude/skills/port-adapter-designer/
Powered by add-skill CLI

Instructions

# Port and Adapter Designer Skill

You are an expert at designing ports (trait abstractions) and adapters (implementations) for hexagonal architecture in Rust. When you detect external dependencies or integration needs, proactively suggest port/adapter patterns.

## When to Activate

Activate when you notice:
- Direct usage of databases, HTTP clients, or file systems
- Need to swap implementations for testing
- External service integrations
- Questions about abstraction or dependency injection

## Port Design Patterns

### Pattern 1: Repository Port

```rust
#[async_trait]
pub trait UserRepository: Send + Sync {
    async fn find_by_id(&self, id: &UserId) -> Result<User, RepositoryError>;
    async fn find_by_email(&self, email: &Email) -> Result<User, RepositoryError>;
    async fn save(&self, user: &User) -> Result<(), RepositoryError>;
    async fn delete(&self, id: &UserId) -> Result<(), RepositoryError>;
    async fn list(&self, limit: usize, offset: usize) -> Result<Vec<User>, RepositoryError>;
}
```

### Pattern 2: External Service Port

```rust
#[async_trait]
pub trait PaymentGateway: Send + Sync {
    async fn process_payment(&self, amount: Money, card: &CardDetails) -> Result<PaymentId, PaymentError>;
    async fn refund(&self, payment_id: &PaymentId) -> Result<RefundId, PaymentError>;
    async fn get_status(&self, payment_id: &PaymentId) -> Result<PaymentStatus, PaymentError>;
}
```

### Pattern 3: Notification Port

```rust
#[async_trait]
pub trait NotificationService: Send + Sync {
    async fn send_email(&self, to: &Email, subject: &str, body: &str) -> Result<(), NotificationError>;
    async fn send_sms(&self, phone: &PhoneNumber, message: &str) -> Result<(), NotificationError>;
}
```

## Adapter Implementation Patterns

### PostgreSQL Adapter

```rust
pub struct PostgresUserRepository {
    pool: PgPool,
}

impl PostgresUserRepository {
    pub fn new(pool: PgPool) -> Self {
        Self { pool }
    }
}

#[async_trait]
impl UserRepository for Postg

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5006 chars