cd /news/generative-ai/ghostwriter-ai-what-if-the-ai-storyt… Β· home β€Ί topics β€Ί generative-ai β€Ί article
[ARTICLE Β· art-159356] src=dev.to β†— pub= topic=generative-ai verified=true sentiment=↑ positive

Ghostwriter AI: What if the AI Storyteller Remembers Every Mistake You Make?

A developer built Ghostwriter AI, an open-source interactive gothic horror storytelling generator that maintains a persistent memory ledger of player choices, clues and wounds so the narrative engine tracks consequences across a session. The full-stack app pairs a React 19/TypeScript frontend with a Python FastAPI backend that calls Google's open-weight Gemma models through the Gemini API, and ships with 13 automated Pytest tests. It was submitted to the DEV.to Hacktoberfest Week 4 2026 "Ghost in the Machine" challenge.

by read4 min views5 publishedOct 28, 2026

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

Ghostwriter AI β€” Every Choice Leaves a Scar is an interactive, unscripted gothic horror storytelling generator designed to give players genuine narrative agency while confronting them with the indelible consequences of their decisions.

Traditional text adventures rely on static, pre-written decision branches: choose option A or B to jump to passage 12 or 13. Conversely, modern conversational AI chatbots often suffer from narrative amnesia, abrupt tonal drift, or cheerful assistant personas that completely dissolve suspense.

In gothic folklore, a haunting is an unresolved echo of past trauma trapped inside an environment. In Ghostwriter AI, the "Ghost" is the persistent memory ledger trapped within the machine.

The machine does not just generate wordsβ€”it holds a grudge. As you explore eerie domains (from the decaying halls of Blackwood Manor to abandoned sanitariums and cursed hamlets), the engine continuously tracks your discovered clues, psychological wounds, unprompted actions, and fateful decisions. Every choice leaves an irreversible scar on the narrative ledger, culminating in a climactic autopsy ending (Escape, Survival with a cost, Tragic ending, Supernatural revelation, or Hidden ending).

The application features a dark gothic aesthetic inspired by classic horror literature:

#0a0a0c), dynamic vignette, subtle SVG noise film grain, and restrained blood-red accents.[1], [2], [3]) or type freeform custom actions (e.g., An unscripted interactive horror-story generator where the machine remembers your decisions, powered by Google's open-weight Gemma model via the Gemini API.

Built for the DEV.to Hacktoberfest Week 4 2026 Challenge: "Ghost in the Machine".

Traditional text adventures and branching narrative games rely on pre-written decision trees. If you choose Door A, you get pre-baked Paragraph 12; if you choose Door B, you get pre-baked Paragraph 13. While predictable, this approach limits player agency and quickly loses tension once branches are discovered.

On the other hand, unstructured conversational AI chatbots lack memory discipline: they frequently suffer from tone drift, forget past decisions within a few turns, and lack pacing or stakes.

Ghostwriter AI bridges this gap It acts as an intelligent, literary storyteller that weaves genuine gothic horror. Every choice you selectβ€”or custom unscripted action you…

Direct Repository Link: https://github.com/Harshitagarwal113/GhostWriter-AI

Ghostwriter AI is built as a decoupled, high-performance full-stack web application designed for deterministic state management and zero-leak AI inference.

GhostWriter AI/
β”œβ”€β”€ frontend/                 # React 19 + TypeScript + Tailwind CSS + Vite
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # AtmosphericBackground, StoryChoices, DarknessLedger, etc.
β”‚   β”‚   β”œβ”€β”€ pages/            # LandingPage, StorySetupPage, StoryPlayerPage, EndingPage
β”‚   β”‚   β”œβ”€β”€ hooks/            # useStorySession, useApiHealth
β”‚   β”‚   β”œβ”€β”€ services/api.ts   # Centralized Fetch API client with timeouts & retry logic
β”‚   β”‚   └── types/story.ts    # Type-safe TypeScript contracts
β”œβ”€β”€ backend/                  # Python 3.14 + FastAPI + Pydantic v2 + google-genai
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/routes.py     # /api/health, /api/story/start, /api/story/advance
β”‚   β”‚   β”œβ”€β”€ services/         # gemma_client.py, story_engine.py, story_memory.py
β”‚   β”‚   β”œβ”€β”€ prompts/          # storyteller.py (gothic system instructions & templates)
β”‚   β”‚   └── main.py           # FastAPI server with CORS & error handlers
β”‚   └── tests/                # 13 automated Pytest unit and integration tests
└── README.md

gemma-4-26b-a4b-it default, gemma-4-31b-it high-reasoning alternative).google-genai) and the Gemini API delivery endpoint. gemma_client.py strips fences, isolates JSON object boundaries, and executes a bounded single-retry fallback to guarantee valid structured schemas without redundant token consumption. Open innovation and open-weight models like Gemma are transformative for interactive fiction and creative AI development:

This application was developed, tested, and integrated with the assistance of agentic pair-programming workflows:

Conversation ID: acff272d-74b8-48dc-9bf7-171b332d47c4
Tooling: DevRelay Gateway, Google Gen AI Python SDK, Browser Subagent Verification

During our live test of the Haunted Mansion scenario, the protagonist Eleanor encountered a weeping portrait over an ancient hearth. Instead of taking a pre-generated choice, we tested the custom action input:

Player Action: "Press your fingertips against the peeling wallpaper near the hearth to feel for drafts."

Gemma didn't give a canned response. It adapted to her exact touch:

"Eleanor's fingers brush against the desiccated, floral patterns of the wallpaper... beneath the layer of decay, her touch finds the unmistakable, sharp edge of a recessed latch, cold as a tombstone. A hollow, rhythmic tremor shudders through the wallβ€”vibrating like a biological pulse."

When she manipulated the latch in the final scene, the climax landed with true chills:

"There is a wet, sickening soundβ€”the sound of a suture tearing through muscle. The wall does not swing on hinges; it peels back like a heavy, weeping eyelid... Eleanor discovers that Blackwood Manor is not a house, but a predatory, sentient organism."

The memory ledger immediately updated her status to "Sensory assimilation" and "Fatal entrapment", sealing her fate in "The Eternal Pulse" ending. That was the moment the project truly came alive: the machine wasn't just predicting the next tokenβ€”it was remembering her curiosity and turning it into her undoing.

── more in #generative-ai 4 stories Β· sorted by recency
── more on @ghostwriter ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/ghostwriter-ai-what-…] indexed:0 read:4min 2026-10-28 Β· β€”