A 30,000-word synthesis of the open-sourced X "For You" feed algorithm — the xai-org/x-algorithm repository (Apache-2.0, May 15 2026 release) — read end-to-end as a working system, then re-derived as an operating manual for maximizing the return on every hour spent posting to X.
"We have eliminated every single hand-engineered feature and most heuristics from the system." —
README.md. The model learns relevance from your engagement history alone.
"Candidates cannot attend to each other." — the candidate-isolation attention mask. Your post is scored on its own absolute merit, never graded on a curve against its neighbours.
Final Score = Σ (weight_i × P(action_i))— the scoring formula. Reach is a weighted basket of predicted engagements, not a popularity contest.
Most advice about "the X algorithm" is folklore — post at 9am, use three hashtags, reply to big accounts, never include a link. In May 2026 xAI open-sourced the actual code. The folklore can now be replaced with the source.
This masterclass is built from a direct reading of that repository: the Rust orchestration layer (home-mixer), the in-memory in-network store (thunder), the JAX/Grok recommendation model (phoenix), the reusable candidate-pipeline framework, and the grox content-understanding service. It is not a summary of the README. Every claim is traced to a file, a function, or a struct field — and where the code alone is not enough, it is grounded in three live runs of the actual inference pipeline (phoenix/run_pipeline.py) against the shipped pre-trained model and an 84,564-post corpus.
The aim is not to make you an ML engineer. It is the opposite: the smallest accurate mental model of how the feed decides what to show, and the operating discipline that follows from it — so that an hour spent posting returns more reach, more followers, and more compounding distribution than an hour spent guessing.
0.39 in front of one user and 0.16 in front of another in the live runs — same post, same model, different viewer history. Your reach is not a property of your post; it is a property of the match between your post and each viewer.Ten modules trace the feed request from the moment it arrives to the moment a ranked list is returned, then a final module re-derives the whole thing as a return-on-investment operating system. Each module follows the same pattern: