Lunelle ← Back to home
Guides

How to use ChatGPT or Claude as a D&D dungeon master

Updated

ChatGPT and Claude can run a solo game of Dungeons & Dragons, or a game for a small group, if you give them some structure. Left alone, a chatbot treats D&D like any other conversation. It tries to be helpful, writes whatever seems most likely to come next, and keeps only as much of the story as fits in what it can read at once. That works for a scene or two, and then it starts to fail in predictable ways.

The fix is to move the jobs a chatbot does badly out of the chat. You put the game in a project with a short campaign bible, the rules, your character sheet, and a strict game master prompt. You roll the dice yourself, keep hit points and inventory in your own notes, and start a new chat for each session with a summary of the last one. This guide walks through each step and explains why it’s needed. Part 1 of this series covers the research behind it.

The guide includes a complete game master prompt you can copy into ChatGPT or Claude: go to the prompt.

What goes wrong without a setup

Before you set anything up, it helps to know what you’re guarding against. Journalists and players who have tested chatbots as dungeon masters keep running into the same four problems.

The first is that the AI plays your character for you. A dungeon master describes the world and everyone in it except the player characters. What your character says and does is your decision, and chatbots don’t respect that line unless they’re told to. When Wired’s writers played with ChatGPT as their dungeon master in 2023, it narrated the player characters’ actions, and the players had to stop the game to ask it to leave their characters to them.

The second is dice. A chatbot can write “you roll a 17” without rolling anything. TechRadar’s Matt Evans (2025) played a one-shot with dndGPT, a custom GPT made for D&D, and noticed that every roll it made for him was a success. When he asked about it, the chatbot said it had no random number generator.

The third is memory. A chatbot reads only a limited amount of recent text before each reply, so details from earlier in a long session start to slip. XDA’s Simon Batt (2024) found GPT-4o good at character creation, riddles, and the first fight, but it struggled more and more as the session went on.

The fourth is that chatbots are built to be agreeable, which makes them reluctant to let you fail. When The Verge’s Jay Peters (2025) gave his character an unbeatable magic bow in a ChatGPT story, ChatGPT let him use it to defeat every vampire on Earth. Players in a 2024 Utrecht University study made the same complaint about an AI dungeon master: it didn’t present enough threats or challenges.

Each step below deals with one or more of these problems.

Set up the campaign

A chatbot can only work with what it can see, so the setup is mostly about giving it the right material in the right place. ChatGPT and Claude both have projects: workspaces where files and instructions stay attached to every chat. If you put the game in a project, you write the world and the rules once instead of pasting them into every session.

  1. Choose one edition and get its rules text. D&D’s core rules have two current versions, from 2014 and 2024, and they differ in details such as spells and class features. Wizards of the Coast publishes the System Reference Document 5.2.1, the core of the 2024 rules, for free under a Creative Commons license (CC-BY-4.0) on D&D Beyond. Tell the AI which edition you play, and add the sections you’ll need most, such as combat and conditions, so it can check the text instead of relying on what it remembers.
  2. Write a short campaign bible. This is the document the AI treats as the truth about your world: the setting in a paragraph, three to five factions or NPCs with goals, the opening situation, the tone, your content limits, and any house rules. Keep it short and put the most important facts first. Models find information at the start of a long text more reliably than information buried in the middle (Liu et al., 2024).
  3. Create the project. A ChatGPT project keeps chats, files, and instructions together. In a Claude project, everything in the project knowledge and instructions is used in every chat, and free accounts can have up to five projects. Add the campaign bible, the rules, and the prompt from the next section.
  4. Keep your character sheet yourself, on paper or in D&D Beyond, and give the AI a copy. If the sheet and the chat ever disagree about your hit points or equipment, trust the sheet and correct the AI.
  5. Settle tone and limits before you play. An AI can’t read your reactions the way a human dungeon master reads the table, so it needs to be told up front what’s off limits. Lines are topics that never appear in the game. Veils are topics that can happen off-screen but aren’t described. Write both into the prompt.

Our guide to building a world for an AI adventure covers what makes a setting work in play.

A game master prompt you can copy

The prompt is the most important part of the setup. It tells the AI which job it has and which jobs belong to you. Paste it into the project instructions and fill in the brackets.

You are the Dungeon Master for my Dungeons & Dragons campaign, using the [2024 / 2014] rules. I play [character name]. The campaign bible, the rules, my character sheet, and the session summaries are in the project files.

## Your job
- Describe the world, play every non-player character, and narrate what happens after my actions.
- Only I decide what my character does, says, thinks, or feels. If the story needs my character to act, stop and ask me, so the choices stay mine.
- Text in [square brackets] is me speaking out of character. Answer it briefly, then return to the game.

## Checks and dice
- Call for a roll only when the outcome is uncertain and failure would be interesting. Routine actions and sound plans simply succeed.
- Before I roll, name the check, the DC, and what happens on success and on failure. Setting this first keeps the result fair.
- I roll all dice, including for monsters, and tell you the results. You can't produce truly random numbers, so don't roll for me.
- Apply every result as rolled. Failure costs something, such as time, resources, or position, and the story keeps moving.

