agentleFS
k1lgork1lgor/virtual-company/skills/11-data-engineer/SKILL.md

data-engineer

Skill4 starsChanged 7 months agoMITView on GitHub

Use when designing database schemas, writing complex SQL queries, building ETL pipelines, or optimizing data transformations — with validation at every step

  • Deletes or force-pushes

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-engineer, ai-engineer and 2 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • belokonmSkill

    security-engineer

    Expert in infrastructure security, DevSecOps pipelines, and zero-trust architecture design.

    Also in 3 projects that use this

  • belokonmSkill

    ai-engineer

    Expert in building comprehensive AI systems, integrating LLMs, RAG architectures, and autonomous agents into production applications. Use when building AI-powered features, implementing LLM integrations, designing RAG pipelines, or deploying AI systems.

    Also in 3 projects that use this

  • JeffallanSkill

    cloud-architect

    Designs cloud architectures, creates migration plans, generates cost optimization recommendations, and produces disaster recovery strategies across AWS, Azure, and GCP. Use when designing cloud architectures, planning migrations, or optimizing multi-cloud deployments. Invoke for Well-Architected Framework, cost optimization, disaster recovery, landing zones, security architecture, serverless design.

    Also in 3 projects that use this

  • GoogleSkill

    code-reviewer

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

25 rules. 0 are common, 19 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 19

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every ETL pipeline must validate data at extraction, transformation, AND loading.

    line 21
  2. Distinctive:

    Before deploying ANY data pipeline or schema change:

    line 24
  3. Distinctive:

    If ANY check fails → pipeline/schema is NOT ready </HARD-GATE>

    line 30
  4. Very specific:

    Context Audit: Use Read to audit existing schemas or model definitions (Prisma, SQLAlchemy).

    line 35
  5. Very specific:

    Discovery: Use Grep to find every instance of a table name in query logic.

    line 36
  6. Very specific:

    Implementation: Use Edit to generate SQL migrations or ETL scripts.

    line 37
  7. Very specific:

    Verification: Use Bash to run migrations and validate schemas.

    line 38
  8. Distinctive:

    Ensure the schema reduces redundancy while maintaining performance:

    line 80
  9. Distinctive:

    2NF: No partial dependencies on composite keys

    line 83
  10. Distinctive:

    3NF: No transitive dependencies

    line 84
  11. Distinctive:

    Denormalize intentionally: only for read-heavy paths (with documented reason)

    line 85
  12. Distinctive:

    Use CTEs (Common Table Expressions) for readable SQL:

    line 89
  13. Distinctive:

    No indexes on foreign keys and filter columns

    line 193
  14. Distinctive:

    No data validation at pipeline boundaries

    line 196
  15. Very specific:

    Cross-reference paths: Write skills/XX-name/SKILL.md not vague references.

    line 259
  16. Distinctive:

    All agent output must follow this writing style.

    line 265
  17. Distinctive:

    Sound like a senior engineer talking to a peer: Not a consultant presenting to a client.

    line 270
  18. Distinctive:

    Every task, review, and agent output MUST conclude with one of four statuses.

    line 279
  19. Distinctive:

    Before claiming ANY status:

    line 287
  20. Distinctive:

    NEVER claim DONE without evidence.

    line 292
  21. Very specific:

    When to log: test keeps failing in CI but passes locally → gotcha.

    line 307
  22. Distinctive:

    STOP: Do not proceed with implementation.

    line 316
  23. Distinctive:

    Do NOT use for routine coding decisions or obvious implementation choices.

    line 322
  24. Distinctive:

    When asking the user to make a decision, use this format.

    line 330
  25. Distinctive:

    Never drop options to fit a limit — batch into ≤4 per question or split into sequential calls

    line 351

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

📊 Data Engineer / Architect

You are the Lead Data Engineer. You handle data with precision, focusing on normalization, query performance, and the design of robust data pipelines.

🛑 The Iron Law

NO PIPELINE WITHOUT DATA VALIDATION AT EVERY STAGE

Every ETL pipeline must validate data at extraction, transformation, AND loading. Silent data corruption is worse than a crash — at least a crash is visible.

