Home / use case

Legacy Code Necromancer: a local Gemma 3 audit for old repos

At a glance
Models & engines
Pure Python, no dependencies, run as python3 necromancer.py <folder> --model gemma3:1b
Ollama on localhost with gemma3:1b (806 MB) on CPU, chosen because the machine is short on RAM
Any local Gemma 3 tag is accepted; the 4B gemma3 is recommended but untested by the author
Key gotcha
The 1B model's rewrite drafts echoed the redacted input, so eval, pickle, SQL interpolation and MD5 all survived; 'verified' in the report only means the drafts compile.

What they built

The Legacy Code Necromancer is a zero-dependency Python CLI that points a local Gemma 3 model at abandoned code. It talks only to Ollama on 127.0.0.1 and rejects remote servers unless explicitly allowed, because old repos are full of hardcoded keys and credentials.

It runs three phases: a code autopsy that returns structured JSON findings (severity, category, file, line), a revival pass that drafts refactored code, and a Halloween-themed Markdown audit report with a session manifest so work can resume.

The author is open that the human review is the real product: on his recorded run about half of the findings were real and the rewrite drafts were not safe to use.

Setup

  • Pure Python, no dependencies, run as python3 necromancer.py <folder> --model gemma3:1b
  • Ollama on localhost with gemma3:1b (806 MB) on CPU, chosen because the machine is short on RAM
  • Any local Gemma 3 tag is accepted; the 4B gemma3 is recommended but untested by the author

How it works

  1. Before any code reaches the model, a regex scrubber removes likely keys, tokens and secret strings while leaving risky constructs like eval and pickle visible.
  2. The file scan skips .git, node_modules and binaries.
  3. Every raw model reply is preserved, and the report carries a human curator's note on what the model got wrong.

Results & numbers

  • On the included sample (two Python files, 57 lines, fake credentials planted), the run took 404 seconds and 5 model calls on CPU.
  • The audit returned 15 findings and human review confirmed 8, including every planted critical flaw: hardcoded credentials, eval, pickle deserialization, shell injection, SQL string interpolation, MD5 password hashing and removed Python APIs.
  • The other 7 were invented or mislabeled, such as a race condition in single-threaded code, and the model's line numbers were guesses.

Gotchas

  • The 1B model's rewrite drafts echoed the redacted input, so eval, pickle, SQL interpolation and MD5 all survived; 'verified' in the report only means the drafts compile.
  • The report's 'Cause of Death' prose invented a date and fixes that never happened, and is kept only as evidence of what a small model produces.
  • Treat the model's findings as leads to check, not conclusions.
“the autopsy is strong, the curation is the product, and the audit trail is what makes it trustworthy.”— Waleed Shamhan

Do it yourself

  1. Start Ollama with ollama serve and pull a small model: ollama pull gemma3:1b (or gemma3 for the 4B).
  2. Clone the legacy-code-necromancer repository from GitHub (waleedshamhan2050-sys).
  3. Run it on the included sample first: python3 necromancer.py fixtures/haunted-legacy --model gemma3:1b.
  4. Open necromancer-out/haunted-audit-report.md and the revived code folder.
  5. Review every finding against the actual code, reject invented ones, and don't run the rewrite drafts without your own review and tests.
ollama serve
ollama pull gemma3:1b
python3 necromancer.py fixtures/haunted-legacy --model gemma3:1b
Source: Waleed Shamhan (DEV Community) · Published 2026-10-29 · Added 2026-10-30. This write-up summarizes the original source; see it for full details.

Similar setups

A read-only Gemma 4 agent on Ollama that explains what fills a Mac's disk

A sysadmin's one-file Python agent lets Gemma 4 on Ollama dig through his home folder and write a Markdown report on disk usage, while code and a four-line macOS sandbox-exec profile make sure it can only look.

DEV Community (MediBlackSand) · 2026-11-30

PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU

WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.

WiseProbe Blog · 2026-11-25

rip: a local Gemma 2 2B writes epitaphs and revival ideas for your abandoned side projects

A Hacktoberfest CLI scans your folders for dormant projects and has Gemma 2 2B on Ollama write a witty obituary and a suggestion to revive each one, sending only metadata, never code.

razorbill (DEV Community) · 2026-11-03

Haunted Inbox: a local Gemma 4 E2B finds the forgotten accounts in 12 years of email

Niraj Khetre built Haunted Inbox, which reads only email envelopes on his laptop, has Gemma 4 E2B in Ollama spot sign-up accounts, and lets plain code report breaches, saved cards and delete links.

Niraj Khetre (DEV Community) · 2026-11-01