trace-data-transformation

Maps data transformation chains — Request DTO to Command to Entity to Response DTO. Identifies mappers, serializers, type conversions, and data loss points across layer boundaries.

59 stars

Best use case

trace-data-transformation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Maps data transformation chains — Request DTO to Command to Entity to Response DTO. Identifies mappers, serializers, type conversions, and data loss points across layer boundaries.

Teams using trace-data-transformation should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/trace-data-transformation/SKILL.md --create-dirs "https://raw.githubusercontent.com/dykyi-roman/awesome-claude-code/main/skills/trace-data-transformation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/trace-data-transformation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How trace-data-transformation Compares

Feature / Agenttrace-data-transformationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Maps data transformation chains — Request DTO to Command to Entity to Response DTO. Identifies mappers, serializers, type conversions, and data loss points across layer boundaries.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Data Transformation Tracer

## Overview

Traces how data transforms as it passes through application layers — from raw HTTP input through DTOs, Commands, Entities, and back to Response objects. Identifies mappers, serializers, converters, and potential data loss points.

## Transformation Chain Patterns

### Standard CQRS Chain

```
HTTP Request Body (JSON/Form)
  → Request DTO (validated input)
    → Command/Query (application layer input)
      → Entity/Aggregate (domain model)
        → Domain Event (side effect data)
        → Response DTO (output format)
          → HTTP Response (JSON/XML)
```

### Detection Patterns

#### Input Transformation

```bash
# Request DTOs / Form Requests
Grep: "class.*Request|class.*Input" --glob "**/Api/**/*.php"
Grep: "class.*Request" --glob "**/Presentation/**/*.php"

# Request to Command mapping
Grep: "new.*Command\\(|Command::from|Command::create" --glob "**/*.php"

# Deserialization
Grep: "deserialize|fromArray|fromRequest|fromJson" --glob "**/*.php"
Grep: "Serializer::deserialize|denormalize" --glob "**/*.php"
```

#### Entity Transformation

```bash
# Entity factories / named constructors
Grep: "static function (create|from|of|new)" --glob "**/Domain/**/*.php"

# Entity to DTO conversion
Grep: "function (toArray|toDTO|toResponse|toView)" --glob "**/Domain/**/*.php"
Grep: "::fromEntity|::fromDomain|::fromModel" --glob "**/*.php"
```

#### Output Transformation

```bash
# Response DTOs
Grep: "class.*Response|class.*Output|class.*View" --glob "**/Api/**/*.php"
Grep: "class.*Resource" --glob "**/Http/**/*.php"

# Serialization
Grep: "jsonSerialize|toArray|normalize" --glob "**/*.php"
Grep: "JsonResponse|json_encode" --glob "**/*.php"

# Collection transformation
Grep: "->map\\(|array_map|->transform" --glob "**/*.php"
```

#### Mappers and Converters

```bash
# Explicit mapper classes
Grep: "class.*Mapper|class.*Converter|class.*Transformer|class.*Assembler" --glob "**/*.php"

# Mapping methods
Grep: "function (map|convert|transform|assemble|adapt)" --glob "**/*.php"

# AutoMapper / Symfony Serializer
Grep: "AutoMapper|ObjectNormalizer|PropertyNormalizer" --glob "**/*.php"
```

## Analysis Process

### Step 1: Identify Transformation Points

For a given request flow:
1. **Read the entry point** — what data format comes in
2. **Find each class boundary** — where data changes shape
3. **Read constructor/factory** — what fields are mapped
4. **Track field names** — which fields are renamed, combined, or dropped

### Step 2: Map Field Transformations

| Source | Target | Transformation |
|--------|--------|---------------|
| `request.customer_name` | `CreateOrderCommand.customerName` | snake_case → camelCase |
| `command.customerId` | `Customer entity` | ID → full entity (repo lookup) |
| `entity.createdAt` | `response.created_at` | DateTime → string ISO 8601 |
| `entity.money` | `response.amount` | Money VO → float |

### Step 3: Identify Data Loss Points

Check for:
- Fields present in source but missing in target
- Type narrowing (DateTime → string, loses timezone)
- Precision loss (float → int)
- Relationship flattening (Entity → ID only)

## Output Format

```markdown
## Data Transformation Map

### Flow: Create Order

#### Transformation Chain

```
[1] JSON Input
    {
      "customer_id": "uuid-123",
      "items": [{"product_id": "p-1", "quantity": 2}],
      "shipping_address": {"street": "...", "city": "..."}
    }
         │
         ▼  (Deserialization + Validation)
[2] CreateOrderRequest
    customerId: string (validated: uuid format)
    items: CreateOrderItemRequest[] (validated: non-empty)
    shippingAddress: AddressRequest (validated: all fields required)
         │
         ▼  (Mapping: CreateOrderRequest → CreateOrderCommand)
[3] CreateOrderCommand
    customerId: CustomerId (Value Object wrapping)
    items: OrderItemData[] (DTO with productId + quantity)
    shippingAddress: AddressData (DTO)
         │
         ▼  (Domain Factory: Order::create())
[4] Order Entity
    id: OrderId (generated)
    customerId: CustomerId
    items: OrderItem[] (entities with calculated prices)
    total: Money (calculated from items)
    status: OrderStatus::Pending
    shippingAddress: ShippingAddress (Value Object)
    createdAt: DateTimeImmutable
         │
         ▼  (Response Mapping: OrderResponse::fromEntity())
