Tech and Ai

I Studied the X Algorithm Code So You Don’t Have To. Here’s Exactly How to Go Viral.

I Studied the X Algorithm Code So You Don't Have To. Here's Exactly How to Go Viral.

The actual source code is public on GitHub. I read every line. This is what it means for you.


X (formerly Twitter) quietly published the code that decides who sees your posts.

Not a blog post. Not a vague explanation. The actual software. The real thing. Engineers can download it, read it, and run it.

I did exactly that.

And what I found changes everything about how you should be posting.

Forget every “Twitter growth hack” you’ve read. Forget the advice about posting 10 times a day. Forget the threads that say “just add value.” Most of it is wrong, outdated, or completely backwards.

This is what the code actually says.

How To Make Money On X: A Complete Guide To Monetizing Your Content In 2025
How To Join And Get Paid From Twitter Creator Ads Revenue Sharing

First, Let Me Explain What This Algorithm Even Does

Imagine you walk into a massive library with 500 million books added every single day.

You can’t read all of them. Nobody can. So the librarian — that’s the algorithm — picks about 1,500 books it thinks you’ll love and puts them on your desk.

That’s it. That’s the For You feed.

Every time you open X, the system has already sorted through 500 million posts and narrowed them down to roughly 1,500 just for you. It does this in under 200 milliseconds — faster than the blink of an eye.

The question is: how does it decide which 1,500?


The Algorithm Has Two Jobs

Think of it like a two-step hiring process.

Step 1: Find the candidates. The algorithm first collects posts from two places.

The first place is called Thunder. This is simple — it grabs recent posts from accounts you already follow. These are the people you chose to follow, so their posts are automatically in the running.

The second place is called Phoenix. This is the magic part. Phoenix goes out into the entire X universe — every post from every account, including accounts you’ve never heard of — and tries to find posts you’d probably like based on your history. It’s like a friend who knows your taste perfectly and says, “Hey, I know you don’t follow this person, but you’re going to love this post.”

Step 2: Rank everything. Once it has candidates from both sources, it runs them all through a scoring system. The highest scores win. Your feed is the winners.

Simple concept. Complicated math.


The Score Is Everything. Here’s How It Works.

Every post gets a number. The higher the number, the more people see it.

That number is calculated by predicting: “If this person sees this post, what are they likely to do?”

The algorithm doesn’t just predict one action. It predicts many:

  • Will they like it?
  • Will they reply?
  • Will they repost it?
  • Will they click a link?
  • Will they bookmark it?
  • Will they watch the video?
  • Will they click the author’s profile?
  • Will they share it in a DM?
  • Will they block the author?
  • Will they report the post?
  • Will they say “not interested”?

Then — and this is the key part — it multiplies each prediction by a weight.

Think of “weights” like points in a video game. Not all actions are worth the same points.

Here’s the actual breakdown, from the code:

ActionPoints
Repost20
Reply13.5
Profile click12
Link click11
Bookmark10
Follow after seeing8
Share / DM7
Dwell (just reading slowly)5
Video view4
Photo expand3
Like1

Read that table again. Slowly.

A like is worth 1 point.

A repost is worth 20 points.

A reply is worth 13.5 points.

This means one person replying to your post does more for your reach than 13 people liking it.

One repost does more than 20 likes.

If your entire strategy is getting likes, you are basically doing volunteer work for zero reward. Likes feel good but they don’t grow your account. Replies and reposts grow your account.


The Negative Points Nobody Talks About

Here’s where it gets scary.

The algorithm also predicts bad actions and gives them negative points that actively hurt your score.

ActionPenalty
Report−2.7
Block−3.0
Mute−2.4
Not Interested−1.8

Now here’s the brutal part that most people don’t understand.

These penalties don’t just affect the one person who blocked or reported you. The algorithm uses that signal to predict that other similar users probably feel the same way.

So if 10 people report one post, the algorithm quietly lowers your score for thousands of users who’ve never even seen it.

One wave of reports can silently tank your reach for weeks.

This is why rage-bait and inflammatory content is a trap. Yes, it might get high engagement in the short term. But the reports and blocks it triggers are quietly destroying your account in the background.


The Rule That Changes Everything About How Often You Should Post

Most “growth gurus” tell you to post 5, 10, even 15 times a day.

The code says that’s a mistake.

There is a piece of the algorithm called the Author Diversity Scorer. Its entire job is to make sure no single account floods everyone’s feed. So if you post 8 times today and all 8 posts score well, the algorithm deliberately turns down the volume on your later posts — just to keep the feed varied.

You’re essentially competing against yourself.

The math is simple: two great posts will almost always outperform eight average ones. The diversity scorer punishes volume and rewards quality.

Post 2-3 times a day, maximum. Make each one count.


The First Hour Is the Only Hour That Matters

The part of the algorithm that handles posts from accounts you follow — the Thunder system — works from an in-memory store. This is engineering speak for: it prioritizes fresh, recent posts, and old posts fall out of the running quickly.

If a post doesn’t get engagement in the first 30 to 60 minutes after you publish it, the algorithm basically moves on.

This is why posting at the wrong time is so damaging. You could write the best post of your life, publish it at 3am when all your followers are asleep, and it dies without ever getting a real chance.

