跳到正文
cccskills
免费在 GitHub 公开

clean-architecture

Clean Architecture practitioner's guide. Trigger when users ask about four-layer architecture, dependency direction & inversion (DIP), an entity directly depending on external SDKs, ORM/data access layer (Repository pattern) design, microservice decomposition, technology selection, over-engineering, or architecture refactoring. Covers business logic organization in Express/Next.js/Go/Spring projects, MongoDB→PostgreSQL migrate, REST→GraphQL migrate, third-party integration (Stripe/PayPal), Redis caching, and Kafka message queue evaluation. Evaluates architecture against Robert C. Martin's Clean Architecture, SOLID principles, and the Dependency Rule; uses Musk's five-step algorithm as an anti-over-engineering gate. Do NOT trigger on: pure code quality, DDD, system design interviews, single-DTO micro-decisions, cache library selection, DI framework debugging, diagram drawing, translation, or formatting requests — answer directly without invoking this skill.

中文简介正在准备中。当前显示原文说明。

tokenaissance/clean-architecture星标 20(GitHub 20 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(29)

  • SKILL.md5.9 KB
  • .gitignore34 B
  • agents/interface.yaml3.5 KB
  • docs/README.zh-CN.md7.9 KB
  • evals/output-eval.json6.2 KB
  • evals/trigger_cases.json3.8 KB
  • LICENSE1.0 KB
  • manifest.json3.2 KB
  • README.md8.9 KB
  • references/clean-architecture.md17.3 KB
  • references/engineering-philosophy.md10.6 KB
  • references/geb-fractal-docs.md6.5 KB
  • references/musk-algorithm.md5.2 KB
  • reports/assets/eval-report.png186.6 KB
  • reports/assets/eval-report.svg4.8 KB
  • reports/assets/four-layer-diagram.png273.6 KB
  • reports/assets/four-layer-diagram.svg4.2 KB
  • reports/assets/upgrade-infographic.png345.6 KB
  • reports/assets/upgrade-infographic.svg7.1 KB
  • reports/creation-handoff.md6.7 KB
  • reports/output-eval.json5.3 KB
  • reports/prior-art-research.md4.3 KB
  • reports/skill-ir.json9.9 KB
  • reports/trigger-eval.json7.7 KB
  • reports/upgrade-summary.md3.9 KB
  • scripts/__pycache__/output_eval.cpython-313.pyc7.7 KB
  • scripts/output_eval.py4.6 KB
  • tests/__pycache__/test_output_eval.cpython-313.pyc5.4 KB
  • tests/test_output_eval.py2.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Clean Architecture

Practical layering, DIP enforcement, and anti-over-engineering — grounded in Robert C. Martin's Clean Architecture, SOLID (SRP/OCP/LSP/ISP/DIP), component principles (CCP/CRP/ADP/SDP/SAP), and Musk's five-step algorithm.

Router Rules

  • Description-based routing: trigger on architecture-significant scenarios — four-layer decomposition, DIP violation, Repository/Adapter boundary design, technology evaluation, over-engineering detection.
  • Once triggered, follow Workflow. This is an architecture governance entrypoint, not a debugging or code-review tool.
  • Hard-exclusion list (answer directly, do NOT invoke): pure code quality, DDD, system design interviews, single-DTO micro-decisions, cache library selection, DI framework debugging, diagram drawing, translation, formatting.
  • Stack-agnostic: explain in canonical four-layer terms (Entities / Use Cases / Interface Adapters / Frameworks & Drivers), then map to the user's actual framework (Express/Next.js/Go/Spring). Service/Repository/Controller are implementation-pattern mappings, not primary layer names. Adopt the user's existing conventions where established.
  • Read-only audit requests: zero file modifications.

Use when

  • Monolithic controller/route bloat → SRP decomposition + DIP-driven refactoring into four layers
  • Entity/Use Case directly importing external SDK (Stripe/PayPal) or DB driver → Dependency Rule audit
  • Technology evaluation: microservices / Kafka / Redis / caching → bounded-context fitness and CCP alignment
  • Storage or API migration (MongoDB→PostgreSQL, REST→GraphQL) → Repository boundary design, Ports & Adapters impact
  • Multi-vendor integration → Adapter layer design, swappability via interface contracts

Do NOT use when

  • Diagramming, translation, formatting, title-writing, document summarization
  • Framework debugging: DI wiring failures, HTTP 500, slow SQL, index optimization
  • Micro-decisions: React component splitting, single DTO addition, naming
  • System design interview problems (Twitter-scale, bit.ly, Saga pattern, multi-tenancy)
  • User explicitly opts out ("don't talk about architecture," "just explain")

Workflow

  1. Diagnose — probe before prescribe: Elicit scale, team size, concurrency, change frequency. CCP: same change reason + same change cadence → co-locate. SRP: different actors → separate. Invest boundaries only on proven variation axes (3+ historical changes at the same seam); YAGNI on unproven axes.
  2. Principle evaluation: Assess against the four-layer concentric model + Dependency Rule (∀ dep → inward; Entities ⊥ Use Cases ⊥ Interface Adapters ⊥ Frameworks & Drivers), SOLID (SRP/OCP/LSP/ISP/DIP), component cohesion (REP/CCP/CRP) + coupling (ADP/SDP/SAP), Musk's five-step algorithm, and engineering dialectics (unity of opposites, quantitative→qualitative change, negation of negation). See Reference Map.
  3. Structured answer (architecture scenario confirmed):
    • Four-layer map: Entities / Use Cases / Interface Adapters / Frameworks & Drivers — each layer named with contents
    • Dependency Rule: source-code dependencies point inward only — concrete direction arrows drawn
    • Stack mapping: canonical layers projected onto user's actual framework + directory structure
    • Code example: minimal before/after with layer labels, ≤ 50 lines
  4. Anti-over-engineering gate: Every "adopt complex solution" recommendation must survive Musk's five steps — Question → Delete → Simplify → Accelerate → Automate, order invariant. Monolith suffices → do NOT propose microservices. Single implementation → do NOT propose interface abstraction.
  5. Documentation isomorphism (as needed): Architecture decisions must persist as discoverable artifacts for downstream Agents and developers. Code change without documentation update = incomplete. Granularity matches impact radius: cross-layer refactor → L3→L2→L1 full loop; single import change → one L3 line. See Reference Map → Documentation Isomorphism.

Output Contract

  • Hit: diagnosis + four-layer map + Dependency Rule explication + stack mapping + ≤50-line code example + anti-over-engineering verdict. Major architecture decisions → append L2/L3 documentation skeletons.
  • Miss: answer directly; suppress this skill's template.
  • Scaffold restraint: full directory scaffold (> 5 directories or named files) only on explicit request. Default: layer-level directory suggestions (≤ 5 directory names, no specific files).

Reference Map

  • Theory & Principles: references/clean-architecture.md
  • Anti-Over-Engineering: references/musk-algorithm.md
  • Engineering Philosophy: references/engineering-philosophy.md
  • Documentation Isomorphism: references/geb-fractal-docs.md

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

报告此技能的问题