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 GitHubEmilLindfors/claude-marketplace
rust-hexagonal
January 20, 2026
Select agents to install to:
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-designerInstallation paths:
.claude/skills/port-adapter-designer/# 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