home / skills / forge-town / skills / dao-best-practice
This skill helps standardize DAO files to align with Drizzle ORM best practices, enforcing structure, naming, types, and performance patterns.
npx playbooks add skill forge-town/skills --skill dao-best-practiceReview the files below or copy the command above to add this skill to your agents.
---
name: dao-best-practice
description: 用于规范化DAO文件,确保遵循Drizzle ORM最佳实践,包括文件结构、方法命名、类型安全和性能优化。当需要重构或创建DAO文件以符合项目标准时使用。
---
# DAO规范化技能
此技能帮助规范化DAO文件,使其符合项目的最佳实践。
## 使用说明
1. 识别需要规范化的DAO文件,通常位于 `apps/web/src/db/models/daos/`。
2. 阅读参考指南:[DAO最佳实践指南](references/dao-best-practice.md) 以了解规范。
3. 代码示例:[DAO代码参考](references/template-dao.ts) 作为参考。
4. 使用[检查清单](references/checklist.md)验证文件是否符合规范。
5. 重构文件以匹配指南中的模式。
**重要:** 调用完毕技能后,强制查看[检查清单](references/checklist.md),并确保返回的内容完全匹配清单中的所有项目。
## 核心规范
- 文件结构:文件名与表名一致,导出为对象。
- 方法:使用驼峰命名,标准CRUD方法。
- 类型安全:使用Drizzle类型推断。
- 性能:使用分页、联表查询等。
如果需要更多细节,请阅读参考文件。
This skill standardizes DAO files to follow Drizzle ORM best practices for file layout, method naming, type safety, and performance. It guides refactors or new DAO creation to meet project conventions and ensures every DAO passes the project's verification checklist. The skill integrates reference patterns and enforces final checklist validation before completion.
The skill scans DAO files in the configured DAO directory, compares each file against the reference patterns and checklist, and identifies deviations in structure, naming, types, and queries. It suggests or applies refactors to align exports, CRUD method signatures, and Drizzle-based typings. Before finishing, it forces a final verification step ensuring the file fully meets the checklist items.
Which directory does the skill inspect by default?
It targets the project's DAO directory configured in the workflow; adjust the path if your DAOs are stored elsewhere.
Does the skill modify files automatically?
It can suggest or apply refactors depending on workflow permissions, but always performs a final checklist verification before completing changes.