Connect your 𝕏 account
· Mike

How the X (Twitter) Algorithm Works in 2026: The Complete Guide

X is the only major social platform where you can actually read the code that decides what gets seen and what gets buried. Not a simplified summary. Not a blog post from a PR team. The actual production code, sitting on GitHub for anyone to look at.

Most creators have not read it. This guide has.

In January 2026, xAI published the complete Grok-powered recommendation system at github.com/xai-org/x-algorithm, replacing the partial 2023 release with the full current architecture. On May 15, 2026, the largest single update to the repo landed: 187 files changed, over 18,000 lines of new code, including a runnable end-to-end pipeline that anyone can execute locally. The repo gained 1,600 GitHub stars in six hours.

This guide breaks down everything the code reveals: how the three-stage pipeline works, what the confirmed engagement weights actually are, what X has eliminated, what it has added, and specifically what you need to do differently to work with the algorithm rather than against it.

What the GitHub Repo Actually Contains

The repository at github.com/xai-org/x-algorithm is written primarily in Rust (62.9%) and Python (37.1%). It is the production code for X's For You feed recommendation system, not a demo or a simplified version.

According to the repo's own README: "This repository contains the core recommendation system powering the 'For You' feed on X. It combines in-network content (from accounts you follow) with out-of-network content (discovered through ML-based retrieval) and ranks everything using a Grok-based transformer model."

The May 2026 update added:

  • A downloadable pre-trained "Phoenix" model (256-dimension embeddings, 4 attention heads, 2 transformer layers) packaged as a roughly 3GB archive via Git LFS, enabling local inference
  • A single run_pipeline.py that runs the full retrieval-to-ranking pipeline end to end
  • An ads-blending module (home-mixer/ads/) that shows exactly how adverts get injected and positioned in the feed
  • "Grox" content-understanding classifiers for spam, policy enforcement, and brand-safety signals

The headline architectural shift: "We have eliminated every single hand-engineered feature and most heuristics from the system. The Grok-based transformer does all the heavy lifting by understanding your engagement history and using that to determine what content you'll want to engage with."

That matters enormously for creators. It means the algorithm is no longer following explicit rules written by engineers. It's a neural network reading the actual meaning of your posts and your history.

Stage One: Candidate Sourcing (How Posts Enter the Pipeline)

Every time someone opens X, the system processes over 500 million daily posts and narrows them to roughly 1,500 candidates per user, in under 200 milliseconds.

The pipeline pulls candidates from two distinct sources, using two different models:

In-Network (Thunder): Posts from accounts the user already follows. This is the simpler path: the system looks at who you follow and retrieves their recent content.

Out-of-Network (Phoenix Retrieval): Posts from accounts the user has never followed. This is where growth happens. Phoenix uses a Two-Tower neural network: one tower represents the user's interests based on their engagement history, the other represents the content of candidate posts. The dot product between the two towers produces a relevance score. Posts above a threshold enter the candidate pool.

This second source is critical for creators trying to reach new audiences. The Phoenix retrieval model doesn't care about your follower count. It cares about whether the content of your post matches the interest profile of users who might like it. That's why a zero-follower account can occasionally reach tens of thousands of people from a single post: if the content maps strongly to an interest cluster, it gets retrieved for users who don't follow the creator.

Both sources are combined and fed into the ranking stage together.

Stage Two: Ranking (How Posts Get Scored)

The combined candidate pool enters the Heavy Ranker, which is the core Phoenix transformer model. This is where the algorithmic magic happens and where most creators need to pay the most attention.

The Heavy Ranker predicts probabilities for multiple actions simultaneously, not a single relevance score. From the code's Weighted Scorer component:

Weighted Score = Sum of (weight x P(action)) across all predicted actions

The model predicts the probability that a given user will like, reply to, repost, bookmark, click through, watch, and dwell on each candidate post. Each predicted probability is multiplied by its corresponding weight, and those weighted probabilities are summed to produce the final score.

After individual scoring, an Author Diversity Scorer attenuates repeated author scores to ensure feed variety. This is why posting very frequently in a short window often hurts reach: the algorithm caps how many of your posts appear in any single follower's feed in a given session.

The final ranked list is sorted, top candidates are selected, and the feed is assembled by mixing those posts with ads, Spaces, trending topics, and who-to-follow suggestions.

Stage Three: Filtering (What Gets Removed Before Your Feed)

Before any post reaches the final feed, a filtering layer applies hard exclusions:

  • Content from blocked or muted accounts is removed entirely
  • NSFW content is filtered based on the Grox classifiers
  • Already-seen content is deprioritised
  • Content flagged for policy violations is removed or downranked
  • Engagement pod signals and artificial engagement patterns are detected and penalised

The filtering stage also applies the author diversity cap discussed above, ensuring no single creator dominates any user's feed in a session.

The Engagement Weights: Exact Numbers from the Code

This is the section most people actually want. The 2023 open-source release published the exact hand-tuned weights used in the legacy Heavy Ranker. The 2026 Phoenix model uses learned weights rather than hand-tuned ones, meaning the exact production values are not published. However, the 2023 weights are widely treated as directionally accurate, and the architecture confirms the same signal types are used. Here is what the code shows:

Action

Approximate Weight

Relative to a Like

Reply from author back to commenter

+75

150x

Repost / Retweet

+20

40x

Reply

+13.5

27x

Profile click

+12

24x

Link click (off-platform)

+11

22x

Bookmark

+10

20x

Like

+0.5

1x (baseline)

Block or mute by viewer

-3.0

-6x (negative)

Report

Strong negative

Significant penalty

A few things in this table that most guides miss entirely:

Link clicks are not penalised at the engagement weight level. They carry +11. What is penalised is having an external link in the post body during the candidate sourcing phase, before the engagement signals are even calculated. Posts with external links get suppressed at retrieval, not at ranking. That is a crucial distinction because it means the penalty applies regardless of engagement: even a great post with a link gets fewer eyeballs to begin with.

Bookmarks are worth 20 times a like. This is consistently underappreciated. The code treats a bookmark as a signal that the content has lasting value worth returning to. Posts with high bookmark rates get significantly better distribution than posts with equivalent like counts.

A single two-way reply chain is worth 150 likes. If you reply to someone's comment on your post, that single exchange generates +75 from the author-reply signal plus the original reply's +13.5. Combined: 88.5 points. That's 177 times a like. Four such exchanges on one post outscores 100 likes by almost three to one.

Negative signals are asymmetric. A block is worth -3 versus a like at +0.5. That's six times the magnitude in the negative direction. The algorithm cares far more about driving users away than about attracting likes. One genuine block from your content does more algorithmic damage than six likes can repair.

The Single Most Important Signal Nobody Talks About

Author-replies-back.

When someone leaves a comment on your post and you reply to that comment, the algorithm generates a specific signal called author-replies-back, weighted at +75 in the code. This is the highest single positive signal in the algorithm by a significant margin.

Most creators think of replying to comments as community management. The algorithm treats it as the strongest quality signal available. A post where the author replies to ten comments, each reply generating +75, has accumulated 750 points from author-replies-back alone before counting any other engagement. That same post with 750 likes generates 375 points from likes. The reply engagement is worth twice as much.

The practical implication: being present and responsive in the 30 to 60 minutes after you post is not optional. It is the primary mechanism by which the algorithm decides whether your post deserves wider distribution. Scheduling a post and going offline is leaving the most valuable engagement signal on the table every single time.

What the Algorithm Actually Reads in Your Posts

Before the January 2026 update, the algorithm used keyword matching and topic tags to classify content. The 2026 Phoenix transformer changed that fundamentally.

From the README: "We have eliminated every single hand-engineered feature and most heuristics from the system."

The Grok-based transformer now reads the actual semantic meaning of every post, using the same transformer architecture as the Grok-1 open-source model adapted for recommendation. It compares the meaning of your post against the interest profile of each potential viewer, based on their engagement history.

What this means practically:

Hashtags matter much less than they used to. The algorithm no longer relies primarily on hashtags for topic classification. It reads the post itself. Using two relevant hashtags is still fine and can help surface content in the Explore tab, but stuffing hashtags is now detected and penalised by the Grox spam classifiers.

Keyword stuffing is dead. Writing "growth marketing digital marketing social media marketing" in your post body in hopes of being classified in those topics doesn't work. The transformer understands context and penalises posts whose keyword distribution looks unnatural.

Your niche consistency signals matter. The transformer learns from your historical engagement: who replies to you, what topics they engage with elsewhere, and what clusters you belong to. Consistent niche posting builds a clearer interest profile, which makes it easier for Phoenix to retrieve your content for the right users.

Post length and structure carry signals. Dwell time is a ranking signal: the longer someone spends reading your post, the stronger the positive signal. Posts that are long enough to require scrolling or reading time (without being so long they lose the reader) perform better than one-line posts purely on dwell time grounds.

TweepCred: Your Reputation Score Explained

The GitHub repository includes a PageRank-derived reputation system called TweepCred (named directly in the codebase). This is essentially your account's trust and authority score, used to calibrate how aggressively the algorithm distributes your content.

TweepCred is calculated using a variant of the PageRank algorithm: accounts that are followed and engaged with by other high-TweepCred accounts accumulate more reputation. It's similar in concept to how Google values links from high-authority sites over links from low-authority ones.

From the repo: "Page-Rank algorithm for calculating X User reputation."

Practical implications:

Engagement quality beats engagement quantity. A reply from a high-TweepCred account (a verified Premium user with strong engagement history) carries more weight than ten replies from low-TweepCred accounts. This is why engagement pods with random strangers largely don't work: the algorithm detects that the engagements come from accounts with no organic relationship to your content.

Premium accounts have higher baseline TweepCred. The verification process and subscriber status feed into the initial score, which then compounds through genuine engagement.

Blocks and reports reduce your TweepCred. When high-TweepCred accounts block or report you, the negative effect is significantly larger than when low-TweepCred accounts do.

Accounts followed by high-TweepCred users get a distribution boost. If prominent accounts in your niche follow you, your reach to their networks increases. This compounds: getting followed by ten high-TweepCred accounts in your niche is algorithmically more valuable than getting followed by 500 low-TweepCred accounts.

SimClusters: How You Get Discovered by New Audiences

The repository includes the SimClusters system, which is the mechanism behind most organic out-of-network discovery on X.

SimClusters are approximately 145,000 interest communities computed from the social graph. Each community is defined by which accounts tend to engage with similar content. The algorithm assigns both users and posts to communities based on engagement patterns.

From the codebase: "Community detection and sparse embeddings into those communities."

When you post content, the algorithm assigns it to relevant SimClusters based on its semantic content and initial engagement patterns. Your post then gets retrieved for users in those clusters through the Phoenix out-of-network retrieval system.

This is why niche consistency accelerates growth. The more consistently you post in one topic area, the more strongly the algorithm associates you with specific SimClusters, and the more reliably it retrieves your content for users who have shown interest in that topic area. Accounts that post across many unrelated topics get assigned to clusters weakly or inconsistently, which means they get retrieved for fewer out-of-network users.

The practical takeaway: every time you post about a completely different topic, you're potentially confusing the SimClusters system about who to show your content to. Occasional off-topic posts are fine. Making them a regular pattern dilutes your cluster affinity and hurts discovery.

The Premium Gap: What Paying Actually Buys You

The algorithm code explicitly includes visibility modifiers for Premium subscribers. This is not speculation: it is in the GitHub repository.

From the code comments in the January 2026 release, Premium accounts receive:

A For You bias: Premium posts appear more frequently to non-followers in the For You feed. The multiplier has increased with each quarterly update since the Premium tier was introduced.

Boosted replies: Premium replies rank higher in conversation threads. This is the single most impactful Premium benefit for growth because it directly amplifies the reply strategy. When you reply to a popular post as a Premium subscriber, your reply surfaces higher in the thread, meaning more of that account's audience sees it.

Higher baseline TweepCred: Premium verification feeds into the initial TweepCred score.

Reduced link penalty: The post-body link suppression is less severe for Premium accounts, though it still exists.

The May 2026 update widened the gap further. The commit notes describe a "visibility multiplier for Premium accounts that increases each quarter."

One important nuance from the code: "Premium amplifies your existing engagement signals. It doesn't replace them." A Premium account posting low-quality content will still underperform a free account posting content that drives genuine replies and bookmarks. The multiplier applies to your score, not to a fixed minimum.

What the 2026 Update Changed

Several significant changes from the May 2026 update are worth calling out specifically.

The Following feed is now algorithmic. In November 2025, X ended the chronological Following feed and switched both feeds to Grok-ranked ordering. A chronological view is still accessible in settings, but it is no longer the default. This means even accounts that follow you don't necessarily see your posts in order: they see whichever of your posts the algorithm predicts they'll engage with most.

