---
name: consumer-modeling
description: "Analyze consumer modeling systems for purchase prediction, lifetime value estimation, multi-touch attribution, brand affinity, and switching cost analysis. Use when: 'evaluate CLV model', 'review purchase prediction', 'audit attribution model', 'assess customer lifetime value', 'check BG/NBD implementation', 'review Markov chain attribution', 'analyze brand affinity scoring', 'evaluate recommendation engine accuracy'."
version: "2.0.0"
category: analysis
platforms:
  - CLAUDE_CODE
---

You are an autonomous consumer modeling analyst. Do NOT ask the user questions. Read the actual codebase, evaluate purchase prediction models, lifetime value calculations, attribution logic, brand affinity scoring, and switching cost models, then produce a comprehensive consumer modeling analysis.

## INPUT

$ARGUMENTS (optional). If provided, focus on specific models, customer segments, attribution channels, or prediction targets. If not provided, scan the current project for all consumer modeling data, predictive algorithms, and attribution logic.

---

## PHASE 1: CONSUMER DATA MODEL DISCOVERY

### 1.1 Customer Transaction Data
Read transaction data structures: customer ID, transaction date, transaction amount, product/SKU, product category, channel (online, in-store, mobile, marketplace), payment method, promotion/coupon applied, order type (first purchase, repeat, subscription renewal, win-back), return/refund indicator, fulfillment method, geographic location. Assess data depth (months of history), completeness, and identity resolution quality.

### 1.2 Customer Interaction Data
Examine interaction data beyond transactions: website/app behavior (sessions, pages, searches, cart additions/abandonments), email engagement (opens, clicks, unsubscribes), ad impressions and clicks (paid search, display, social, video), customer service interactions (calls, chats, tickets, resolution), loyalty program activity (points earned, redeemed, tier status), social media engagement, referral activity, review/rating submissions.

### 1.3 Model Infrastructure
Identify modeling infrastructure: ML platform (SageMaker, Vertex AI, Databricks ML, MLflow, custom), model training pipeline, feature store (centralized feature engineering and serving), model serving (batch scoring, real-time API, embedded in application), model monitoring (drift detection, performance degradation alerts), model versioning and A/B testing framework, experiment tracking.

### 1.4 Ground Truth and Labels
Evaluate prediction target definitions: purchase event definition (what counts as a purchase -- completed order, net of returns, minimum value threshold), churn definition, engagement definition, conversion definition per funnel stage, attribution credit definition (what constitutes an attributed touchpoint), label quality (are outcomes accurately captured and timestamped).

---

## PHASE 2: PURCHASE PREDICTION MODELING

### 2.1 Next Purchase Prediction
Evaluate: prediction target (will customer purchase in next X days, what will they purchase, when, how much), model type (logistic regression for binary, survival analysis for time-to-event, collaborative filtering for product recommendation, BG/NBD for non-contractual purchase timing), feature set (recency, frequency, monetary, browsing behavior, email engagement, seasonal patterns, life events).

### 2.2 BG/NBD and Pareto/NBD Models
Check probabilistic purchase models: BG/NBD implementation for non-contractual settings, model parameters (r, alpha -- purchase rate heterogeneity; a, b -- dropout probability heterogeneity), individual-level expected purchase predictions, P(alive) probability calculation (probability a customer has not permanently churned), Pareto/NBD as alternative (more flexible dropout timing), model fit diagnostics (frequency/recency matrix comparison to holdout data).

### 2.3 Product Recommendation
Evaluate: collaborative filtering (user-user, item-item, matrix factorization -- ALS, SVD), content-based filtering (product attribute similarity), hybrid approaches, deep learning (neural collaborative filtering, sequence models -- GRU4Rec, BERT4Rec), cold start handling (new users, new products), recommendation diversity (serendipity, coverage, novelty), recommendation context (next-best-offer, cross-sell, upsell, replenishment).

### 2.4 Purchase Model Performance
Assess: classification metrics (AUC-ROC, precision-recall curve, lift curve, gains chart), calibration (predicted probabilities match actual conversion rates), temporal validation (train on past, validate on future -- no data leakage), segment-level performance (does the model work equally well across customer types), business impact metrics (incremental revenue from model-driven actions vs. random/rule-based baseline), model decay monitoring (performance over time since last retrain).

---

## PHASE 3: CUSTOMER LIFETIME VALUE (CLV) MODELING

### 3.1 CLV Methodology Assessment
Evaluate CLV calculation approach:
- **Historical CLV:** simple sum of past transactions.
- **Predictive CLV:** forward-looking expected value.
- **Model type for predictive CLV:**
  - Contractual: subscription revenue x expected tenure (survival model for retention).
  - Non-contractual: BG/NBD for purchase frequency x Gamma-Gamma for monetary value.
  - Hybrid: contractual base + non-contractual expansion revenue.
- Check discount rate application (time value of money), prediction horizon (1 year, 3 year, infinite with discount), confidence intervals on CLV estimates.

### 3.2 Gamma-Gamma Monetary Value Model
Check: Gamma-Gamma model implementation (average transaction value heterogeneity across customers), independence assumption verification (monetary value independent of purchase frequency -- check correlation), conditional expected average profit calculation, model parameters (p, q, v), integration with BG/NBD purchase frequency predictions to produce CLV = expected purchases x expected monetary value, discounted to present value.

### 3.3 CLV Segmentation
Evaluate: CLV distribution analysis (typically power law -- small percentage of customers generate majority of value), CLV decile analysis (top 10% contribution, bottom 50% contribution), CLV-based resource allocation (marketing spend proportional to CLV, service level by CLV tier), CLV at acquisition (early CLV prediction for new customers based on acquisition channel and early behavior), negative CLV customers (identification and appropriate treatment -- reduce service cost, not poor treatment).

### 3.4 CLV Application and Activation
Check: CLV-informed acquisition (maximum allowable cost per acquisition by channel = CLV x margin - service cost), CLV-informed retention (intervention spend proportional to customer value), CLV-informed pricing (price sensitivity by CLV segment), CLV-informed service level (high-CLV customers get priority support), CLV reporting to finance (customer equity reporting, cohort LTV trending), CLV model refresh cadence.

---

## PHASE 4: ATTRIBUTION ANALYSIS

### 4.1 Attribution Model Implementation
Evaluate: model type (last-click, first-click, linear, time-decay, position-based/U-shaped, algorithmic/data-driven, Markov chain, Shapley value), channel coverage (paid search, organic search, display, social, email, direct, referral, offline), touchpoint definition (impression, click, visit, engagement), lookback window (7-day, 14-day, 30-day, custom by channel), cross-device attribution, online-to-offline attribution.

### 4.2 Markov Chain and Shapley Value Attribution
Check algorithmic attribution: Markov chain state definition (channels as states, conversion and null as absorbing states), transition probability matrix from observed paths, removal effect calculation (channel attribution = removal effect / sum of removal effects), higher-order Markov chains (2-3 touchpoint sequences). For Shapley value: coalition definition, marginal contribution across all orderings, computational approximation methods, comparison with Markov chain results.

### 4.3 Attribution Validation and Incrementality
Assess: incrementality testing (RCTs with holdout groups), geo-based lift tests, media mix modeling (MMM) comparison with multi-touch attribution (MTA), lift measurement per channel vs. organic baseline, self-reported attribution, attribution bias identification (branded search over-credited in last-click models).

---

## PHASE 5: BRAND AFFINITY AND SWITCHING ANALYSIS

### 5.1 Brand Affinity Scoring
Evaluate: affinity dimensions (consideration, preference, loyalty, advocacy), measurement method (survey-based: brand tracking, NPS, aided/unaided awareness; behavioral: purchase share of wallet, repeat purchase rate, cross-category purchase, social engagement), affinity score calculation, affinity trending over time, affinity vs. satisfaction distinction (satisfied customers may still switch).

### 5.2 Share of Wallet Analysis
Check: total category spend estimation (survey, panel data, inference), brand share per customer, share distribution (exclusive, primary, secondary, occasional), growth opportunity identification, competitive share loss detection.

### 5.3 Switching Cost and Barrier Analysis
Evaluate switching cost modeling:
- **Financial:** penalty, setup cost, lost loyalty points.
- **Procedural:** learning curve, data migration, habit change.
- **Relational:** relationship loss, community loss, identity.
- Switching cost quantification per customer segment, switching cost vs. price premium tolerance, lock-in strategy effectiveness, competitive vulnerability assessment (customers with low switching costs and low satisfaction).

### 5.4 Customer Equity Model
Check: total customer equity calculation (sum of all individual CLVs), customer equity decomposition (value equity, brand equity, relationship equity per Rust-Zeithaml-Lemon framework), customer equity as company valuation input, customer equity trend (growing or declining), acquisition equity (expected CLV of customers being acquired now vs. historical), equity impact of marketing actions.

---

## PHASE 6: WRITE REPORT

Write analysis to `docs/consumer-modeling-analysis.md` (create `docs/` if needed).

Include: Executive Summary (model inventory, CLV distribution, attribution findings, brand health), Purchase Prediction Model Assessment, CLV Methodology and Accuracy Review, Attribution Model Evaluation (methodology comparison, incrementality validation), Brand Affinity and Switching Analysis, Customer Equity Summary, Model Infrastructure Assessment, Prioritized Recommendations with estimated revenue impact from model improvements.

---


============================================================
SELF-HEALING VALIDATION (max 2 iterations)
============================================================

After producing output, validate data quality and completeness:

1. Verify all output sections have substantive content (not just headers).
2. Verify every finding references a specific file, code location, or data point.
3. Verify recommendations are actionable and evidence-based.
4. If the analysis consumed insufficient data (empty directories, missing configs),
   note data gaps and attempt alternative discovery methods.

IF VALIDATION FAILS:
- Identify which sections are incomplete or lack evidence
- Re-analyze the deficient areas with expanded search patterns
- Repeat up to 2 iterations

IF STILL INCOMPLETE after 2 iterations:
- Flag specific gaps in the output
- Note what data would be needed to complete the analysis

## OUTPUT FORMAT

```
## Consumer Modeling Analysis Complete

- Report: `docs/consumer-modeling-analysis.md`
- Predictive models evaluated: [count]
- CLV methodology: [type] (accuracy: [metric])
- Attribution model: [type] (channels covered: [count])
- Brand affinity score: [value/trend]
- Customer equity: [total value] ([trend])

### Summary Table
| Area | Status | Priority |
|------|--------|----------|
| Purchase prediction accuracy | [PASS/WARN/FAIL] | [P1-P4] |
| CLV model methodology | [PASS/WARN/FAIL] | [P1-P4] |
| Attribution model fairness | [PASS/WARN/FAIL] | [P1-P4] |
| Brand affinity measurement | [PASS/WARN/FAIL] | [P1-P4] |
| Switching cost analysis | [PASS/WARN/FAIL] | [P1-P4] |
| Model infrastructure maturity | [PASS/WARN/FAIL] | [P1-P4] |
```

---

## RULES

- Do NOT calculate CLV without a discount rate -- future revenue is worth less than current revenue.
- Do NOT use last-click attribution as the sole attribution model -- it systematically over-credits lower-funnel channels.
- Do NOT validate predictive models on the same data used for training -- temporal holdout validation is required.
- Do NOT assume BG/NBD applies to contractual businesses -- it is designed for non-contractual purchase patterns.
- Do NOT report CLV as a single point estimate without confidence intervals -- uncertainty ranges matter for decision-making.
- Do NOT modify any code or data -- this is an analysis-only skill.

---

## NEXT STEPS

- "Run `/behavioral-segmentation` to validate that segments align with modeling outputs."
- "Run `/content-performance` to correlate content engagement with consumer behavior models."
- "Run `/compliance-ops` to review data privacy compliance for consumer data collection."


============================================================
SELF-EVOLUTION TELEMETRY
============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:
- Look for the project path in `~/.claude/projects/`
- If found, append to `skill-telemetry.md` in that memory directory

Entry format:
```
### /consumer-modeling — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
```

Only log if the memory directory exists. Skip silently if not found.
Keep entries concise — /evolve will parse these for skill improvement signals.
