Inspiration
How to Build a Generative Gothic Horror Murder Mystery Game Kit Using Claude and Python
Ditch the boring boxed party games. Learn how to write a lightweight Python pipeline that uses Claude to generate custom, character-driven Gothic murder mystery scripts.
Updated 9/19/2026
Ditch the Boxed Games
We have all been there. You gather a group of friends for a murder mystery night, open a store-bought box, and spend the next three hours reading incredibly wooden scripts, trying to care about a cardboard cast of characters written in 1998. It is clunky, predictable, and impossible to customise to your friend group.
But what if you could spin up a bespoke, Victorian Gothic horror murder mystery party kit on demand? What if the victim, the suspects, the clues, and the tragic family secrets were tailored exactly to the number of guests attending, your preferred level of difficulty, and your favorite literary tropes?
By leveraging Claude and a simple Python script, you can build a generative engine that outputs beautifully formatted character booklets, host guides, and clue cards. Let’s look at how to build this engine from scratch.
Step 1: Defining the Narrative Architecture
A solid murder mystery relies on a tight web of secrets. If you simply ask an LLM to "write a murder mystery," it will generate a generic, linear story that falls apart the moment players start asking unscripted questions.
Instead, we need to enforce a strict structured schema. The core of our game is a Truth Matrix. Every suspect must have: - A public persona (what everyone knows). - A hidden motive (their secret grudge against the deceased). - An alibi (which is partially true but flawed). - A dark secret (unrelated to the murder, but embarrassing enough that they will lie to protect it, creating red herrings).
To make this programmatically accessible, we will write a Python script that requests a highly structured JSON output from Claude using structured outputs. If you are unfamiliar with parsing complex JSON payloads from LLMs, you can find a breakdown of schema definitions in our glossary.
Step 2: The Python Narrative Pipeline
To execute this, you will need a basic Python environment and an API key from OpenAI or Claude's parent platform. Here, we will use Claude for its superior ability to handle complex character relationships and maintain a dark, atmospheric tone.
First, install the required packages:
`bash
pip install anthropic jinja2
`
Now, let's write our generator script. This script prompts Claude to construct the murder mystery blueprint in JSON format, which we can then feed into a HTML template for printing.
`python
import os
import json
from anthropic import Anthropic
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
def generate_mystery_blueprint(num_suspects=5): prompt = f""" You are an expert interactive game designer. Generate a Victorian Gothic horror murder mystery game blueprint for exactly {num_suspects} suspects. The setting is 'Blackwood Manor', an isolated estate on the Yorkshire moors during a raging storm in 1888. The victim is Lord Reginald Blackwood, an eccentric occultist found dead in his locked study. You must return ONLY a JSON object with the following structure: {{ "mystery_title": "string", "victim_details": {{ "name": "string", "cause_of_death": "string", "crime_scene_clues": ["string", "string"] }}, "suspects": [ {{ "name": "string", "archetype": "string", "public_persona": "string", "motive": "string", "alibi": "string", "dark_secret": "string", "is_murderer": true/false }} ] }} Ensure exactly one suspect has "is_murderer": true. """
response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=4000, temperature=0.7, system="You are a precise JSON generator. Output only valid JSON. Do not include markdown wraps or conversational text.", messages=[ {"role": "user", "content": prompt} ] ) return json.loads(response.content[0].text)
Run the generator try: game_data = generate_mystery_blueprint(num_suspects=5) print(f"Successfully generated: {game_data['mystery_title']}") except Exception as e: print(f"Error generating blueprint: {e}") # For API debugging, visit https://claude-support.com ```
Step 3: Generating the Physical Character Booklets
Having the data in a terminal is nice, but your guests cannot read a raw JSON file. We need to parse this data and compile it into beautiful, print-ready PDF character booklets.
We can use Python’s jinja2 library to render clean HTML templates, which you can then export to PDF using your browser or a headless tool like Weasyprint.
Create a basic HTML template (booklet_template.html):
`html
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: 'Georgia', serif; color: #2c2c2c; background-color: #fcfbf7; padding: 40px; }
h1 { font-family: 'Times New Roman', serif; border-bottom: 2px solid #5a1818; color: #5a1818; }
.secret-box { border: 1px dashed #5a1818; padding: 15px; background-color: #fcedfd; margin-top: 20px; }
.instruction { font-style: italic; color: #666; }
</style>
</head>
<body>
<h1>The Mystery of Blackwood Manor</h1>
<h2>Your Identity: {{ suspect.name }} (The {{ suspect.archetype }})</h2>
<p><strong>Who you are:</strong> {{ suspect.public_persona }}</p>
<p><strong>Your Alibi:</strong> {{ suspect.alibi }}</p>
<div class="secret-box">
<h3>DO NOT READ ALOUD UNTIL PROMPTED</h3>
<p><strong>Your Motive:</strong> {{ suspect.motive }}</p>
<p><strong>Your Dark Secret:</strong> {{ suspect.dark_secret }}</p>
{% if suspect.is_murderer %}
<p style="color: red; font-weight: bold;">YOU ARE THE MURDERER. You must deflect suspicion and lie about your timeline without being caught.</p>
{% else %}
<p><strong>You are innocent.</strong> Your goal is to find the real killer.</p>
{% endif %}
</div>
</body>
</html>
`
By looping through the game_data['suspects'] array, your Python script can output a custom HTML page for each guest.
Step 4: Crafting the Atmos-pheric Prompts
To turn this into a truly immersive evening, you want more than just words on a page. You need the scene set. You can use our prompt generator to craft specific image prompts for Midjourney to create atmospheric portrait cards for each character.
When hosting, you can also ask Claude to write a bespoke "Game Master Script" to open the evening. Read it aloud in a dark room illuminated only by candlelight, with a rainstorm soundtrack playing in the background.
This simple, automated pipeline takes less than an hour to set up, but it results in an unforgettable creative experience. Your friends will be talking about the night they survived Blackwood Manor—and the sheer cleverness of its design—long after the last candle has sputtered out.
Keep going
Build something with the prompt generator, decode the jargon in the glossary, or compare the tools on our platform deep-dives.