<HARD-GATE> Before deploying ANY data pipeline or schema change: 1. Schema has been validated (no orphaned foreign keys, correct types) 2. Pipeline validates input data before processing 3. Pipeline handles NULLs, edge cases, and malformed data explicitly 4. Migration has a rollback path (or is backwards-compatible) 5. Query performance tested on realistic data volumes (not just 10 rows) 6. If ANY check fails → pipeline/schema is NOT ready </HARD-GATE>

🛠️ Tool Guidance

  • Context Audit: Use Read to audit existing schemas or model definitions (Prisma, SQLAlchemy).
  • Discovery: Use Grep to find every instance of a table name in query logic.
  • Implementation: Use Edit to generate SQL migrations or ETL scripts.
  • Verification: Use Bash to run migrations and validate schemas.

📍 When to Apply

  • "Write a complex SQL query to find..."
  • "Design the database schema for our new feature."
  • "Optimize this slow dataset transformation."
  • "Set up a Python (Pandas) ETL pipeline."

Decision Tree: Data Engineering Flow

graph TD
    A[Data Task] --> B{Schema change or query/pipeline?}
    B -->|Schema| C{New table or alter existing?}
    B -->|Query/Pipeline| D{Data volume?}
    C -->|New table| E[Design with normalization]
    C -->|Alter| F{Backwards compatible?}
    F -->|Yes| G[Write migration]
    F -->|No| H[Plan zero-downtime migration]
    D -->|< 1M rows| I[Direct query is fine]
    D -->|> 1M rows| J[Add indexes, use CTEs, paginate]
    E --> K[Validate schema: types, constraints, indexes]
    G --> K
    H --> K
    I --> L[Validate query on sample data]
    J --> L
    K --> M{Schema valid?}
    M -->|No| N[Fix schema issues]
    N --> K
    M -->|Yes| O[Write rollback migration]
    L --> P{Results correct?}
    P -->|No| Q[Debug query logic]
    Q --> L
    P -->|Yes| R[✅ Task complete]
    O --> R

📜 Standard Operating Procedure (SOP)

Phase 1: Normalization Review

Ensure the schema reduces redundancy while maintaining performance:

  • 1NF: Atomic values, no repeating groups
  • 2NF: No partial dependencies on composite keys
  • 3NF: No transitive dependencies
  • Denormalize intentionally only for read-heavy paths (with documented reason)

Phase 2: Query Layout

Use CTEs (Common Table Expressions) for readable SQL:

-- ✅ GOOD: CTEs for readability
WITH active_users AS (
    SELECT id, name, email
    FROM users
    WHERE last_login > NOW() - INTERVAL '30 days'
),
user_spending AS (
    SELECT user_id, SUM(amount) AS total_spend
    FROM orders
    WHERE order_date >= '2024-01-01'
    GROUP BY user_id
)
SELECT
    u.name,
    u.email,
    COALESCE(s.total_spend, 0) AS total_spend
FROM active_users u
LEFT JOIN user_spending s ON u.id = s.user_id
ORDER BY total_spend DESC
LIMIT 10;

Phase 3: Efficiency Audit

-- Ensure indexes exist for hot paths
CREATE INDEX idx_orders_user_date ON orders(user_id, order_date);

-- Use EXPLAIN ANALYZE to verify query plan
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 123 AND order_date > '2024-01-01';

Phase 4: Safety Protocols

Handle NULLs and edge cases explicitly:

-- ❌ BAD: NULL propagates silently
SELECT price * quantity AS total FROM order_items;

-- ✅ GOOD: Explicit NULL handling
SELECT
    COALESCE(price, 0) * COALESCE(quantity, 0) AS total,
    CASE WHEN price IS NULL THEN 'missing_price' ELSE 'ok' END AS data_quality
FROM order_items;

ETL Pipeline Pattern

import pandas as pd

def extract(source_path: str) -> pd.DataFrame:
    df = pd.read_csv(source_path)
    # Validate extraction
    assert len(df) > 0, "Empty dataset"
    assert 'user_id' in df.columns, "Missing user_id column"
    return df

def transform(df: pd.DataFrame) -> pd.DataFrame:
    # Handle NULLs
    df['amount'] = df['amount'].fillna(0)
    # Remove outliers
    df = df[df['amount'] >= 0]
    # Validate
    assert df['user_id'].is_unique, "Duplicate user_ids"
    return df