Long-form single posts now outperform threads in distribution. The algorithm scores per-post engagement, not per-thread. A thread splits likes, replies, and bookmarks across multiple posts, diluting signals. A single long-form post (Premium subscribers can write up to 25,000 characters) concentrates all engagement on one piece of content. From the explainx.ai analysis of the code release: "Threads fragment engagement; long-form consolidates signals." Threads still work well for specific formats (tutorials, sequential breakdowns), but the distribution advantage has shifted toward long-form single posts for opinion and analysis content.

Reply downvoting is now a training signal. Since March 2026, Premium users can downvote replies they perceive as low-quality or AI-generated. From the Social Pilot analysis of the update: vague or AI-sounding replies now carry real ranking risk. The Grox classifiers use downvote patterns as training data to identify and suppress similar content going forward.

The creator diversity cap is more aggressive. The Author Diversity Scorer now applies a stricter daily limit on how many of your posts appear in any single follower's For You feed per session. Posting ten times per day does not reach ten times as many people: the algorithm distributes impressions across fewer viewers per post.

What Suppresses Your Reach (From the Code)

The algorithm's negative signals are as important as the positive ones, and the code is explicit about what triggers them.

External links in the post body. Applied at candidate sourcing, before engagement is measured. A post with an external link gets retrieved for fewer potential viewers regardless of content quality. The fix is always to put links in the first reply, not the post body.

High block or mute rate. The code tracks what percentage of users who see your content choose to block or mute you. A consistently high block rate is a strong negative TweepCred signal. If certain types of posts generate blocks, the algorithm learns to show those posts to fewer people.

Engagement pod patterns. The Grox classifiers specifically look for engagement patterns that suggest coordinated artificial boosting: accounts with no organic relationship engaging simultaneously, unusual like-to-reply ratios, and timing patterns inconsistent with organic discovery. Detected engagement pods generate a penalty rather than a boost.

Posting at very high volume. The author diversity cap means posting ten or more times per day actively dilutes your impressions per post. The algorithm limits each creator's presence in any single feed session, so more posts just means fewer viewers per post rather than more total reach.

Inconsistent posting. The algorithm treats accounts that post in sporadic bursts as lower quality than accounts posting consistently. From the code's candidate sourcing logic, recency and posting consistency both feed into account quality signals.

Hashtag stuffing. The Grox spam classifiers detect more than two hashtags as a spam signal in most contexts. The algorithm has moved away from hashtag-based classification, so hashtag stuffing no longer helps discovery and now actively hurts distribution.

Engagement bait. Explicit engagement bait phrases ("like if you agree", "RT to share") are detected by the Grox classifiers and flagged. The resulting engagements carry reduced weight because they're predicted to be low-quality signals.

NSFW content without appropriate flagging. The Grox content classifiers apply hard filtering to NSFW content. Unflagged NSFW content gets suppressed across the board.

How to Beat the Algorithm: 12 Tactics Grounded in the Code

Every one of these is derived from specific things in the GitHub repository, not general social media advice.

1. Reply to every comment within the first hour. The author-replies-back signal (+75 each) is the highest-weight positive signal in the algorithm. Four replies to comments on your post generates 300 points, which outscores 600 likes. Schedule posts when you can be present to engage for at least 30 minutes afterwards.

2. Write for bookmarks, not likes. Bookmarks are worth 20 times a like in the code. The content type that drives bookmarks is reference material: data, frameworks, how-to guides, resource lists, research summaries. Ask yourself before posting: would someone save this to read again later? If no, it's probably optimised for likes rather than for algorithmic distribution.

3. Keep external links out of post bodies. Put every link in the first reply to your own post. The link suppression happens at candidate sourcing, so even the best content gets retrieved for fewer people when it contains a link. This is one of the highest-impact, lowest-effort changes you can make.

4. Post consistently within one niche. SimClusters assigns you to interest communities based on your engagement patterns. Consistent niche posting builds cluster affinity, which improves your out-of-network discovery. Spreading across many topics dilutes this affinity. Post about related subjects within a broad niche rather than completely different topics.

5. Consider long-form single posts over threads. Since the November 2025 Following feed change and the May 2026 update, long-form posts concentrate engagement signals in one place rather than splitting them across a thread. If you have Premium (and therefore 25,000 characters available), a single well-structured 600-word post will often outperform a 10-post thread on the same topic.

