beeops 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.ja.md +156 -0
- package/README.md +80 -0
- package/bin/beeops.js +502 -0
- package/command/bo.md +120 -0
- package/contexts/agent-modes.json +100 -0
- package/contexts/code-reviewer.md +118 -0
- package/contexts/coder.md +247 -0
- package/contexts/default.md +1 -0
- package/contexts/en/agent-modes.json +100 -0
- package/contexts/en/code-reviewer.md +129 -0
- package/contexts/en/coder.md +247 -0
- package/contexts/en/default.md +1 -0
- package/contexts/en/fb.md +15 -0
- package/contexts/en/leader.md +158 -0
- package/contexts/en/log.md +16 -0
- package/contexts/en/queen.md +240 -0
- package/contexts/en/review-leader.md +190 -0
- package/contexts/en/reviewer-base.md +27 -0
- package/contexts/en/security-reviewer.md +200 -0
- package/contexts/en/test-auditor.md +146 -0
- package/contexts/en/tester.md +135 -0
- package/contexts/en/worker-base.md +69 -0
- package/contexts/fb.md +15 -0
- package/contexts/ja/agent-modes.json +100 -0
- package/contexts/ja/code-reviewer.md +129 -0
- package/contexts/ja/coder.md +247 -0
- package/contexts/ja/default.md +1 -0
- package/contexts/ja/fb.md +15 -0
- package/contexts/ja/leader.md +158 -0
- package/contexts/ja/log.md +17 -0
- package/contexts/ja/queen.md +240 -0
- package/contexts/ja/review-leader.md +190 -0
- package/contexts/ja/reviewer-base.md +27 -0
- package/contexts/ja/security-reviewer.md +200 -0
- package/contexts/ja/test-auditor.md +146 -0
- package/contexts/ja/tester.md +135 -0
- package/contexts/ja/worker-base.md +68 -0
- package/contexts/leader.md +158 -0
- package/contexts/log.md +16 -0
- package/contexts/queen.md +240 -0
- package/contexts/review-leader.md +190 -0
- package/contexts/reviewer-base.md +27 -0
- package/contexts/security-reviewer.md +200 -0
- package/contexts/test-auditor.md +146 -0
- package/contexts/tester.md +135 -0
- package/contexts/worker-base.md +69 -0
- package/hooks/checkpoint.py +89 -0
- package/hooks/prompt-context.py +139 -0
- package/hooks/resolve-log-path.py +93 -0
- package/hooks/run-log.py +429 -0
- package/package.json +42 -0
- package/scripts/launch-leader.sh +282 -0
- package/scripts/launch-worker.sh +184 -0
- package/skills/bo-dispatch/SKILL.md +299 -0
- package/skills/bo-issue-sync/SKILL.md +103 -0
- package/skills/bo-leader-dispatch/SKILL.md +211 -0
- package/skills/bo-log-writer/SKILL.md +101 -0
- package/skills/bo-review-backend/SKILL.md +234 -0
- package/skills/bo-review-database/SKILL.md +243 -0
- package/skills/bo-review-frontend/SKILL.md +236 -0
- package/skills/bo-review-operations/SKILL.md +268 -0
- package/skills/bo-review-process/SKILL.md +181 -0
- package/skills/bo-review-security/SKILL.md +214 -0
- package/skills/bo-review-security/references/finance-security.md +351 -0
- package/skills/bo-self-improver/SKILL.md +145 -0
- package/skills/bo-self-improver/refs/agent-manager.md +61 -0
- package/skills/bo-self-improver/refs/command-manager.md +46 -0
- package/skills/bo-self-improver/refs/skill-manager.md +59 -0
- package/skills/bo-self-improver/scripts/analyze.py +359 -0
- package/skills/bo-task-decomposer/SKILL.md +130 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bo-log-writer
|
|
3
|
+
description: Record work logs to JSONL. Extract changes, decisions, error resolutions, and learnings from git diff and conversation context.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bo-log-writer: Work Log Recording
|
|
7
|
+
|
|
8
|
+
Record session work to `.claude/beeops/logs/log.jsonl` in JSONL format.
|
|
9
|
+
|
|
10
|
+
## Procedure
|
|
11
|
+
|
|
12
|
+
1. Get log path and current timestamp:
|
|
13
|
+
```bash
|
|
14
|
+
LOG_BASE=$(python3 "$(dirname "$(python3 -c "import beeops; print(beeops.__file__)" 2>/dev/null || echo "$BO_CONTEXTS_DIR/../hooks/resolve-log-path.py")")/resolve-log-path.py" 2>/dev/null || python3 hooks/resolve-log-path.py) && mkdir -p "$LOG_BASE" && date '+%Y-%m-%dT%H:%M:%S'
|
|
15
|
+
```
|
|
16
|
+
If the above fails, use the simpler fallback:
|
|
17
|
+
```bash
|
|
18
|
+
LOG_BASE=".claude/beeops/logs" && mkdir -p "$LOG_BASE" && date '+%Y-%m-%dT%H:%M:%S'
|
|
19
|
+
```
|
|
20
|
+
2. Check changed files with `git diff --name-only` and `git status`
|
|
21
|
+
3. Extract work content, intent, errors, and learnings from conversation context
|
|
22
|
+
4. Append JSONL entry to `$LOG_BASE/log.jsonl`
|
|
23
|
+
|
|
24
|
+
## Log Format (JSONL)
|
|
25
|
+
|
|
26
|
+
File: `$LOG_BASE/log.jsonl`
|
|
27
|
+
One line = one JSON object per work unit. All entries appended to a single file.
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"timestamp": "2026-03-02T14:30:00",
|
|
32
|
+
"title": "Brief work title",
|
|
33
|
+
"category": "implementation | review | design | bugfix | refactor | research | meta",
|
|
34
|
+
"changes": [{ "file": "src/domain/foo.ts", "description": "Added validation" }],
|
|
35
|
+
"decisions": [
|
|
36
|
+
{ "what": "What was decided", "why": "Rationale", "alternatives": "Alternatives considered" }
|
|
37
|
+
],
|
|
38
|
+
"errors": [
|
|
39
|
+
{
|
|
40
|
+
"message": "Error message",
|
|
41
|
+
"cause": "Root cause",
|
|
42
|
+
"solution": "How it was resolved",
|
|
43
|
+
"tags": ["prisma", "enum"]
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"learnings": ["Reusable insights"],
|
|
47
|
+
"patterns": ["Recurring patterns observed"],
|
|
48
|
+
"remaining": ["Unresolved issues / TODOs"],
|
|
49
|
+
"skills_used": ["bo-task-decomposer"],
|
|
50
|
+
"agents_used": ["code-reviewer", "planner"],
|
|
51
|
+
"commands_used": ["commit", "review"],
|
|
52
|
+
"resources_created": [{ "type": "skill", "name": "meta-task-planner", "action": "created" }]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Field Description
|
|
57
|
+
|
|
58
|
+
| Field | Required | Purpose |
|
|
59
|
+
| ------------------- | --------- | ------------------------------------ |
|
|
60
|
+
| `timestamp` | Required | Chronological tracking |
|
|
61
|
+
| `title` | Required | Summary generation, search |
|
|
62
|
+
| `category` | Required | Pattern classification |
|
|
63
|
+
| `changes` | Required | Change tracking, design change detection |
|
|
64
|
+
| `decisions` | Required | Knowledge capture of reasoning |
|
|
65
|
+
| `errors` | When applicable | Error knowledge accumulation |
|
|
66
|
+
| `learnings` | When applicable | Generic knowledge extraction |
|
|
67
|
+
| `patterns` | When applicable | Recurring operation detection |
|
|
68
|
+
| `remaining` | When applicable | Remaining issue tracking |
|
|
69
|
+
| `skills_used` | When applicable | Usage frequency analysis |
|
|
70
|
+
| `agents_used` | When applicable | Usage frequency analysis |
|
|
71
|
+
| `commands_used` | When applicable | Usage frequency analysis |
|
|
72
|
+
| `resources_created` | When applicable | Resource change recording |
|
|
73
|
+
|
|
74
|
+
### Omission Rules
|
|
75
|
+
|
|
76
|
+
- `errors`, `learnings`, `patterns`, `remaining`, `skills_used`, `agents_used`, `commands_used`, `resources_created` may be omitted when not applicable (exclude the key entirely)
|
|
77
|
+
- `decisions` must never be omitted — always record at least one
|
|
78
|
+
- `changes` must come from git diff, never guessed
|
|
79
|
+
|
|
80
|
+
## Deduplication Check (Required)
|
|
81
|
+
|
|
82
|
+
Before appending, verify no duplicates exist:
|
|
83
|
+
|
|
84
|
+
1. Read the last 50 lines of `log.jsonl` with the Read tool
|
|
85
|
+
2. Check if any planned entry's `title` is similar to existing entries
|
|
86
|
+
3. Skip if the same session content has already been recorded
|
|
87
|
+
|
|
88
|
+
**Dedup criteria (skip if any match):**
|
|
89
|
+
- Exact title match
|
|
90
|
+
- Title keywords match AND same category
|
|
91
|
+
- Same changes (2+ matching file paths) already exist
|
|
92
|
+
- Same category + same file changes recorded within the last 24 hours
|
|
93
|
+
|
|
94
|
+
## Rules
|
|
95
|
+
|
|
96
|
+
- **timestamp MUST be obtained via `date` command. LLM must never fabricate timestamps**
|
|
97
|
+
- One log entry = one line (JSONL), appended
|
|
98
|
+
- When multiple turn summaries are provided, append one line per turn
|
|
99
|
+
- Increment timestamp by 1 second between turns to avoid duplicates
|
|
100
|
+
- `decisions` must never be omitted — always record why
|
|
101
|
+
- Logs must be fact-based. No embellishment or opinions
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bo-review-backend
|
|
3
|
+
description: Triggered for backend code and API design reviews, INCLUDING after bugfixes and implementation changes. [Required pair: bo-review-security] Auto-trigger after any implementation/bugfix to server-side code (.ts/.js/.py etc., including CLI scripts like bin/*.js), API design docs (doc/design/api), domain models. Use bo-review-frontend for frontend, bo-review-database for DB.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage Contract
|
|
7
|
+
|
|
8
|
+
When using this skill, always include the following at the beginning of your output:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
[SKILL_USED: bo-review-backend]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Backend Review Guide
|
|
17
|
+
|
|
18
|
+
Checklist for reviewing backend code.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## API Design
|
|
23
|
+
|
|
24
|
+
### RESTful Design
|
|
25
|
+
|
|
26
|
+
- [ ] Are resource names nouns in plural form (`/users`, `/orders`)?
|
|
27
|
+
- [ ] Are HTTP methods used appropriately?
|
|
28
|
+
|
|
29
|
+
| Method | Purpose | Idempotent |
|
|
30
|
+
| ------ | ------------ | ---------- |
|
|
31
|
+
| GET | Retrieve | Yes |
|
|
32
|
+
| POST | Create | No |
|
|
33
|
+
| PUT | Full update | Yes |
|
|
34
|
+
| PATCH | Partial update | Yes |
|
|
35
|
+
| DELETE | Delete | Yes |
|
|
36
|
+
|
|
37
|
+
### Status Codes
|
|
38
|
+
|
|
39
|
+
| Code | Usage |
|
|
40
|
+
| ---- | ------------------------- |
|
|
41
|
+
| 200 | Success |
|
|
42
|
+
| 201 | Created |
|
|
43
|
+
| 204 | Success (no content) |
|
|
44
|
+
| 400 | Bad request |
|
|
45
|
+
| 401 | Authentication error |
|
|
46
|
+
| 403 | Authorization error |
|
|
47
|
+
| 404 | Resource not found |
|
|
48
|
+
| 409 | Conflict |
|
|
49
|
+
| 422 | Validation error |
|
|
50
|
+
| 429 | Rate limited |
|
|
51
|
+
| 500 | Server error |
|
|
52
|
+
|
|
53
|
+
### Endpoint Design
|
|
54
|
+
|
|
55
|
+
- [ ] Does the URL express hierarchical structure (`/users/:id/orders`)?
|
|
56
|
+
- [ ] Are query parameters used appropriately (filtering, sorting, pagination)?
|
|
57
|
+
- [ ] Is the versioning strategy clear (`/v1/users` or Header)?
|
|
58
|
+
|
|
59
|
+
### Response Design
|
|
60
|
+
|
|
61
|
+
- [ ] Does it return only the minimum necessary data (Excessive Data Exposure prevention)?
|
|
62
|
+
- [ ] Is pagination implemented (cursor-based recommended)?
|
|
63
|
+
- [ ] Is the response format consistent?
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"data": { ... },
|
|
68
|
+
"meta": { "page": 1, "total": 100 },
|
|
69
|
+
"errors": []
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Domain Model
|
|
76
|
+
|
|
77
|
+
### Entity Design
|
|
78
|
+
|
|
79
|
+
- [ ] Do entities accurately represent business concepts?
|
|
80
|
+
- [ ] Is the ID generation strategy appropriate (UUID v7 recommended)?
|
|
81
|
+
- [ ] Are invariants maintained?
|
|
82
|
+
|
|
83
|
+
### Value Objects
|
|
84
|
+
|
|
85
|
+
- [ ] Are business concepts expressed using primitive types inappropriately?
|
|
86
|
+
- [ ] Are value objects immutable?
|
|
87
|
+
- [ ] Is equality determined by value?
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Bad: primitives
|
|
91
|
+
function processOrder(userId: string, amount: number) {}
|
|
92
|
+
|
|
93
|
+
// Good: value objects
|
|
94
|
+
function processOrder(userId: UserId, amount: Money) {}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Domain Logic
|
|
98
|
+
|
|
99
|
+
- [ ] Is business logic consolidated in domain objects?
|
|
100
|
+
- [ ] Is logic leaking into the service layer?
|
|
101
|
+
- [ ] Are business rules expressed as collections of if/switch statements?
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Error Handling
|
|
106
|
+
|
|
107
|
+
### Error Classification
|
|
108
|
+
|
|
109
|
+
| Type | Example | Response |
|
|
110
|
+
| -------------- | -------------------- | ----------------------- |
|
|
111
|
+
| Business error | Out of stock | Notify user |
|
|
112
|
+
| Technical error| DB connection failed | Retry + alert |
|
|
113
|
+
| Input error | Validation failed | Return details |
|
|
114
|
+
|
|
115
|
+
### Exception Handling
|
|
116
|
+
|
|
117
|
+
- [ ] Are exceptions caught at the appropriate layer?
|
|
118
|
+
- [ ] Are there swallowed exceptions (catch with no action)?
|
|
119
|
+
- [ ] Are retryable errors distinguished?
|
|
120
|
+
|
|
121
|
+
### Error Response
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"error": {
|
|
126
|
+
"code": "INSUFFICIENT_BALANCE",
|
|
127
|
+
"message": "Insufficient balance",
|
|
128
|
+
"details": { "required": 1000, "available": 500 }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- [ ] Are technical details (stack traces, etc.) not exposed?
|
|
134
|
+
- [ ] Are error codes systematic?
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Performance
|
|
139
|
+
|
|
140
|
+
### Database
|
|
141
|
+
|
|
142
|
+
- [ ] Are there N+1 query problems?
|
|
143
|
+
- [ ] Are appropriate indexes set?
|
|
144
|
+
- [ ] Is unnecessary data being fetched (avoid SELECT \*)?
|
|
145
|
+
- [ ] Is cursor-based pagination used for large datasets?
|
|
146
|
+
|
|
147
|
+
### Caching
|
|
148
|
+
|
|
149
|
+
- [ ] Has a caching strategy been considered?
|
|
150
|
+
- [ ] Is cache invalidation handled properly?
|
|
151
|
+
- [ ] Are cache keys appropriate?
|
|
152
|
+
|
|
153
|
+
| Strategy | Use case |
|
|
154
|
+
| ------------- | -------------------------- |
|
|
155
|
+
| Cache-Aside | General purpose |
|
|
156
|
+
| Write-Through | Write consistency priority |
|
|
157
|
+
| Write-Behind | Write performance priority |
|
|
158
|
+
|
|
159
|
+
### Async Processing
|
|
160
|
+
|
|
161
|
+
- [ ] Are heavy operations made asynchronous?
|
|
162
|
+
- [ ] Are timeouts configured?
|
|
163
|
+
- [ ] Is concurrency control appropriate?
|
|
164
|
+
- [ ] Is there a retry strategy (Exponential Backoff)?
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Testing
|
|
169
|
+
|
|
170
|
+
### Unit Tests
|
|
171
|
+
|
|
172
|
+
- [ ] Is domain logic tested?
|
|
173
|
+
- [ ] Are boundary values tested?
|
|
174
|
+
- [ ] Are error cases tested?
|
|
175
|
+
|
|
176
|
+
### Integration Tests
|
|
177
|
+
|
|
178
|
+
- [ ] Are API endpoints tested?
|
|
179
|
+
- [ ] Are external services mocked?
|
|
180
|
+
- [ ] Is database integration tested?
|
|
181
|
+
|
|
182
|
+
### Test Quality
|
|
183
|
+
|
|
184
|
+
- [ ] Can tests be read as specifications?
|
|
185
|
+
- [ ] Are tests tightly coupled to implementation details?
|
|
186
|
+
- [ ] Is coverage of critical paths prioritized over raw coverage numbers?
|
|
187
|
+
|
|
188
|
+
### Cross-Platform Compatibility (Node.js CLI / package.json scripts)
|
|
189
|
+
|
|
190
|
+
- [ ] Does `package.json` `test` script use a glob pattern? If so, verify it works on **Linux CI** (not just macOS/zsh).
|
|
191
|
+
- `node --test 'test/**/*.test.js'` fails on Linux because the shell does not expand single-quoted globs
|
|
192
|
+
- Fix: pass a literal path (`node --test test/cli.test.js`) or use a glob library (`glob` npm package or `--test-reporter` options)
|
|
193
|
+
- Root cause: macOS/zsh expands globs before passing to node, Linux/sh does not
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Code Quality
|
|
198
|
+
|
|
199
|
+
- [ ] Is Dependency Injection (DI) used appropriately?
|
|
200
|
+
- [ ] Are interfaces and implementations separated?
|
|
201
|
+
- [ ] Are transaction boundaries appropriate?
|
|
202
|
+
- [ ] Is resource cleanup ensured (DB connections, file handles)?
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Anti-Pattern Detection
|
|
207
|
+
|
|
208
|
+
- [ ] Is there business logic in controllers?
|
|
209
|
+
- [ ] Is there domain logic in repositories?
|
|
210
|
+
- [ ] Are there god classes (classes that do everything)?
|
|
211
|
+
- [ ] Are there circular dependencies?
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Output Format
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
## Backend Review Result
|
|
219
|
+
[LGTM / Needs Changes / Needs Discussion]
|
|
220
|
+
|
|
221
|
+
## Check Results
|
|
222
|
+
| Category | Status | Notes |
|
|
223
|
+
|----------|--------|-------|
|
|
224
|
+
| API Design | OK/NG | ... |
|
|
225
|
+
| Domain Model | OK/NG | ... |
|
|
226
|
+
| Error Handling | OK/NG | ... |
|
|
227
|
+
| Performance | OK/NG | ... |
|
|
228
|
+
| Testing | OK/NG | ... |
|
|
229
|
+
|
|
230
|
+
## Issues Found
|
|
231
|
+
- Problem: [what is the issue]
|
|
232
|
+
- Location: [file:line_number]
|
|
233
|
+
- Suggestion: [how to fix]
|
|
234
|
+
```
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bo-review-database
|
|
3
|
+
description: Triggered for DB schema, query, and migration reviews. [Required pair: bo-review-security] Targets: SQL, ORM schema definitions, DB design docs (doc/design/database). PostgreSQL-centric.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage Contract
|
|
7
|
+
|
|
8
|
+
When using this skill, always include the following at the beginning of your output:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
[SKILL_USED: bo-review-database]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Database Review Guide
|
|
17
|
+
|
|
18
|
+
Checklist for reviewing database design and queries.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Schema Design
|
|
23
|
+
|
|
24
|
+
### Table Design
|
|
25
|
+
|
|
26
|
+
- [ ] Are table names clear and consistent (snake_case, plural recommended)?
|
|
27
|
+
- [ ] Are primary keys properly set (UUID v7 recommended)?
|
|
28
|
+
- [ ] Are foreign key constraints set?
|
|
29
|
+
- [ ] Is the normalization level appropriate?
|
|
30
|
+
|
|
31
|
+
| Normalization | Criteria |
|
|
32
|
+
| ------------- | ------------------------------- |
|
|
33
|
+
| 3NF | Default (most cases) |
|
|
34
|
+
| Denormalized | Only when read performance is critical |
|
|
35
|
+
|
|
36
|
+
### Column Design
|
|
37
|
+
|
|
38
|
+
- [ ] Are column names semantically clear?
|
|
39
|
+
- [ ] Are data types appropriate?
|
|
40
|
+
|
|
41
|
+
| Use Case | Recommended Type (PostgreSQL) |
|
|
42
|
+
| --------- | ----------------------------- |
|
|
43
|
+
| ID | UUID (v7) |
|
|
44
|
+
| Money | DECIMAL / NUMERIC |
|
|
45
|
+
| Datetime | TIMESTAMPTZ |
|
|
46
|
+
| JSON | JSONB (not JSON) |
|
|
47
|
+
| Text | TEXT (VARCHAR unnecessary) |
|
|
48
|
+
| Enum | ENUM or CHECK constraint |
|
|
49
|
+
|
|
50
|
+
- [ ] Is NULL allowance appropriate (default NOT NULL)?
|
|
51
|
+
- [ ] Are default values set?
|
|
52
|
+
|
|
53
|
+
### Constraints
|
|
54
|
+
|
|
55
|
+
- [ ] Are UNIQUE constraints set where needed?
|
|
56
|
+
- [ ] Are CHECK constraints enforcing data integrity?
|
|
57
|
+
- [ ] Are CASCADE delete/update settings appropriate?
|
|
58
|
+
|
|
59
|
+
### Audit Columns
|
|
60
|
+
|
|
61
|
+
- [ ] Are `created_at` / `updated_at` present?
|
|
62
|
+
- [ ] Are `created_by` / `updated_by` present if needed?
|
|
63
|
+
- [ ] Is `deleted_at` present for soft deletes?
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Index Design
|
|
68
|
+
|
|
69
|
+
### Index Selection
|
|
70
|
+
|
|
71
|
+
- [ ] Are columns frequently used in WHERE clauses indexed?
|
|
72
|
+
- [ ] Are JOIN condition columns indexed?
|
|
73
|
+
- [ ] Have columns used in ORDER BY / GROUP BY been considered?
|
|
74
|
+
- [ ] Are foreign keys indexed?
|
|
75
|
+
|
|
76
|
+
### Index Types (PostgreSQL)
|
|
77
|
+
|
|
78
|
+
| Type | Use Case |
|
|
79
|
+
| ------ | -------------------------- |
|
|
80
|
+
| B-tree | General purpose (default) |
|
|
81
|
+
| Hash | Equality comparisons only |
|
|
82
|
+
| GIN | Arrays, JSONB, full-text search |
|
|
83
|
+
| GiST | Geographic, range |
|
|
84
|
+
| BRIN | Large data, time-series |
|
|
85
|
+
|
|
86
|
+
### Composite Indexes
|
|
87
|
+
|
|
88
|
+
- [ ] Is column order appropriate (highest selectivity first)?
|
|
89
|
+
- [ ] Has cardinality been considered?
|
|
90
|
+
- [ ] Has a covering index been considered?
|
|
91
|
+
|
|
92
|
+
### Cautions
|
|
93
|
+
|
|
94
|
+
- [ ] Are there unnecessary indexes (impact on write performance)?
|
|
95
|
+
- [ ] Has a partial index been considered?
|
|
96
|
+
- [ ] Should the index be created CONCURRENTLY?
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Query Optimization
|
|
101
|
+
|
|
102
|
+
### SELECT
|
|
103
|
+
|
|
104
|
+
- [ ] Is SELECT \* avoided?
|
|
105
|
+
- [ ] Are only necessary columns fetched?
|
|
106
|
+
- [ ] Is LIMIT used to restrict result count?
|
|
107
|
+
|
|
108
|
+
### JOIN
|
|
109
|
+
|
|
110
|
+
- [ ] Are JOIN conditions appropriate?
|
|
111
|
+
- [ ] Are there unnecessary JOINs?
|
|
112
|
+
- [ ] Is JOIN order optimal (start from smaller tables)?
|
|
113
|
+
|
|
114
|
+
### N+1 Problem
|
|
115
|
+
|
|
116
|
+
- [ ] Are queries being issued inside loops?
|
|
117
|
+
- [ ] Is necessary data fetched in bulk upfront?
|
|
118
|
+
- [ ] Is Eager Loading / Batch Loading used?
|
|
119
|
+
|
|
120
|
+
### Subqueries
|
|
121
|
+
|
|
122
|
+
- [ ] Has replacing subqueries with JOINs been considered?
|
|
123
|
+
- [ ] Are correlated subqueries avoided?
|
|
124
|
+
- [ ] Is the choice between EXISTS and IN appropriate (EXISTS is usually faster)?
|
|
125
|
+
|
|
126
|
+
### EXPLAIN
|
|
127
|
+
|
|
128
|
+
- [ ] Has the execution plan (EXPLAIN ANALYZE) been checked?
|
|
129
|
+
- [ ] Has the absence of Seq Scan been verified?
|
|
130
|
+
- [ ] Is there a discrepancy between estimated and actual row counts?
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Migrations
|
|
135
|
+
|
|
136
|
+
### Safe Migrations
|
|
137
|
+
|
|
138
|
+
- [ ] Can the migration be applied without downtime?
|
|
139
|
+
- [ ] Is a rollback procedure prepared?
|
|
140
|
+
- [ ] Has the impact on large datasets been considered?
|
|
141
|
+
|
|
142
|
+
### Expand and Contract Pattern
|
|
143
|
+
|
|
144
|
+
| Phase | Description |
|
|
145
|
+
| -------- | ------------------------------------ |
|
|
146
|
+
| Expand | Add new structure (maintain compatibility) |
|
|
147
|
+
| Migrate | Move data to new structure |
|
|
148
|
+
| Contract | Remove old structure |
|
|
149
|
+
|
|
150
|
+
### Safe Changes
|
|
151
|
+
|
|
152
|
+
| Change | Safe Method |
|
|
153
|
+
| ------------- | ---------------------------------------------- |
|
|
154
|
+
| Add column | NULL-allowed or with default value |
|
|
155
|
+
| Drop column | Stop using first, drop later |
|
|
156
|
+
| Rename column | Add new column -> migrate data -> drop old |
|
|
157
|
+
| Type change | Add new column -> convert data -> swap |
|
|
158
|
+
|
|
159
|
+
### Large Data Handling
|
|
160
|
+
|
|
161
|
+
- [ ] Is batch processing used?
|
|
162
|
+
- [ ] Can progress be checked and resumed?
|
|
163
|
+
- [ ] Is lock time minimized?
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Data Integrity
|
|
168
|
+
|
|
169
|
+
### Transactions
|
|
170
|
+
|
|
171
|
+
- [ ] Are transaction boundaries appropriate?
|
|
172
|
+
- [ ] Is the isolation level appropriate?
|
|
173
|
+
|
|
174
|
+
| Isolation Level | Use Case |
|
|
175
|
+
| --------------- | ------------------------------- |
|
|
176
|
+
| READ COMMITTED | General purpose (PostgreSQL default) |
|
|
177
|
+
| REPEATABLE READ | Reports, aggregations |
|
|
178
|
+
| SERIALIZABLE | Financial transactions, strict consistency |
|
|
179
|
+
|
|
180
|
+
- [ ] Has deadlock risk been considered?
|
|
181
|
+
- [ ] Is the choice between optimistic and pessimistic locking appropriate?
|
|
182
|
+
|
|
183
|
+
### Referential Integrity
|
|
184
|
+
|
|
185
|
+
- [ ] Are foreign key constraints appropriate?
|
|
186
|
+
- [ ] Is the choice between soft and hard deletes appropriate?
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Performance Monitoring
|
|
191
|
+
|
|
192
|
+
- [ ] Is pg_stat_statements enabled?
|
|
193
|
+
- [ ] Is slow query logging configured?
|
|
194
|
+
- [ ] Are statistics up to date (ANALYZE)?
|
|
195
|
+
- [ ] Is connection pooling properly configured?
|
|
196
|
+
|
|
197
|
+
### Recommended Tools
|
|
198
|
+
|
|
199
|
+
| Tool | Use Case |
|
|
200
|
+
| ------------------ | ----------------- |
|
|
201
|
+
| EXPLAIN ANALYZE | Query analysis |
|
|
202
|
+
| pg_stat_statements | Query statistics |
|
|
203
|
+
| pgMustard | Plan visualization|
|
|
204
|
+
| pgBadger | Log analysis |
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Migration Management
|
|
209
|
+
|
|
210
|
+
- [ ] Is a migration tool (Flyway, Prisma, etc.) being used?
|
|
211
|
+
- [ ] Are migrations version-controlled?
|
|
212
|
+
- [ ] Are rollback migrations available?
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Output Format
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
## Database Review Result
|
|
220
|
+
[LGTM / Needs Changes / Needs Discussion]
|
|
221
|
+
|
|
222
|
+
## Check Results
|
|
223
|
+
| Category | Status | Notes |
|
|
224
|
+
|----------|--------|-------|
|
|
225
|
+
| Schema Design | OK/NG | ... |
|
|
226
|
+
| Indexes | OK/NG | ... |
|
|
227
|
+
| Query Optimization | OK/NG | ... |
|
|
228
|
+
| Migrations | OK/NG | ... |
|
|
229
|
+
| Data Integrity | OK/NG | ... |
|
|
230
|
+
|
|
231
|
+
## Issues Found
|
|
232
|
+
- Problem: [what is the issue]
|
|
233
|
+
- Location: [table name / query]
|
|
234
|
+
- Suggestion: [how to fix]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## References
|
|
240
|
+
|
|
241
|
+
- [PostgreSQL Documentation](https://www.postgresql.org/docs/current/)
|
|
242
|
+
- [Use The Index, Luke](https://use-the-index-luke.com/)
|
|
243
|
+
- [pgMustard](https://www.pgmustard.com/)
|