From zenbu-powers
處理 Given 步驟中建立 Aggregate 初始狀態的 handler 參考文件。觸發關鍵字:「的...為」「包含」「存在」「有」。 非 user-invocable,由 /aibdd.auto.php.it.red 在實作測試方法時載入。
npx claudepluginhub zenbuapps/zenbu-powers --plugin zenbu-powersThis skill uses the workspace's default tool permissions.
本 handler 適用於 **Given** 步驟中描述 Aggregate 初始狀態存在的語句:
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Guides code writing, review, and refactoring with Karpathy-inspired rules to avoid overcomplication, ensure simplicity, surgical changes, and verifiable success criteria.
Share bugs, ideas, or general feedback.
本 handler 適用於 Given 步驟中描述 Aggregate 初始狀態存在的語句:
關鍵字:為、包含、存在、有、已建立(描述既有狀態時)
使用 WP Factory Methods + Repository.save() 將資料寫入真實 WordPress DB,並把自然鍵 → WP ID 映射存入 $this->ids,供後續步驟引用。
| Handler | 時機 | 目的 | 方法 |
|---|---|---|---|
| aggregate-given | Given | 建立初始狀態(fixture) | Factory + Repository.save() |
| command | Given/When | 執行寫入操作(業務行為) | Service.xxx() |
| query | When | 執行讀取操作 | Service.getXxx() → $this->queryResult |
| aggregate-then | Then | 驗證 DB 狀態 | Repository.findXxx() + assert |
aggregate-given 僅負責「讓資料存在」,不觸發任何業務邏輯流程。
$this->factory()->xxx->create([...]) 取得 ID。$this->ids['Alice'] = $userId;new LessonProgress($userId, 1, 50, 'IN_PROGRESS')。$wpdb->insert)。Given 用戶 "Alice" 在課程 1 的進度為 50%,狀態為 "進行中"
$userId = $this->factory()->user->create(['display_name' => 'Alice']);
$this->ids['Alice'] = $userId;
$progress = new LessonProgress($userId, 1, 50, 'IN_PROGRESS');
$this->repos->lessonProgress->save($progress);
| Factory | 回傳 | 常用參數 |
|---|---|---|
$this->factory()->user->create([...]) | User ID | display_name, user_login, user_email, role |
$this->factory()->post->create([...]) | Post ID | post_title, post_type, post_status, post_author |
$this->factory()->term->create([...]) | Term ID | name, slug, taxonomy |
$this->factory()->category->create([...]) | Category ID | name, slug |
$this->factory()->attachment->create([...]) | Attachment ID | post_title, post_parent |
Given 系統中有以下用戶:
| 姓名 | 角色 |
| Alice | administrator |
| Bob | subscriber |
$users = [
['姓名' => 'Alice', '角色' => 'administrator'],
['姓名' => 'Bob', '角色' => 'subscriber'],
];
foreach ($users as $row) {
$userId = $this->factory()->user->create([
'display_name' => $row['姓名'],
'role' => $row['角色'],
]);
$this->ids[$row['姓名']] = $userId;
}
Given 用戶 "Alice" 的購物車中有以下商品:
| 商品 ID | 數量 |
| PROD-001 | 2 |
| PROD-002 | 1 |
$userId = $this->ids['Alice'];
$items = [
['商品 ID' => 'PROD-001', '數量' => 2],
['商品 ID' => 'PROD-002', '數量' => 1],
];
foreach ($items as $row) {
$item = new CartItem($userId, $row['商品 ID'], (int) $row['數量']);
$this->repos->cartItem->save($item);
}
| 中文 | Enum 值 | 使用情境 |
|---|---|---|
| 進行中 | IN_PROGRESS | Progress, Status |
| 已完成 | COMPLETED | Progress, Status |
| 未開始 | NOT_STARTED | Progress, Status |
| 已付款 | PAID | Order |
| 待付款 | PENDING | Order |
| 已取消 | CANCELLED | Order |
specs/*/erm.dbml,禁止猜測。stdClass。$this->repos->xxx->save(),禁止直接 $wpdb。$this->ids["{natural_key}"],key 為 Gherkin 可讀的自然鍵。$this->ids 中。save() 方法應處理 insert/update 雙情境,避免重複資料。$this->ids$wpdb 操作