技能 software-architecture
🏗️

software-architecture

安全

构建可扩展的软件架构

也可从以下获取: Doyajin174,Chemiseblanc

别再重复造轮子去编写自定义工具函数和辅助代码。本技能教授整洁架构(Clean Architecture)和领域驱动设计(DDD)原则,帮助你编写可维护、可扩展的代码。

支持: Claude Codex Code(CC)
🥉 75 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“software-architecture”。 Review this UserService class for architectural issues: [ UserService class with database queries, API calls, and UI rendering all mixed together ]

预期结果:

发现架构问题:1) 关注点混合 - 数据库查询应属于 Repository 层,2) UI 渲染应在单独的视图组件中,3) API 调用应在专用服务中。推荐重构:拆分为 UserRepository(数据层)、UserService(业务逻辑层)和 UserView(表示层)。

正在使用“software-architecture”。 I need to implement payment processing. Should I build my own or use a library?

预期结果:

推荐:使用 Stripe 或 Paddle 而不是构建自定义支付处理。这些服务处理 PCI 合规性、循环计费、webhooks 和各种边界情况,自己构建需要数月时间。只有在你有现有解决方案无法满足的高度独特需求时,才考虑自定义实现。

正在使用“software-architecture”。 Design a module for order processing in an e-commerce app

预期结果:

推荐架构(DDD):1) 订单实体(领域):Order、OrderItem、OrderStatus。2) 仓库:OrderRepository、InventoryRepository。3) 服务:OrderService(placeOrder、cancelOrder)、PaymentService(processPayment)、InventoryService(reserveItems)。4) 避免的反模式:OrderController 执行业务逻辑、控制器中的数据库查询、通用的 OrderUtils 类。

安全审计

安全
v1 • 2/25/2026

All static analysis findings are false positives. Detected 'backtick execution' patterns are markdown code emphasis formatting for library names and file examples. 'Weak cryptographic algorithm' detections are references to 'Clean Architecture' design pattern, not cryptography. 'System reconnaissance' patterns match legitimate software development guidance. This skill contains no executable code and provides educational architecture guidance only.

1
已扫描文件
81
分析行数
0
发现项
1
审计总数
未发现安全问题
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
100
安全
100
规范符合性

你能构建什么

新项目架构设计

启动新项目时需要从第一天就建立坚实的架构基础

重构遗留代码

通过应用整洁架构原则改进现有代码库的代码质量

代码审查标准

为团队代码审查和 Pull Request 建立一致的架构指南

试试这些提示

审查我的代码结构
Review this code component for architectural issues. Check for: generic naming (utils/helpers), business logic mixed with UI, file length over 200 lines, and functions over 50 lines. Suggest improvements following Clean Architecture principles.
设计模块架构
I need to build a [feature] module. Design the architecture following DDD principles. Suggest domain-specific names for entities, services, and repositories. Define clear boundaries and separation of concerns.
寻找更好的库解决方案
I need to implement [feature] functionality. Search for existing libraries or services that solve this problem. Evaluate options based on: maintenance status, community adoption, documentation quality, and fit for my requirements.
重构反模式识别
Analyze this codebase for architectural anti-patterns: NIH syndrome (custom implementations instead of libraries), generic file names, poor separation of concerns, and deep nesting. Provide specific refactoring recommendations with examples.

最佳实践

  • 在编写自定义代码前先搜索现有的库和服务,以减少维护负担
  • 使用领域特定的名称如 OrderCalculator 和 UserAuthenticator,而不是通用的 utils 或 helpers
  • 保持业务逻辑独立于框架,并与 UI 组件分离
  • 应用早期返回模式以减少嵌套并提高代码可读性

避免

  • 创建 utils.js 或 helpers.ts 文件存放不相关的函数,而不是使用领域特定的模块
  • 将业务逻辑与 UI 组件混合,或将数据库查询直接放在控制器中
  • 当存在成熟的库时,仍构建自定义的身份验证、状态管理或表单验证
  • 使用通用的文件命名(common、shared、misc),没有清晰的领域目的

常见问题

什么是整洁架构?
整洁架构(Clean Architecture)是一种软件设计模式,将关注点分离到不同的层:领域实体(业务规则)、用例(应用规则)、接口适配器(控制器、展示器)和框架(UI、数据库)。这种独立性使你的代码具有可测试性和灵活性。
为什么要避免 utils 和 helpers 文件?
通用的 utils 和 helpers 文件会成为不相关代码的堆积场。它们缺乏清晰的目的,变得难以维护。领域特定的名称如 OrderCalculator 或 EmailValidator 可以传达意图,并按业务上下文组织代码。
什么时候应该编写自定义代码而不是使用库?
仅在以下情况编写自定义代码:独特的业务逻辑、具有特殊需求的性能关键路径、需要完全控制的安全敏感代码,或在彻底评估后现有解决方案确实无法满足你的需求。
推荐的文件大小限制是多少?
尽可能将函数控制在 50 行以内,文件控制在 200 行以内。将较长的组件分解为更小的、专注的部分。如果代码无法在其他地方复用,就将其保留在同一文件中,直到为了可维护性需要拆分为止。
这个技能与通用编码助手有何不同?
本技能专注于架构决策和代码组织,而不是语法或实现细节。它指导高级结构、设计模式和可维护性,而不是编写具体算法或修复 bug。
我可以将这个技能用于任何编程语言吗?
可以。架构原则(整洁架构、DDD、关注点分离)适用于所有编程语言。但是,实现细节因语言和框架而异,因此需要根据你的具体技术栈调整建议。

开发者详情

文件结构

📄 SKILL.md