返回 AiToEarn
repository-naming.yaml
根目录 / project / aitoearn-backend / .claude / instincts / repository-naming.yaml
1 ---
2 id: aitoearn-repository-naming
3 trigger: "when creating or naming repository methods"
4 confidence: 0.95
5 domain: typescript
6 source: local-repo-analysis
7 ---
8
9 # Repository Method Naming Convention
10
11 ## Action
12 Use strict prefix conventions for repository methods.
13
14 ## Required Prefixes
15
16 | Prefix | Returns | Format |
17 |--------|---------|--------|
18 | `get` | Single value | `getById`, `getByUserId`, `getByIdAndStatus` |
19 | `list` | Array | `listByUserId`, `listByStatus`, `listWithPagination` |
20 | `create` | Created entity | `create`, `createMany`, `createByUser` |
21 | `update` | Updated entity | `updateById`, `updateByStatus`, `updateManyByIds` |
22 | `delete` | Deleted entity | `deleteById`, `deleteByUserId`, `deleteManyByIds` |
23 | `count` | Number | `countByUserId`, `countByStatus` |
24 | `aggregate` | Aggregation | `aggregateByDate`, `sum`, `avg` |
25
26 ## Pagination Methods
27 Must end with `WithPagination`: `listWithPagination`
28
29 ## Forbidden Prefixes
30 | ❌ Wrong | ✅ Correct |
31 |----------|-----------|
32 | `findById` | `getById` |
33 | `findList` | `listWithPagination` |
34 | `delOne` | `deleteById` |
35 | `addUseCount` | `updateUseCountById` |
36 | `verify` | `updateVerifyById` |
37 | `markAsRead` | `updateAsReadByIds` |
38 | `check` | `get` + business logic in Service |
39
40 ## Evidence
41 - Enforced in CLAUDE.md development standards
42 - Consistent pattern in libs/*-db/repositories/
43
43 lines YAML