DM Framework — run a long, persistent, rules-honest D&D campaign with Claude as your Dungeon Master
An AI can run one scene beautifully. Running a campaign is harder. Over dozens of sessions it has to remember what happened, keep secrets from the player it is talking to, roll honestly, keep every number straight, and start each new conversation with no memory of the last.
This is the machinery one table built to solve that, over about eighty sessions and a dozen modules of solo Dungeons & Dragons (5e, 2024 rules). It is an empty, ready-to-play campaign folder: copy it, add your character, and start session one.
What makes it different
- Modules are built and audited before you play them. The DM writes or adapts a module to a spec, then separate fresh agents put it through a blind rules audit, a setting check, and a red team that plays your real habits against it. It is frozen before play and run as written.
- A spoiler firewall, so the player can own the folder. Everything the DM writes ahead of play is sealed. A git hook refuses any commit that leaks a sealed name into a file the player reads.
- Honest dice, shown. A fair roller logs every die. The outcomes are written down before the roll, and DM mistakes are rolled back, not noted.
- A record that survives the conversation. Every person, place and item is a plain Markdown file. State is written the moment it changes. A status card tells the next conversation exactly where play stopped.
- It checks itself. Boot checks, truncation tripwires, a stale-file sweep and a ledger with an age gate catch drift before it reaches the table.
Quick start
- Copy this folder and run
git init, then git config core.hooksPath _tools/hooks.
- Download the free System Reference Document 5.2.1 from Wizards of the Coast into
srd/ (not included here).
- Fill in your table’s settings and make your character from the templates.
- Open the folder with Claude Code (or any agent that can run shell commands there) and say you are starting session one.
- When you are done, say “let’s wrap”. The close procedure saves everything and commits.
The full steps are under How to start below. None of the original campaign is here — no characters, places, sessions or story — and no published game text.
Built by hawaiidocpsb-dev, with Claude as the DM and co-author.
What problem it solves
An AI can run a scene beautifully. Running a campaign is harder: over many sessions it has to remember what happened, keep secrets, roll honestly, not invent pressure, not decide for the player, keep every number straight, and boot cleanly into a new conversation with no memory of the last. This framework is the answer one table arrived at.
The design ideas
- The campaign is a graph of plain files. Every character, place, item, quest, faction, creature and ability is a Markdown file — prose for people, plus a small JSON
## Data block for the tools (_schema.md). A script assembles the whole graph on demand; the DM loads only what the scene touches.
- A boot set and a status card. Six files are read at every session start (
CLAUDE.md ## 0); _RESUME.md says exactly where play stopped and what the next beat is. A new conversation starts warm, not cold.
- The module is the content. The DM plays the printed (or the DM-built and audited) module as written, on its own triggers. Nothing is invented at the table; friction the module keys is checked against what play has actually done before it fires, and may only be subtracted. This one rule fixed more bad sessions than any other.
- Write it the moment it happens. Every change lands in its owning file at the beat; numbers and items are data, edited only through tools (
_tools/sheet.py, _tools/inventory.py), with every view rendered from them. Orders and debts live in a ledger with an age gate, so nothing promised is forgotten.
- Pre-send sentinels. A short checklist run before every narrated turn: load every person, place and spell before writing them; keep game mechanics out of the fiction; never invent past events; keep secrets out of chat (
CLAUDE.md ## 4).
- A spoiler firewall with a machine half. Content the DM writes ahead of play is sealed from the moment it is written; its proper nouns go on a watchlist, and a git pre-commit hook fails any commit that puts one in a player-readable file — or in the commit message.
- Honest dice, shown. A fair roller that logs every die; the outcome bands written before the roll; the DM’s errors rolled back, not “noted”.
- File integrity as a first-class concern. Every file carries start and end markers (a truncation tripwire), edits are byte-safe, git is the backup, and a boot gate refuses to narrate until the checks pass.
- A module-building workshop. Original modules are built to a written spec, then put through a blind rules audit, a setting-fit audit, a creative-player red team that plays the player’s real habits against the key, and cast passes for the companions — with every helper agent writing to disk so a usage limit loses nothing (
_workshop/).
- Lessons, kept.
_workshop/LESSONS.md starts empty; after each module you play, the DM writes what it taught — what failed, why, and the rule that fixes it — and the next build reads it first.
What is in the box
| Path |
What it is |
CLAUDE.md |
the DM’s session rules — the boot set, the game loop, load discipline, beat-triggered writes, the sentinels, the hard rules, file integrity, session close |
_schema.md · _glossary.md · _INDEX.md |
the data contract, the jargon in plain words, the trigger table for non-graph files |
DM_GUIDE.md |
the DM-reserve bible, empty: directives, world palette, pull-engine design, watch-clocks, release log |
canon/ |
the procedures (session close, audit, sourcebook ingest), the DM’s operating rules, and a house-rules template with the reasoning behind each dial |
voice/dm_voice.md |
the DM voice reference, with a fill-in for your persona |
_tools/ |
the machinery (below) |
_workshop/ |
the module-building spec, audit and red-team briefs, the player playbook (fill-in), templates, build tools, and LESSONS.md |
skills/ |
the close procedure, the pre-send sentinel scanner, the purchased-module ingest procedure |
pc/ npc/ locations/ items/ factions/ quests/ creatures/ abilities/ races/ |
one template per kind, an empty index each, and one example PC |
state/ sessions/ modules/ _RESUME.md |
an empty campaign ready for session one |
The tools (_tools/, all plain Python 3, standard library except where noted): graph_extract (builds the graph), check_consistency and boot_check (integrity and vocabulary), manifest_check (mid-body truncation), firewall_check + hooks/ (the spoiler firewall), git_safe (git over a bridge that cannot delete), roll (dice), sheet (character numbers), inventory (items, and the player-facing Register), explore (rooms seen and explored, EXITS, the player’s known-ground page), site_maps (scaled player maps revealed as seen; needs Pillow), threads_due and pull_due (what is near the party; what the world could bring to it), calls_check (the open-calls ledger and its age gate), stale_check (objects that fell behind the play record), state_lint, inventory_check, quest_audit, rotation_audit, rotate_logs (keep live files thin), close_checks and close_sweep (the bundled close runners), backup_campaign, srd (serves the SRD one entry at a time), lore (serves the owner’s own sourcebooks one section at a time), module_ingest (a purchased adventure PDF to a playable kit; needs poppler-utils and tesseract, and subagents to do the reading). In _workshop/tools/: stat_blocks, audit_packet, exits_check, balance_calc.
How to start
- Copy this folder to where your agent can read and write it, and make it a git repository:
git init, then git config core.hooksPath _tools/hooks to arm the firewall.
- Get the rules text. Download the System Reference Document 5.2.1 from Wizards of the Coast (it is free, under CC BY 4.0), convert it to markdown into
srd/ with the file names in srd/README.txt, keep its attribution in srd/_PROVENANCE.md, and run python3 _tools/srd.py build. The SRD is not included here.
- Write your table’s settings.
canon/world-rules.md (the dials), voice/dm_voice.md (the persona), _calendar.md (your setting’s months — and the same list in _tools/threads_due.py), canon/setting-primer.md, _workshop/SPEC.md ## 1 and ## 1b (what the player finds fun; who the character is), _workshop/PLAYBOOK.md.
- Make your character. Copy
pc/_pctemplate.md and state/sheets/_sheettemplate.json.txt; delete the example hero (pc/pc-example-hero.md, state/sheets/sheet-example-hero.json, its row in pc/_pcindex.md and state/char.md).
- Fill in
_RESUME.md and state/scene.md with the opening scene, then run python3 _tools/boot_check.py --manifest once to set the boot files’ size bands to your files.
- Point Claude at
CLAUDE.md (Claude Code reads a CLAUDE.md in its working folder automatically; otherwise tell it to read CLAUDE.md first) and say you are starting session one. At the end, say “let’s wrap” — the close procedure writes everything and commits.
What you supply, and what is never included
- Rules text: the SRD 5.2.1, downloaded by you, CC BY 4.0. Nothing from it is redistributed here; the combat and conditions cards in
canon/ are empty stubs for you to write.
- Purchased modules and sourcebooks: yours, bought by you, kept in
_sources/ (git-ignored) and inside your own modules/ folders. The ingest tools read them; nothing from them belongs in a public copy of your campaign. .gitignore keeps PDFs, _sources/ and srd/ out of git by default.
- Your campaign: characters, places, sessions and secrets are yours. This framework ships with none.
Requirements
Python 3.8+. Optional: Pillow (site_maps.py), poppler-utils and tesseract (module_ingest.py). An agent that can run shell commands in the folder (Claude Code, or a desktop app with folder access).
Credits
- Built by hawaiidocpsb-dev, with Claude (Anthropic) as the DM and co-author of the tools and rules.
- Rules: the System Reference Document 5.2.1 © 2024 Wizards of the Coast LLC, used under CC BY 4.0 — supplied by each user, not redistributed. Dungeons & Dragons is a trademark of Wizards of the Coast; this project is unofficial and not affiliated with or endorsed by Wizards of the Coast.
Licence
Code: MIT (LICENSE). Written material: Creative Commons Attribution 4.0 (LICENSE-docs.md). Credit: hawaiidocpsb-dev.
评论