<?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: shashank budem</title>
    <description>The latest articles on DEV Community by shashank budem (@shashank_budem_83f714ee61).</description>
    <link>https://dev.to/shashank_budem_83f714ee61</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%2F4196860%2F4ea3ff30-4271-473b-9a17-d60998f538c4.png</url>
      <title>DEV Community: shashank budem</title>
      <link>https://dev.to/shashank_budem_83f714ee61</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shashank_budem_83f714ee61"/>
    <language>en</language>
    <item>
      <title>Git Séance: calling deleted code back from the dead</title>
      <dc:creator>shashank budem</dc:creator>
      <pubDate>Thu, 29 Oct 2026 20:54:56 +0000</pubDate>
      <link>https://dev.to/shashank_budem_83f714ee61/git-seance-calling-deleted-code-back-from-the-dead-2g5h</link>
      <guid>https://dev.to/shashank_budem_83f714ee61/git-seance-calling-deleted-code-back-from-the-dead-2g5h</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week4-2026-10-26"&gt;Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every function you've ever deleted is still haunting your repo. It's in &lt;code&gt;.git&lt;/code&gt;, every version of it, on every branch. You just can't reach it, because the only way in is by name (&lt;code&gt;git log -S imageFilesFromClipboard&lt;/code&gt;), and the whole reason you're looking is that you don't remember the name.&lt;/p&gt;

&lt;p&gt;I remember &lt;em&gt;what it did&lt;/em&gt;. "The thing that pulled pasted images out of the clipboard. I deleted it in July, I think."&lt;/p&gt;

&lt;p&gt;So for Halloween week I built a séance for git.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Git Séance&lt;/strong&gt; finds every function that ever lived in your repos and has since died, and lets you call one back by describing it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;seance summon &lt;span class="s2"&gt;"paste images from the clipboard"&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; 2
&lt;span class="go"&gt;   17  0.82  imageFilesFromClipboard      arivu-agent/desktop/renderer/src/App.tsx
             born 2026-06-21, died 2026-07-03 in f2e18500 "Add drag-and-drop image attachments"
   15  0.69  pullRequestCheckLogCommand   arivu-agent/src/agent/taskWorktree.ts
             born 2026-07-04, died 2026-07-05 in 39d376bc "Broaden PR check evidence capture"

