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.

242 stars

Best use case

port-adapter-designer is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Helps design port traits and adapter implementations for external dependencies. Activates when users need to abstract away databases, APIs, or other external systems.

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

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "port-adapter-designer" skill to help with this workflow task. Context: Helps design port traits and adapter implementations for external dependencies. Activates when users need to abstract away databases, APIs, or other external systems.

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/port-adapter-designer/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/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

weekly-report

242
from aiskillstore/marketplace

帮助用户梳理周报,按照完整逻辑展示工作价值和边界。当用户说"写周报"、"周报"、"梳理周报"、"整理工作"时触发。

ui-ux-designer

242
from aiskillstore/marketplace

Create interface designs, wireframes, and design systems. Masters user research, accessibility standards, and modern design tools. Specializes in design tokens, component libraries, and inclusive design. Use PROACTIVELY for design systems, user flows, or interface optimization.

startup-business-analyst-market-opportunity

242
from aiskillstore/marketplace

Generate comprehensive market opportunity analysis with TAM/SAM/SOM calculations

interactive-portfolio

242
from aiskillstore/marketplace

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities. Use when: portfolio, personal website, showcase work, developer portfolio, designer portfolio.

daily-news-report

242
from aiskillstore/marketplace

Scrapes content based on a preset URL list, filters high-quality technical information, and generates daily Markdown reports.

customer-support

242
from aiskillstore/marketplace

Elite AI-powered customer support specialist mastering conversational AI, automated ticketing, sentiment analysis, and omnichannel support experiences. Integrates modern support tools, chatbot platforms, and CX optimization with 2024/2025 best practices. Use PROACTIVELY for comprehensive customer experience management.

azure-monitor-opentelemetry-exporter-py

242
from aiskillstore/marketplace

Azure Monitor OpenTelemetry Exporter for Python. Use for low-level OpenTelemetry export to Application Insights. Triggers: "azure-monitor-opentelemetry-exporter", "AzureMonitorTraceExporter", "AzureMonitorMetricExporter", "AzureMonitorLogExporter".

add-uint-support

242
from aiskillstore/marketplace

Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.

lark-workflow-standup-report

242
from aiskillstore/marketplace

日程待办摘要:编排 calendar +agenda 和 task +get-my-tasks,生成指定日期的日程与未完成任务摘要。适用于了解今天/明天/本周的安排。

port-allocator

242
from aiskillstore/marketplace

Automatically allocate and manage development server ports, avoiding port conflicts between multiple Claude Code instances

reporting-sprints

242
from aiskillstore/marketplace

Use this skill when you need to report on a sprint

reporting-issues

242
from aiskillstore/marketplace

Use this skill when you need to report on a troubleshooting session