MCPInstall

architecture-patterns

Architecture validation and patterns for clean architecture, backend structure enforcement, project structure validation, test standards, and context-aware sizing. Use when designing system boundaries, enforcing layered architecture, validating project structure, defining test standards, or choosing the right architecture tier for project scope.

Installs
229
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/yonatangross/orchestkit --skill architecture-patterns
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads architecture-patterns automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

<!-- directive-density: intentional (teaches anti-patterns; NEVER markers describe real layering violations, not aspirational guidance) -->

Architecture Patterns

Consolidated architecture validation and enforcement patterns covering clean architecture, backend layer separation, project structure conventions, and test standards. Each category has individual rule files in rules/ loaded on-demand. House scars and dated decisions rescued from retired reference tutorials live in references/ork-delta.md; the tutorials themselves are upstream's job (see "Upstream coverage" below).

Quick Reference

CategoryRulesImpactWhen to Use
Clean Architecture3HIGHSOLID principles, hexagonal architecture, ports & adapters, DDD
Project Structure2HIGHFolder conventions, nesting depth, import direction, barrel files
Backend Layers3HIGHRouter/service/repository separation, DI, file naming
Test Standards3MEDIUMAAA pattern, naming conventions, coverage thresholds
Right-Sizing2HIGHArchitecture tier selection, over-engineering prevention, context-aware enforcement

Total: 13 rules across 5 categories

Quick Start

# Clean Architecture: Dependency Inversion via Protocol
class IUserRepository(Protocol):
    async def get_by_id(self, id: str) -> User | None: ...

class UserService:
    def __init__(self, repo: IUserRepository):
        self._repo = repo  # Depends on abstraction, not concretion

# FastAPI DI chain: DB -> Repository -> Service
def get_user_service(db: AsyncSession = Depends(get_db)) -> UserService:
    return UserService(PostgresUserRepository(db))
# Project Structure: Unidirectional Import Architecture
shared/lib  ->  components  ->  features  ->  app
(lowest)                                    (highest)

# Backend Layers: Strict Separation
Routers (HTTP) -> Services (Business Logic) -> Repositories (Data Access)

Clean Architecture

SOLID principles, hexagonal architecture, ports and adapters, and DDD tactical patterns for maintainable backends.

RuleFileKey Pattern
Hexagonal Architecturerules/clean-hexagonal.mdDriving/driven ports, adapter implementations, layer structure
SOLID & Dependency Rulerules/clean-dependency-rule.mdProtocol-based interfaces, dependency inversion, FastAPI DI
DDD Tactical Patternsrules/clean-ports-adapters.mdEntities, value objects, aggregate roots, domain events

Design review checklist: checklists/solid-checklist.md. Domain entity scaffold: scripts/domain-entity-template.py.

Key Decisions

DecisionRecommendation
Protocol vs ABCProtocol (structural typing)
Dataclass vs PydanticDataclass for domain, Pydantic for API
Repository granularityOne per aggregate root
Transaction boundaryService layer, not repository
Event publishingCollect in aggregate, publish after commit

Project Structure

Feature-based organization, max nesting depth, unidirectional imports, and barrel file prevention.

RuleFileKey Pattern
Folder Structure & Nestingrules/structure-folders.mdReact/Next.js and FastAPI layouts, 4-level max nesting, barrel file rules
Import Direction & Locationreferences/structure-import-direction.mdUnidirectional imports, cross-feature prevention, component/hook placement

Blocking Rules