[5] OrderResponse
    id: string (OrderId → string)
    customerId: string (CustomerId → string)
    items: OrderItemResponse[] (entity → response)
    total: float (Money → float, currency separate)
    currency: string (from Money)
    status: string (enum → string)
    shippingAddress: AddressResponse
    createdAt: string (ISO 8601)
         │
         ▼  (JSON Serialization)
[6] JSON Output
    {"id": "...", "customer_id": "...", "total": 150.00, ...}
```

#### Field Mapping Table

| Layer | Field | Type | Source | Transformation |
|-------|-------|------|--------|---------------|
| Input → Request | customer_id → customerId | string | JSON key | snake → camel |
| Request → Command | customerId → customerId | string → CustomerId | DTO | Wrap in VO |
| Command → Entity | items → OrderItem[] | DTO[] → Entity[] | Factory | Enrich with prices |
| Entity → Response | total → total | Money → float | Mapper | Extract amount |
| Entity → Response | createdAt → createdAt | DateTimeImmutable → string | Mapper | Format ISO 8601 |
| Response → JSON | customerId → customer_id | string | Serializer | camel → snake |

#### Data Enrichment Points

| Step | What's Added | Source |
|------|-------------|--------|
| Command → Entity | OrderId | Generated (UUID) |
| Command → Entity | Item prices | ProductRepository lookup |
| Command → Entity | Total amount | Calculated from items |
| Command → Entity | Created timestamp | System clock |
| Command → Entity | Initial status | Domain default (Pending) |

#### Potential Data Loss Points

| Step | Field | Issue |
|------|-------|-------|
| Money → float | precision | Floating point precision loss |
| DateTime → string | timezone | Check if timezone preserved |
| Entity → Response | internal state | Domain internals not exposed (expected) |
```

## Transformation Quality Indicators

| Indicator | Good | Warning |
|-----------|------|---------|
| Type safety | Typed DTOs at boundaries | Untyped arrays |
| Validation | At input boundary | Scattered or missing |
| Mapping | Explicit mapper/factory | Implicit in controller |
| Value Objects | Domain uses VOs | Primitives throughout |
| Serialization | Controlled (toArray/normalize) | json_encode on entity |

## Common Anti-Patterns

| Anti-Pattern | Detection | Issue |
|-------------|-----------|-------|
| Entity as Response | `return json_encode($entity)` | Exposes internals |
| Array transport | `$data = ['key' => $value]` | No type safety |
| Missing DTO | Controller → Repository direct | Skips validation |
| Leaky abstraction | Domain types in API response | Tight coupling |

## Integration

This skill is used by:
- `data-flow-analyst` — documents data transformation chains
- `trace-request-lifecycle` — enriches lifecycle with data details
- `explain-business-process` — shows data perspective of processes

Related Skills

trace-request-lifecycle

59
from dykyi-roman/awesome-claude-code

Traces full request lifecycle from Router through Middleware, Controller, UseCase, Repository to Response. Documents HTTP methods, routes, middleware stack, response codes, and error handling paths.

check-sensitive-data

59
from dykyi-roman/awesome-claude-code

Analyzes PHP code for sensitive data exposure. Detects plaintext secrets, exposed credentials, PII in logs, insecure storage, hardcoded keys.

check-database-scaling

59
from dykyi-roman/awesome-claude-code

Analyzes PHP code for database scaling issues. Detects single DB connection for all queries, missing read replica configuration, SELECT queries hitting master, and missing connection pooling.

yii-knowledge

59
from dykyi-roman/awesome-claude-code

Yii framework knowledge base. Provides Yii3 modular architecture, DDD integration, PSR-7/PSR-15 compliance, persistence, DI, security (RBAC, auth), event system (PSR-14), queue/jobs, infrastructure components (cache, rate limiter, HTTP client), testing, and antipatterns for Yii PHP projects.

troubleshooting-template

59
from dykyi-roman/awesome-claude-code

Generates troubleshooting guides and FAQ sections for PHP projects. Creates problem-solution documentation.

testing-knowledge

59
from dykyi-roman/awesome-claude-code

Testing knowledge base for PHP 8.4 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

task-progress-knowledge

59
from dykyi-roman/awesome-claude-code

TaskCreate pattern guidelines for progress tracking in coordinator agents

symfony-knowledge

59
from dykyi-roman/awesome-claude-code

Symfony framework knowledge base. Provides architecture, DDD integration, persistence, DI, security, messenger, workflow, events, infrastructure components, testing, and antipatterns for Symfony PHP projects.

suggest-testability-improvements

59
from dykyi-roman/awesome-claude-code

Suggests testability improvements for PHP code. Provides DI refactoring suggestions, mock opportunities, interface extraction, testing strategy recommendations.

suggest-simplification

59
from dykyi-roman/awesome-claude-code

Suggests code simplification opportunities. Identifies extract method candidates, complex expressions, redundant code, refactoring opportunities.

stability-patterns-knowledge

59
from dykyi-roman/awesome-claude-code

Stability Patterns knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Circuit Breaker, Retry, Rate Limiter, Bulkhead, and resilience audits.

solid-knowledge

59
from dykyi-roman/awesome-claude-code

SOLID principles knowledge base for PHP 8.4 projects. Provides quick reference for SRP, OCP, LSP, ISP, DIP with detection patterns, PHP examples, and antipattern identification. Use for architecture audits and code quality reviews.