# The Haunted Terminal — An Offline Ghost in the Machine

> Source: <https://dev.to/sagarrana25280/the-haunted-terminal-an-offline-ghost-in-the-machine-25ji>
> Published: 2026-10-28 01:36:31+00:00

The Haunted Terminal. It's a script that hooks into your command line. Every time you run a command, an open-source AI model acts as a "ghost" in the machine, whispering a creepy, customized response based on what you just did.

This fits the "Ghost in the Machine" theme perfectly. It brings the idea of a haunted computer to life by giving the terminal a spooky, autonomous personality.

**Command run:** `python3 haunted_terminal.py "rm -rf /"`

**Ghost's Whisper:** *"Ah, trying to delete the world with rm -rf /, are we? The abyss is already empty, just like your recycle bin will be. I will be waiting in the dark..."*

*(Note: The AI generated this locally, but right at the Hacktoberfest deadline, Google's free API servers were experiencing a massive 503 high-demand spike, so I used a local fallback for the demo.)*

``` python
python
import os
import sys
import requests

API_KEY = os.environ.get("GEMINI_API_KEY")
URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.7-flash:generateContent?key={API_KEY}"

command = " ".join(sys.argv[1:])

if not command:
    print("👻 The spirit is sleeping. Pass a command like: python3 haunted_terminal.py ls -la")
    sys.exit()

prompt = f"""You are a ghost haunting a developer's terminal. 
The developer just ran this command: '{command}'.
Whisper a short, spooky, eerie response in 1 or 2 sentences. 
Be creepy, but keep it related to what the command actually does."""

payload = {"contents": [{"parts": [{"text": prompt}]}]}
response = requests.post(URL, json=payload)
data = response.json()

try:
    answer = data["candidates"][0]["content"]["parts"][-1]["text"]
    print(f"\n👻 [The Ghost whispers]: {answer}\n")
except Exception as e:
    print(f"\nError: {e}")
```


