How stacking works
When you request a prompt, wobble-bibble:- Loads the master prompt (
prompts/master_prompt.md) - Loads the requested addon (e.g.,
prompts/hadith.md) - Concatenates them with a newline separator
- Returns the combined text
The master prompt always comes first. This ensures base rules are loaded before specialized overrides.
Why stacking?
Islamic texts span multiple genres with different conventions:- Ḥadīth uses isnād chains with specific narrator name rules
- Fiqh uses technical legal terminology
- Tafsīr quotes Qurʾānic verses with special formatting
- Fatāwā uses Q&A structure with speaker labels
- Too large (exceeding token budgets)
- Full of conflicting rules
- Difficult to maintain
Stacking API
The library provides several ways to access stacked prompts:Get a specific stacked prompt
Get all prompts
Get just the text
Get only the master
Rule precedence
When master and addon rules conflict, the addon typically wins because:- LLMs read prompts sequentially
- Later instructions often override earlier ones
- Addons are more specific than the master
Hard constraints (cannot override)
These master rules apply to all prompts, regardless of addon:- Script lock: No Arabic script except ﷺ
- ID integrity: Never invent or duplicate segment IDs
- No inference: Don’t guess missing text
- Plain text: No Markdown formatting
Soft constraints (can extend)
These master rules can be specialized by addons:- Transliteration style: Addons can define genre-specific name handling
- Term definitions: Addons can require specific
translit (English)patterns - Structure: Addons can add formatting rules (Q&A labels, verse brackets)
Example: Encyclopedia mixed
Theencyclopedia_mixed addon demonstrates advanced stacking. It handles texts that switch between multiple genres (ḥadīth, fiqh, tafsīr) within a single work.
- Extends the master’s transliteration rules
- Adds state-based logic for switching between modes
- Defines priority when rules conflict
The
encyclopedia_mixed addon explicitly states “Priority: Isnad > Rijal > Fiqh” to resolve ambiguity when technical terms overlap between genres.Conflict resolution patterns
Explicit override
Addons can explicitly override master rules:Final sweep override
Some addons add a “final sweep” that runs after all other rules:Disambiguation
Addons can disambiguate terms that mean different things in different contexts:Token budget management
Prompt tokens are a constrained resource. Wobble-bibble’s stacking design minimizes waste:Master prompt principles
- Lean rule blocks (no redundant wording)
- High-signal constraints only
- No duplicate rules across master/addons
Addon principles
- Only add rules justified by failure evidence
- Replace/tighten existing master rules rather than append
- Avoid duplicate constraints unless closing a proven escape hatch
Stacking in practice
Here’s what happens when you callgetPrompt('fiqh'):
- Checks if the prompt is the master
- If yes, returns master content only
- If no, stacks master + fiqh addon
- Wraps in a
StackedPromptobject
Generated prompt structure
The final stacked prompt looks like:Prompt generation workflow
Prompts are bundled at build time:- Developer writes prompt files as Markdown in
prompts/ - Developer runs
bun run generate(part ofnpm run build) - Script reads all
.mdfiles fromprompts/ - Generates TypeScript definitions in
.generated/prompts.ts - Main code imports from
@generated/promptsvia path alias
The
.generated/ directory is git-ignored. This keeps the source tree clean and separates content from code.Custom stacking
You can create custom prompt combinations:- Testing new rules
- One-off translation needs
- Extending prompts without modifying the library
Debugging stacked prompts
To see exactly what the LLM receives:- Rule conflicts
- Missing constraints
- Token budget issues
Next steps
Prompts
Learn about master and addon prompts
Validation
Understand validation error types