Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

pact-architecture-patterns契约架构模式

Agent Skill

pact-architecture-patterns 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

404

周安装

17

GitHub Stars

62

下载量

141
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pact-architecture-patterns(契约架构模式)
来源仓库:https://github.com/profsynapse/pact-plugin
仓库路径:skills/pact-architecture-patterns
安装命令:
npx skills add https://github.com/profsynapse/pact-plugin --skill pact-architecture-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/profsynapse/pact-plugin --skill pact-architecture-patterns

简介

提供软件架构设计的最佳实践和模式参考。

  • 涵盖API设计、数据访问和存储库模式等内容。
  • 包含错误响应格式和分页设计等规范示例。
  • 适用于多宿主环境的架构标准化参考。pact-architecture-patterns 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 建议结合具体项目需求选择适用模式。

SKILL.md

PACT Architecture Patterns

Design patterns and templates for the Architect phase of PACT. This skill provides quick references for architectural decisions and links to detailed pattern implementations.

C4 Model Quick Reference

The C4 model provides four levels of abstraction for system architecture documentation.

Level 1: System Context

Shows your system as a box surrounded by users and other systems it interacts with.

                    +------------------+
                    |   External User  |
                    +--------+---------+
                             |
                             v
+------------------+    +----+----+    +------------------+
| Payment Gateway  |<-->|   Your  |<-->|   Email Service  |
+------------------+    | System  |    +------------------+
                        +---------+
                             ^
                             |
                    +--------+---------+
                    |   Admin User     |
                    +------------------+

What to include:

  • Your system (single box)
  • Users/personas
  • External systems
  • High-level interactions

Level 2: Container

Shows the high-level technical building blocks (not Docker containers).

+----------------------------------------------------------------+
|                         Your System                             |
|  +----------------+     +----------------+     +--------------+ |
|  |   Web App      |     |    API         |     |   Database   | |
|  |   (React)      |---->|    (Node.js)   |---->|   (Postgres) | |
|  +----------------+     +----------------+     +--------------+ |
|                               |                                 |
|                               v                                 |
|                         +----------+                            |
|                         |  Cache   |                            |
|                         | (Redis)  |                            |
|                         +----------+                            |
+----------------------------------------------------------------+

Containers are:

  • Separately deployable/runnable units
  • Web applications, APIs, databases, file systems, message queues

Level 3: Component

Shows the internal structure of a container.

+---------------------------------------------------------------+
|                         API Container                          |
|  +-------------+    +-------------+    +-------------------+  |
|  | Controllers |    |  Services   |    |   Repositories    |  |
|  |             |--->|             |--->|                   |  |
|  | UserCtrl    |    | UserService |    | UserRepository    |  |
|  | OrderCtrl   |    | OrderService|    | OrderRepository   |  |
|  +-------------+    +-------------+    +-------------------+  |
|                           |                                    |
|                           v                                    |
|                    +-------------+                             |
|                    |   Clients   |                             |
|                    | PaymentAPI  |                             |
|                    | EmailClient |                             |
|                    +-------------+                             |
+---------------------------------------------------------------+

Components are:

  • Logical groupings of related functionality
  • Controllers, services, repositories, clients

For full C4 templates with Mermaid diagrams: See c4-diagram-templates.md


SOLID Principles Quick Reference

PrincipleSummaryViolation Sign
Single ResponsibilityOne reason to changeClass does too many things
Open/ClosedOpen for extension, closed for modificationFrequent changes to existing code
Liskov SubstitutionSubtypes replaceable for base typesOverride breaks expectations
Interface SegregationMany specific interfaces > one generalUnused interface methods
Dependency InversionDepend on abstractionsDirect instantiation of dependencies

Design Patterns by Context

API Design Patterns

Resource Naming:

GET    /users           # List users
GET    /users/123       # Get user
POST   /users           # Create user
PUT    /users/123       # Replace user
PATCH  /users/123       # Update user
DELETE /users/123       # Delete user

# Nested resources
GET    /users/123/orders
POST   /users/123/orders

# Actions (when CRUD doesn't fit)
POST   /orders/123/cancel
POST   /users/123/verify-email

Pagination:

// Cursor-based (recommended for real-time data)
GET /posts?cursor=abc123&limit=20

// Offset-based (simpler, but has issues with real-time data)
GET /posts?page=2&per_page=20

Error Response Format:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "details": [
      { "field": "email", "message": "Invalid email format" }
    ],
    "request_id": "req_abc123"
  }
}

Data Access Patterns

Repository Pattern:

// Interface
interface UserRepository {
  findById(id: string): Promise<User | null>;
  findByEmail(email: string): Promise<User | null>;
  save(user: User): Promise<User>;
  delete(id: string): Promise<void>;
}

// Implementation
class PostgresUserRepository implements UserRepository {
  async findById(id: string) {
    return this.db.user.findUnique({ where: { id } });
  }
  // ...
}

Service Layer Pattern:

