# Dead-Code Ghost: Find Dead JavaScript and TypeScript Functions, Locally, with Gemma 3 1B

> Source: <https://dev.to/mohsinakram91/dead-code-ghost-find-dead-javascript-and-typescript-functions-locally-with-gemma-3-1b-3a8e>
> Published: 2026-10-31 07:10:38+00:00

*This is a submission for the [Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine](https://dev.to/challenges/hacktoberfest-week4-2026-10-26)*

**Dead-Code Ghost** is a free, local, read-only tool that finds dead functions in JavaScript and TypeScript repos — functions that are never called anywhere — and writes a Markdown report about them, with a plain-English note and a last-touched date for each one. It runs entirely on your machine with Gemma 3 1B via Ollama: no cloud, no API key, no subscription.

My interpretation of the theme is literal. A "ghost" in a codebase is a function that was written once and then abandoned — still sitting in the repo, never called by anything. Every real project accumulates them: the helper from a retired feature, the utility left over from a refactor, the exported function nobody imports anymore. They slow down readers, confuse new contributors, and make refactors risky. Ghost finds them so a human can decide what to do. It never deletes or modifies anything itself.

It is built for developers and open-source maintainers cleaning up JavaScript and TypeScript codebases, and it is brand-new code written October 27–31, 2026, for this challenge — not a repackage of anything else I have built.

Repo: [https://github.com/onyxailabs/dead-code-ghost](https://github.com/onyxailabs/dead-code-ghost)

There is no hosted demo — this is a local command-line tool, so the demo is a real terminal run. Here is the exact output from a scan of the sample repo that ships with the tool, run on a Windows 10 PC:

```
> npm test
PASS: dead=[deadTsHelper, idle, oldHelper, unusedCalc] exported-unused=[formatDate, publicApi] files=3 functions=9 sample-untouched=true

> node ghost.js scan sample-repo --out dead-code-report.md --no-model
Report written to dead-code-report.md
Files: 3 | Functions: 9 | Dead: 4 | Exported-unused: 2
```

And the report it writes looks like this (excerpt):

```
## Dead functions (4) — never referenced anywhere, not exported
- deadTsHelper, idle, oldHelper, unusedCalc
## Exported but never called internally (2) — review, not necessarily dead
- formatDate, publicApi
```

`sample-untouched=true` matters: the scan only reads your code. The only file it ever writes is the report you point it at.

To verify the tool computes rather than returning a canned answer, I ran it on a second, completely different folder with different function names — a tiny shop example. It correctly found 4 dead functions (`applyOldCoupon`, `removeFromCart`, `legacyDiscount`, `unusedHelper`) and 2 exported-but-unused ones (` formatPrice`, `taxRate`) out of 10 functions. The same check was then repeated on a Windows 10 PC with the identical result. Same tool, unseen code, correct result.

[https://github.com/onyxailabs/dead-code-ghost](https://github.com/onyxailabs/dead-code-ghost)

Zero-dependency Node.js. Run it with:

```
node ghost.js scan <your-repo-dir> --out dead-code-report.md --no-model
```

Drop `--no-model` once Ollama is running with Gemma 3 1B pulled (`ollama pull gemma3:1b`) and the report carries a short plain-English note per dead function instead of the skipped-note line. `npm test` runs the built-in verification suite.

Try it on your own repo and tell me what it found.

The scanner parses `.js`, `.jsx`, `.ts`, and `.tsx` files and builds a name-based call graph: every function definition is collected, then every other reference to that name across the repo is counted. Comments and strings are stripped first, so a name mentioned only in a comment does not count as a use. Functions with zero references that are not exported are reported as dead; exported functions with zero internal references are listed separately, because code outside the repo might use them.

The open-weight model is at the core of the notes, not bolted on. **Gemma 3 1B, running locally through Ollama** (`http://127.0.0.1:11434`), writes a 1–3 sentence plain-English note for each dead function — what it appears to do, without guessing beyond the code. If Ollama or the model is not reachable, the note says so plainly instead of inventing one. That honesty is deliberate: a cleanup tool that invents explanations would be worse than no tool at all.

Last-touched dates come from `git log` (definition line first, file level as fallback). If the folder is not a git repo, the date is reported as unavailable — never invented.

Honest limits, stated in the report itself: the graph is name-based, not scope-resolved, so two functions sharing a name across files count as one name, and dynamic calls (`obj[name]()`, `eval`, string-built calls) are not seen. Detection is best-effort, never claimed perfect. The demo transcript above uses `--no-model`, so what you see is the honest fallback; the Gemma note path is implemented and wired to local Ollama, and its first live run happens once the model is pulled.

It runs on Windows 10/11 with Node.js and Ollama, no GPU, on an 8 GB machine — the 1B model class is the whole point.

Three things a closed API could not give this tool at the same time:

Open innovation is what makes a privacy-sensitive, offline, zero-cost tool possible at all — not just cheaper, but possible in a form a closed service cannot match.