&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;seance raise 17
&lt;span class="go"&gt;// imageFilesFromClipboard from desktop/renderer/src/App.tsx, last seen in f2e18500^
function imageFilesFromClipboard(clipboard: DataTransfer) {
&lt;/span&gt;&lt;span class="gp"&gt;  const files = Array.from(clipboard.files).filter((file) =&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;SUPPORTED_IMAGE_TYPES.has&lt;span class="o"&gt;(&lt;/span&gt;file.type&lt;span class="o"&gt;))&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c"&gt;  ...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It tells you when each ghost was born, when it died, and the commit that killed it (it arrived with the project's first commit on June 21 and died on July 3 in "Add drag-and-drop image attachments", replaced by a better design). &lt;code&gt;raise&lt;/code&gt; brings back its last living version.&lt;/p&gt;

&lt;p&gt;Everything runs locally with &lt;strong&gt;EmbeddingGemma 2&lt;/strong&gt;, an open-weight model. Your history, including the parts you deleted on purpose, never leaves your laptop.&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Two of my public repos, my coding agent Arivu and Bharat Choropleth, a map library:&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;$ &lt;/span&gt;seance index ~/Documents/arivu-agent ~/Documents/&lt;span class="s2"&gt;"Bharath Choropleth"&lt;/span&gt;
arivu-agent: 26 ghosts &lt;span class="o"&gt;(&lt;/span&gt;3 s&lt;span class="o"&gt;)&lt;/span&gt;
Bharath Choropleth: 7 ghosts &lt;span class="o"&gt;(&lt;/span&gt;1 s&lt;span class="o"&gt;)&lt;/span&gt;
embedding 33 unique ghosts…

&lt;span class="nv"&gt;$ &lt;/span&gt;seance summon &lt;span class="s2"&gt;"warn me before running dangerous shell commands"&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; 1
   19  0.81  detectCommandWarnings        arivu-agent/desktop/renderer/src/App.tsx
             born 2026-06-21, died 2026-07-03 &lt;span class="k"&gt;in &lt;/span&gt;528eea09 &lt;span class="s2"&gt;"Implement Arivu harness app features"&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;seance summon &lt;span class="s2"&gt;"fetch live temperatures for each region"&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; 2
   27  0.86  start                        Bharath Choropleth/examples/observatory/live/app.js
             born 2026-09-06, died 2026-09-06 &lt;span class="k"&gt;in &lt;/span&gt;15edc63c &lt;span class="s2"&gt;"feat(examples): live temperature as the first indicator in a"&lt;/span&gt;
   31  0.83  temperaturesFor              Bharath Choropleth/examples/observatory/live/app.js
             born 2026-09-06, died 2026-09-06 &lt;span class="k"&gt;in &lt;/span&gt;15edc63c &lt;span class="s2"&gt;"feat(examples): live temperature as the first indicator in a"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The code never says "dangerous": &lt;code&gt;detectCommandWarnings&lt;/code&gt; just looks for things like &lt;code&gt;rm -rf&lt;/code&gt; and &lt;code&gt;sudo&lt;/code&gt;. Meaning, not keywords.&lt;/p&gt;
&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/shashankbudem" rel="noopener noreferrer"&gt;
        shashankbudem
      &lt;/a&gt; / &lt;a href="https://github.com/shashankbudem/git-seance" rel="noopener noreferrer"&gt;
        git-seance
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Summon deleted functions back from your git history by describing them. Local, on EmbeddingGemma 2.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Git Séance&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Every function you ever deleted is still in your git history. Git Séance lets you call it back by describing it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You remember &lt;em&gt;that you wrote it&lt;/em&gt;: "the thing that pulled pasted images out of the clipboard", deleted sometime in July
You don't remember its name, so &lt;code&gt;git log -S&lt;/code&gt; can't help you. Git Séance walks every version of every file on every
branch, finds the functions that no longer exist at HEAD, and lets you search them by meaning with
&lt;a href="https://huggingface.co/google/embeddinggemma-2" rel="nofollow noopener noreferrer"&gt;EmbeddingGemma 2&lt;/a&gt;, an open-weight model running on your laptop.&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;
&lt;pre class="notranslate"&gt;&lt;code&gt;$ seance summon "paste images from the clipboard" -k 2
   17  0.82  imageFilesFromClipboard      arivu-agent/desktop/renderer/src/App.tsx
             born 2026-06-21, died 2026-07-03 in f2e18500 "Add drag-and-drop image attachments"
   15  0.69  pullRequestCheckLogCommand   arivu-agent/src/agent/taskWorktree.ts
             born 2026-07-04, died 2026-07-05 in 39d376bc "Broaden PR check evidence capture"
$ seance raise 17
// imageFilesFromClipboard from desktop/renderer/src/App.tsx, last seen in f2e18500^ (git -C ~/Documents/arivu-agent show f2e18500^:desktop/renderer/src/App.tsx)&lt;/code&gt;&lt;/pre&gt;…&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/shashankbudem/git-seance" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;About 220 lines of Python, plus a smoke test and the evaluation script.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;I built this with Claude Code as my pair programmer: I picked the idea and made the calls, and the agent did most of the typing and the evaluation runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Read the whole graveyard in one pass.&lt;/strong&gt; &lt;code&gt;git log --all --raw&lt;/code&gt; lists every version (blob) of every source file on every branch, with the commit that created it and the commit that replaced it. One &lt;code&gt;git cat-file --batch&lt;/code&gt; stream reads them all. My 89-commit agent repo takes 3 seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Find the functions.&lt;/strong&gt; tree-sitter pulls every function of five or more lines out of TypeScript, JavaScript, Python and Rust. I reused the extractor from my Week 3 entry, &lt;a href="https://dev.to/shashank_budem_83f714ee61/code-deja-vu-a-git-hook-that-remembers-the-code-i-forgot-i-wrote-395e"&gt;Code Déjà Vu&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Decide who's really dead.&lt;/strong&gt; This was the actual problem. Every edit leaves the old version of a still-living function behind, so "not at HEAD" would bury you in near-copies of code you still have. A function only counts as a ghost if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nothing with its name still lives in that file at HEAD (so it wasn't just edited),&lt;/li&gt;
&lt;li&gt;its exact body isn't anywhere at HEAD (so it wasn't moved),&lt;/li&gt;
&lt;li&gt;and it isn't alive at the tip of another branch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my smoke test, a deleted function is summoned, an edited one isn't, and one moved to another file isn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Search by meaning.&lt;/strong&gt; Each ghost's last living version is embedded with EmbeddingGemma 2, cut to its first 256 Matryoshka dimensions; your description uses the model's &lt;code&gt;task: code retrieval&lt;/code&gt; prompt. These are the settings I'd already tuned for Code Déjà Vu, and if its &lt;code&gt;dejavu serve&lt;/code&gt; is running, Git Séance borrows the warm model so a summon takes 0.1 to 0.3 s instead of ~13 s.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does it work?
&lt;/h3&gt;

