DEV Community

Cover image for I held a séance for a line of code, and the ghost cited its commits
Fuad ALIPHATIC Adegoke
Fuad ALIPHATIC Adegoke

Posted on

I held a séance for a line of code, and the ghost cited its commits

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Every codebase has a haunted line. You know the one:

time.sleep(0.3)  # do not remove
Enter fullscreen mode Exit fullscreen mode

Nobody knows why it's there. The person who wrote it left years ago. The commit message says fix. Removing it feels like reading the Necronomicon out loud.

git-seance is a command-line ritual that summons the ghost of whoever wrote that line and lets you question them. It reads git blame, follows the line through the log, digs up its past lives (times the same code was added, deleted, and brought back), and then hands all of that to a small open-weight model running on my own laptop. The model speaks in the first person as the original author, in the voice of their own commit messages.

There's one rule the ghost can't break: it has to cite the commit before it accuses anyone. After it speaks, git-seance checks every hash it mentioned against the real history. A citation is either ✓ sealed in git, ~ real but not in the evidence, or ✗ a lie. Spirits lie. Git does not.

It has three rituals:

  • seance summon FILE:LINE raises the author of one line. You can keep asking follow-up questions until you release it.
  • seance graveyard draws tombstones for contributors who've gone quiet for a year or more. Each shows how many of their lines still run in HEAD and an epitaph the model carves from their last commit message. Below them is "the crypt", the oldest lines nobody has dared to touch.
  • seance ofrenda NAME is the Día de los Muertos half of the project. Instead of a ghost story, it builds a warm remembrance for a contributor with their first words (first commit), their last words (last commit), what they left us, and offerings for their altar. It saves the result as Markdown and as an offline HTML ofrenda with papel picado and flickering candles.

And if the line you summon turns out to have been written by you, three years ago at 3 a.m., the ghost knows. It waits until the last sentence to tell you.

I built it for anyone who has inherited a codebase, or stared at their own old code with no memory of writing it. And a little bit for the people whose code is still running long after they left.

Demo

git-seance summoning the ghost of Marcus Bell for printer.py line 9, with every cited commit verified

Everything below is a real run on my Intel MacBook. The repo is a small, made-up "haunted house" that ships with the project, so you can run the exact same séance.

Here's what the séance pulls out of git before the model says a word:

  lighting candles over lantern/printer.py:9 ...
  reading the blame ... the hand that wrote this belonged to Marcus Bell
  the line was born 6 years ago, in commit 8637131
  it has lived 3 lives in the log
  channeling gemma3:4b through the veil, entirely on this machine ...

  >> time.sleep(0.3)  # do not remove
  evidence: [8637131] Revert "remove pointless sleep in printer wake"
Enter fullscreen mode Exit fullscreen mode

The blame points at Marcus, but Marcus didn't invent that line. git log -S finds its earlier lives: Edna added it at 2 a.m. in 2019 ("the printer swallows the first bytes it hears… Do not remove."), Marcus deleted it as "pointless", and that same night he reverted it ("The printer screamed. Every receipt came out blank. Edna was right.").

Then Gemma 3 4B, running on the laptop with no internet needed, speaks as Marcus:

I am Marcus Bell. The printer screamed, you see? [8637131] — I reverted "remove pointless sleep in printer wake." Edna was right. […] Do not remove. My memory… it fades there. [81a8dff] — I removed it, then I immediately reverted. The printer screamed. It's a delicate dance, this printing. [821248a] — Edna insisted on the 300ms. I yielded. I am trapped here, eternally guarding this single line. It's… unsettling, isn't it?

  ✓ [8637131] is sealed in git history
  ✓ [81a8dff] is sealed in git history
  ✓ [821248a] is sealed in git history
Enter fullscreen mode Exit fullscreen mode

Three citations, three real commits. "I am trapped here, eternally guarding this single line" is the most accurate description of legacy code maintenance I've ever read.

The call is coming from inside the repo

lantern/till.py starts with MAGIC = 37 # ???, committed at 3:12 a.m. with the message fix it (do not ask). The blame says the author is the same person running the séance. The ghost holds that back until its very last sentence:

I am Silas Finch. [7848510]… fix it (do not ask). That's all. My memory… it's fractured, like the glass of a shattered mirror. I simply… corrected a calculation. […] The MAGIC value, 37, was… arbitrary. A placeholder. […] I don't recall the reasoning. It was… necessary. It's all I can offer.

