DEV Community

Gabriel Almeida
Gabriel Almeida

Posted on

I Haunted My Terminal With a Local Ghost (Gemma 3, No Internet Needed)

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

shell-ghost is a haunted terminal. After some of the commands you run, a ghost whispers one eerie line about what you just did:

$ rm -rf node_modules
  👻 Don't worry, it just wanted a little... tidier oblivion.

$ git push --force
  👻 Don't you dare rewrite my carefully crafted digital chaos.

$ sudo make me a sandwich
  👻 It wants fillings… and a very long, slow, digital chew.
Enter fullscreen mode Exit fullscreen mode

By default it speaks on about 1 in 3 commands, so it stays a surprise instead of a nuisance.

Demo

Repo: https://github.com/GAlmeidaDev/shell-ghost

How It Works

Two tiny files, no dependencies beyond Python 3 and zsh:

  • haunt.zsh hooks into zsh with preexec (to remember the command) and precmd (to read its exit code). It rolls a die, and if the ghost is feeling chatty it calls the script.
  • ghost.py sends the command and exit code to a local model through Ollama's HTTP API and prints one dim purple line.

The whole prompt is a few lines: you are a ghost trapped inside a computer, reply with one short eerie whisper, spooky and a little funny. Temperature 0.9 and a 48-token cap keep it short and weird.

Try it:

ollama pull gemma3:4b
python3 ghost.py "rm -rf node_modules" --code 1
echo 'source /path/to/shell-ghost/haunt.zsh' >> ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Set GHOST_ODDS=1 and it speaks after every command.

Why Open Source AI Matters Here

A terminal sees everything: your commands, paths, hostnames, sometimes secrets typed inline. Sending that to a hosted API for a joke would be a bad trade.

With an open-weight model running locally:

  • Nothing leaves your machine. The only network call is to localhost.
  • It works offline. Plane, train, or a dead Wi-Fi: the ghost still haunts you.
  • It can't break your shell. If Ollama isn't running, the call fails silently and the ghost simply stays quiet.
  • You pick the ghost. --model swaps in any model Ollama can run.

A 4B model is plenty for one spooky sentence, and that's the point: small, open models are good enough to make tools feel alive without a cloud dependency.

What I Learned

  • Small models follow "ONE line, max 18 words" surprisingly well, but splitlines()[0] is still a cheap safety net.
  • For shell tooling, failing silently is a feature. A decorative tool must never be able to hurt the thing it decorates.
  • Randomness (the 1-in-3 odds) matters more than model quality for the "haunted" feel.

hf26challenge

Top comments (0)