---
name: pltv-warehouse-prep
description: Prepare read-only, SHA-256 hashed acquisition views and append-only revenue ledgers for Predicted Lifetime Value (pLTV) modeling in BigQuery, Snowflake, Databricks, or Redshift, and audit tables for backfilling data leakage.
version: 1.0.0
license: MIT
homepage: https://pltv.io/skills
maintainer: Churney (https://churney.io)
---

# pLTV Warehouse Prep & Leakage Audit

Use this skill when an engineer or data scientist needs to prepare cloud data warehouse tables for user-level Predicted Lifetime Value (pLTV) bidding without exposing raw PII or introducing backfilling data leakage.

## Core Rules
1. **Read-only, zero raw PII:** Normalize and SHA-256 hash emails (trim + lowercase) and phone numbers (E.164 digits only) *inside* the warehouse view before sharing or exporting.
2. **Never hash click/browser IDs:** Pass `fbp`, `fbc`, `gclid`, `gbraid`, `wbraid`, and `ttclid` verbatim in plaintext.
3. **Zero backfilling leakage:** Never train pLTV models on mutable user dimension tables whose columns were overwritten after Day 1. Verify `updated_at` vs `created_at` first; reconstruct Day-0 features from append-only event logs.
4. **Immutable revenue ledger:** Store purchases, renewals, refunds, and chargebacks as separate append-only rows with exact `event_timestamp_utc` and `order_id`.

## Workflow
1. Identify the user's warehouse dialect (`bigquery`, `snowflake`, `databricks`, or `redshift`).
2. If connected to the `pltv-io` MCP server (`https://pltv.io/mcp`), call `generate_warehouse_sql` for both `acquisition_view` and `leakage_audit`. Otherwise fetch `https://pltv.io/sql.md`.
3. Run the leakage audit query on a mature cohort (acquired 90 to 180 days ago) and report `pct_mutated`.
4. Run the D90 value-spread query to verify `p95 / p05 >= 3.0x` and top-decile revenue share.
5. Verify SHA-256 normalization matches Meta CAPI and Google Enhanced Conversions specs (`https://pltv.io/api/spec.json`).
