Ecom rfm analysis

From asgard-ai-platform/skills · View interactive version

Ecom rfm analysis is an AI agent skill from the GitHub repository asgard-ai-platform/skills. Perform RFM (Recency, Frequency, Monetary) customer segmentation from transaction data. Use this skill when the user needs to segment customers by purchase behavior, identify high-value buyers, design retention campaigns, or prioritize marketing spend by customer value — even if they say 'who are ou

How to use this skill

Skill file

RFM Analysis

Overview

RFM segments customers based on three behavioral dimensions: Recency (when they last bought), Frequency (how often they buy), and Monetary (how much they spend). It converts raw transaction data into actionable customer segments for targeted marketing.

Framework

IRON LAW: RFM Uses ACTUAL Behavior, Not Demographics

RFM is behavioral segmentation — it classifies by what customers DO,
not who they ARE. A 25-year-old and a 65-year-old in the same RFM segment
should receive the same treatment. Never mix RFM with demographic
assumptions.

The Three Dimensions

| Dimension | What It Measures | How to Calculate |

|-----------|-----------------|-----------------|

| Recency (R) | Days since last purchase | Today - Last purchase date |

| Frequency (F) | Number of purchases in period | Count of distinct transactions |

| Monetary (M) | Total spend in period | Sum of transaction values |

Scoring Method (Quintile-Based)

  1. For each dimension, rank all customers and divide into 5 equal groups (quintiles)
  2. Score 5 (best) to 1 (worst): R=5 means most recent, F=5 means most frequent, M=5 means highest spend
  3. Combine into 3-digit RFM score (e.g., R5-F4-M5 = recent, frequent, high-value)

Note: For Recency, LOWER days = HIGHER score (more recent is better).

Key Segments

| Segment | RFM Pattern | Description | Strategy |

|---------|------------|-------------|----------|

| Champions | R5, F5, M5 | Best customers, recent, frequent, high-value | Reward, loyalty program, early access |

| Loyal | R4-5, F4-5, M3-5 | Consistent buyers | Upsell, cross-sell, referral program |

| Potential Loyalists | R4-5, F2-3, M2-3 | Recent, moderate frequency | Nurture to increase frequency |

| At Risk | R2-3, F3-5, M3-5 | Were frequent/high-value, not buying recently | Win-back campaign, special offers |

| Hibernating | R1-2, F1-2, M1-2 | Long dormant, low value | Low-cost reactivation or let go |

| New Customers | R5, F1, M1-2 | Just made first purchase | Onboarding, second-purchase incentive |

Implementation Steps

Phase 1: Data Preparation

Phase 2: Calculate RFM Scores

Phase 3: Segment and Act

Output Format

# RFM Analysis: {Business}

## Data Summary
- Customers analyzed: {N}
- Analysis window: {start} to {end}
- Transactions: {N}

## Segment Distribution
| Segment | Count | % | Avg R (days) | Avg F | Avg M |
|---------|-------|---|-------------|-------|-------|
| Champions | {N} | {%} | {days} | {count} | ${X} |
| At Risk | {N} | {%} | ... | ... | ... |
| ... | ... | ... | ... | ... | ... |

## Key Findings
- Top 20% customers contribute {X%} of revenue
- {N} customers at risk of churning (were high-value, now dormant)
- {N} new customers need second-purchase nurturing

## Recommended Actions
| Segment | Action | Channel | Expected Impact |
|---------|--------|---------|----------------|
| Champions | {loyalty reward} | {email/app} | Increase AOV by X% |
| At Risk | {win-back offer} | {email/SMS} | Recover X% of dormant revenue |

Gotchas

Scripts

| Script | Description | Usage |

|--------|-------------|-------|

| scripts/rfm_score.py | Score customers on R/F/M and assign segment labels | python scripts/rfm_score.py --help |

Run python scripts/rfm_score.py --verify to execute built-in sanity tests.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.