DEV Community

Cover image for Haunted Terminal: a shell possessed by a ghost
Vikram Rautela
Vikram Rautela

Posted on

Haunted Terminal: a shell possessed by a ghost

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

This week's theme is "Ghost in the Machine" — something spooky, built with open-source AI. I took it fairly literally: I built a terminal that's haunted.

Haunted Terminal is a shell. You type real commands — ls, mkdir, git status, rm, whatever — and they run exactly like they would anywhere else. But something is watching. After every command, a ghost — a local open-weight model running through Ollama — reacts to what you just did. One short, eerie, in-character line, every time.

Delete something and it mourns it. Run sudo and it treats it like a dangerous summoning. A command fails, and it mocks you, gently. When you leave, it says goodbye — and it remembers: the whole session gets saved to a haunting_*.md log, a small ledger of everything it watched you do, like a ghost keeping a diary of the living.

Demo

A real session, nothing staged:

A real haunted-terminal session: ls, mkdir, rm, and a failed sudo, each with the ghost's reaction

👻 haunted-terminal > ls
docs
haunted_terminal.py
👻 Files of the living, how... tedious.

👻 haunted-terminal > mkdir ghost_test
👻 A new home for me now.

👻 haunted-terminal > rm -r ghost_test
👻 My little experiment... gone to dust.

👻 haunted-terminal > sudo whoami
sudo: a password is required
👻 Little one still learning, I suppose.

👻 haunted-terminal > exit
👻 Your departure won't silence me, I've watched others like you forever, in these cold, echoing halls.
The ghost remembers. Saved to haunting_20261027_1737.md.
Enter fullscreen mode Exit fullscreen mode

Notice it never repeats the command back verbatim and never breaks character into an explanation — that's enforced by the prompt, not scripted responses. Every line above came straight from the model.

Code

👻 Haunted Terminal

A shell possessed by a ghost.

Built for Hacktoberfest 2026 Week 4: "Ghost in the Machine" — build something spooky with open-source AI.

What it does

Haunted Terminal is a small interactive shell. You type real commands — ls, git status, mkdir, whatever — and they run exactly like they would in a normal terminal. But after each one, a ghost is watching. A local open-weight model (Llama 3.2 via Ollama) reacts to what you just did: eerie, witty, in character, one line, every time.

Delete something and it mourns it. Run sudo and it treats it like a dangerous summoning. Fail a command and it mocks you, gently. When you exit, it says goodbye — and it remembers: every session is saved to a haunting_*.md log, a little ledger of everything it watched you do.

Demo

Haunted Terminal: a real session showing ls, mkdir, rm, and a failed sudo, each with the ghost's reaction

That's a real captured session —…




One Python file, standard library only — no dependencies beyond Ollama itself.

How I Built It

The stack:

Part What I used
The ghost Llama 3.2 (3B), local, via Ollama
Command execution subprocess.run(cmd, shell=True, cwd=...) — real shell syntax, pipes and all
Working directory cd handled specially so it persists across commands (subprocess alone can't do this)

Built and tested on a laptop: Ubuntu, 15 GB RAM, no GPU.

Keeping the ghost in character

The first version of the ghost's replies sometimes broke character — a stray stage direction in asterisks, a quoted line, a 40-word aside explaining the joke. I tightened the system prompt to explicitly forbid quotation marks, asterisks, and explanations, and capped it at one plain-text line, 20 words. That alone fixed almost all of it — small models follow hard constraints much better than soft suggestions like "keep it brief."

Reacting to intent, not output

The ghost only ever sees the command text and whether it succeeded or failed — never the actual command output. That was a deliberate choice: output can be huge, sensitive, or binary, and the ghost doesn't need to read your cat secrets.env to react to the fact that you ran it. Reacting to what kind of thing you just did (deleting, summoning root, failing) turned out to be both simpler and funnier than reacting to raw text.

Degrading gracefully

If Ollama isn't running, the shell still works as a completely normal shell — the ghost just goes quiet instead of crashing the whole thing. A haunting is a bonus, not a dependency.

--quiet mode

Commenting on literally every ls gets old fast in a long session, so --quiet only triggers the ghost on commands that are actually interesting: rm, sudo, git, mv, kill, chmod, chown, or anything that fails.

Why Does Open Innovation Matter?

  1. It works with the lights (and the internet) off. Once the model's pulled, the ghost haunts you completely offline. No connectivity check, no "service unavailable," just a possessed shell on a plane.

  2. Your terminal history is one of the most private things on your machine. Half-typed commands, file paths, project names, the occasional pasted secret you immediately regret — none of that should be going to a cloud API just so a shell can crack a joke. Running it locally means it never leaves the laptop.

  3. It's meant to be left running constantly, so it has to be free. The entire gag only works if the ghost comments on everything, all session, every day. A per-call API charge would turn a toy into a bill. A local 3B model makes "haunt me forever" cost nothing.

  4. No model to lose. This is a silly, personal tool — exactly the kind of thing that would get orphaned if a cloud provider deprecated the model it depended on. An open weight I've already downloaded doesn't get discontinued out from under a joke.

Try It Out

git clone https://github.com/VIKRAM-009/haunted-terminal
cd haunted-terminal
ollama pull llama3.2
python3 haunted_terminal.py
Enter fullscreen mode Exit fullscreen mode

Type exit or quit when you're ready to leave — the ghost gets the last word.

👉 GitHub Repository: VIKRAM-009/haunted-terminal


Thanks for reading, and happy Halloween. Something is still watching your terminal. 👻

Top comments (0)