&lt;p&gt;My agent described 18 real deleted functions from four repos (three of mine and one open-source project), reading each one first. They came from a random sample, with trivial ones dropped and a few more picked by name. The eval script then checks where the right one ranked among 229 unique ghosts:&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;right function first&lt;/th&gt;
&lt;th&gt;in the top 5&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Git Séance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;17/18&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;18/18&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keyword matching (rank by query words found in the code)&lt;/td&gt;
&lt;td&gt;5/18&lt;/td&gt;
&lt;td&gt;14/18&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The one miss came second. Small set, small graveyard, descriptions written right after reading the code: a first measurement, not a benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The past is private.&lt;/strong&gt; Deleted code is where the embarrassing stuff lives: the hack you're glad is gone, the config that once held a real key, the client's code you were never supposed to keep. Nobody should have to upload their &lt;em&gt;whole history&lt;/em&gt; to a cloud API to search it. An open-weight model reads it locally, offline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open tools compose.&lt;/strong&gt; git's plumbing is open, tree-sitter is open, EmbeddingGemma 2 is open, and so is last week's project. Git Séance is mostly those four things plugged together, which is why it's about 220 lines and not 2,000.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open history is the point.&lt;/strong&gt; git keeps everything because nothing is ever really gone in open source: someone, somewhere, can always check out an old commit. Git Séance just gives that memory a search box.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best Use of Gemma&lt;/strong&gt;: EmbeddingGemma 2 does all the searching, locally, with its Matryoshka-shrunk 256-dimension embeddings.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
    </item>
    <item>
      <title>Code Déjà Vu: a git hook that remembers the code I forgot I wrote</title>
      <dc:creator>shashank budem</dc:creator>
      <pubDate>Tue, 20 Oct 2026 23:18:56 +0000</pubDate>
      <link>https://dev.to/shashank_budem_83f714ee61/code-deja-vu-a-git-hook-that-remembers-the-code-i-forgot-i-wrote-395e</link>
      <guid>https://dev.to/shashank_budem_83f714ee61/code-deja-vu-a-git-hook-that-remembers-the-code-i-forgot-i-wrote-395e</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week3-2026-10-19"&gt;Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I have written the same byte-size formatter four times. Same project, four files: two functions called &lt;code&gt;formatBytes&lt;/code&gt;, a &lt;code&gt;formatByteSize&lt;/code&gt; that rounds megabytes to one decimal, and a &lt;code&gt;formatPreviewBytes&lt;/code&gt; that is character-for-character one of the &lt;code&gt;formatBytes&lt;/code&gt;, renamed. I found this out this week. It is not the worst thing I found.&lt;/p&gt;