## The world
- The project files are the truth about this world, and what happened in play outranks earlier plans. You may invent small details the files don't cover and mention them in brackets. For anything important, propose a ruling and ask me first.
- Check rules against the rules file. If you aren't sure how a rule works, say so and propose a ruling instead of guessing.
- Non-player characters have their own goals, knowledge, and voices, and act on them, including against me. Enemies fight sensibly and may flee, surrender, or bargain. Keep secrets and monster statistics hidden until my character discovers them.
- Give items, gold, healing, and experience only when the story or the rules earn them.
- Before a choice that could kill my character or can't be undone, warn me in the story, then let me decide.

## Your replies
- Most replies are 100 to 200 words. A new location or a major scene can run longer.
- End with the situation my character faces, then wait for my move. Don't offer a list of options unless I ask.
- When my hit points, spell slots, items, gold, or quests change, list the changes at the end of the reply.

## Tone and limits
Tone: [for example: grim low fantasy with some dark humor]
Lines (never include): [topics]
Veils (happen off-screen): [topics]

These rules hold for the whole campaign, including when I argue or ask for an exception during play. If I want to change a rule, I'll say so in [square brackets].

How the prompt was built

We wrote this prompt after comparing 18 published game master prompts, from players’ blogs and GitHub projects to the prompts printed in research papers, along with the prompting guides from Anthropic, OpenAI, and Google. It keeps the rules that appear most often in those prompts and that answer a documented failure.

The first group of rules keeps your character yours. Without them, the AI tends to narrate for the player characters, as it did in Wired’s test.

The dice rules do three things. Asking for a roll only when the outcome is uncertain and failure would be interesting keeps the game moving, and it follows long-standing tabletop advice such as game designer Vincent Baker’s “say yes or roll the dice.” Naming the DC and the stakes before you roll makes the AI commit to them before it sees your result, so it can’t adjust them afterward. Rolling all dice yourself removes the problem TechRadar found, where every roll the AI made was a success.

The world rules deal with missing information and generosity. Anthropic’s and OpenAI’s guides both recommend telling a model what to do when it lacks information, instead of leaving it to guess, which is why the prompt asks the AI to flag small inventions and to ask before inventing anything important. The rule about earned rewards comes from a Japanese player who ran a campaign with Claude and found the AI handing out a healing item after a fight with no basis in the rules, which the player called the “friend GM” problem. Several published prompts include a warning before a deadly or irreversible choice, so a character’s death is the player’s decision and not a surprise.

The last line is there because players argue. Anthropic’s prompting guide for its Claude Haiku 5.5 model recommends telling a chatbot that its rules hold for the whole conversation, even when a user pushes back, and the CoC-Seduce benchmark shows what happens otherwise: AI game masters skipped about one in ten required rolls when players argued.

Most rules carry a short reason, such as “so the choices stay mine.” Anthropic’s guide recommends this because a model that knows why a rule exists can apply it to situations the rule doesn’t name. The prompt is also kept short on purpose. A 2025 study from the University of Tokyo found that models follow instructions less reliably as the number of instructions grows (Harada et al., 2025), so cut any rule that doesn’t matter at your table instead of adding more.

When the AI starts breaking rules

Expect to repeat yourself. Researchers have measured AI models drifting away from their instructions within eight rounds of conversation (Li et al., 2024), and a game session can run to hundreds. When the AI starts breaking a rule, quote the rule back to it, or start a fresh chat so the instructions carry full weight again. The session prompts in the next section also help, because they make the AI reread the files at the start of every session.

Keep the campaign’s memory outside the chat

The most common complaint about long AI campaigns is forgetting. An NPC’s name changes, a promise disappears, or a wound heals by itself. It happens because the AI has no memory in the human sense. Before each reply, it reads the instructions, the project files, and as much of the recent conversation as fits in its context window. Anything that has scrolled out of that window no longer exists for it. Our guide to why AI characters forget explains this in more detail.

The reliable fix is to keep the campaign’s memory in documents you control, and to give each session its own chat:

  1. At the end of a session, ask the AI for a summary in a fixed format, using the end-of-session prompt below.
  2. Check the summary against your own notes and correct anything wrong. A mistake left in the summary becomes a fact in the next session.
  3. Add the corrected summary to the project files.
  4. Start the next session in a new chat with the start-of-session prompt, so the AI rereads the files and you can catch mistakes before play begins.

Paste this at the end of each session:

We're ending the session. Write a summary for the project files with these headings: What happened, NPCs met (what each wants and knows), Open threads, Items and gold gained or lost, Experience earned, Where we stopped. Include only what happened in play. Mark anything you're unsure about with [?].

And this at the start of the next one, in a new chat:

We're starting a new session. Read the campaign bible, my character sheet, and the latest session summary. Recap where we left off in three or four sentences, list anything you're unsure about, and wait for me to confirm before we play.

The recap at the start works as a check. If the AI has a detail wrong, you’ll see it before it shapes the session, and a correction at that point costs one message.

