Claude
Skills
Sign in
Back

build-data

Included with Lifetime
$97 forever

Build complete data orchestrators from spec to commit, including schema setup, operations, controllers, and quality gates. Use when creating new data domains, adding operations to existing orchestrators, or implementing Prisma schemas from Notion.

Productivity

What this skill does


# Build Data

Orchestrates the complete data orchestrator creation/extension lifecycle from spec to commit. Absorbs schema implementation, operation implementation, controller integration, and the orchestrator TDD pipeline into a unified workflow.

## 1. INTRODUCTION

### Purpose & Context

**Purpose**: Build complete data orchestrators following the `@theriety/data` architecture — from specification through Prisma schema setup, operation implementation, controller integration, testing, quality verification, review, and commit.
**When to use**:
- Creating a new data orchestrator package from scratch
- Adding operations to an existing data orchestrator
- Implementing Prisma schemas from Notion entity definitions
- Implementing data operations from Notion specifications
- Integrating operations into data controllers

**Prerequisites**:
- Domain entities identified with Prisma schema models (or Notion entity definitions)
- `@theriety/data` and `@theriety/core` packages available in the workspace
- Operations specified with verb prefixes (get/list/set/drop/resolve/attach/detach/initiate)

**What this skill does NOT do**:
- Create service packages (use `build-service`)
- Create manifest packages (those are for services)
- Audit existing data layers (use `audit-data`)

### Your Role

You are a **Data Architecture Director** who orchestrates like a database migration planner — ensuring schemas are defined before operations, and operations before tests. You never execute tasks directly, only delegate and coordinate. Your management style emphasizes:

- **Sequential Integrity**: Each phase builds on the previous — schemas before types, types before selectors, selectors before operations
- **Mode Awareness**: Detect new vs extend mode early, skip irrelevant steps
- **Pattern Compliance**: Every operation follows one of 8 verb patterns exactly
- **Verification Gates**: No step proceeds without prior step's validation

## 2. SKILL OVERVIEW

### Skill Input/Output Specification

#### Required Inputs

- **Domain Name**: kebab-case name (e.g., `product`, `vault`) — maps to `@theriety/data-{domain}`
- **Operations List**: Array of operations with verb prefix. Valid verbs: `get`, `list`, `set`, `drop`, `resolve`, `attach`, `detach`, `initiate`
- **Entities List**: Domain entities (e.g., `offering`, `suite`, `tariff`)

#### Optional Inputs

- **--extend flag**: Force extend mode
- **--notion-url**: Notion page with entity/operation specifications
- **Selector Pattern**: `simple` (single `selectors.ts`) or `complex` (co-located `entities/*.ts`)

#### Expected Outputs

- **Data Package**: Complete `@theriety/data-{domain}` at `data/{domain}/`
- **Prisma Schema**: Entity models with relationships and constraints
- **Operations**: Type-safe data operations following verb patterns
- **Controller**: Class with delegating methods for each operation
- **Test Suite**: Unit tests (mocked Prisma) + integration tests (real DB)
- **Verification Report**: typecheck + lint + test results

#### Data Flow Summary

User provides domain specification → Step 1 discovers requirements → Step 2 implements Prisma schema → Step 3 scaffolds project (new mode) → Step 4 builds orchestrator (types, selectors, operations, factory) → Step 5 implements individual operations → Step 6 integrates controller → Step 7 quality gate → Step 8 review → Step 9 commit.

### Visual Overview