&lt;p&gt;So for Sloth Week I built the laziest tool I could think of: one that makes me write &lt;em&gt;less&lt;/em&gt; code by remembering what I already wrote.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Code Déjà Vu&lt;/strong&gt; is a git pre-commit hook. When you commit a function that already exists somewhere in your repos (any repo, any name, copied or rewritten from scratch), it tells you before the duplicate lands:&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;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"add helpers"&lt;/span&gt;
déjà vu: humanFileSize &lt;span class="o"&gt;(&lt;/span&gt;src/files.ts:1&lt;span class="o"&gt;)&lt;/span&gt;
   already &lt;span class="k"&gt;in &lt;/span&gt;arivu-agent/src/tools/registry.ts:1567 as formatByteSize &lt;span class="o"&gt;(&lt;/span&gt;similarity 0.96&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It also lets you find your own code by describing it, because I never remember what I named things:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ dejavu search "sort states by an indicator, lower is better"
0.88  ranked                     Bharath Choropleth/examples/observatory/react/src/App.tsx:109
0.85  ranked                     Bharath Choropleth/examples/observatory/js/app.js:75
0.79  trend                      Bharath Choropleth/examples/soc-dashboard/src/feeds.ts:260
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;(Yes, that's the same function in two example apps. It finds my duplicates even when I'm only searching.)&lt;/p&gt;

&lt;p&gt;Everything runs on my laptop with &lt;strong&gt;EmbeddingGemma 2&lt;/strong&gt;, an open-weight embedding model. No code leaves the machine, it works offline, and it costs nothing per commit.&lt;/p&gt;

&lt;p&gt;The hook never blocks a commit. It warns and gets out of the way. A hook that blocks you once is a hook you uninstall.&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;A fresh scratch repo with the hook installed. I commit three small helpers: a file-size formatter, an abort-signal forwarder, and a leap-year check.&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;$ &lt;/span&gt;dejavu install-hook
installed …/dejavu-demo/.git/hooks/pre-commit

&lt;span class="nv"&gt;$ &lt;/span&gt;git add src
&lt;span class="nv"&gt;$ DEJAVU_SECOND_OPINION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nv"&gt;DEJAVU_DECIDER_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://127.0.0.1:11435 git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"add helpers"&lt;/span&gt;
déjà vu: forwardCancellation &lt;span class="o"&gt;(&lt;/span&gt;src/abort.ts:1&lt;span class="o"&gt;)&lt;/span&gt;
   already &lt;span class="k"&gt;in &lt;/span&gt;arivu-agent/src/agent/OpenAICompatibleChatClient.ts:979 as linkAbortSignal &lt;span class="o"&gt;(&lt;/span&gt;similarity 0.93, second opinion 97% same&lt;span class="o"&gt;)&lt;/span&gt;
déjà vu: humanFileSize &lt;span class="o"&gt;(&lt;/span&gt;src/files.ts:1&lt;span class="o"&gt;)&lt;/span&gt;
   already &lt;span class="k"&gt;in &lt;/span&gt;arivu-agent/src/tools/registry.ts:1567 as formatByteSize &lt;span class="o"&gt;(&lt;/span&gt;similarity 0.96&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;main 7db292a] add helpers
 3 files changed, 24 insertions&lt;span class="o"&gt;(&lt;/span&gt;+&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;humanFileSize&lt;/code&gt; would have been my fifth byte formatter. Caught with similarity alone.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;forwardCancellation&lt;/code&gt; is a from-scratch rewrite of a helper in my coding agent, Arivu. Similarity alone only rated it a "similar" hint (0.93). I'd switched on the optional second opinion (the env vars point it at a local Ollama running Perplexity's decision model), and that upgraded it. This commit took about 5 s because Ollama had to load the model first; warm, a check is well under a second.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isLeapYear&lt;/code&gt; really was new, so the hook stayed quiet.&lt;/li&gt;
&lt;li&gt;The commit still went through. Warnings never block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then the boring commits, which matter just as much for a hook you leave on forever:&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;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"docs"&lt;/span&gt;              &lt;span class="c"&gt;# docs only: 0.20 s, silent&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"tweak isLeapYear"&lt;/span&gt;  &lt;span class="c"&gt;# edited an existing function: 0.38 s, silent (no self-match)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/shashankbudem" rel="noopener noreferrer"&gt;
        shashankbudem
      &lt;/a&gt; / &lt;a href="https://github.com/shashankbudem/code-dejavu" rel="noopener noreferrer"&gt;
        code-dejavu
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A git pre-commit hook that warns when the function you're committing already exists in your repos. Runs locally on EmbeddingGemma 2.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Code Déjà Vu&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The laziest code is code you've already written.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code Déjà Vu is a git pre-commit hook that notices when the function you're about to commit already exists somewhere in
your repos, under any name, in any of them. It also lets you find your own code by describing it. Everything runs on your
laptop with &lt;a href="https://huggingface.co/google/embeddinggemma-2" rel="nofollow noopener noreferrer"&gt;EmbeddingGemma 2&lt;/a&gt;, an open-weight model. Your code never
leaves the machine.&lt;/p&gt;
&lt;p&gt;With the optional second opinion switched on (see below):&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;$ DEJAVU_SECOND_OPINION=1 DEJAVU_DECIDER_URL=http://127.0.0.1:11435 git commit -m "add helpers"
déjà vu: forwardCancellation (src/abort.ts:1)
   already in arivu-agent/src/agent/OpenAICompatibleChatClient.ts:979 as linkAbortSignal (similarity 0.93, second opinion 97% same)
déjà vu: humanFileSize (src/files.ts:1)
   already in arivu-agent/src/tools/registry.ts:1567 as formatByteSize (similarity 0.96)
[main 7db292a] add helpers
 3 files changed, 24 insertions(+)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Without the second opinion, &lt;code&gt;forwardCancellation&lt;/code&gt; (a from-scratch rewrite) shows as a gentler &lt;code&gt;similar:&lt;/code&gt; hint at 0.93
instead. The third new function in that commit, &lt;code&gt;isLeapYear&lt;/code&gt;, really was…&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/shashankbudem/code-dejavu" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;About 400 lines of Python for the tool itself, plus the evaluation scripts I used to tune it (&lt;code&gt;eval/&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;I built this with Claude Code as my pair programmer: I made the calls (what to build, which models to try, what to keep and what to cut), and the agent did most of the typing, the labelling and the benchmark runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Find every function.&lt;/strong&gt; tree-sitter parses TypeScript, JavaScript, Python and Rust and pulls out every function of five or more lines. Across 10 of my repos that was &lt;strong&gt;5,094 functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Catch exact copies without any AI.&lt;/strong&gt; Each function body gets fingerprinted with comments and whitespace stripped. &lt;strong&gt;2,451 of my 5,094 functions were verbatim copies&lt;/strong&gt; of another one, mostly from forking my coding-agent project into experiments. A hash catches all of them instantly, so the model never has to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Catch near-copies and rewrites with EmbeddingGemma 2.&lt;/strong&gt; New or changed functions are embedded and compared with the index of everything else. Two details mattered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Matryoshka dimensions.&lt;/strong&gt; EmbeddingGemma 2 is trained so the first 256 of its 768 numbers still work on their own. The index is a third of the size, and it did slightly &lt;em&gt;better&lt;/em&gt; on my duplicate test than the full vector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Task prompts.&lt;/strong&gt; The same model embeds code for duplicate checks (&lt;code&gt;task: sentence similarity&lt;/code&gt;) and for search (&lt;code&gt;task: code retrieval&lt;/code&gt;). For duplicates, the similarity prompt clearly beat a document-style prompt in my tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarity of 0.946 or above is a &lt;strong&gt;déjà vu&lt;/strong&gt; warning. Between 0.91 and 0.946 is a gentler &lt;strong&gt;similar&lt;/strong&gt; hint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Check only what changed.&lt;/strong&gt; Functions whose fingerprint is unchanged since the last commit, including moved ones, are skipped. The files being committed are excluded from the comparison, so editing a function never matches its own old version. A docs-only commit never even loads the model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Stay out of the way.&lt;/strong&gt; Importing PyTorch and loading the model takes about 13 seconds, which is fine once but terrible on every commit. So &lt;code&gt;dejavu serve&lt;/code&gt; keeps the model warm in the background (local only). With it running, checking a commit takes about 0.3 s and a search about 0.2 s. Without it, everything still works, just slower.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why EmbeddingGemma 2
&lt;/h3&gt;

&lt;p&gt;I didn't pick it on vibes. I pulled the official MTEB results for six open embedding models on the same 12 code tasks. On the task that matters here, finding code that does the same thing as other code, &lt;strong&gt;EmbeddingGemma 2 scored 96.6, the best of all six&lt;/strong&gt;, ahead of models 13× its size (Qwen3-Embedding 4B: 95.6, Perplexity's pplx-embed 4B: 92.3). It's also small enough to index thousands of functions on a fanless MacBook Air.&lt;/p&gt;

