port-adapter-designer

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

25 stars

Best use case

port-adapter-designer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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

Teams using port-adapter-designer should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/port-adapter-designer/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/aiskillstore/marketplace/emillindfors/port-adapter-designer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/port-adapter-designer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How port-adapter-designer Compares

Feature / Agentport-adapter-designerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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 PostgresUserRepository {
    async fn find_by_id(&self, id: &UserId) -> Result<User, RepositoryError> {
        let row = sqlx::query_as!(
            UserRow,
            "SELECT id, email, name FROM users WHERE id = $1",
            id.as_str()
        )
        .fetch_one(&self.pool)
        .await
        .map_err(|e| match e {
            sqlx::Error::RowNotFound => RepositoryError::NotFound,
            _ => RepositoryError::Database(e.to_string()),
        })?;

        Ok(User::try_from(row)?)
    }

    async fn save(&self, user: &User) -> Result<(), RepositoryError> {
        sqlx::query!(
            "INSERT INTO users (id, email, name) VALUES ($1, $2, $3)
             ON CONFLICT (id) DO UPDATE SET email = $2, name = $3",
            user.id().as_str(),
            user.email().as_str(),
            user.name()
        )
        .execute(&self.pool)
        .await
        .map_err(|e| RepositoryError::Database(e.to_string()))?;

        Ok(())
    }
}
```

### HTTP Client Adapter

```rust
pub struct StripePaymentGateway {
    client: reqwest::Client,
    api_key: String,
}

#[async_trait]
impl PaymentGateway for StripePaymentGateway {
    async fn process_payment(&self, amount: Money, card: &CardDetails) -> Result<PaymentId, PaymentError> {
        #[derive(Serialize)]
        struct PaymentRequest {
            amount: u64,
            currency: String,
            card: CardDetailsDto,
        }

        let response = self
            .client
            .post("https://api.stripe.com/v1/charges")
            .bearer_auth(&self.api_key)
            .json(&PaymentRequest {
                amount: amount.cents(),
                currency: amount.currency().to_string(),
                card: CardDetailsDto::from(card),
            })
            .send()
            .await
            .map_err(|e| PaymentError::Network(e.to_string()))?;

        if !response.status().is_success() {
            return Err(PaymentError::GatewayRejected(response.status().to_string()));
        }

        let data: PaymentResponse = response
            .json()
            .await
            .map_err(|e| PaymentError::ParseError(e.to_string()))?;

        Ok(PaymentId::from(data.id))
    }
}
```

### In-Memory Adapter (for testing)

```rust
pub struct InMemoryUserRepository {
    users: Arc<Mutex<HashMap<UserId, User>>>,
}

impl InMemoryUserRepository {
    pub fn new() -> Self {
        Self {
            users: Arc::new(Mutex::new(HashMap::new())),
        }
    }

    pub fn with_users(users: Vec<User>) -> Self {
        let map = users.into_iter().map(|u| (u.id().clone(), u)).collect();
        Self {
            users: Arc::new(Mutex::new(map)),
        }
    }
}

#[async_trait]
impl UserRepository for InMemoryUserRepository {
    async fn find_by_id(&self, id: &UserId) -> Result<User, RepositoryError> {
        self.users
            .lock()
            .await
            .get(id)
            .cloned()
            .ok_or(RepositoryError::NotFound)
    }

    async fn save(&self, user: &User) -> Result<(), RepositoryError> {
        self.users
            .lock()
            .await
            .insert(user.id().clone(), user.clone());
        Ok(())
    }
}
```

## Port Design Guidelines

1. **Use domain types**: Parameters and return types should be domain objects
2. **Async by default**: Most I/O is async in Rust
3. **Return domain errors**: Convert infrastructure errors at the boundary
4. **Send + Sync**: Required for multi-threaded async runtimes
5. **Focused interfaces**: Each port should have a single responsibility

## Your Approach

When you see external dependencies:
1. Identify the interface needed
2. Design a port trait with domain types
3. Suggest adapter implementations
4. Show testing strategy with mocks

Proactively suggest port/adapter patterns when you detect tight coupling to external systems.

Related Skills

vulnerability-report-generator

25
from ComeOnOliver/skillshub

Vulnerability Report Generator - Auto-activating skill for Security Advanced. Triggers on: vulnerability report generator, vulnerability report generator Part of the Security Advanced skill category.

vpc-network-designer

25
from ComeOnOliver/skillshub

Vpc Network Designer - Auto-activating skill for AWS Skills. Triggers on: vpc network designer, vpc network designer Part of the AWS Skills skill category.

tracking-crypto-portfolio

25
from ComeOnOliver/skillshub

Track cryptocurrency portfolio with real-time valuations, allocation analysis, and P&L tracking. Use when checking portfolio value, viewing holdings breakdown, analyzing allocations, or exporting portfolio data. Trigger with phrases like "show my portfolio", "check crypto holdings", "portfolio allocation", "track my crypto", or "export portfolio".

torchscript-exporter

25
from ComeOnOliver/skillshub

Torchscript Exporter - Auto-activating skill for ML Deployment. Triggers on: torchscript exporter, torchscript exporter Part of the ML Deployment skill category.

generating-test-reports

25
from ComeOnOliver/skillshub

This skill generates comprehensive test reports with coverage metrics, trends, and stakeholder-friendly formats (HTML, PDF, JSON). It aggregates test results from various frameworks, calculates key metrics (coverage, pass rate, duration), and performs trend analysis. Use this skill when the user requests a test report, coverage analysis, failure analysis, or historical comparisons of test runs. Trigger terms include "test report", "coverage report", "testing trends", "failure analysis", and "historical test data".

status-report-generator

25
from ComeOnOliver/skillshub

Status Report Generator - Auto-activating skill for Enterprise Workflows. Triggers on: status report generator, status report generator Part of the Enterprise Workflows skill category.

skill-adapter

25
from ComeOnOliver/skillshub

Execute analyzes existing plugins to extract their capabilities, then adapts and applies those skills to the current task. Acts as a universal skill chameleon that learns from other plugins. Activates when you request "skill adapter" functionality. Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

rest-endpoint-designer

25
from ComeOnOliver/skillshub

Rest Endpoint Designer - Auto-activating skill for API Development. Triggers on: rest endpoint designer, rest endpoint designer Part of the API Development skill category.

report-template-generator

25
from ComeOnOliver/skillshub

Report Template Generator - Auto-activating skill for Data Analytics. Triggers on: report template generator, report template generator Part of the Data Analytics skill category.

model-export-helper

25
from ComeOnOliver/skillshub

Model Export Helper - Auto-activating skill for ML Deployment. Triggers on: model export helper, model export helper Part of the ML Deployment skill category.

finding-arbitrage-opportunities

25
from ComeOnOliver/skillshub

Detect profitable arbitrage opportunities across CEX, DEX, and cross-chain markets in real-time. Use when scanning for price spreads, finding arbitrage paths, comparing exchange prices, or analyzing triangular arbitrage opportunities. Trigger with phrases like "find arbitrage", "scan for arb", "price spread", "exchange arbitrage", "triangular arb", "DEX price difference", or "cross-exchange opportunity".

feature-importance-analyzer

25
from ComeOnOliver/skillshub

Feature Importance Analyzer - Auto-activating skill for ML Training. Triggers on: feature importance analyzer, feature importance analyzer Part of the ML Training skill category.