I suppose… I am you, older now.

(Yes, the ghost of "You" calls itself Silas. More on Silas below.)

The ghost of till.py line 1 reveals it is the person running the séance

The graveyard

seance graveyard finds everyone who has been silent for over a year, counts how many of their lines still run, and has Gemma carve an epitaph:

 ╭────────────────────────────────╮
 │             R.I.P.             │
 │           Edna Voss            │
 │          2019 – 2021           │
 │                                │
 │  May her debugging brilliance  │
 │   illuminate the afterlife's   │
 │             code.              │
 │                                │
 │   16 lines still haunt HEAD    │
 ┴────────────────────────────────┴
   last words: "leave the light on for whoever comes next"  (4 years ago)

 ╭────────────────────────────────╮
 │             R.I.P.             │
 │              You               │
 │          2023 – 2023           │
 │                                │
 │     The solution is here.      │
 │    Compliance is mandatory,    │
 │            always.             │
 │                                │
 │    4 lines still haunt HEAD    │
 ┴────────────────────────────────┴
   ...wait. this grave has your name on it.
Enter fullscreen mode Exit fullscreen mode

seance graveyard: tombstones with Gemma-written epitaphs and the crypt of untouched lines

The ofrenda

For Día de los Muertos, seance ofrenda edna switches the tone from spooky to tender:

Their last words

"leave the light on for whoever comes next" – A comforting sentiment, suggesting a thoughtful awareness of continuity.

Offerings

  • A collection of shiny pennies: representing "add till totals. counting coins by candlelight".
  • A freshly printed receipt: honoring "wait for the printer to wake up".
  • A single, beautifully crafted paper lantern: a reminder of "leave the light on for whoever comes next".
  • A miniature hourglass: because Sundays were her favorite day, and time seemed to move differently.

It also writes an offline HTML altar with papel picado, a marigold-framed portrait card, and flickering candles.

The offline HTML ofrenda for Edna Voss, with papel picado, candles, and offerings

Code

👻 git-seance

Summon the ghost who wrote that line of code. git-seance reads your git blame, your log, and every past life of a line, then lets a small open-weight model running on your own machine speak as the person who wrote it. The ghost has to cite its commits before it accuses anyone, and the CLI checks every hash it mentions against git. Spirits lie. Git does not.

Built for the DEV Hacktoberfest 2026 "Ghost in the Machine" challenge.

      )        )        )
     (_)      (_)      (_)
     |~|      |~|      |~|
    _|_|______|_|______|_|_

  lighting candles over lantern/printer.py:9 ...
  reading the blame ... the hand that wrote this belonged to Marcus Bell
  the line was born 6 years ago, in commit 8637131
  3 commits have disturbed it since
  channeling gemma3:4b through the veil, entirely on this machine ...

  >> time.sleep(0.3)  # do not remove

Three rituals













Command What it does
seance summon FILE:LINE
…





The repo ships a small, fictional "haunted house" so you can try it in a couple of minutes:

ollama pull gemma3:4b
git clone https://github.com/ALIPHATICHYD/GIT-SEANCE && cd GIT-SEANCE && pip install .
python demo/haunted_house.py /tmp/haunted-house && cd /tmp/haunted-house
seance summon lantern/printer.py:9
Enter fullscreen mode Exit fullscreen mode

git-seance has no dependencies outside Python's standard library. Any model that Ollama or an OpenAI-compatible local server can run works with --model.

How I Built It

It's about 1,000 lines of Python. Here's how a séance actually works.

1. Evidence comes only from git. For a summon, it collects:

  • git blame --line-porcelain for the author, time, and commit of the line
  • git log -L for every commit that changed the line during its current life
  • git log -S "<the line>" for its past lives. This took me the longest to figure out. Blame only shows the last person to touch a line, which is often whoever reverted or reformatted it. The pickaxe search finds the original author and the whole argument around them.
  • the full commit message and the diff of that file in that commit
  • ±6 lines of surrounding code
  • the author's other commit subjects, which become the ghost's "voice"

2. A strict séance prompt. The system prompt makes the model speak in the first person as the author, cite hashes in [brackets], never invent motives or tickets, and say "my memory fades" when the evidence runs out. If the blamed email matches your git config user.email, one more rule is added: the summoner is you, older now; reveal it only in the last sentence.