Post when your specific audience is online and awake. For most English-speaking audiences, Tuesday through Thursday mornings tend to work well — but check your own analytics because your niche may differ.


Replies Are the Most Underrated Feature on the Platform

We already established that a reply is worth 13.5x a like.

But it goes even further than that.

When you reply to someone and they reply back, you’ve created a conversation chain. The algorithm reads that chain as a strong positive signal — two people so engaged with this content that they’re talking to each other.

Even better: when you reply to comments on your own posts, you’re generating additional reply signals on your own content. You’re literally boosting your own score.

The practical move: for at least the first hour after every post, stay online and reply to every single comment you receive. Be genuine. Ask follow-up questions. Keep the conversation going.

Not because it’s nice (though it is). Because the algorithm is watching and counting.


The Video Secret Nobody Is Using

If you post videos, there’s a specific rule in the code that changes how your video is scored.

Videos only receive the full video-quality scoring boost if they clear a minimum duration threshold. Short, throwaway clips — the kind people swipe past in two seconds — don’t qualify for the bonus.

If your video doesn’t hit that minimum length, it gets scored like a regular post. None of the video-specific engagement signals apply.

What this means: if you’re going to do video, make it long enough to watch. Aim for at least 30-60 seconds of genuine content. A video someone actually watches all the way through is a massive signal to the algorithm. A video someone scrolls past in 1 second is almost worthless.


How the Algorithm Decides What “Your Type of Content” Even Is

Here’s the part that feels like magic but is actually just math.

Every user on X has what’s called an embedding — think of it as a fingerprint made from your behavior. Every post you liked, every account you followed, every topic you engaged with gets fed into a model that builds a picture of who you are and what you care about.

Posts also have embeddings. Every post gets turned into a similar fingerprint based on its content and who has engaged with it.

The algorithm then plays matchmaker. It finds posts whose fingerprint closely matches your fingerprint, and shows you those.

Why this matters for you as a creator:

If you post about 10 completely different topics — tech, cooking, politics, sports, memes — your content fingerprint is a blur. You don’t match anyone well. The algorithm can’t figure out who to show your posts to.

But if you consistently post about one or two specific things, your fingerprint gets sharp and clear. The algorithm knows exactly which audience to push your content to. Your posts start finding people who’ve never heard of you but are almost guaranteed to love what you write.

Pick a lane. Stay in it. This isn’t just content advice. It’s literally how the math works.


The Grok Layer: Your Posts Are Being Read and Judged Now

This is the newest and most underestimated change.

In late 2025, X announced that Grok — the AI — is now reading every post and watching every video to help rank content.

What Grok is doing, among other things, is sentiment analysis. It’s judging the tone of your posts.

Constructive, positive, interesting content gets a distribution boost.

Negative, combative, rage-inducing content gets quietly throttled — even if it generates high engagement.

This is a huge shift. For years, “controversy gets clicks” was a reliable growth strategy on social media. The algorithm rewarded any engagement, good or bad.

That era is over on X.

A post that makes people angry might still get replies and reposts — but the sentiment penalty from Grok can cancel out those gains and then some. You can write a post that goes “viral” in terms of attention and still see your reach slowly shrink because of the tone signal.

Write content that makes people think, laugh, learn, or feel something good. That’s not just good advice. That’s the algorithm’s current scoring model.


The Link Problem (And the Easy Fix)

Here’s a fact that should make you rethink everything: external links kill reach.

Posts with links in them receive a 30-50% reach penalty. X wants people to stay on X, and every external link is a threat to that goal.

The easy fix that actually works:

Write your post without any link. Publish it. Then immediately reply to your own post with the link. The post itself doesn’t take the penalty. Your audience still gets the link. The algorithm sees a clean engagement signal.

It takes an extra 10 seconds and it makes a significant difference.


The Audit Checklist: How to Score Every Post Before You Publish

Before you hit post, run through this:

Will this make someone want to reply? If the answer is no, rewrite it. A reply is 13.5x a like. Design for conversation.

Am I posting at the right time? Check when your followers are online. Don’t publish when they’re asleep.

Have I removed any links from the post itself? Put them in a reply after posting.

Is this consistent with what I always post about? If it’s a random topic, it works against your content fingerprint.

Could this get me reported or blocked? If yes, the downside risk is severe. Ask yourself if it’s worth it.

Is it positive or constructive in tone? With Grok sentiment scoring active, inflammatory framing is a hidden tax on your reach.

Am I able to stick around for 60 minutes to reply to comments? If not, consider posting when you can.


The Simple Version of Everything Above

The X algorithm rewards content that starts real conversations.

That’s it. Everything else — the weights, the embeddings, the diversity scorer, the sentiment analysis — all of it is just math trying to answer one question: did this post make people want to engage meaningfully?

A like is a head nod. A reply is a conversation. The algorithm wants conversations.

So write things worth talking about. Reply to everyone who responds. Stay consistent in your topic. Post less but make it count.

The code is public. The rules are known. There’s no more excuse for guessing.

Now you know exactly how the game is played.


All technical details in this article are sourced directly from the open-source X algorithm repository published at github.com/xai-org/x-algorithm.

Leave a Reply