class UserService {
  constructor(
    private userRepo: UserRepository,
    private emailService: EmailService
  ) {}

  async registerUser(data: CreateUserDto): Promise<User> {
    // Business logic
    const existingUser = await this.userRepo.findByEmail(data.email);
    if (existingUser) {
      throw new ConflictError('Email already registered');
    }

    const user = await this.userRepo.save({
      ...data,
      passwordHash: await hash(data.password)
    });

    await this.emailService.sendWelcome(user.email);

    return user;
  }
}

Integration Patterns

Backend-for-Frontend (BFF):

Mobile App  -->  Mobile BFF  -->
                                   Core Services
Web App     -->  Web BFF     -->

Circuit Breaker:

class CircuitBreaker {
  constructor(
    private threshold: number = 5,
    private timeout: number = 30000
  ) {
    this.failures = 0;
    this.state = 'CLOSED';
  }

  async execute<T>(fn: () => Promise<T>): Promise<T> {
    if (this.state === 'OPEN') {
      if (Date.now() - this.lastFailure > this.timeout) {
        this.state = 'HALF_OPEN';
      } else {
        throw new Error('Circuit breaker is OPEN');
      }
    }

    try {
      const result = await fn();
      this.onSuccess();
      return result;
    } catch (error) {
      this.onFailure();
      throw error;
    }
  }

  private onSuccess() {
    this.failures = 0;
    this.state = 'CLOSED';
  }

  private onFailure() {
    this.failures++;
    this.lastFailure = Date.now();
    if (this.failures >= this.threshold) {
      this.state = 'OPEN';
    }
  }
}

For detailed patterns: See design-patterns.md


Anti-Patterns to Avoid

Anti-PatternProblemSolution
God ObjectOne class does everythingSplit by responsibility
Distributed MonolithMicroservices with tight couplingDefine proper boundaries
N+1 QueriesOne query per item in listEager loading, batching
Premature OptimizationOptimizing before measuringMeasure, then optimize
Magic Numbers/StringsHardcoded values everywhereUse constants/config
Leaky AbstractionImplementation details exposedProper encapsulation
Circular DependenciesA depends on B, B depends on AIntroduce abstraction

For comprehensive anti-patterns: See anti-patterns.md


Architecture Decision Records (ADR)

Document significant decisions for future reference:

# ADR-001: Use PostgreSQL for Primary Database

## Status
Accepted

## Context
We need to select a primary database for our application. Key requirements:
- Complex queries across related data
- Strong consistency guarantees
- Support for JSON data when needed
- Team familiarity

## Decision
We will use PostgreSQL as our primary database.

## Alternatives Considered

### MongoDB
- Pros: Flexible schema, good for rapid iteration
- Cons: Eventual consistency, complex joins difficult

### MySQL
- Pros: Widely used, good performance
- Cons: Less feature-rich than PostgreSQL

## Consequences

### Positive
- Strong ACID guarantees
- Rich query capabilities
- JSON support when needed
- Excellent tooling ecosystem

### Negative
- Stricter schema requirements
- Requires upfront data modeling
- Horizontal scaling more complex

## Notes
Review this decision if we encounter significant scaling challenges
or if data model becomes highly document-oriented.

Component Boundary Guidelines

When to Split Components

Split when you have:

  • Different rates of change
  • Different scaling requirements
  • Different team ownership
  • Different security requirements
  • Circular dependencies forming

When to Keep Together

Keep together when:

  • Highly cohesive functionality
  • Frequently change together
  • Performance-critical interactions
  • Single team ownership
  • Adds unnecessary complexity to split

Boundary Definition Checklist

  • Clear public interface defined
  • Implementation details hidden
  • Dependencies flow inward (to stable parts)
  • Can be tested in isolation
  • Can be deployed independently
  • Owns its data (if applicable)

Quick Architecture Review Checklist

Before finalizing architecture:

Structure

  • Clear separation of concerns
  • Cohesive components
  • Loose coupling between components
  • No circular dependencies

Scalability

  • Identified bottlenecks addressed
  • Stateless services where possible
  • Caching strategy defined
  • Database scaling approach planned

Security

  • Authentication/authorization designed
  • Sensitive data protection planned
  • Backend proxy pattern for external APIs
  • Input validation at boundaries

Operations

  • Logging strategy defined
  • Monitoring approach planned
  • Error handling consistent
  • Health check endpoints

Documentation

  • C4 diagrams created
  • API contracts defined
  • ADRs for key decisions
  • Component responsibilities documented

Detailed References

For comprehensive architectural guidance:

- ASCII and Mermaid templates - All four C4 levels - Common system patterns

- Detailed pattern implementations - When to use each pattern - Code examples

- Common architectural mistakes - Detection signs - Refactoring strategies

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

40.06%
按下载量换算56

Claude

29.79%
按下载量换算42

Cursor

18%
按下载量换算25

Gemini CLI

8.99%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills