Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

apply-clean-architecture应用干净的架构

Agent Skill

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

总安装

297

周安装

12

GitHub Stars

5

下载量

93
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/yigitkonur/skills-by-yigitkonur --skill apply-clean-architecture

简介

用于查找、检索和筛选相关信息。apply-clean-architecture 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

  • 适合根据关键词快速定位候选结果。
  • 通过 GitHub 安装,需确认权限和维护状态。
  • 可能触发联网或文件读写,建议提前评估风险。
  • 适用于 Codex、Claude、Cursor 和 Gemini CLI。

SKILL.md

Clean Architecture — TypeScript

Apply Clean Architecture (Robert C. Martin), DDD tactical patterns, Hexagonal/Explicit Architecture (Herberto Graca), and Clean Code practices to TypeScript codebases. 76 rules across 11 categories.

Guardrails — never violate these

  • Never import outer layers from inner layers — domain imports nothing; application imports only domain
  • Never put ORM decorators or Prisma types on domain entities — use mappers in infrastructure
  • Never return null for domain errors — use a discriminated Result<T, E> return. In this repo the result branch uses ok: true | false; if E is a rich error union, give each error variant an _tag for exhaustive handling.
  • Never use as any or @ts-ignore without a documented justification comment
  • Never dispatch domain events before persistence — pull events AFTER save(), dispatch AFTER commit
  • Never share one type across domain/API/DB layers — accept cross-layer duplication, each model serves a different master
  • Never use barrel files (index.ts with export *) in application code — use direct imports
  • Never validate inside domain or use cases — parse at the adapter boundary with Zod, trust inside
  • Always use # private fields on entities (runtime encapsulation) — not the private keyword
  • Always separate Entity.create() (validates, emits events) from Entity.reconstitute() (loads from DB, no events)
  • Always wire dependencies in a single composition root (main.ts) — the only file that knows all concretions
  • Always use import type for cross-layer type imports — enable verbatimModuleSyntax: true
  • Always require strict: true + noUncheckedIndexedAccess + exactOptionalPropertyTypes in tsconfig

Trigger boundary

Use this skill when:

  • Designing new modules, services, or bounded contexts
  • Reviewing code for architectural or dependency-direction violations
  • Refactoring coupled systems toward cleaner layer separation
  • Implementing entities, value objects, aggregates, or domain events
  • Auditing tsconfig strictness, naming quality, or function design
  • Choosing between layered architecture and vertical slices

Do NOT use this skill when:

  • The task is purely about React/Vue/Angular component rendering (use framework skill)
  • The task is about build tooling, CI/CD, or deployment only
  • The task is a quick script or throwaway prototype with no long-term maintenance

Mode detection

Before starting, determine your mode:

SignalModeBehavior
"Design", "architect", "structure", "plan"DesigningPropose layer structure, reference decision-tables.md
"Review", "audit", "check", "assess"ReviewingReport findings with severity, never auto-fix, block on guardrail violations
"Implement", "write", "create", "add", "build"ImplementingWrite code following loaded references, verify with typecheck
"Refactor", "migrate", "extract", "move"RefactoringApply minimal targeted changes, preserve behavior, verify tests pass
AmbiguousAskClarify with the user before proceeding

Required workflow

Step 1 — Classify the task

Identify the primary category and one adjacent category:

CategoryReferences to loadWhen
Dependency Directiondep-inward-only, dep-interface-ownership, dep-dry-vs-duplicationImport direction issues, layer coupling, DRY vs duplication
Entity Designentity-rich-not-anemic, entity-aggregate-roots, entity-create-reconstituteDomain modeling, invariants, aggregates, factories
Use Case Isolationusecase-orchestrates-not-implements, usecase-input-output-portsUse case design, port definitions, orchestration
Clean Codecode-error-handling, code-parse-dont-validate, code-objects-vs-dataNaming, functions, error handling, validation
TypeScript Strictnessts-strict-config, ts-branded-types, ts-result-type, ts-lsp-performanceType safety, config, branded types, LSP speed
Architecture Patternspattern-cqrs-separation, pattern-domain-events, pattern-vertical-slicesCQRS, events, vertical slices
Boundariesbound-composition-root, adapt-explicit-architecture, adapt-controller-thinComposition root, ports, adapters, controllers
Framework Isolationframe-domain-purity, frame-orm-in-infrastructureORM leaks, framework coupling
Testingtest-testing-pyramid, test-layer-isolationTest strategy, pyramid alignment
Steering note: Most tasks span two categories. Load the primary reference plus one adjacent. If uncertain, scan the category table for keywords matching the user's request.

Step 2 — Load references

Read the reference file(s) from references/ identified in Step 1. Read the full file — do not skim. If a loaded reference example conflicts with the guardrails or repo conventions in this file, follow this file.

If the task involves existing code, also read:

  • The project's tsconfig.json (compare against ts-strict-config.md)
  • The project's layer structure (identify domain/, application/, infrastructure/ or equivalents)
Steering note: Always check if the project already has an AGENTS.md or architecture docs. Adapt your output to match the project's existing naming conventions and layer structure.

Step 3 — Execute the task

Apply patterns from loaded references. Follow mode-specific behavior:

In designing mode:

  • Propose folder structure per comp-screaming-architecture.md (package-by-component)
  • Define port interfaces in application/domain layer, implementations in infrastructure
  • Load decision-tables.md for architecture selection based on domain complexity

In implementing mode:

  • Entities: # private fields, create() + reconstitute() factories, pullDomainEvents()
  • Use cases: constructor-injected ports, Result<T,E> returns, orchestrate-not-implement
  • Adapters: thin controllers (parse, delegate, respond), Zod schemas at boundary
  • import type for all type-only imports across layers

In reviewing mode:

  • Check every guardrail (top of this file) — violations are automatically CRITICAL
  • Check dependency direction: inner layers must never import from outer layers
  • Check entity design: no anemic models, no ORM decorators, proper factories
  • Flag severity: CRITICAL (guardrail), WARNING (quality degradation), INFO (polish)

In refactoring mode:

  • Apply minimal changes. One refactoring at a time.
  • Preserve public API contracts. Preserve test behavior.
  • Load decision-tables.md for anti-pattern recognition table
  • For low-complexity requests, the smallest acceptable boundary split is: pure domain logic, one application entry point, boundary parsing in adapters, and one composition root.
Steering note: Never apply Clean Architecture to a simple CRUD app that doesn't need it. Check domain complexity first. For LOW complexity, vertical slices + Zod + Result types are sufficient. If the user explicitly asks for a refactor toward cleaner boundaries anyway, do the smallest useful version: isolate pure domain logic, keep one composition root, and move boundary parsing to adapters without forcing extra ceremony.

Step 4 — Verify

After making changes:

  1. Read the project's scripts or workspace docs first, then run the strongest project-native typecheck command available (npm run typecheck, pnpm typecheck, tsc --noEmit -p tsconfig.json, or npx tsc --noEmit only if the repo installs TypeScript locally and that command works here)
  2. Run tests if configured (npm test, pnpm test, or project equivalent). If no tests are configured, state that explicitly and fall back to build + typecheck instead of pretending a test step exists.
  3. Check imports: no outer-to-inner violations
  4. Check entities: # private fields, create/reconstitute separation
  5. Check boundaries: ports in consuming layer, implementations in infrastructure

If the project contains TSX but the task is architecture-only, either install the required React runtime/types before typechecking or scope the verification command to the non-UI packages/modules you actually changed. State which path you took.

Step 5 — Deliver

  • Designing: Output folder structure, port interfaces, layer diagram
  • Implementing: Output complete, compilable code with explicit return types
  • Reviewing: Output structured findings list with severity, file, line references
  • Refactoring: Output targeted diffs with before/after
Steering note: Always produce a deliverable — code, findings list, or structure. Never end with only commentary.

Common mistakes to avoid

