Lesson completed!
-

Lesson 12 / 21 · App 1: Competitor Tracker

Build the Tracker

Max Techera
Next

Build the Tracker

Now the fun part: you don't write the tracker, you describe it. One prompt, and Claude Code builds a single Python file with a SQLite database, the median math, and a ranked table. This is the whole point of building inside Claude Code — you bring a clear description of the output, it brings the code.

That's not a stretch. Jithin Raaj, a non-dev, built a dashboard that monitors 37 Instagram accounts this exact way: "I didn't write the code from scratch. What I brought was a clear description of the problem and a clear picture of what the output should look like." That's the only skill you need.

The build prompt

Paste this into Claude Code, exactly as written:

Build a Python CLI `track.py` that maintains a competitor content tracker in SQLite.

Input: a `competitors.txt` file of handles/channel URLs (TikTok, YouTube, IG).
For each account:
  1. Use yt-dlp `--dump-json` for YouTube/TikTok and the ScrapeCreators API
     (key in $SCRAPECREATORS_KEY) for Instagram reels to fetch the last 30 posts
     with: id, url, caption, views, likes, comments, shares, saves, posted_at.
  2. Store rows in a `posts` table (upsert on id).
  3. Compute per-account baseline = MEDIAN of views across that account's last 30 posts.
  4. Compute for every post:
       outlier_multiplier = views / account_median
       velocity = views / hours_since_posted
       weighted_engagement = (0.5*likes + 2*comments + 3*saves + 4*shares) / NULLIF(reach, views)
  5. Print a ranked table (highest outlier_multiplier first) of every post with
     multiplier >= 2.0, showing account, caption, views, multiplier, velocity.
     Tag: >=2 "outlier", >=5 "strong", >=10 "MONSTER".
Add a `--since 7d` flag to only rank posts from the last N days ("this week's outliers").
Keep it a single file, no framework. Use requests + sqlite3 + statistics.median.

What each step does

Read it top to bottom — it's a spec, not magic:

  1. Input & fetch. competitors.txt is your tracked universe: the specific handles in your niche, one per line. For YouTube/TikTok, yt-dlp --dump-json pulls metadata with no API key. For Instagram reels, the ScrapeCreators API (more on the stack next lesson). Last 30 posts each.
  2. Store. Rows go into a posts table, upsert on id — re-running never duplicates, it updates. Your data lives in a file, not a chat, so it compounds over time.
  3. Baseline. The median of that account's last 30 views. This is the denominator from the last lesson — median, so one breakout doesn't poison it.
  4. The three numbers. outlier_multiplier (did it break through?), velocity (is it breaking through now?), and a weighted_engagement score that values saves and shares over likes — the signals that actually move the algorithm.
  5. Ranked output. Everything ≥2x, sorted by multiplier, tagged outlier / strong / MONSTER. The --since 7d flag gives you "this week's outliers" — the weekly view you'll actually live in.
Tip:

Keep the prompt asking for one file, no framework. A single track.py with sqlite3 and statistics.median is easy to read, easy to fix, and easy to hand back to Claude Code when you want to change something. Simplicity is a feature here.

How I wired mine to real Instagram data

The prompt above gets you a working tracker. Here's how I made mine pull real numbers, the way the one in the reel works.

  • Meta business_discovery — one API call per creator returns their follower count plus their recent posts. One call, one creator, the public profile view. This is the backbone: it's how you get a competitor's posts without scraping HTML.
  • The media-info endpoint — Instagram's endpoint returns plays and the handle, which are public. That's your view count for the score, straight from the source.
  • viral_ratio vs each creator's own median — same math as lesson 1, computed per creator so a small account's 10x isn't buried under a big account's raw numbers.
  • Storage layout — every post saved as data/refs/<creator-handle>/<shortcode>.json. Organized by creator, one file per post. This mirrors the data/refs/ folder from your setup, and it's what lets App 2 (the vault) later read across every competitor at once.

The key idea: reach, saves, and shares are owner-only — nobody sees those for someone else's posts. But plays and handles are public, so business_discovery + media-info gives you exactly enough to score the whole niche for free.

Knowledge check

Why does the tracker store each post 'upsert on id' in SQLite?

Key takeaway

You don't write the tracker — you paste one prompt and Claude Code builds track.py: scrape → SQLite → median baseline → multiplier + velocity → ranked table. To make it real like mine, feed it Meta's business_discovery (one call per creator) and the media-info endpoint (public plays + handle), compute viral_ratio per creator, and store each post at data/refs/<handle>/<shortcode>.json.

Share