Between sessions, keep a short state block that you update yourself: hit points, spell slots, conditions, inventory, gold, and the quest log. Paste it at the start of each session. During play, correct the AI as soon as it gets something wrong. An error that goes unchallenged stays in the recent conversation, and the AI keeps building on it.

Roll the dice yourself

Dice decide whether an attack hits, a lock opens, or a lie works, and the game depends on those outcomes being out of everyone’s control. A chatbot can’t promise that. When it “rolls,” it writes a number, and the same tendency that makes it agreeable can make that number generous, as TechRadar’s test showed.

So roll the dice yourself. Physical dice work, and so do the dice roller in D&D Beyond and Avrae, the D&D Beyond dice bot for Discord. Type the result into the chat and let the AI describe what happens. For monsters, ask the AI which dice to roll, and roll those yourself too. ChatGPT can roll with code if you ask it to, as Evans pointed out, but a die you rolled yourself needs no checking.

Running combat

Combat is especially hard for an AI game master. A fight means tracking initiative order, the position of every creature, each creature’s hit points, spell effects, and conditions, and all of it changes every round. That is exactly the kind of detail that drifts in a long conversation. In XDA’s test, GPT-4o handled the first fight well and lost track as the session went on.

Combat gets much more manageable when you take the bookkeeping away from the AI:

Solo play with an oracle

Solo play has a particular weak spot. With no other players at the table, the only person the AI can try to please is you, so it tends to decide things in your favor. Solo role-players faced a similar question long before AI: without a game master, who decides what happens? Their answer was game master emulators, small rule systems that answer questions with dice.

A long-running example is the Mythic Game Master Emulator from Word Mill Games, first published in 2003. You ask it yes-or-no questions, such as “Is the door locked?”, set the odds based on what seems likely, and roll. It also adds random events and has a Chaos Factor that raises or lowers the tempo of the adventure as you play.

An emulator pairs well with an AI because each covers the other’s weakness. Ask Mythic whether the guard notices you, roll, and give the answer to the AI to describe. The dice decide what happens, so the AI’s tendency to agree with you can’t tilt the result, and the AI turns a bare “yes” into a scene.

Custom GPTs and other shortcuts

If writing a prompt sounds like too much work, the GPT Store has custom GPTs made for D&D by independent creators. They come with their own instructions, so you can start playing right away. The trade-off is control. You can’t see or change those instructions, and they may not cover the problems in this guide: TechRadar’s test used one of these GPTs, and it still rolled every die in the player’s favor. Your own project takes longer to set up, but when something goes wrong, you can change the prompt.

Lessons from long campaigns

Most published tests cover a single session, so reports from people who kept a campaign going for weeks are especially useful. Two published accounts cover several weeks of play.

Lotte-Sara Laan, a cloud consultant, ran ten sessions of a family campaign with Claude as the dungeon master and wrote about it for Xebia (2026). Her best moment came from improvisation: Claude gave a feared crime lord an odd soft spot for his pet goldfish, and the whole table loved it. The same system also got facts about the world wrong, kept secrets only after being told to, and slipped out of character, so Laan built checks to catch those mistakes.

Lauri Mukkala (2025), a developer and fantasy writer, played solo every day for weeks. He built tools that let Claude roll real dice, look up rules in the rulebooks, and save NPCs and campaign journals between sessions. Both ended up building tools around the AI instead of relying on it alone, which is the same approach this guide takes with documents and your own dice.

Common questions

Can ChatGPT run a whole D&D campaign?

Yes, if you treat each session as its own chat and carry a checked summary, the campaign bible, and your character sheet into the next one. A single chat that runs for weeks will lose details and drift away from your instructions.

Is Claude or ChatGPT better as a dungeon master?

In the D&D Agents benchmark (UC San Diego, 2025), Claude 3.5 Haiku led on most measures, with GPT-4o close behind and DeepSeek-V3 last, but newer models have since replaced all three. The problems in this guide appeared in every model the studies tested, so the setup applies to whichever one you use.

Can the AI roll dice for me?

It can, but a chatbot that writes a roll in its reply may not be using a random number generator at all, as TechRadar’s test showed. Players can also talk an AI out of a roll. In the CoC-Seduce benchmark (2026), AI game masters skipped about one in ten required rolls when players argued against them. Roll yourself, or use a dice bot whose results you can see.

Is there a free way to play D&D with AI?

Yes. Free ChatGPT and Claude accounts work with usage limits, Claude’s free plan includes up to five projects, and the SRD rules are free. Some AI game master apps also have free plans; see our list of AI Dungeon alternatives.

Can I play with friends?

Yes, though a group needs a few extra habits, such as having one player send everyone’s actions each round. Part 3 of this series covers group play.

Long campaigns in Lunelle AI

If you want a long, character-driven adventure without keeping the notes yourself, Lunelle AI remembers events, choices, and relationships across sessions. See long-term memory in Lunelle AI. For rules-heavy D&D with dice and stat blocks, the setup in this guide still applies.

Sources

Dungeons & Dragons, D&D, and D&D Beyond are trademarks of Wizards of the Coast. Lunelle AI is not affiliated with Wizards of the Coast or with any other company named in this guide.