6. Post native video, vertically, under 60 seconds. Video generates watch-time signals unavailable to any other format. The algorithm tracks 50% completion rate and full completion as distinct signals. A YouTube link generates zero video-watch signals. Upload directly to X, format vertically (9:16), and keep it under 60 seconds for the biggest distribution bonus.

7. Build TweepCred through quality over quantity. The PageRank-based reputation system values engagement from high-TweepCred accounts. Getting followed and replied to by established accounts in your niche compounds your distribution over time. One genuine interaction from a respected account in your field is worth more than dozens from low-engagement accounts.

8. Get X Premium. The visibility multiplier is in the code. It's not speculation. Premium replies rank higher in threads, Premium posts appear more often in For You feeds, and the gap has widened with each quarterly update. At £6 to £8 per month for a creator trying to grow, it's one of the cheaper distribution investments available.

9. Make your replies genuinely valuable. Reply downvoting (introduced March 2026) feeds into the Grox training data and can suppress your replies across the platform. One-word replies, generic praise, and AI-generated responses are the primary targets. Write replies that would stand alone as good content. The algorithm now treats your reply quality as a signal about your account quality.

10. Post when you can engage immediately. Tuesday to Thursday, 9am to 11am in your audience's time zone, is the established peak window. But what matters more than the specific time is whether you're available afterwards. A post at 10am Wednesday where you reply to every comment in the first hour will consistently outperform a post at the theoretically perfect time where you're unavailable to engage.

11. Avoid posting at very high volume. The author diversity cap limits how many of your posts appear in any one follower's feed per session. Ten posts in one day means each post reaches fewer of your followers than one carefully timed post would. For most accounts, two to three well-executed posts per day is the ceiling before the diversity cap starts reducing per-post reach.

12. Track your bookmark rate, not just your like rate. Since bookmarks carry 20x the algorithmic weight of likes, a post with 50 bookmarks and 200 likes is outperforming a post with 20 bookmarks and 500 likes. X Analytics shows bookmark data per post. Use it as your primary content quality signal.

Frequently Asked Questions

Is the GitHub repo really the production algorithm?

Yes. The repository at github.com/xai-org/x-algorithm is explicitly described as the production code for the For You feed. It is not a demo, a simplified version, or a research prototype. The May 2026 update even includes a runnable inference pipeline that executes the same retrieval-to-ranking logic as the production system. That said, some proprietary components (live real-time signals, A/B testing infrastructure, operational tooling) are not included.

Do the 2023 engagement weights still apply?

The 2026 Phoenix model uses learned weights rather than the hand-tuned weights published in 2023. The exact production values are not in the public repo. However, the same signal types are confirmed in the architecture, and the 2023 weights are treated as directionally accurate by researchers who have analysed both releases. The relative ordering (replies much more valuable than likes, bookmarks much more valuable than likes) is confirmed in the 2026 code structure.

Does follower count affect reach?

Yes, but less directly than most people assume. Follower count feeds into TweepCred and provides your in-network candidate pool. But the author diversity cap means a large following doesn't translate proportionally to reach: you still can't dominate any single follower's feed. Out-of-network discovery through Phoenix retrieval and SimClusters is based on content quality and cluster affinity, not follower count.

What is TweepCred and can I improve it?

TweepCred is X's PageRank-based reputation score, named directly in the codebase. It's improved by: getting followed and engaged with by high-TweepCred accounts, maintaining a low block and mute rate, having Premium verification, and posting consistently without triggering spam signals. It compounds over time and is one reason why accounts that post genuinely useful niche content grow faster over the long term than accounts trying to chase short-term virality.

Is it possible to game the algorithm?

The Grox classifiers specifically detect and penalise coordinated artificial engagement, hashtag stuffing, engagement bait, and posting patterns that look automated. The May 2026 update made these classifiers significantly more sophisticated. "Gaming" in the traditional sense (pods, bots, follow/unfollow) actively backfires. Working with the algorithm means genuinely producing content that drives replies, bookmarks, and dwell time. There is no shortcut that the code doesn't already account for.

How often does the algorithm change?

The repo commits to public updates every four weeks. The May 2026 update was the largest single change since the January 2026 launch. Minor weight adjustments and classifier updates happen more frequently and are not always reflected in the public repo. The core principles (rewarding genuine engagement, penalising spam and off-platform links, prioritising replies and bookmarks over likes) have remained consistent across all updates.

GitHub source: github.com/xai-org/x-algorithm