Skip to main content

Function Signature

function getPrompt(id: PromptId): StackedPrompt
Retrieves a specific prompt by its ID. For addon prompts, automatically stacks the master prompt with the specialized addon content. Returns the complete stacked prompt ready for use with an LLM.

Parameters

id
PromptId
required
The prompt ID to retrieve. Must be one of the available prompt IDs:
  • 'master_prompt' - Base prompt for all translations
  • 'encyclopedia_mixed' - For mixed-discipline scholarly works
  • 'fatawa' - For Islamic legal rulings and Q&A
  • 'fiqh' - For Islamic jurisprudence
  • 'hadith' - For hadith narrations
  • 'jarh_wa_tadil' - For narrator criticism and praise
  • 'tafsir' - For Quranic commentary
  • 'usul_al_fiqh' - For principles of Islamic jurisprudence

Returns

StackedPrompt
object
A stacked prompt object ready for LLM use
id
PromptId
Unique identifier matching the requested ID
name
string
Human-readable display name (e.g., “Hadith”, “Fiqh”)
content
string
The full prompt content. For master prompt, returns as-is. For addon prompts, returns master + addon stacked together.
isMaster
boolean
Whether this is the master prompt (not stacked). true only for 'master_prompt', false for all addons.

Example

import { getPrompt } from 'wobble-bibble';

// Get the hadith prompt (automatically stacked with master)
const hadithPrompt = getPrompt('hadith');

console.log(hadithPrompt);
// {
//   id: 'hadith',
//   name: 'Hadith',
//   content: '... [master prompt]\n... [hadith addon]',
//   isMaster: false
// }

// Use with an LLM
const response = await llm.chat({
  system: hadithPrompt.content,
  messages: [{
    role: 'user',
    content: 'P1: قال رسول الله صلى الله عليه وسلم...'
  }]
});

Errors

Throws an Error if the prompt ID is not found:
try {
  const prompt = getPrompt('invalid_id' as PromptId);
} catch (error) {
  console.error(error.message); // "Prompt not found: invalid_id"
}
The PromptId type is strongly typed based on available prompt files. TypeScript will provide autocomplete and catch invalid IDs at compile time.

Build docs developers (and LLMs) love