MistakeWhy it's wrongWhat to do instead
Applying full Clean Architecture to a simple CRUD appOver-engineering; 4+ layers for no benefitUse vertical slices; add layers only when complexity emerges
Sharing one type across all layers ("DRY")DB schema change breaks API; passwordHash leaksPer-layer models with mappers — each has different change reason
Mocking domain entities in testsEntities are pure — mocking defeats the purposeTest entities directly; mock only ports in use case tests
Dispatching events before commitEvent published, DB rolled back = inconsistencyPull events after save, dispatch after commit
Using private keyword on entity fieldsCompile-time only — bypassable with as anyUse # private fields for runtime encapsulation
Putting Zod validation inside domain/use casesWrong layer — parsing belongs at the adapter boundaryParse at HTTP boundary with Zod; domain receives trusted types
Using barrel index.ts in app codeCascade loads 3x+ modules, causes circular depsDirect imports from source files
One constructor for both creation and DB loadingDuplicate event emission on every load; or skipped validationcreate() for new entities, reconstitute() for DB loads
Flagging absence of patterns as violationsOptional patterns (events, CQRS) are not mandatoryOnly audit what exists — don't flag absence of optional patterns

Reference routing

All references live in references/. Load by category:

PrefixCategoryCountKey files
dep-Dependency Direction7dep-inward-only, dep-interface-ownership, dep-dry-vs-duplication, dep-acyclic-dependencies, dep-data-crossing-boundaries, dep-no-framework-imports, dep-stable-abstractions
entity-Entity Design8entity-rich-not-anemic, entity-aggregate-roots, entity-create-reconstitute, entity-domain-services, entity-encapsulate-invariants, entity-no-persistence-awareness, entity-pure-business-rules, entity-value-objects
usecase-Use Case Isolation6usecase-orchestrates-not-implements, usecase-input-output-ports, usecase-explicit-dependencies, usecase-no-presentation-logic, usecase-single-responsibility, usecase-transaction-boundary
code-Clean Code11code-error-handling, code-parse-dont-validate, code-objects-vs-data, code-comments-discipline, code-composition-over-inheritance, code-flag-arguments, code-function-arguments, code-immutability, code-meaningful-names, code-no-side-effects, code-small-functions
comp-Component Cohesion6comp-screaming-architecture, comp-barrel-file-discipline, comp-common-closure, comp-common-reuse, comp-reuse-release-equivalence, comp-stable-dependencies
ts-TypeScript Strictness11ts-strict-config, ts-branded-types, ts-result-type, ts-lsp-performance, ts-boundary-enforcement, ts-conditional-types, ts-discriminated-unions, ts-module-structure, ts-phantom-types, ts-satisfies-operator, ts-verbatim-module-syntax
pattern-Architecture Patterns4pattern-cqrs-separation, pattern-domain-events, pattern-vertical-slices, pattern-repository-ts
bound-Boundary Definition7bound-composition-root, bound-main-component, bound-boundary-cost-awareness, bound-defer-decisions, bound-humble-object, bound-partial-boundaries, bound-service-internal-architecture
adapt-Interface Adapters6adapt-controller-thin, adapt-explicit-architecture, adapt-anti-corruption-layer, adapt-gateway-abstraction, adapt-mapper-translation, adapt-presenter-formats
frame-Framework Isolation5frame-domain-purity, frame-orm-in-infrastructure, frame-di-container-edge, frame-logging-abstraction, frame-web-in-infrastructure
test-Testing Architecture5test-testing-pyramid, test-layer-isolation, test-boundary-verification, test-testable-design, test-tests-are-architecture
Decision Tables1decision-tables (architecture selector, anti-patterns, conflicts, Do/Don't)

Additional supporting files:

Guardrails — repeated for recall

  • Source dependencies point inward only — domain never imports outer layers
  • Entities use # private fields, create() + reconstitute() factories, Result<T,E> returns using the repo's discriminated union convention
  • Parse at boundary with Zod — never validate inside domain
  • Events dispatched AFTER persistence — never before commit
  • Accept cross-layer DTO duplication — DRY ends at the layer boundary
  • main.ts is the only composition root — the only file that knows all concretions

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

32.07%
按下载量换算30

Claude

31.24%
按下载量换算29

Cursor

19.96%
按下载量换算19

Gemini CLI

9.79%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills