GUIDE

Build a Churn Risk Detector with Claude Code

Churn detection usually takes a data science team and six months. Here's how a CS leader can build a working churn risk detector with Claude Code in an afternoon, scoring accounts on usage drops, ticket spikes, missed meetings, and late payments.

Every churned account your team didn't see coming is a failure of tooling, not effort. Your CSMs are working hard. They're buried in renewal calls, QBRs, and support escalations. They don't have time to manually cross-reference usage logs, support tickets, and billing data to figure out who's about to leave.

So accounts slip through. The cancellation email hits, and your team says "I had no idea." The VP of CS scrambles to do a post-mortem. Everyone agrees they need "better data." Nothing changes.

I've taught over 100 people to build real tools with Claude Code, and one of the most common requests I get from CS leaders is exactly this: "Can I build something that tells me which accounts are about to churn?" The answer is yes. And you don't need a data science team or a six-month project to do it.

Why Traditional Churn Detection Takes So Long

The typical approach: hire a data scientist, spend weeks getting access to the right databases, build a machine learning model, validate it against historical data, deploy it somewhere, then build a dashboard nobody checks. Six months minimum. $200k+ in salary costs before you see a single alert.

Most CS teams don't need ML-grade predictions. They need a simple scoring system that flags the obvious warning signs they're too busy to track manually. That's a problem Claude Code can solve in an afternoon.

The Risk Signals That Actually Matter

Before you build anything, you need to know what to track. I've worked with CS teams across SaaS companies, and these signals show up everywhere:

  • Usage drop-off. A 30%+ decline in logins, API calls, or feature usage over two weeks. This is the single strongest predictor of churn. If they're not logging in, they're already gone mentally.
  • Support ticket spikes. Three or more tickets in a week, especially ones tagged "bug" or "not working." Frustrated users file tickets. Silent users just cancel.
  • Missed meetings. A customer who no-shows a QBR or cancels two consecutive check-ins is telling you something. That signal gets lost if your meeting data lives in Calendly and your CRM lives in Salesforce.
  • Late payments. Overdue invoices, failed credit cards, requests to downgrade. Finance sees these. CS often doesn't.
  • Champion departure. The person who bought your product leaves the company. LinkedIn data or contact bounce-backs are your early warning here.
  • Contract timeline. Accounts within 60 days of renewal with no renewal conversation scheduled. This one's embarrassingly common to miss.
  • Feature adoption stall. Customers who activated but never adopted key features past the first week. They bought the vision but never got the value.

Building the Detector with Claude Code

Here's the workflow. You don't need to be an engineer. You need access to your data (even if it's just CSV exports) and Claude Code installed. If you haven't set it up yet, start here with our setup guide.

Step 1: Pull your data together

Export usage data, support tickets, billing status, and meeting logs. CSVs are fine. Most tools (Intercom, Zendesk, Stripe, Salesforce) let you export. Drop them into a project folder.

mkdir churn-detector
cd churn-detector
# Drop your CSVs here: usage.csv, tickets.csv, billing.csv, meetings.csv
claude

Step 2: Tell Claude Code what you want

Open Claude Code and give it a prompt like this:

I have four CSV files in this directory:
- usage.csv (columns: account_id, date, logins, api_calls, features_used)
- tickets.csv (columns: account_id, date, priority, category, status)
- billing.csv (columns: account_id, plan, mrr, payment_status, renewal_date)
- meetings.csv (columns: account_id, scheduled_date, status)

Build me a Python script that:
1. Reads all four files
2. Scores each account on churn risk (0-100) based on these signals:
   - Usage decline over last 14 days (weight: 30)
   - Support ticket volume last 7 days (weight: 20)
   - Missed meetings in last 30 days (weight: 15)
   - Payment issues (weight: 20)
   - Days until renewal with no recent contact (weight: 15)
3. Outputs a ranked list of at-risk accounts with their scores and specific risk signals
4. Saves results to churn_risk_report.csv

Claude Code will read your CSV headers, understand the data shape, and write the scoring logic. It handles the pandas work, the date calculations, the weighted scoring, all of it.

Step 3: Review and iterate

The first output will be functional but probably needs tuning. You'll want to adjust weights based on your business. Maybe for your product, missed meetings matter more than usage drop-off. Maybe support tickets are noisy and should be weighted lower.

Tell Claude Code: "Adjust the weights so missed meetings count for 25 and support tickets count for 10." It rewrites the script instantly. Run it again. Check the results against accounts you know churned last quarter. Keep iterating until the scores match your gut.

Step 4: Build the alert output

A CSV is fine for the first version. But what your CSMs actually need is a morning alert they can act on. Ask Claude Code to bolt on an email or Slack notification:

Add a function that sends a Slack message to #cs-alerts every morning
with the top 10 at-risk accounts. Format it like this:

🔴 HIGH RISK (score 80+):
  Acme Corp (score: 92) - Usage down 45%, 2 missed meetings, payment overdue
  Beta Inc (score: 85) - Usage down 60%, 4 support tickets this week

🟡 WATCH LIST (score 50-79):
  Gamma LLC (score: 67) - Renewal in 30 days, no QBR scheduled
  Delta Co (score: 55) - Usage down 25%, champion left company

Now your team has a daily action list. No dashboard to check. No report to pull. It lands in the channel they already live in.

The Scoring System in Detail

Here's how the weighted scoring works. Each signal gets a sub-score from 0 to its max weight, then they're summed for a total risk score out of 100.

  • Usage decline (0-30 points): Compare last 7 days to the prior 7 days. A 50%+ drop gets the full 30. A 25-50% drop gets 15-20. Under 25% gets 5-10. No decline gets 0.
  • Support ticket spike (0-20 points): 5+ tickets in 7 days gets 20. 3-4 tickets gets 12. 1-2 tickets gets 5. Zero tickets gets 0.
  • Missed meetings (0-15 points): 2+ no-shows in 30 days gets 15. 1 no-show gets 8. All attended gets 0.
  • Payment issues (0-20 points): Overdue invoice gets 20. Failed payment retry gets 15. Downgrade request gets 10. Current gets 0.
  • Renewal proximity (0-15 points): Within 30 days with no scheduled QBR gets 15. Within 60 days with no scheduled QBR gets 8. QBR scheduled or 60+ days out gets 0.

An account scoring 70+ needs immediate outreach. 50-69 goes on the watch list. Under 50 is healthy. These thresholds are starting points; calibrate them against your actual churn history.

From Data to Action: The Real Workflow

The detector is only useful if it changes behavior. Here's the workflow I recommend:

  1. Daily alert at 8 AM. The script runs, scores all accounts, and posts the top risks to Slack.
  2. CS standup at 9 AM. The team reviews the high-risk list. Each account gets assigned an owner and an action (call, email, executive escalation, success plan).
  3. Action within 24 hours. Every flagged account gets human contact within a day. The goal is to surface the problem before the customer decides to leave.
  4. Weekly retro. Did any accounts churn that the detector missed? Add those signals. Did the detector flag accounts that were actually fine? Adjust the weights down.

This feedback loop is what turns a script into a system. After four to six weeks of tuning, your detector will catch 80%+ of at-risk accounts before they cancel.

Scaling It Up with MCP Servers

The CSV approach works to get started. But if you want live data instead of manual exports, Claude Code's MCP server system lets you connect directly to your tools. Plug into your CRM, support platform, and billing system so the detector pulls fresh data every time it runs.

You can also use Claude Code agents to automate the entire pipeline: pull data, score accounts, send alerts, and even draft the outreach emails for your CSMs to review.

What You'll Have at the End

A working churn risk detector, built in a few hours, that scores every account daily on real signals. A Slack alert your team actually reads. A feedback loop that gets smarter every week. And zero data science hires required.

The accounts that slip through the cracks don't slip because your team doesn't care. They slip because nobody had the time to connect the dots across six different tools. This detector connects those dots for them.

Want to build this yourself? ClaudeFluent walks you through building real tools like this in a live training session. We go from zero to a working system in one class.

Related Guides

WANT MORE LIKE THIS?

Learn to build with Claude Code

6 hours of hands-on training. Build real projects. Ship without waiting on engineering.

View Class Details