RuleCheck
Max NestingMax 4 levels from src/ or app/
No Barrel FilesNo index.ts re-exports (tree-shaking issues)
Component LocationReact components in components/ or features/ only
Hook LocationCustom hooks in hooks/ or features/*/hooks/ only
Import DirectionUnidirectional: shared -> components -> features -> app

Backend Layers

FastAPI Clean Architecture with router/service/repository layer separation and blocking validation.

RuleFileKey Pattern
Layer Separationrules/backend-layers.mdRouter/service/repository boundaries, forbidden patterns, async rules
Dependency Injectionrules/backend-di.mdDepends() chains, blocked DI patterns, violation detection
File Naming & Exceptionsrules/backend-repository.mdNaming conventions, async rules, domain exceptions

House scars for this category (exception-to-HTTP status map, import-level violation greps, DI override teardown): references/ork-delta.md.

Layer Boundaries

LayerResponsibilityForbidden
RoutersHTTP concerns, request parsing, auth checksDatabase operations, business logic
ServicesBusiness logic, validation, orchestrationHTTPException, Request objects
RepositoriesData access, queries, persistenceHTTP concerns, business logic

Test Standards

Testing best practices with AAA pattern, naming conventions, isolation, and coverage thresholds.

RuleFileKey Pattern
AAA Pattern & Isolationrules/testing-aaa.mdArrange-Act-Assert, test isolation, parameterized tests
Naming Conventionsreferences/testing-naming-conventions.mdDescriptive behavior-focused names for Python and TypeScript
Coverage & Locationrules/testing-coverage.mdCoverage thresholds, fixture scopes, and (per references/ork-delta.md) the no-co-location rule

Coverage Requirements

AreaMinimumTarget
Overall80%90%
Business Logic90%100%
Critical Paths95%100%
New Code100%100%

Right-Sizing

Context-aware backend architecture enforcement. Rules adjust strictness based on project tier detected by scope-appropriate-architecture.

Enforcement procedure:

  1. Read project tier from scope-appropriate-architecture context (set during brainstorm/implement Step 0)
  2. If no tier set, auto-detect using signals in Read("rules/right-sizing-tiers.md")
  3. Apply tier-based enforcement matrix — skip rules marked OFF for detected tier
  4. Security rules are tier-independent — always enforce SQL parameterization, input validation, auth checks
RuleFileKey Pattern
Architecture Sizing Tiersrules/right-sizing-tiers.mdInterview/MVP/production/enterprise sizing matrix, LOC estimates, detection signals
Right-Sizing Decision Guiderules/right-sizing-decision.mdORM, auth, error handling, testing recommendations per tier, over-engineering tax

Tier-Based Rule Enforcement

RuleInterviewMVPProductionEnterprise
Layer separationOFFWARNBLOCKBLOCK
Repository patternOFFOFFWARNBLOCK
Domain exceptionsOFFOFFBLOCKBLOCK
Dependency injectionOFFWARNBLOCKBLOCK
OpenAPI documentationOFFOFFWARNBLOCK

Manual override: User can set tier explicitly to bypass auto-detection (e.g., "I want enterprise patterns for this take-home to demonstrate skill").

Decision Flowchart

Is this a take-home or hackathon?
  YES --> Flat architecture. Single file or 3-5 files. Done.
  NO  -->

Is this a prototype or MVP with < 3 months runway?
  YES --> Simple layered. Routes + services + models. No abstractions.
  NO  -->

Do you have > 5 engineers or complex domain rules?
  YES --> Clean architecture with ports/adapters.
  NO  --> Layered architecture. Add abstractions only when pain appears.

When NOT to Use

Not every project needs architecture patterns. Match complexity to project tier:

PatternInterviewHackathonMVPGrowthEnterpriseSimpler Alternative
Repository patternOVERKILL (~200 LOC)OVERKILLBORDERLINEAPPROPRIATEREQUIREDDirect ORM calls in service (~20 LOC)
DI containersOVERKILL (~150 LOC)OVERKILLLIGHT ONLYAPPROPRIATEREQUIREDConstructor params or module-level singletons (~10 LOC)
Event-driven archOVERKILL (~300 LOC)OVERKILLOVERKILLSELECTIVEAPPROPRIATEDirect function calls between services (~30 LOC)
Hexagonal architectureOVERKILL (~400 LOC)OVERKILLOVERKILLBORDERLINEAPPROPRIATEFlat modules with imports (~50 LOC)
Strict layer separationOVERKILL (~250 LOC)OVERKILLWARNBLOCKBLOCKRoutes + models in same file (~40 LOC)
Domain exceptionsOVERKILL (~100 LOC)OVERKILLOVERKILLBLOCKBLOCKBuilt-in ValueError/HTTPException (~5 LOC)

Rule of thumb: If a pattern shows OVERKILL for the detected tier, do NOT use it. Use the simpler alternative. A take-home with hexagonal architecture signals over-engineering, not skill.

Anti-Patterns (FORBIDDEN)

# CLEAN ARCHITECTURE
# NEVER import infrastructure in domain layer
from app.infrastructure.database import engine  # In domain layer!

# NEVER leak ORM models to API layer
@router.get("/users/{id}")
async def get_user(id: str, db: Session) -> UserModel:  # Returns ORM model!

# NEVER have domain depend on framework
from fastapi import HTTPException
class UserService:
    def get(self, id: str):
        raise HTTPException(404)  # Framework in domain!

# PROJECT STRUCTURE
# NEVER create files deeper than 4 levels from src/
# NEVER create barrel files (index.ts re-exports)
# NEVER import from higher layers (features importing from app)
# NEVER import across features (use shared/ for common code)

# BACKEND LAYERS
# NEVER use database operations in routers
# NEVER raise HTTPException in services
# NEVER instantiate services without Depends()

# TEST STANDARDS
# NEVER mix test files with source code
# NEVER use non-descriptive test names (test1, test, works)
# NEVER share mutable state between tests without reset

Upstream coverage (do not restate)

Long-form tutorials on these topics were removed from this skill (2026-07-31 wrap-plus-delta campaign). Read them at the first-party source; only floors, scars, and house decisions belong here (see references/ork-delta.md).

TopicFirst-party source
Hexagonal architecture, ports and adapters walkthroughAlistair Cockburn, https://alistair.cockburn.us/hexagonal-architecture/ and Architecture Patterns with Python, https://www.cosmicpython.com/
SOLID principles tutorial (Protocol-based)Architecture Patterns with Python, https://www.cosmicpython.com/ and Python Protocol spec, https://typing.python.org/en/latest/spec/protocol.html
DDD tactical patterns (entities, value objects, aggregates, domain events)Architecture Patterns with Python, https://www.cosmicpython.com/
FastAPI dependency injection, auth dependencies, DI test overridesFastAPI docs (context7: /tiangolo/fastapi), https://fastapi.tiangolo.com/tutorial/dependencies/ and skill ork:python-backend
Router/service/repository layer walkthroughFastAPI bigger applications, https://fastapi.tiangolo.com/tutorial/bigger-applications/ and skill ork:python-backend
Full FastAPI clean-architecture example appFastAPI full-stack template, https://github.com/fastapi/full-stack-fastapi-template
Next.js folder layout and structure-violation catalogNext.js project structure docs, https://nextjs.org/docs/app/getting-started/project-structure (skill vercel:nextjs)
AAA pattern, isolation, parameterized tests, fixture scoping, coverage configSkill ork:testing-unit; pytest docs, https://docs.pytest.org/en/stable/ and Vitest coverage, https://vitest.dev/config/#coverage

Related Skills

  • ork:scope-appropriate-architecture - Project tier detection that drives right-sizing enforcement
  • ork:quality-gates - YAGNI gate uses tier context to validate complexity
  • ork:distributed-systems - Distributed locking, resilience, idempotency patterns
  • ork:api-design - REST API design, versioning, error handling
  • ork:testing-unit - Unit testing: AAA pattern, fixtures, mocking, factories
  • ork:testing-e2e - E2E testing: Playwright, page objects, visual regression
  • ork:testing-integration - Integration testing: API endpoints, database, contracts
  • ork:python-backend - FastAPI, SQLAlchemy, asyncio patterns
  • ork:database-patterns - Schema design, query optimization, migrations

FAQ

What does the architecture-patterns skill do?

Architecture validation and patterns for clean architecture, backend structure enforcement, project structure validation, test standards, and context-aware sizing. Use when designing system boundaries, enforcing layered architecture, validating project structure, defining test standards, or choosing the right architecture tier for project scope.

How do I install architecture-patterns?

Run npx skills add https://github.com/yonatangross/orchestkit --skill architecture-patterns in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/architecture-patterns/ (personal) or .claude/skills/architecture-patterns/ (project).

Which AI agents can use architecture-patterns?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is architecture-patterns safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains architecture-patterns?

It is published by yonatangross in yonatangross/orchestkit. It has 229 recorded installs.

More from yonatangross/orchestkit

View all →

devops-deployment

yonatangross/orchestkit

Use when setting up CI/CD pipelines, containerizing applications, deploying to Kubernetes, or writing infrastructure as code. DevOps & Deployment covers GitHub Actions, Docker, Helm, and Terraform patterns.

DevOps & Cloud1.6K installs

responsive-patterns

yonatangross/orchestkit

Responsive design with Container Queries, fluid typography, cqi/cqb units, subgrid, intrinsic layouts, foldable devices, and mobile-first patterns for React applications. Use when building responsive layouts or container queries.

Frontend & Design1.6K installs

architecture-decision-record

yonatangross/orchestkit

ADR templates in the Nygard format with context, decision, consequences, and alternatives. Use when writing ADRs, recording an architectural decision, or evaluating options.

ui-components

yonatangross/orchestkit

UI component library patterns for shadcn/ui and Radix Primitives. Use when building accessible component libraries, customizing shadcn components, using Radix unstyled primitives, or creating design system foundations.

Frontend & Design1.5K installs

rag-retrieval

yonatangross/orchestkit

Retrieval-Augmented Generation patterns for grounded LLM responses. Use when building RAG pipelines, embedding documents, implementing hybrid search, contextual retrieval, HyDE, agentic RAG, multimodal RAG, query decomposition, reranking, or pgvector search.

AI & Agents1.5K installs

zustand-patterns

yonatangross/orchestkit

Reference for Zustand 5.x state management including slices, middleware, Immer, useShallow, persistence, selectors, and devtools integration. Documents 7 core patterns with TypeScript examples and anti-patterns. Use when building React state management with Zustand instead of Redux.

Frontend & Design1.4K installs

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.