Made an AI agent help me DM D&D in Foundry, and went too far
Six years into a Dungeons & Dragons campaign, I used Claude Code in Foundry VTT to track lore, help run NPCs, and customize each player's screen.
For the last six years I’ve been the Dungeon Master for a Dungeons & Dragons campaign with five friends, mostly in Greek. We play online in Foundry Virtual Tabletop, hosted on my own server. A few months ago I pointed Claude Code at six years of messy session notes so I’d stop forgetting my own world.
Then things escalated. Foundry is a web app, so Claude Code can open it in a browser, build scenes, and ship custom modules straight to the server. Last weekend our custom Foundry module hit 26 versions in two days. By Sunday night each of my five friends was seeing a slightly different version of the same battle map. I also had to stop and delete half the extra stuff I’d built.
Putting six years of D&D notes in one folder
After 94 sessions, our campaign sat scattered across too many places. The first year existed only in 122 hours of D&D recordings I transcribed with Whisper. Later sessions lived in the players’ wiki, alongside 192 pages of scanned handouts from 2017 and 850 old Foundry chat logs. Half our maps and portraits sat on the server, and the rest sat on a backup drive under useless file names.
Once I pulled all of that into one folder, Claude Code could keep our campaign continuity books without guessing. It separated confirmed canon from lies an NPC had told three years earlier, and it tracked open promises still waiting to pay off. It also indexed 2,688 campaign pictures by era and subject so finding an old portrait stopped eating twenty minutes of prep.
With the whole archive in one place, I threw together a password-protected website for the players. They use it to read old recaps and search early transcripts, or vote on names for forgotten pictures while campaign songs play. One session number in a config file holds back future prep, keeping 77 upcoming pictures off the site until we play through them.
Letting Claude Code open Foundry VTT
Foundry runs in a browser, and Foundry VTT modules are ordinary web code. That means Claude Code doesn’t stay stuck in a terminal editing Markdown. It opens Foundry directly and works on the tabletop.
That helped most with the dull parts of running a game. Between sessions, Claude builds scenes and updates character sheets, and repairs broken art links when files move on the server. It also fixed rules annoyances that Foundry’s default D&D 5e system leaves behind. When a player drops concentration on a summoning spell, the default system leaves summoned creatures on the map. Players lack permission to delete tokens, so our module watches for dropped concentration and has my Game Master browser remove them.
We also had a 27-page homebrew class book for one player whose character links into a mechanical companion. Every time we tweaked a rule in the PDF, the Foundry copy drifted out of date. Now a script builds Foundry’s class abilities straight from the book text. Spending energy or resting in one body updates the other on its own. While rewriting those rules we caught a 2024 snag: marking his left-behind body “Incapacitated” broke concentration, so the dormant body needed its own state.
It helps with non-player characters as well. In a six-year campaign, one city holds a dozen recurring NPCs who know different pieces of the plot. With their dossiers and the archive beside it, Claude tracks what each NPC knows or hides. Inside Foundry’s web interface, it can also operate an NPC’s side of the board while I run the session.
Showing each player a different screen on the same map
Normally in Foundry, everyone stares at the same battle map and private moments go through chat whispers. Because modules run inside each friend’s browser, I built a small GM panel that changes one player’s screen without showing the other four.
I wouldn’t have spent two weekends coding browser effects for five friends by hand. With Claude Code, an afternoon idea goes live before anyone joins the call.

The one that hit hardest at the table was the gold machine-code view above. When that player links into his mechanical companion, a shader turns his battle map into glowing glyphs. A small monitor at the top tracks his dormant body breathing. On the first combat test, though, I had put the shader over the whole scene, which turned the monsters into gold code too. He could barely tell where the enemies stood until I moved the filter onto the background layer alone so tokens stayed solid on top.
The second one I use a lot is a private notebook tucked under another player’s portrait. His character has been losing memories of home, so the book holds entries written in his own ink. My GM panel has a hidden clarity slider for each one, and lowering it sends no alert. Words blur out in a fixed order and titles cut in half until only a short feeling stays on the page. If I drag a slider while he has the book open, the words dissolve while he reads.

The other three friends got their own screen pieces too. One has a painted hand with a glowing number on its palm that burns down in embers on one click. Another sees faint fate strands rising off tokens on the map, and the fifth has a flickering memory terminal. When these fired in a live session, the table noticed right away and liked them. Private moments moved out of the chat sidebar and onto the board itself.
Where the Foundry automation went too far
If you’ve read about tinkering with my homelab, you can guess what happened once a weird Foundry idea took twenty minutes.
Between Saturday morning and Sunday night our UI module went through 26 versions. I stopped prepping the next session and kept adding themed character sheets and custom dice trays. I spent part of Sunday tweaking a login page five friends see for three seconds. Whenever I replaced custom art, Cloudflare kept serving the old file for four hours unless I bumped the filename (-v1.webp). By Sunday night I had to stop and delete dead code and unused images I’d piled up in two days.
The other real risk had nothing to do with Foundry. Putting six years of DM secrets beside the players’ website creates an easy way to leak twists I’ve guarded since 2020.
What I’d recommend to another Foundry DM
A lot of what made Foundry feel better had nothing to do with shaders or custom books. Start with the boring fixes first:
- Hide Foundry’s unused clutter for players. Turning off twenty toolbars and sidebar tabs they rarely touch, and giving each person one corner plate with their portrait and hit points plus a click to their sheet, sped up combat more than any animation.
- Separate canon from player notes before letting an agent read your wiki. Player notes record lies villains told three years ago, so tag confirmed canon, player rumor, and DM secrets apart.
- Put a mirror toggle on your GM panel. Once five browsers show different screens, you’ll forget whose notebook faded or whose map has a shader on unless you can preview their exact view.
- Generate custom rules from one file. Typing a homebrew class into Foundry by hand guarantees it drifts away from your PDF within three sessions.

The harder line is deciding what to keep away from the agent. Claude is great at remembering six years of favors and wiring Foundry scenes, and keeping an NPC’s dossier straight. I still wouldn’t let it write the main story turns or run conversations on autopilot. Running D&D with friends works because a human DM reads the room and improvises when players wreck the plan.
Prep takes a fraction of the time it used to. I no longer lose evenings hunting through folders for an old map or checking what an NPC promised years ago. When the next session starts, I’ll have the custom screens ready and the notes open beside me. Claude stays in the terminal until I need it.