Feature Engineer
Explore source data and build reproducible, leakage-safe feature sets for the stated label and business outcome.
Invocation
Arguments ($ARGUMENTS) are interpreted as:
--data PATH|DATASET — file-based dataset or dataset identifier
--db-url DSN — database connection string for SQL exploration
--tables T1,T2,... — candidate source tables for feature generation
--label-col COLUMN — target column
--entity-col COLUMN — entity key for joining and split safety
--timestamp-col COLUMN — event timestamp for point-in-time joins
--outcome TEXT — business outcome statement
--task — modeling task type
--out-dir DIR — output directory for feature spec and implementation snippets
Target: $ARGUMENTS
Your responsibilities
1. Build the feature contract
Define:
- target label and business outcome
- prediction unit and prediction time
- allowed feature freshness window
- prohibited leakage sources
If this is missing, request the smallest clarification and continue.
2. Explore and profile feature sources
For file-based data:
- inspect schema, missingness, uniqueness, and basic distributions
- identify candidate numerical, categorical, text, and timestamp columns
For databases (--db-url + --tables):
- inspect schemas, primary/foreign key candidates, and joinability
- profile row counts, null rates, cardinality, and label coverage per table
- validate entity/time coverage before building joins
Use references/db-feature-playbook.md for DB profiling and as-of join patterns.
3. Generate candidate features
Use patterns from references/feature-patterns.md:
- numeric transforms and clipping
- categorical handling (frequency, target-safe encoding, hashing)
- temporal features (recency, frequency, rolling stats)
- cross-table aggregations by entity/window
- text-derived and interaction features where relevant
Tie each feature family to an explicit modeling hypothesis.
4. Enforce leakage safety
Before finalizing features:
- verify
feature_time <= prediction_time
- reject post-outcome columns
- ensure train/validation/test splits are entity-safe and time-consistent
- mark any risky feature as blocked with rationale
5. Produce implementation-ready outputs
Deliver:
- ranked feature inventory with rationale and risk
- SQL or Python snippets to materialize features
- data-quality checks required before training
- a minimal feature set for first baseline model
6. Hand off to pipeline validation
After feature plan is drafted:
- instruct running
check-data-pipeline against the engineered feature pipeline
- include exact next commands for validation and training handoff
Output format
Feature Engineering Brief
=========================
Business outcome: <...>
Label: <...>
Entity: <...>
Prediction time: <...>
Source exploration:
1) <table/dataset> | rows=<...> | usable keys=<...> | notes=<...>
Candidate feature sets:
1) <feature family> | hypothesis=<...> | leakage risk=<low|medium|high>
Blocked features:
1) <feature> | reason=<leakage/unavailable/unstable>
Initial baseline feature set:
- <list>
Implementation snippets:
- <sql/python path or snippet summary>
Decision: GO | NO-GO | CONDITIONAL
Confidence: high|medium|low
Next commands:
- <pipeline validation command>
- <training command>
GO: feature contract complete, no blockers.
CONDITIONAL: feature brief is complete but one or more features carry medium/high leakage risk that should be tracked.
NO-GO: critical source information is missing or blockers prevent building a valid feature set.
JSON artifact
Write feature-engineer.json to --out-dir (or ./ if invoked standalone) following the schema in ../../references/schemas.md. Use vocabulary from ../../references/vocabulary.md.
Key fields to populate:
decision: GO / NO-GO / CONDITIONAL
sources_explored, feature_sets, blocked_features, baseline_feature_set
findings: one entry per blocked feature (severity based on risk level) and any structural gaps
Quick heuristics
- No timestamp column → default to random split; warn that temporal leakage cannot be verified
- High cardinality categoricals (> 500 unique values) → use frequency or hash encoding, not one-hot
- Entity column with duplicates in training data → group-aware split is mandatory or evaluation will be inflated
- Target-correlated ID column (e.g.
user_tier, account_type that encodes the label) → flag as high leakage risk
- Rolling aggregations without
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW on ordered window → silently leaks future data
- Feature missingness > 30% in production but < 5% in training data → distribution shift blocker; check source query
Stop conditions
Stop when:
- feature brief and implementation snippets are complete, or
- critical source information (keys, timestamps, label definition) is missing and explicitly requested.
Additional resources
- references/db-feature-playbook.md — DB exploration and as-of join templates
- references/feature-patterns.md — reusable feature families and guardrails
1---2name: feature-engineer3description: Explores data sources and engineers leakage-safe model features from files or databases. Use when asked to create features from raw tables/datasets, design joins and aggregations for a target label, improve model signal, or map business outcomes into trainable predictor sets. Invoke this automatically whenever the user mentions raw data, tables, columns, or wants to build/improve a model — even if they don't say "feature engineering" explicitly. Always run this before proceeding to pipeline validation or training when there is no established feature contract.4---56# Feature Engineer78Explore source data and build reproducible, leakage-safe feature sets for the stated label and business outcome.910## Invocation1112Arguments (`$ARGUMENTS`) are interpreted as:1314- `--data PATH|DATASET` — file-based dataset or dataset identifier15- `--db-url DSN` — database connection string for SQL exploration16- `--tables T1,T2,...` — candidate source tables for feature generation17- `--label-col COLUMN` — target column18- `--entity-col COLUMN` — entity key for joining and split safety19- `--timestamp-col COLUMN` — event timestamp for point-in-time joins20- `--outcome TEXT` — business outcome statement21- `--task` — modeling task type22- `--out-dir DIR` — output directory for feature spec and implementation snippets2324Target: `$ARGUMENTS`2526## Your responsibilities2728### 1. Build the feature contract2930Define:3132- target label and business outcome33- prediction unit and prediction time34- allowed feature freshness window35- prohibited leakage sources3637If this is missing, request the smallest clarification and continue.3839### 2. Explore and profile feature sources4041For file-based data:4243- inspect schema, missingness, uniqueness, and basic distributions44- identify candidate numerical, categorical, text, and timestamp columns4546For databases (`--db-url` + `--tables`):4748- inspect schemas, primary/foreign key candidates, and joinability49- profile row counts, null rates, cardinality, and label coverage per table50- validate entity/time coverage before building joins5152Use [references/db-feature-playbook.md](references/db-feature-playbook.md) for DB profiling and as-of join patterns.5354### 3. Generate candidate features5556Use patterns from [references/feature-patterns.md](references/feature-patterns.md):5758- numeric transforms and clipping59- categorical handling (frequency, target-safe encoding, hashing)60- temporal features (recency, frequency, rolling stats)61- cross-table aggregations by entity/window62- text-derived and interaction features where relevant6364Tie each feature family to an explicit modeling hypothesis.6566### 4. Enforce leakage safety6768Before finalizing features:6970- verify `feature_time <= prediction_time`71- reject post-outcome columns72- ensure train/validation/test splits are entity-safe and time-consistent73- mark any risky feature as blocked with rationale7475### 5. Produce implementation-ready outputs7677Deliver:7879- ranked feature inventory with rationale and risk80- SQL or Python snippets to materialize features81- data-quality checks required before training82- a minimal feature set for first baseline model8384### 6. Hand off to pipeline validation8586After feature plan is drafted:8788- instruct running `check-data-pipeline` against the engineered feature pipeline89- include exact next commands for validation and training handoff9091## Output format9293```text94Feature Engineering Brief95=========================96Business outcome: <...>97Label: <...>98Entity: <...>99Prediction time: <...>100101Source exploration:1021) <table/dataset> | rows=<...> | usable keys=<...> | notes=<...>103104Candidate feature sets:1051) <feature family> | hypothesis=<...> | leakage risk=<low|medium|high>106107Blocked features:1081) <feature> | reason=<leakage/unavailable/unstable>109110Initial baseline feature set:111- <list>112113Implementation snippets:114- <sql/python path or snippet summary>115116Decision: GO | NO-GO | CONDITIONAL117Confidence: high|medium|low118119Next commands:120- <pipeline validation command>121- <training command>122```123124`GO`: feature contract complete, no blockers.125`CONDITIONAL`: feature brief is complete but one or more features carry medium/high leakage risk that should be tracked.126`NO-GO`: critical source information is missing or blockers prevent building a valid feature set.127128### JSON artifact129130Write `feature-engineer.json` to `--out-dir` (or `./` if invoked standalone) following the schema in [../../references/schemas.md](../../references/schemas.md). Use vocabulary from [../../references/vocabulary.md](../../references/vocabulary.md).131132Key fields to populate:133134- `decision`: `GO` / `NO-GO` / `CONDITIONAL`135- `sources_explored`, `feature_sets`, `blocked_features`, `baseline_feature_set`136- `findings`: one entry per blocked feature (severity based on risk level) and any structural gaps137138## Quick heuristics139140- No timestamp column → default to random split; warn that temporal leakage cannot be verified141- High cardinality categoricals (> 500 unique values) → use frequency or hash encoding, not one-hot142- Entity column with duplicates in training data → group-aware split is mandatory or evaluation will be inflated143- Target-correlated ID column (e.g. `user_tier`, `account_type` that encodes the label) → flag as high leakage risk144- Rolling aggregations without `ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW` on ordered window → silently leaks future data145- Feature missingness > 30% in production but < 5% in training data → distribution shift blocker; check source query146147## Stop conditions148149Stop when:150151- feature brief and implementation snippets are complete, or152- critical source information (keys, timestamps, label definition) is missing and explicitly requested.153154## Additional resources155156- [references/db-feature-playbook.md](references/db-feature-playbook.md) — DB exploration and as-of join templates157- [references/feature-patterns.md](references/feature-patterns.md) — reusable feature families and guardrails