# RPG Forge > RPG Forge (https://rpgforge.ai) makes text RPGs that play in a browser. An AI narrates; the author > decides what the world contains and how its rules work. These docs are for writing those > rules: the sandboxed `$` expression API, rule bodies, hooks, quests and plugins. Games are built in the editor at https://rpgforge.ai/create, by prompting its AI or by editing entities directly. Every page below is also a web page at the same URL without `.md`; `.json` gives the rendered HTML plus the nav. The full text of every page here, in one file: https://rpgforge.ai/llms-full.txt ## Editing games from an agent (MCP) - Endpoint: `https://rpgforge.ai/api/mcp`, MCP over Streamable HTTP, `Authorization: Bearer `. - The author creates a token at https://rpgforge.ai/profile/edit, which also shows the `claude mcp add` command. - It offers the same world tools as the in-app agent, and its own instructions say where to start. - Edits land on the working copy at once. Players see them only after a publish, and an agent publishes only when the author asks. ## Before writing a rule - Read `expressions.md` and `rule-bodies.md` first, and `common-mistakes.md`: a wrong rule raises no error, it simply never fires. - A rule body is steps and `if`s. Plain JavaScript (variables, loops) works, but inside code only a short list of verbs exists, so a `$.veto` below a `var` line cannot run - `rule-bodies.md`. - A missing field reads `null`, and `null` fails every comparison, `<` included. A missing stat reads `0` - `missing-values.md`. - Stats are read by role: `$.stat('might')` works whatever the game calls it. A display name (`$.stat('brawn')`) breaks when the stat is renamed - `reading-values.md`. ## Building a game - [How a game plays](https://rpgforge.ai/docs/how-it-plays.md): What the player gets at the table - turns, combat, multiplayer - and what the engine does not do. - [Translations](https://rpgforge.ai/docs/translations.md): Your game's text in other languages, for players who read the site in them. - [Skills](https://rpgforge.ai/docs/skills.md): Trained competence characters hold in ranks (0-10): checks, weapon/ability scaling, and practice. - [Damage types](https://rpgforge.ai/docs/damage-types.md): Kinds of harm (Fire, Poison) that weapons, creatures and damage steps deal, and effects resist. ## Expressions - [Expressions](https://rpgforge.ai/docs/expressions.md): The $ object, and how a rule reads the world before it decides anything. - [Reading values](https://rpgforge.ai/docs/reading-values.md): Paths and readers that give you a number or a name: $.subject, $.stat(), $.field(). - [Asking questions](https://rpgforge.ai/docs/questions.md): The true/false half of the API: $.hasItem, $.alive, $.hasPlugin and friends. - [Missing values](https://rpgforge.ai/docs/missing-values.md): Why a rule silently never fires. Null loses every comparison, including <. - [Minutes are not time](https://rpgforge.ai/docs/minutes-are-not-time.md): Why pricing a rule off $.event.minutes can make a wordy turn seven times costlier. ## Writing rules - [Steps](https://rpgforge.ai/docs/steps.md): Reads are expressions; writes are steps. The verbs that change the world. - [Rule bodies](https://rpgforge.ai/docs/rule-bodies.md): A rule body is steps and ifs, with plain JavaScript where you need it. - [Hooks](https://rpgforge.ai/docs/hooks.md): The moments a rule can attach to, and what each one carries. - [Conditions](https://rpgforge.ai/docs/conditions.md): The gate shared by items, abilities, hooks, world events and quests. - [Quests](https://rpgforge.ai/docs/quests.md): Multi-stage objectives, mixing hard gates with model judgment. ## Plugins - [Plugins](https://rpgforge.ai/docs/plugins.md): Bundle fields, hooks and dials into a system you can switch off, share and reuse. - [Designing a plugin](https://rpgforge.ai/docs/good-plugin.md): How to make a system that's fun to play, not just one that saves without errors. - [Fields](https://rpgforge.ai/docs/fields.md): Declaring values on things: ranges, tiers, and the prose the narrator reads. - [Cooperation](https://rpgforge.ai/docs/plugin-cooperation.md): How plugins work together without depending on each other. - [Formulas and dials](https://rpgforge.ai/docs/formulas.md): Tuning numbers, the engine's own editable formulas, and why never to freeze one. - [Seams](https://rpgforge.ai/docs/seams.md): The one thing a plugin can replace rather than add to. - [Generators](https://rpgforge.ai/docs/generators.md): A plugin tool that makes new places, creatures and things while people are playing. - [What you can't build](https://rpgforge.ai/docs/limits.md): The edges of the rules system, and what to do when your idea is past one. ## Reference - [Vendor stock and money](https://rpgforge.ai/docs/vendor-stock.md): How a vendor's stock, till and pockets work, and what each one refuses. - [Vendor services](https://rpgforge.ai/docs/vendor-services.md): Work a vendor does for a price, written as steps. Who each step lands on, and what it can reach. - [Common mistakes](https://rpgforge.ai/docs/common-mistakes.md): The mistakes that produce no error at all, in one place. ## Optional Using the editor, for helping a person build a game without code: - [Your first game](https://rpgforge.ai/docs/first-game.md): From an empty editor to something playable, in about ten minutes and no code. - [Making it good](https://rpgforge.ai/docs/good-game.md): What separates a game people finish from a pile of valid locations. - [The editor](https://rpgforge.ai/docs/editor.md): The steps down the side of /create, what each is for, and why some disappear. - [The Prompt panel](https://rpgforge.ai/docs/prompt-panel.md): Plans, undo, and how to ask for what you actually want. - [Story and world events](https://rpgforge.ai/docs/story.md): The opening, the narrator's voice, world quests, and events that fire on their own. - [Locations and the map](https://rpgforge.ai/docs/locations.md): Places, how they connect, and what makes one feel different from the next. - [The map](https://rpgforge.ai/docs/map.md): Connecting locations, maps inside places, map tabs, travel distance and painted backdrop art. - [Characters and NPCs](https://rpgforge.ai/docs/characters.md): The tabs behind an NPC: memories, schedules, speech, quests and shops. - [Factions](https://rpgforge.ai/docs/factions.md): Groups that want things, and how they feel about each other, written in plain words. - [Lore](https://rpgforge.ai/docs/lore.md): Background the narrator looks up when a scene needs it, so you can write as much as you like. - [Items and creatures](https://rpgforge.ai/docs/items-creatures.md): Things to carry, things to fight, effects, abilities, and loot. - [Quests without code](https://rpgforge.ai/docs/quests-no-code.md): Multi-stage objectives built in the editor, judged by the story or by hard conditions. - [World systems](https://rpgforge.ai/docs/world-systems.md): The Setup toggles that decide which systems your game has. - [Shops and loadouts](https://rpgforge.ai/docs/shops.md): What players start with, and what they can buy. - [Assets and packs](https://rpgforge.ai/docs/assets.md): Take characters, items, plugins and packs other authors share, or share your own. - [Sound and images](https://rpgforge.ai/docs/sounds.md): Ambience, sound effects, voices, and the art generated for each entity. - [Working together](https://rpgforge.ai/docs/collaborating.md): Co-authors, shared notes, and undoing any one edit from the history. - [Publishing and sharing](https://rpgforge.ai/docs/publishing.md): Validation, publishing, remixes, and playing with other people.