一键导入
hexagonal-architecture
Ports-and-adapters architecture patterns for testable, framework-independent domain logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Ports-and-adapters architecture patterns for testable, framework-independent domain logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Optimize token usage and context window discipline. Reduce costs and improve response quality through smart context management.
Unified context lifecycle for FlowDeck sessions — ingest, filter, prune, protect, summarize, and persist with telemetry.
Predict affected files, modules, APIs, tests, and DB paths before changes. Returns an impact map for human review.
Map architecture, conventions, and file structure into `.codebase/`. Use when onboarding or before deep feature work.
Plan differently when the agent has low certainty — ask for clarification or narrow scope instead of pretending full understanding.
Protect critical context from pruning during compaction. Preserve active plans, safety files, pending operations, and user intent anchors.
| name | hexagonal-architecture |
| description | Ports-and-adapters architecture patterns for testable, framework-independent domain logic. |
| origin | FlowDeck |
When building applications that must remain flexible to changing external systems (databases, APIs, UI frameworks) and need to support multiple entry points (ports) for the same business logic.
// Domain Core - Pure business logic, no infrastructure dependencies
class Transfer {
constructor(
public readonly fromAccountId: string,
public readonly toAccountId: string,
public readonly amount: number
) {}
execute(accounts: Map<string, Account>): TransferResult {
const from = accounts.get(this.fromAccountId)
const to = accounts.get(this.toAccountId)
if (!from || !to) {
return TransferResult.failed('Account not found')
}
if (!from.canDebit(this.amount)) {
return TransferResult.failed('Insufficient funds')
}
from.debit(this.amount)
to.credit(this.amount)
return TransferResult.success()
}
}
// Inbound Port (Primary Port) - Interface for driving operations
interface TransferUseCase {
execute(transfer: Transfer): TransferResult
}
// Outbound Port (Secondary Port) - Interface for driven operations
interface AccountRepository {
findById(id: string): Promise<Account | null>
save(account: Account): Promise<void>
}
interface EventBus {
publish(event: DomainEvent): Promise<void>
}
// Primary Adapter - REST API
class TransferController implements TransferUseCase {
constructor(private readonly accounts: AccountRepository) {}
async execute(transfer: Transfer): Promise<TransferResult> {
const allAccounts = await this.accounts.findById(transfer.fromAccountId)
// ... handle via injected port
}
}
// Secondary Adapter - PostgreSQL implementation
class PostgresAccountRepository implements AccountRepository {
constructor(private readonly db: Database) {}
// ... implementation
}