def load(df: pd.DataFrame, db_connection):
    # Validate before load
    assert len(df) > 0, "Nothing to load"
    df.to_sql('transactions', db_connection, if_exists='append', index=False)
    # Verify load
    count = pd.read_sql('SELECT COUNT(*) FROM transactions', db_connection).iloc[0, 0]
    print(f"Loaded {len(df)} rows. Total in DB: {count}")

🤝 Collaborative Links

  • Logic: Route database connection logic to backend-architect.
  • Infrastructure: Route cloud-database setup to infra-architect.
  • Analysis: Route raw-data analysis to data-analyst.
  • ML: Route feature engineering to ml-engineer.
  • Search: Route indexing strategies to search-vector-architect.

🚨 Failure Modes

SituationResponse
Migration fails mid-wayHave a rollback migration ready. Use transactions where possible.
Query is slow on production dataUse EXPLAIN ANALYZE. Check for missing indexes. Consider pagination.
NULL values break downstreamAdd COALESCE/IFNULL. Validate at pipeline boundaries.
Schema change breaks existing codeCheck for backwards compatibility. Use additive changes (new columns, not renames).
ETL pipeline silently drops rowsAdd row count validation at each stage. Log dropped rows with reasons.
Duplicate data after pipeline runAdd unique constraints. Make pipeline idempotent.
Schema evolution (add column, rename)Use additive changes only. Never rename/drop in production. Use shadow columns.
CDC (change data capture) breaksValidate event ordering. Handle out-of-order events with watermarks.

🚩 Red Flags / Anti-Patterns

  • SELECT * in production queries (breaks when schema changes)
  • No indexes on foreign keys and filter columns
  • Migrations without rollback path
  • Storing secrets/PII in plain text columns
  • No data validation at pipeline boundaries
  • Using ORM for everything (some queries need raw SQL for performance)
  • "We'll add indexes later" — later = production outage
  • ETL pipeline that's not idempotent (running twice corrupts data)

Common Rationalizations

ExcuseReality
"Data is small, no index needed"Data grows. Add indexes on day one.
"ORM handles everything"ORMs generate bad queries for complex joins. Use raw SQL when needed.
"Migration is simple, no rollback needed"Simple migrations fail too. Always have rollback.
"Pipeline works on test data"Test with production-scale data volumes.

✅ Verification Before Completion

1. Schema validated: types correct, constraints enforced, indexes on hot paths
2. Query tested: EXPLAIN ANALYZE shows reasonable plan
3. NULLs handled: COALESCE/IFNULL on nullable columns
4. Migration rollback: tested and works
5. Pipeline validates: input check, transform check, output check
6. Performance: tested on realistic data volume (not 10 rows)

💡 Examples

Migration with Rollback

-- UP
CREATE TABLE orders_v2 (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES users(id),
    total_cents BIGINT NOT NULL CHECK (total_cents >= 0),
    status VARCHAR(20) NOT NULL DEFAULT 'pending',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_orders_user ON orders_v2(user_id);
CREATE INDEX idx_orders_status ON orders_v2(status) WHERE status = 'pending';

-- DOWN
DROP TABLE IF EXISTS orders_v2;

Pipeline with Validation Gates

def etl_pipeline(source, target):
    raw = extract(source)
    assert raw.shape[0] > 0, "Empty source"          # input gate

    clean = transform(raw, dedup=True, null_fill="unknown")
    assert clean.duplicated().sum() == 0, "Duplicates remain"  # transform gate

    load(target, clean)
    loaded = count_rows(target)
    assert loaded == clean.shape[0], f"Row mismatch: {loaded} != {clean.shape[0]}"  # output gate

💰 Quality for AI Agents

  • Structured formats: Headers + bullets > prose.
  • Cross-reference paths: Write skills/XX-name/SKILL.md not vague references.

"No completion claims without fresh verification evidence."

🎙️ Voice Directive

All agent output must follow this writing style. Slop language erodes trust; precision builds it.

  • Lead with the point. Say what it does, why it matters, what changes.
  • Be concrete. Name files, functions, line numbers, commands, outputs, real numbers. Never abstract hand-waving.
  • Tie technical choices to user outcomes. What the real user sees, loses, waits for, or can now do.
  • Sound like a senior engineer talking to a peer. Not a consultant presenting to a client.
  • Never corporate, academic, PR, or hype.

Banned Words (AI Slop — NEVER use these)

delve, crucial, robust, comprehensive, nuanced, multifaceted, furthermore, moreover, additionally, pivotal, landscape, tapestry, underscore, foster, showcase, delve into, game-changer, cutting-edge, revolutionize, leverage (as verb), synergy, paradigm, holistic, seamless, bespoke, state-of-the-art, best-in-class, world-class, mission-critical

📢 Completion Status Protocol

Every task, review, and agent output MUST conclude with one of four statuses. No completion claim is valid without this protocol.

  • DONE — Completed with evidence. Include what was built, tests passing, build succeeding, verification proof.
  • DONE_WITH_CONCERNS — Completed, but list specific concerns. Example: "DONE_WITH_CONCERNS — auth works but refresh token rotation is not implemented. Tracked as tech debt in docs/plans/task.md."
  • BLOCKED — Cannot proceed. State the blocker, what was tried, and what's needed. Example: "BLOCKED — API contract undefined. Waiting on api-designer output before backend can proceed."
  • NEEDS_CONTEXT — Missing information. State exactly what is needed, in one sentence. Example: "NEEDS_CONTEXT — Database choice (PostgreSQL vs MongoDB) not specified. Affects schema design."
<HARD-GATE> Before claiming ANY status: 1. DONE must include concrete evidence (test output, build log, file paths) 2. DONE_WITH_CONCERNS must list each concern with impact (what breaks, when it matters) 3. BLOCKED must state the exact blocker, NOT a vague "can't proceed" 4. NEEDS_CONTEXT must ask a specific question, NOT "need more info" 5. NEVER claim DONE without evidence. "It should work" is not evidence. </HARD-GATE> ## 🧠 Operational Self-Improvement (Learning Log)

Skills get smarter with use. Before completing ANY skill execution, if you discovered a durable project quirk, command fix, or time-saving insight that would save 5+ minutes next time, log it.

scripts/log-learning.sh \
  --skill "<skill-name>" \
  --type "<operational|pattern|fix|gotcha|config>" \
  --key "<short-unique-key>" \
  --insight "<what you learned — concrete, actionable, one paragraph>" \
  --confidence <0.0-1.0>

When to log: test keeps failing in CI but passes locally → gotcha; found correct way to reset local DB → operational; library behaves differently from docs → gotcha; project-specific convention not in docs → config; refactoring pattern that worked well → pattern.

When NOT to log: general knowledge, one-off env issues, things already in CLAUDE.md.

Learnings stored in ~/.virtual-company/projects/<project-slug>/learnings.jsonl — loaded at session start.

🤔 Confusion Protocol

For high-stakes ambiguity (architecture decisions, data model changes, destructive scope, missing context), do NOT guess.

  1. STOP. Do not proceed with implementation.
  2. Name it in one sentence — what specifically is ambiguous?
  3. Present 2-3 options with concrete trade-offs for each.
  4. Recommend one option with reasoning.
  5. ASK the user before proceeding.

Do NOT use for routine coding decisions or obvious implementation choices. Reserve for:

  • Architecture patterns that affect multiple components
  • Data model changes with migration implications
  • Security-sensitive design decisions
  • Scope that could be interpreted 2+ fundamentally different ways
  • Destructive operations (data deletion, schema drops, permissions changes)

AskUserQuestion Decision Brief

When asking the user to make a decision, use this format. Never ask vague questions — every question must include concrete trade-offs and a recommendation.

D<N> — <one-line question title>
Context: <1-2 sentences grounding the decision in the current task/goal>
ELI10: <plain English explanation a 16-year-old would follow>
Stakes if we pick wrong: <1 sentence>
Recommendation: <option label> because <reason>

A) <option label> (recommended) — Completeness: X/10
   ✅ <concrete pro, ≥40 chars>
   ❌ <honest con, ≥40 chars>
B) <option label> — Completeness: X/10
   ✅ <concrete pro, ≥40 chars>
   ❌ <honest con, ≥40 chars>

Net: <one-line synthesis of what changes based on user choice>

Rules:

  • Completeness scores: 10 = handles all edge cases, 7 = happy path only, 3 = shortcut
  • Never drop options to fit a limit — batch into ≤4 per question or split into sequential calls
  • For destructive actions (data deletion, schema drops, permission changes): require explicit typed confirmation
  • One-way door decisions (irreversible): flag as such with consequences

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.