关于 webman-best-practices
面向 Webman 开发者的实践技能,涵盖 DDD 架构、依赖规则和 PER Coding Style。内容按常见架构与代码规范问题分类。
主要功能
- 01DDD 架构与依赖指导
- 02命名规范检查
- 03PER Coding Style 指导
- 04领域模式指导
- 05依赖注入指导
适用场景
- 01检查 Webman 项目架构
- 02核对目录与接口命名
- 03改进领域模型设计
- 04审查依赖注入模式
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ kitephp/ webman-design-skills --skill webman-best-practices安装后在 Claude Code 中输入/webman-best-practices确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/architecture/avoid-static-methods.mdconstructor-injection.mdcontroller-skip-service.mddomain-framework-dependency.mdinfrastructure-without-contract.mdno-service-locator.mdservice-circular-dependency.mdservice-direct-model-access.mdreferences/code-style/complete-type-declarations.mdconstructor-property-promotion.mdprefer-final-classes.mdreadonly-properties.mdstrict-types-declaration.mdreferences/domain/business-logic-in-domain.mddomain-events.mdentity-identity.mdrich-domain-model.mdvalue-object-immutability.mdreferences/naming/directory-lowercase.mdinterface-naming.mdnamespace-directory-mismatch.mdrepository-implementation-naming.mdservice-naming-pattern.md详细介绍
遵循 DDD 架构、依赖规则和 PER 编码风格的 Webman 框架最佳实践。
架构与依赖
- 控制器直接依赖 Model,跳过 Service 层 → 参见 controller-skip-service
- Domain 层依赖框架类(Request、DB 等)→ 参见 domain-framework-dependency
- Service 层与另一个 Service 存在循环依赖 → 参见 service-circular-dependency
- Infrastructure 层未实现 Contract 接口 → 参见 infrastructure-without-contract
- 在 Service 中直接使用 Model,而非 Repository → 参见 service-direct-model-access
命名约定
- 目录名使用 camelCase 或 PascalCase → 参见 directory-lowercase
- 接口名称未使用 Interface 后缀 → 参见 interface-naming
- Service 未遵循 VerbNounService 模式 → 参见 service-naming-pattern
- Repository 实现类未使用描述性前缀 → 参见 repository-implementation-naming
- 命名空间与目录结构不匹配 → 参见 namespace-directory-mismatch
代码风格(PER 编码风格)
- 文件开头缺少 declare(strict_types=1) → 参见 strict-types-declaration
- 默认未将类声明为 final → 参见 prefer-final-classes
- 不可变属性未使用 readonly → 参见 readonly-properties
- 参数或返回类型缺少类型声明 → 参见 complete-type-declarations
- 未使用构造函数属性提升 → 参见 constructor-property-promotion
领域模式
- 实体没有唯一标识 → 参见 entity-identity
- 值对象可变 → 参见 value-object-immutability
- 业务逻辑放在 Service 中,而非 Domain 中 → 参见 business-logic-in-domain
- 副作用未使用领域事件处理 → 参见 domain-events
- 贫血领域模型仅包含 getter/setter → 参见 rich-domain-model
依赖注入
- 使用静态方法而非依赖注入 → 参见 avoid-static-methods
- 未使用构造函数注入 → 参见 constructor-injection
- 使用服务定位器模式而非依赖注入 → 参见 no-service-locator
评论
支持 Markdown