DEV Community

Kritika Mandale
Kritika Mandale

Posted on

Haunt 👻: A Terminal That Whispers Back — Powered by Local Gemma 3

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

Built for the Hacktoberfest Open-Source AI Challenge — Week 4: Ghost in the Machine.

What I Built

It was late at night, and I had just typed:

git push origin main --force
Enter fullscreen mode Exit fullscreen mode

I expected the usual terminal output. Instead, a purple italic whisper appeared:

You are force-pushing over history. The dead remember what you just erased.

What if your terminal could react to your commands—not just execute them?

Meet Haunt, a tiny, privacy-first haunted terminal built in Python, powered by Google Gemma 3 1B running locally.

Haunt executes your everyday shell commands against your real operating system and occasionally responds with an eerie, character-driven whisper. Whether you're running git status, building a project, or encountering an ominous rm -rf, your terminal gains a personality of its own.

Four ghosts. One terminal.

  • Sysadmin: A sleep-deprived spirit haunted by production outages and missing backups.
  • Victorian: A 19th-century ghost convinced modern CLI commands are dark sorcery.
  • Poltergeist: A mischievous trickster who pretends to shuffle files and hide semicolons.
  • Ofrenda: A warm, comforting presence inspired by remembrance traditions, celebrating the people behind every late-night coding session.

I wanted to interpret Ghost in the Machine through two contrasting ideas: the unsettling side of technology and the comforting feeling of remembering those who came before us.

Demo


Imagine running a test suite and seeing:

haunt ~/code $ pytest
================ 4 passed in 0.06s ================

Marigolds on the keyboard tonight. Keep going.
Enter fullscreen mode Exit fullscreen mode

Or triggering a warning:

haunt ~/code $ sudo rm -rf /tmp/cache

You are summoning root powers. Tread gently where the dead sleep.
Enter fullscreen mode Exit fullscreen mode

Haunt also includes Séance Mode, which reads supported local shell-history files, filters suspicious entries, and weaves past commands into a short ghost story.

Run it with:

python -m haunt --persona ofrenda
Enter fullscreen mode Exit fullscreen mode

Explore your shell's past with:

python -m haunt seance
Enter fullscreen mode Exit fullscreen mode

Code

GitHub Repository: https://github.com/kritikamandale/Haunt

Haunt is designed to be a lightweight, open-source project that developers can experiment with, customize, and extend.

How I Built It

Haunt is written in Python and uses Google Gemma 3 1B Instruct through Hugging Face Transformers for local inference.

The workflow is intentionally simple:

  1. You enter a shell command.
  2. Haunt executes it on your operating system.
  3. The application records basic execution metadata, including the command, exit code, and duration.
  4. Rule-based patterns detect potential omens, such as force pushes and destructive commands.
  5. The local model generates a short whisper in the selected ghost's personality.

A cleanup function keeps responses concise and in character. If the model cannot load because of memory constraints—or you launch Haunt with --no-model—the application falls back to handcrafted whispers.

Privacy by design

Terminal output can contain passwords, API keys, and other sensitive information. Haunt is designed so that stdout and stderr are not captured or sent to the model. Inference happens locally, and only selected command metadata is used to generate responses.

Important: Command text and shell history can themselves contain sensitive information. Haunt therefore aims to minimize exposure, but users should still review their privacy settings and history-filtering behavior before using it with sensitive commands.

Why Does Open Innovation Matter?

Haunt would be a very different project if it depended on a closed, cloud-hosted AI API.

Using an open-weight model makes local inference possible, removes per-request API costs, and allows the experience to work without an internet connection once the model is downloaded and cached.

It also makes experimentation accessible. Developers can change ghost personalities, adjust prompts, or try compatible models without rebuilding the entire application.

For example, a lightweight alternative can be selected through an environment variable:

HAUNT_MODEL=Qwen/Qwen2.5-0.5B-Instruct python -m haunt
Enter fullscreen mode Exit fullscreen mode

Local execution does come with trade-offs: model downloads, RAM requirements, inference speed, and model licensing still matter. But the ability to run AI on your own machine opens up creative possibilities beyond conventional chatbots.

The Spirit of It

The biggest challenge was getting a small language model to stop acting like a helpful assistant.

Instead of whispering something mysterious, it sometimes wanted to explain commands or suggest shell flags. I addressed this with stricter prompting, response cleanup, and length limits.

Memory was another challenge. Loading Gemma on hardware with limited available RAM could fail, so I implemented a graceful fallback that keeps the terminal usable even when inference is unavailable.

But the idea behind Haunt goes beyond jump scares.

The Ofrenda persona was inspired by traditions of remembrance, including Día de los Muertos and diya-lit observances. It represents a gentler kind of ghost: a reminder that behind every line of code is a person who stayed up late, struggled with a bug, and kept going.

Sometimes, the best response to a failed build isn't another debugging suggestion.

It's a little encouragement from the machine.

Prize Categories

  • Primary category: Best Use of Gemma — using google/gemma-3-1b-it through Hugging Face Transformers.

Give it a run, turn down the lights, and let your terminal whisper back. 🕯️👻

Top comments (0)