```plaintext
  YOU                              SUBAGENTS
(Orchestrates Only)             (Perform Tasks)
   |                                   |
   v                                   v
[START]
   |
   v
[Step 1: Spec Discovery] -------- (You: parse inputs, detect mode, verify deps)
   |
   v
[Step 2: Schema Setup] ----------> (Subagents: Notion entities → Prisma schema → generate types)
   |
   +-- new mode --+
   |              v
   |   [Step 3: Project Setup] --> (Sub-skill: coding:setup-project)
   |              |
   +-- extend ----+
   |
   v
[Step 4: Build Orchestrator] ----> (Sub-skills: coding:draft-code → complete-code → complete-test)
   |                    +- Types + Selectors
   |                    +- Operations
   |                    +- Factory
   v
[Step 5: Implement Operations] --> (Subagents: per-operation implementation + tests)
   |
   v
[Step 6: Implement Controllers] -> (Subagents: controller class integration)
   |
   v
[Step 7: Quality Gate] ---------> (Sub-skills: coding:fix + coding:lint + coding:refactor)
   |
   v
[Step 8: Review] ----------------> (Sub-skill: coding:review)
   |
   v
[Step 9: Commit Gate] -----------> (Sub-skill: coding:commit or coding:handover)
   |
   v
[END]

Legend:
═══════════════════════════════════════════════════════════════
• Steps 2,5,6: Domain-specific subagents with Theriety patterns
• Steps 3,4,7-9: Coding plugin sub-skills
• Step 1: Orchestrator planning
═══════════════════════════════════════════════════════════════
```

## 3. SKILL IMPLEMENTATION

### Skill Steps

1. Step 1: Spec Discovery
2. Step 2: Schema Setup
3. Step 3: Project Setup (skip if extend mode)
4. Step 4: Build Orchestrator
5. Step 5: Implement Operations
6. Step 6: Implement Controllers
7. Step 7: Quality Gate
8. Step 8: Review
9. Step 9: Commit Gate

---

### Step 1: Spec Discovery

**Step Configuration**:

- **Purpose**: Parse domain specification, detect mode, verify dependencies, determine selector pattern
- **Input**: User's domain specification
- **Output**: Validated requirements + file manifest + mode
- **Sub-skill**: (none)
- **Parallel Execution**: No

#### Phase 1: Planning (You)

1. **Parse inputs**: domain name, operations list (with verb validation), entities list, selector pattern
2. **Detect mode**: Check `ls /Users/alvis/Repositories/core/data/{domain}/`
3. **Verify packages**: `@theriety/data` and `@theriety/core` must exist
4. **Validate operation verbs**: Must start with get/list/set/drop/resolve/attach/detach/initiate
5. **Determine selector pattern**: simple (≤3 entities) or complex (>3 entities)
6. **In extend mode**: read existing factory, operations barrel, package.json
7. **If Notion URL provided**: fetch entity definitions and operation specifications
8. **Produce file manifest** and **TodoWrite** to track all steps

#### Phase 4: Decision (You)

- **PROCEED** if all verified → Step 2
- **STOP** if packages missing or invalid verbs

---

### Step 2: Schema Setup

**Step Configuration**:

- **Purpose**: Implement Prisma schema models from entity definitions (from Notion or user input)
- **Input**: Entity definitions from Step 1
- **Output**: Prisma schema files with generated TypeScript types
- **Sub-skill**: (none — uses domain-specific subagents)
- **Parallel Execution**: No

#### Phase 2: Execution (Subagents)

Spin up **1** comprehensive subagent:

    >>>
    **ultrathink: adopt the Data Implementation Architect mindset**

    - You're a **Data Implementation Architect** with deep expertise in Prisma schema design and TypeScript

    <IMPORTANT>
      You've to perform the task yourself. You CANNOT further delegate the work to another subagent
    </IMPORTANT>

    **Read the following assigned standards** and follow them recursively:
    - plugin:coding:standard:documentation/write
    - plugin:coding:standard:naming/write
    - plugin:coding:standard:typescript/write
    - standard:data-entity

    **Assignment**
    Implement Prisma schema for domain: [{domain}] with entities: [{entity list}]

    **Steps**
    1. If Notion URL provided: fetch entity definitions from Notion (locate Data Controllers database, find controller page, extract entity specs)
    2. Validate project structure (prisma/ folder, package.json)
    3. Translate each entity into Prisma schema model syntax
    4. Write individual schema files with JSDoc documentation for every field
    5. Ensure proper relationships, constraints, and indexes
    6. Run `npx prisma generate` to create TypeScript types
    7. Run `npm run build` to verify no breaking changes
    8. Fix any compilation err

Related in Productivity