ワンクリックで
retro-data-model
Extracts data models, entity schemas, relationships, validation rules, and state machines from legacy code
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Extracts data models, entity schemas, relationships, validation rules, and state machines from legacy code
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
| name | retro-data-model |
| description | Extracts data models, entity schemas, relationships, validation rules, and state machines from legacy code |
| argument-hint | Invoked by Retro-Spec Coordinator - do not call directly |
This skill is invoked by the Retro-Spec Coordinator as the second extraction skill. It analyzes the legacy codebase to extract data models, entity definitions, relationships, validation rules, and state machines, producing Section 7 (Data Model) and companion artifacts.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | accumulator_path | Path to the spec file being built |
| 3 | artifacts_dir | Path to companion artifacts directory |
| 4 | discovery_manifest_path | Path to the discovery manifest |
| 5 | source_path | Path to the legacy source code |
| 6 | target_language | Target language for artifacts |
| 7 | project_name | Name of the project |
| 8 | module_filter | Modules to analyze |
#tool:search/usages to trace entity relationships and #tool:search/searchSubagent to discover model definitions.data-schemas.<ext> and state-machines.<ext> in the artifacts directory[INFERRED: confidence] for every entity and relationship claimSearch for data model definitions in priority order:
ORM Models (highest confidence):
grep "Model.init|define\(|@Table|@Column" in *.ts, *.jsschema.prisma file -- each model block is an entitygrep "@Entity|@Column|@PrimaryColumn" in *.tsgrep "models.Model|models.CharField|models.ForeignKey" in *.pygrep "Base|Column|relationship|ForeignKey" in *.pygrep "gorm.Model" in *.gogrep "< ApplicationRecord|< ActiveRecord" in *.rbgrep "DbSet|DbContext|\[Key\]|\[Required\]" in *.csDatabase Migrations (high confidence):
migrations/, db/migrate/, alembic/Schema Files (high confidence):
*.sql in schema/, db/, sql/*.graphql, *.gql*.proto*.schema.jsonopenapi.yaml, swagger.jsonTypeScript/Language Interfaces (medium confidence):
types/, interfaces/, models/API Response Shapes (lower confidence):
For each identified entity:
Read the source file containing the entity definition
Extract fields: name, type, nullability, default value, constraints
Map types to portable types:
| Source Type | Portable Type |
|---|---|
VARCHAR(N), string, String, str | string (max: N) |
INT, INTEGER, number, int, i32 | integer |
FLOAT, DOUBLE, DECIMAL, f64 | float |
BOOLEAN, bool, Boolean | boolean |
TIMESTAMP, DATETIME, DateTime | datetime |
DATE | date |
UUID, Uuid | UUID |
JSON, JSONB, dict, object | JSON |
TEXT, LONGTEXT | text |
ENUM(...) | enum (list values) |
BLOB, BYTEA, bytes | binary |
Extract constraints:
@Unique, unique=True)NOT NULL, required, !)Extract indexes:
belongsTo / ManyToOne / ForeignKey -> N:1hasMany / OneToMany -> 1:NhasOne / OneToOne -> 1:1belongsToMany / ManyToMany / junction tables -> N:MSearch for validation logic associated with each entity:
validate*, check*, is_validIdentify entities with state/status fields and their transitions:
status/state/phase: Extract all enum valuesFor each state machine, document:
## 7. Data Model
### 7.1 <Entity Name>
<One-line description of the entity's purpose>
[INFERRED: confidence] Source: <file:lines>
| Field | Type | Required | Constraints | Default | Description |
|-------|------|----------|-------------|---------|-------------|
| id | UUID | yes | primary key | generated | Unique identifier |
| name | string | yes | max 255 | - | <description> |
| status | <EnumName> (enum) | yes | see state machine | "draft" | Current state |
#### Relationships
| Related Entity | Cardinality | FK Location | Cascade | Source |
|---------------|-------------|-------------|---------|--------|
| <Entity B> | 1:N | <Entity B>.entity_a_id | CASCADE | <file:line> |
#### Validation Rules
- <Rule description> [INFERRED: confidence] Source: <file:line>
#### Indexes
| Name | Columns | Type | Source |
|------|---------|------|--------|
| idx_entity_email | email | unique | <migration file:line> |
(If state machine detected:)
#### State Machine: <EnumName>
**States**: `draft`, `active`, `archived`
| From | To | Trigger | Guard | Source |
|------|-----|---------|-------|--------|
| draft | active | publish() | all fields valid | <file:line> |
| active | archived | archive() | no pending refs | <file:line> |
Produce typed entity definitions in the TARGET language:
// Generated by: retro-data-model skill (retro-spec)
// Source legacy code: <source_path>
// Target language: TypeScript
// Confidence: HIGH
// DO NOT EDIT MANUALLY -- regenerated on retro-spec re-run
export interface User {
id: string; // UUID, primary key
email: string; // max 255, unique, email format
name: string; // max 100
status: UserStatus; // enum, default "active"
createdAt: Date; // immutable
updatedAt: Date;
}
export enum UserStatus {
ACTIVE = "active",
INACTIVE = "inactive",
SUSPENDED = "suspended",
}
Produce state machine definitions in the TARGET language (only if state machines were detected):
// Generated by: retro-data-model skill (retro-spec)
// Source legacy code: <source_path>
// Target language: TypeScript
// Confidence: MEDIUM
// DO NOT EDIT MANUALLY -- regenerated on retro-spec re-run
export const UserStatusTransitions: Record<UserStatus, UserStatus[]> = {
[UserStatus.ACTIVE]: [UserStatus.INACTIVE, UserStatus.SUSPENDED],
[UserStatus.INACTIVE]: [UserStatus.ACTIVE],
[UserStatus.SUSPENDED]: [UserStatus.ACTIVE],
};