Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when implementing dialogue — data structures for branching dialogue, conditions, and UI presentation
.claude/skills/jame581-dialogue-system/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 31% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 38% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 26% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 120% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 51% | 0% |
All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.
> Related skills: resource-pattern for dialogue data as Resources, godot-ui for Control node layout, state-machine for dialogue flow management, save-load for dialogue state persistence, dialogue-manager for a full-featured dialogue addon, popochiu for adventure games.
┌─────────────────────────────────────────────────────────┐
│ UI Layer │
│ DialogueUI (Control) │
│ ├─ Label (speaker_name) │
│ ├─ TextureRect (portrait) │
│ ├─ RichTextLabel (dialogue_text, typewriter effect) │
│ └─ VBoxContainer (choice_container) │
│ └─ Button × N (choice buttons) │
│ │
│ Connects to: line_displayed, choice_presented signals │
└───────────────────────┬─────────────────────────────────┘
│ drives UI via signals
┌───────────────────────▼─────────────────────────────────┐
│ DialogueManager (Autoload / Node) │
│ start_dialogue(dialogue_data) │
│ advance() → next line or end │
│ choose(choice_index) │
│ current_line: DialogueLine (read-only) │
│ │
│ signals: dialogue_started │
│ line_displayed(line) │
│ choice_presented(choices) │
│ dialogue_ended │
└───────────────────────┬─────────────────────────────────┘
│ reads
┌───────────────────────▼─────────────────────────────────┐
│ Data Layer (Resources) │
│ DialogueData (Resource) │
│ lines: Dictionary ← id → DialogueLine │
│ start_line_id: String │
│ │
│ DialogueLine (Resource) │
│ speaker, text, choices, next_line_id, condition │
└─────────────────────────────────────────────────────────┘DialogueLine holds all data for a single beat of dialogue. Choices is an Array[Dictionary] so each entry can carry a text, next_line_id, and optional condition without a separate class.
gdscript# dialogue_line.gd class_name DialogueLine extends Resource ## Display name shown in the UI speaker box. @export var speaker: String = "" ## The body text. Supports BBCode and variable placeholders: {player_name}. @export_multiline var text: String = "" ## When non-empty, overrides next_line_id. Each Dictionary must have: ## "text" : String — label on the choice button ## "next_line_id": String — line to jump to when chosen ## "condition" : String — (optional) expression; omit or "" to always show @export var choices: Array = [] ## ID of the next DialogueLine. Ignored when choices is non-empty. @export var next_line_id: String = "" ## Optional condition expression evaluated before displaying this line. ## If the expression returns false the manager skips to next_line_id. ## Example: "GameState.has_item('key')" @export var condition: String = ""
csharp// DialogueLine.cs using Godot; using Godot.Collections; [GlobalClass] public partial class DialogueLine : Resource { /// <summary>Display name shown in the speaker box.</summary> [Export] public string Speaker { get; set; } = ""; /// <summary>Body text. Supports BBCode and {variable} placeholders.</summary> [Export(PropertyHint.MultilineText)] public string Text { get; set; } = ""; /// <summary> /// When non-empty, overrides NextLineId. Each Dictionary entry must contain: /// "text" : string — choice button label /// "next_line_id" : string — line to jump to /// "condition" : string — (optional) expression; omit or "" to always show /// </summary> [Export] public Array Choices { get; set; } = new(); /// <summary>ID of the next DialogueLine. Ignored when Choices is non-empty.</summary> [Export] public string NextLineId { get; set; } = ""; /// <summary> /// Optional condition expression. Evaluated before displaying this line. /// Example: "GameState.HasItem(\"key\")" /// </summary> [Export] public string Condition { get; set; } = ""; }
DialogueData is a container Resource that holds a dictionary of all lines, keyed by their string ID. Creating it as a .tres file lets you assign it to NPCs in the Inspector.
gdscript# dialogue_data.gd class_name DialogueData extends Resource ## Dictionary mapping line ID strings to DialogueLine resources. ## Example: { "intro": <DialogueLine>, "ask_quest": <DialogueLine> } @export var lines: Dictionary = {} ## ID of the first line to display when dialogue starts. @export var start_line_id: String = "" ## Convenience accessor — returns null for unknown IDs. func get_line(id: String) -> DialogueLine: return lines.get(id, null)
csharp// DialogueData.cs using Godot; using Godot.Collections; [GlobalClass] public partial class DialogueData : Resource { /// <summary>Maps line ID strings to DialogueLine resources.</summary> [Export] public Dictionary Lines { get; set; } = new(); /// <summary>ID of the first line to display when dialogue starts.</summary> [Export] public string StartLineId { get; set; } = ""; /// <summary>Returns the DialogueLine for id, or null if not found.</summary> public DialogueLine GetLine(string id) { if (Lines.ContainsKey(id)) return Lines[id].As<DialogueLine>(); return null; } }
> Populate lines in the Inspector by adding Dictionary entries with string keys and DialogueLine resource values, or load them programmatically from JSON (see section 7).
A singleton autoload owns the active DialogueData and tracks current line ID. start(data) sets the data and emits the first line; advance(choice_index) moves forward. Wires three signals: line_changed(line), choices_presented(choices), dialogue_ended().
> See references/dialogue-manager.md for the full GDScript and C# manager (line traversal, choice handling, condition evaluation hooks, signals).
Choices live on DialogueLine.choices (an Array of Dictionary). Each choice has text, next_line_id, optional condition. Conditions are GDScript expressions evaluated via the Expression class — passed a context object with project state (e.g. GameState).
> See references/branching-and-conditions.md for the full choice-handling and condition-evaluator implementations (GDScript + C#), plus security notes on Expression input.
A CanvasLayer with a RichTextLabel for the line body (BBCode-enabled), a Label for speaker name, and a VBoxContainer for choice buttons. Typewriter effect via RichTextLabel.visible_characters driven by a Tween. UI subscribes to DialogueManager signals.
> See references/ui-presentation.md for the scene-tree fragment, typewriter recipe, choice-button spawning, and full GDScript + C# wiring.
Load dialogue from JSON for designer-friendly editing — map JSON keys to DialogueLine properties at load time. Or integrate the Dialogic addon for a node-graph editor (community standard).
> See references/external-formats.md for the JSON loader recipe and Dialogic integration notes.
Dialogue text supports {player_name}-style placeholders. Resolve via a small templater: text.format(vars) (GDScript) or string.Format with named-tag preprocessing (C#).
> See references/variable-interpolation.md for the GDScript and C# interpolation helpers.
DialogueLine and DialogueData extend Resource and carry [GlobalClass] (C#) for Inspector integrationDialogueManager is registered as an Autoload so all scenes share a single instancestart_dialogue() asserts that dialogue_data is non-null before accessing itadvance() guards against being called when choices are pendingchoose() operates on the filtered visible-choices list, not the raw choices array_evaluate_condition() passes a known base instance (GameState) to Expression.execute() to resolve method callsvisible_characters, not frame-by-frame string slicing, for BBCode compatibilityui_accept mid-typewriter reveals full text; a second press advances the linequeue_free) before creating new ones — never accumulate stale children_interpolate() helper, not scattered across signal handlersnext_line_id = "" signals end-of-dialogue — no magic sentinel strings beyond the empty stringpush_error() messages include class name and method for easy log tracing| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 17,084 | 9,446 | -45% | 1 | 1 | 0% | 3,213 | 4,213 | +31% | 0 | 0 | — |
case-02 | fail→pass | 17,852 | 12,071 | -32% | 1 | 1 | 0% | 3,460 | 4,769 | +38% | 0 | 0 | — |
case-03 | fail→pass | 17,421 | 7,931 | -54% | 1 | 1 | 0% | 3,053 | 3,839 | +26% | 0 | 0 | — |
case-04 | pass→pass | 13,538 | 11,762 | -13% | 1 | 1 | 0% | 2,288 | 4,396 | +92% | 0 | 0 | — |
case-05 | pass→pass | 15,976 | 15,206 | -5% | 1 | 1 | 0% | 3,086 | 5,337 | +73% | 0 | 0 | — |
case-06 | pass→pass | 12,177 | 12,693 | +4% | 1 | 1 | 0% | 1,897 | 4,469 | +136% | 0 | 0 | — |
case-07 | pass→pass | 15,602 | 11,807 | -24% | 1 | 1 | 0% | 2,713 | 4,366 | +61% | 0 | 0 | — |
case-08 | pass→pass | 13,091 | 8,920 | -32% | 1 | 1 | 0% | 2,449 | 3,904 | +59% | 0 | 0 | — |
case-09 | pass→pass | 13,420 | 10,252 | -24% | 1 | 1 | 0% | 2,098 | 3,979 | +90% | 0 | 0 | — |
case-10 | fail→pass | 13,895 | 16,407 | +18% | 1 | 1 | 0% | 2,454 | 5,394 | +120% | 0 | 0 | — |
case-11 | pass→fail | 14,578 | 8,425 | -42% | 1 | 1 | 0% | 2,269 | 3,904 | +72% | 0 | 0 | — |
case-12 | pass→pass | 18,027 | 17,678 | -2% | 1 | 1 | 0% | 3,010 | 5,164 | +72% | 0 | 0 | — |
case-13 | pass→pass | 18,506 | 12,325 | -33% | 1 | 1 | 0% | 2,793 | 4,367 | +56% | 0 | 0 | — |
case-14 | pass→pass | 10,941 | 8,167 | -25% | 1 | 1 | 0% | 1,869 | 3,774 | +102% | 0 | 0 | — |
case-15 | pass→pass | 14,384 | 9,509 | -34% | 1 | 1 | 0% | 2,314 | 3,944 | +70% | 0 | 0 | — |
case-16 | fail→pass | 15,000 | 7,986 | -47% | 1 | 1 | 0% | 2,457 | 3,709 | +51% | 0 | 0 | — |
case-17 | pass→pass | 10,128 | 6,271 | -38% | 1 | 1 | 0% | 1,468 | 3,315 | +126% | 0 | 0 | — |
case-18 | pass→pass | 15,430 | 16,496 | +7% | 1 | 1 | 0% | 2,746 | 5,797 | +111% | 0 | 0 | — |
case-19 | pass→pass | 12,344 | 8,031 | -35% | 1 | 1 | 0% | 2,094 | 3,787 | +81% | 0 | 0 | — |
case-20 | fail→pass | 15,211 | 13,007 | -14% | 1 | 1 | 0% | 2,405 | 4,663 | +94% | 0 | 0 | — |
case-21 | pass→pass | 3,156 | 2,363 | -25% | 1 | 1 | 0% | 458 | 2,770 | +505% | 0 | 0 | — |
case-22 | pass→pass | 5,584 | 3,844 | -31% | 1 | 1 | 0% | 905 | 2,937 | +225% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +23 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.