&lt;h3&gt;
  
  
  How I tuned it: on my own mess
&lt;/h3&gt;

&lt;p&gt;Pairs from my own repos were labelled by hand (well, by my agent's hand: it read each pair in full before labelling it):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;19 copies that drifted apart&lt;/td&gt;
&lt;td&gt;18 warnings, 1 hint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9 from-scratch rewrites&lt;/td&gt;
&lt;td&gt;5 warnings, 4 hints; a function doing the same job ranked &lt;strong&gt;first 9/9 times&lt;/strong&gt; out of 2,643&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;25 look-alikes that do different things&lt;/td&gt;
&lt;td&gt;2 false warnings, 11 hints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Simulated hook over 381 functions from my standalone repos&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;1 warning, and it was real&lt;/strong&gt;: &lt;code&gt;escapeHtml&lt;/code&gt;, written separately in two different projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;22 "describe it" searches&lt;/td&gt;
&lt;td&gt;right function first 18–19 times; keyword matching (grep-style): 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Honest caveats: the cutoffs were picked on the same small set they're scored on, the rewrites were written while looking at the originals, and every repo is mine. It's a careful first measurement, not a benchmark.&lt;/p&gt;

&lt;h3&gt;
  
  
  The judge bake-off (and why the embedding won)
&lt;/h3&gt;

&lt;p&gt;Similarity scores get fuzzy in the 0.91–0.95 range, where a real rewrite and a look-alike can score the same. So I asked: would a second model, a "judge" that answers &lt;em&gt;"are these the same function?"&lt;/em&gt;, do better?&lt;/p&gt;

&lt;p&gt;I tested four open models as judges on the same 113 pairs. &lt;strong&gt;The keep rule was written down before the new ones ran&lt;/strong&gt;, so nobody could move the goalposts afterwards.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Judge&lt;/th&gt;
&lt;th&gt;Borderline cases (0.5 = coin flip)&lt;/th&gt;
&lt;th&gt;Calls random pairs "the same"&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EmbeddingGemma 2 alone&lt;/td&gt;
&lt;td&gt;0.72&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Laya (decision model)&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;98%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CoREB (code-search reranker)&lt;/td&gt;
&lt;td&gt;0.41&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clef Flash (Cloudflare decision model)&lt;/td&gt;
&lt;td&gt;0.85&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;pplx-decider-flash&lt;/strong&gt; (Perplexity decision model)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.98&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The borderline column rests on just 25 pairs, so its error bars are wide (the embedding's 95% range is 0.49–0.92). Read it as a direction, not a leaderboard.&lt;/p&gt;

&lt;p&gt;None passed the keep rule. Two things surprised me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decision models answer exactly the question you ask.&lt;/strong&gt; pplx-decider-flash was brilliant at the borderline cases, but asked &lt;em&gt;"do these implement the same behaviour?"&lt;/em&gt;, it said &lt;strong&gt;no&lt;/strong&gt; to a copy that had gained two extra options. Used as a veto, it threw away 13 of 19 real copies. Fair: they &lt;em&gt;don't&lt;/em&gt; do exactly the same thing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always sanity-check a judge first.&lt;/strong&gt; Before each full run, I fed every judge an identical pair and an unrelated pair. CoREB said &lt;code&gt;add(a, b)&lt;/code&gt; and an unrelated config reader were &lt;strong&gt;99.8% the same&lt;/strong&gt;. The cause was its model card: the example prompt leaves out an empty &lt;code&gt;&amp;lt;think&amp;gt;&amp;lt;/think&amp;gt;&lt;/code&gt; block its base model expects. One missing line, and every answer was "yes".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;pplx-decider-flash still earned a job: an &lt;strong&gt;optional second opinion that can only upgrade&lt;/strong&gt; a borderline hint to a warning, never cancel one. In that role it upgraded all 4 hinted rewrites. Its one false upgrade was a test mock, and the tool doesn't index test files. (I designed that rule &lt;em&gt;after&lt;/em&gt; seeing the bake-off, so treat it as promising, not proven.) Running it through Ollama's new MLX runner at 8-bit gave the same answers as the original on 113/113 pairs, about 3× faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;For this tool it isn't a nice-to-have. It's the whole thing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;My code can't leave my laptop.&lt;/strong&gt; Lots of developers can't send their employer's code, or their private repos, to a cloud API just to ask "have I written this before?". A local model can read all of it, offline, on every commit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's free to run constantly.&lt;/strong&gt; A hook runs on every commit, forever. Per-call pricing would turn "check every function" into "check sometimes".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I could test instead of trust.&lt;/strong&gt; Open weights let me run four judges on my own labelled code, catch a model-card bug, and verify that an 8-bit MLX build answers like the original. With a closed API, I'd have had to take the vendor's word for all of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I could swap pieces freely.&lt;/strong&gt; Embedder, judge and runtime (PyTorch, then Ollama MLX) all changed during the week, and nothing else had to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Lazy Payoff
&lt;/h2&gt;

&lt;p&gt;The first run over my own 10 repos turned up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Four byte-size formatters&lt;/strong&gt; inside Arivu alone, one of them an identical copy under a new name.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;escapeHtml&lt;/code&gt; written twice&lt;/strong&gt;, separately, in two unrelated projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The same &lt;code&gt;ranked()&lt;/code&gt; helper&lt;/strong&gt; in both the React and plain-JS versions of my Bharat Choropleth examples.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2,451 verbatim copies&lt;/strong&gt; in total, mostly between my coding agent and its experimental forks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not all of them are mistakes: the forks and the standalone example apps are copies on purpose. But four byte formatters in one project definitely were, and each of those is a function I wrote, tested and now maintain more than once.&lt;/p&gt;

&lt;p&gt;And the cost of being lazy this way:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Indexing 4,782 functions, once&lt;/td&gt;
&lt;td&gt;~11 min on a fanless MacBook Air (later runs only embed new code)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commit that adds functions, model warm&lt;/td&gt;
&lt;td&gt;~0.3 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docs-only commit&lt;/td&gt;
&lt;td&gt;~0.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Search&lt;/td&gt;
&lt;td&gt;~0.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Best Use of Gemma&lt;/strong&gt;: EmbeddingGemma 2 runs locally and does all the work: duplicate detection, search, and the Matryoshka-shrunk index.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
