This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
A terminal that's haunted. You type commands like normal, and a ghost lives inside the shell and reacts to everything you do.
-
It runs real commands.
git,ls,vim, whatever you like. Onlycdandexportpersist between commands, since each command runs in its own subshell. - It comments on them. After each command, a local model writes a one-line ghostly remark. Fail a command and you get a blinking ASCII grin and a taunt. Succeed and the ghost grudgingly allows it.
- It laughs at you. A few stock haunted-laugh clips play when you fail, try something dangerous, or get haunted by your past.
-
It resurrects old commands. Every command is saved to a history file. When you run something, the ghost digs up the most similar older command and offers to re-run it. If your command just failed, it prefers a similar one that worked. A botched
git pshbrings back thegit push origin mainfrom last week. Pure necromancy, and weirdly useful. -
It stops you from doing something dumb.
rm -rf,sudo,git push --force,reset --hardand similar commands get a warning and a confirmation prompt before they run.
Demo
Code
https://github.com/anubhabdaserrr/haunted-terminal-hacktoberfest-2026
It's one Python file with zero pip dependencies. You need Python, Ollama, and a few laugh clips in a voices/ folder.
How I Built It
I built it with Claude over a few iterations.
The first idea was a "Necromancer" that picks a random GitHub repo whose last commit is over 10 years old and writes its autopsy with a local model. Then I decided the haunting would feel better if it lived in the place I spend all day, the terminal, so I switched to that.
The pieces:
-
The ghost's brain: Ollama running
qwen3.5:2b. The prompt asks for one short, spooky, unhelpful sentence about the command, its exit code and the directory. Qwen has a "thinking" mode that burns tokens on hidden reasoning, which is wasted on a 20-word taunt, so I turn it off in the request. The model also warms up in the background at startup so the first comment isn't slow. - A safety net: if Ollama isn't running or the model times out, the ghost falls back to a bank of canned curses. The terminal never breaks, it just gets less personal.
-
Resurrection: command history goes into a JSONL file. I match new commands against old ones with Python's
difflib, with bonuses for a shared first word and for past commands that succeeded when the current one failed. -
Audio: it plays random clips from the
voices/folder with whatever player the OS already has (afplay,paplay,ffplayand so on), and never plays the same clip twice in a row. The laughs are stock clips from [source]. - The grin: a two-frame ASCII face that blinks using ANSI cursor movement.
I haven't added a big framework or any pip installs. That was on purpose, so anyone can clone it and haunt their own terminal in two minutes.
Why Does Open Innovation Matter?
Think about what a terminal knows about you. Your command history includes project names, server addresses, half-typed passwords, and what you were doing at 3am. A ghost that comments on every command needs to see all of that.
Sending every keystroke-adjacent thing to a third-party API for a joke doesn't feel right, and it would be slow and cost money across hundreds of commands a day. With an open-weight model like Qwen3.5:2B running locally through Ollama:
- Your shell history never leaves your machine.
- It works with the Wi-Fi off.
- It costs nothing per command. A ghost that comments on everything you type is only practical when each comment is free.
-
I can swap the model with one environment variable (
MODEL=...) and compare how different models haunt you.
A closed API could write good taunts, but it couldn't be trusted with this data, and it couldn't run offline on a laptop. Here, the open model is what makes the project possible.
Happy haunting! 🕯 If you try it, let me know what your ghost said when you typed rm -rf.

Top comments (0)