3. The hash check. Small models make things up, and a ghost story is a good excuse to admit it. Every hex string in the reply that looks like a hash gets checked with git cat-file -e. If the ghost invents a commit, you see a red ✗ right under its speech.

4. A tiny, local medium. The model client is about 100 lines of urllib that streams from Ollama's /api/chat by default, or from any OpenAI-compatible local server (llama.cpp's llama-server, LM Studio, vLLM) with --backend openai. Requests to localhost bypass any configured proxy, so the only network hop goes to your own machine.

5. Theatre. Tokens stream with a typewriter flicker, and the occasional letter glitches into ▒ before it settles. The theatrics switch off automatically for pipes, NO_COLOR, or --plain, so it still behaves like a good Unix citizen.

Model choice. I used Gemma 3 4B (gemma3:4b, about 3.3 GB). It runs on the CPU of an Intel MacBook, which Homebrew no longer even builds packages for. All four rituals (two summons, the graveyard, and an ofrenda) finished in about five minutes, including loading the model cold. It followed the citation rule every time: across every run, every commit hash it cited was real. And it has enough personality to make a revert commit sound like a confession. Swap in any model with --model.

Testing. The unit tests build the haunted house from scratch with backdated commits by fictional authors. They check blame, past lives, the summoner twist, the census, the hash check, and the streaming client against a fake local Ollama server.

Where Gemma struggled (and what I learned)

  • git blame only tells you who touched a line last. For the real story you need git log -S.
  • Gemma followed specific rules ("cite in brackets, under 140 words") far better than vague ones ("be accurate").
  • The hash check catches fake commits, not fake facts. In the first real run, every citation was genuine, but Marcus's ghost still said "Thirty milliseconds is all it needed," while Edna's commit clearly says 300. In another run it claimed Edna's "200ms is not" experiment as its own. A real hash attached to the wrong claim is a subtler kind of haunting. I tightened the prompt ("only claim a commit as yours if the evidence lists you as its author"), but it's a good reminder that grounding a model means checking claims as well as citations.
  • A ghost named "You" will rename itself, and it is always Silas. When the author in the log was literally called You, Gemma introduced itself as Silas Blackwood. I added "use exactly that name", and it became Silas Thorne. I added "never say your own name at all", and it became Silas Finch. Three prompt fixes, three Silases, and the reveal at the end ("I suppose… I am you, older now") still landed every time. I've left Silas in. A 4B model has habits you can nudge but not always break, and somewhere in Gemma's weights there's a programmer named Silas who really wants to be remembered.
  • Small models copy your examples. My ofrenda prompt suggested "green CI for the one who fought flaky tests" as a sample offering, and Gemma offered Edna a green CI badge, even though the repo has no tests. I removed the example and now every offering has to be tied to a fact in the evidence. On the next run, every offering pointed at a real commit: shiny pennies for "counting coins by candlelight", a freshly printed receipt for "wait for the printer to wake up".

Why Does Open Innovation Matter?

A git log is more personal than it looks. It has people's names and emails, the times they were up at 3 a.m., and the odd frustrated commit message. I didn't want to send my coworkers' history to a hosted API just to make a joke about a sleep() call. With Gemma running in Ollama, everything stays on my laptop. The HTML ofrenda doesn't even load a font from the internet.

It also means it works anywhere. The legacy code that really needs a séance usually lives on some locked-down work machine with no internet access, and a 4B model runs fine there.

And it won't break on me. Tools built on a paid API stop working when the API changes or the free tier goes away, which is how a lot of haunted code gets made in the first place. This one just needs git, Python, and a model file I can keep.

The Spirit of It

The first time it worked, I was watching a 4B model on my Intel laptop slowly type out a confession for a line of code. It cited every commit correctly, insisted its name was Silas, and then finished with "I suppose… I am you, older now." I've never been haunted by my own git blame before. I felt bonita 😂🙂‍↔️

I also keep thinking about the ofrenda. Edna isn't real, but her last commit, "leave the light on for whoever comes next," is the kind of thing real people write at 2 a.m. and nobody ever reads again. I liked making something that reads it.

Prize Categories

  • Best Use of Gemma: Gemma 3 4B (gemma3:4b) is the voice of every ghost, epitaph, and ofrenda, running entirely on my laptop through Ollama.

Thanks for reading. Go summon something. 👻🌼

Top comments (0)