$ sudo teach IT

Imagine you’re writing a letter — but not from scratch every time. You already have templates: a greeting, a wrap-up, phrases for refusal or thanks. You simply combine the needed blocks. That’s exactly how prompt components work — reusable fragments of requests to an LLM.

In this lesson, we’ll break down how to design modular prompts, reuse them across different tasks, update, test, and document them. This is especially important when prompts become part of a product or automation.

📘 What you’ll learn

  • What prompt components are and why to separate them
  • How to design reusable blocks
  • How to organize a prompt library in PromptHub or Obsidian
  • How to test and maintain prompts as the project grows

🧩 Key terms

  • Prompt component — a reusable fragment of a prompt (e.g., instruction, format, response style)
  • Modularity — a design principle where logic is split into independent parts
  • PromptHub — a tool or repository for storing and documenting prompts
  • Prompt Slotting — inserting specific parameters into a prompt template
  • Prompt Registry — a centralized database of all working prompts in a project

🧱 Why modularity is needed

When you’re just starting with LLMs, a prompt is just text. One file, one request. It works — for a while. But as soon as the number of tasks grows, prompts reach dozens, and versions hundreds, without modularity the project becomes unmanageable.

Suppose you’re working on a product that uses LLMs for different purposes: email generation, translations, dialogue summaries, customer Q&A, short instructions, phrasing in different languages and tones. If each prompt is written as a single monolithic text, any change (for example, updating the output format) has to be made manually everywhere. It’s slow, risky, and leads to bugs.

📎 Analogy 1: Code without functions

Imagine writing a program without functions — all logic in one long block. Does it work? Yes. But if you need to change behavior in one place, it’s easy to break another. And reuse is impossible. Same with prompts.

📎 Analogy 2: Copy-paste without templates

It’s like creating documents in Word and rewriting the header, signature, and opening text every time. Any mistake in one place can repeat in ten. If you updated the logo or style, you must remember where you used it.

📎 Analogy 3: A kitchen without prep

If you chop onions from scratch every time, you waste time. In a professional kitchen there’s pre-cutting, sauces, and semi-finished bases — they keep flavor, speed up cooking, and reduce errors. Modular prompts are like prepared ingredients.

Modularity in prompts solves several tasks at once:

  • 🔹 Flexibility: you can change the instruction or output format without touching the rest of the prompt.
  • 🔹 Reusability: the same component can be used for email generation, reviews, instructions.
  • 🔹 Maintenance and scaling: easier to make changes, add versions, and track behavior.
  • 🔹 Separation of concerns: some work on instructions, others on output templates, others on logic.

What modularity gives in practice:

  • You extract instructions separately: “You are an HR assistant,” “Answer briefly and friendly.”
  • You describe the output format as a template: JSON, Markdown, table.
  • You create slots for variables: {{topic}}, {{language}}, {{tone}}.
  • You build a component library: like in UI, where each block can assemble a new interface.

📎 Analogy 4: Lego prompts

Modular prompts are like a Lego set. From the same blocks you can assemble a castle, a rocket, or a bridge. Depending on the task, you just compose them differently without recreating everything.

🧩 How to design prompt components

When you create dozens (or hundreds) of prompts, it becomes clear: many consist of repeating elements. That’s a great reason to move from hand-assembly to a component-based approach.

🧠 What is a prompt component

A prompt component is an autonomous block within a prompt: instruction, context, output structure, or style that can be reused across scenarios.

Instead of one long text, build the prompt like a constructor: combine role, instruction, format, and variables. This lets you quickly adapt the prompt to different tasks without rewriting from scratch.

📎 Analogy: Like in design — don’t draw a button from scratch every time. Use a ready Button component where you can pass text and style.

🧱 Examples of components

Prompt components come in different types:

  • 🎓 Role: e.g., “You are a recruiter at an IT company”
  • 📋 Instruction: “Answer step by step” or “Give a brief conclusion”
  • 📊 Structure: “Format the response as a Markdown table”
  • 🗣️ Tone: “Formal yet friendly”
  • 🔧 Template: “Question: {{question}}\nAnswer:”

📎 Analogy: You don’t rebuild a house from scratch each time. You take a standard block — say, a bathroom or kitchen — and reuse it, changing finishes as needed.

🔁 How to use in practice

The same component can be used for:

  • email generation,
  • chatbots,
  • email templates,
  • AI assistants,
  • data-processing systems.

If you need to switch the style from “friendly” to “official,” you change one component. If you need the output not as a list but as a table — you replace only the structure.

📎 It’s like changing one CSS block in a web project to instantly update all cards on the site.

🛠 Where to store and how to test

Store components in Markdown files, templating systems (e.g., Handlebars or Mustache), or tools like PromptHub. This way you can:

  • see where each component is used;
  • update it in one place;
  • run A/B tests on individual blocks;
  • quickly scale prompts for new tasks.

📎 Analogy: like having a Figma component library — you don’t redraw each element, you use standard blocks that can be updated globally.

🔄 How to reuse and scale

When you create dozens of prompts, it’s easy to slip into copy-paste. The same text again and again: “You are an expert, answer the question…”, “Format as a table…”, “Keep the style…”. Each time a bit different. That’s not only tedious but risky: any change must be applied manually in many places.

Instead, create a flexible template once — and just substitute the needed values.

🧱 Prompt as a template

Instead of hard-coding text, write:

You are acting as {{role}}.
Answer the question: {{question}}
Return the answer as {{format}}

Now you can use this template in any interface: substitute values via API, UI form, Google Sheets, even manually — and get dozens of variations for different tasks.

📎 Analogy: like an email template — “Hello, {{name}}! Your order {{order_number}} is ready.” You don’t write it from scratch each time; you just fill the variables.

🔁 Where this works best

Parametric templates work especially well when logic stays while context changes.

For example, in chatbots you may have the same instruction (“answer briefly”), but different roles — a psychologist, marketer, consultant. Or you generate articles on various topics, but each article shares the same structure: introduction, points, conclusion.

📎 Analogy: like one presentation layout where different data is inserted but the design and structure remain the same.

⚙️ How to apply in practice

If you’re working via API, substitute parameters programmatically. In a UI — with a form or configurator. For local work, use templating engines (Handlebars, Mustache, Jinja).

This makes your work faster and much easier to maintain. You don’t need to fear “breaking” something in ten prompts — just update the template in one place.

🗃 Organizing prompts

As the number of prompts grows, it’s important not only to write them well but also to organize them properly. A mess of files, tabs, and drafts quickly becomes a barrier — hard to find the right version, hard to update, hard to test.

To avoid this, there are dedicated prompt management tools. Their goal is to help you store, version, reuse, and test prompts as full-fledged project components.

📎 Analogy: it’s like an IDE for prompts. Instead of glued-together notes, a structured library where each prompt lives as a separate file with parameters, history, and purpose.

👉 Among such tools are PromptHub, PromptLayer, Flowise, Obsidian with plugins, and even Git repositories set up as prompt systems.

They all share one idea: automate routine and simplify maintenance. You can group prompts by projects, track versions, monitor usage metrics, and quickly change templates without copy-paste.

🔹 PromptHub: a prompt library as a product

When you work with many prompts — for different tasks, roles, interfaces — you’ll want order: where is which prompt? when was it updated? what’s already tested? It’s convenient to use PromptHub — not necessarily a product by that name, but a design-system style approach to organizing prompts.

🧱 What PromptHub is in practice

PromptHub is a centralized repository where each prompt is structured as a module with metadata. It can be:

  • 📁 A Git repo where each prompt is a .json or .yaml file with parameters and template
  • 📓 A document in Obsidian or Notion with a name, description, and examples
  • 🧩 A visual environment (Flowise, Dust, Langflow) where prompts are blocks connected like in no-code tools

Inside each prompt you might store:

  • Name and short description — to understand its purpose
  • Version and modification date — to track evolution
  • Task type — e.g., email generation, data analysis, translation
  • Examples of input and output
  • Labels like draft, tested, prod — akin to development statuses

📎 Analogy: think of a Figma design system where each component has a name (“Primary Button”), variations (small, large), documentation, and change history. PromptHub works the same — only for prompts.

⚙️ Why it’s convenient

Without PromptHub you risk “copy-paste prompting”: each time you grab a template from memory or an old file, manually tweak it for a new case — and it’s easy to make mistakes. With PromptHub you:

  • reuse templates without duplication;
  • quickly update all linked components;
  • document behavior and explain to teammates how to use the prompt;
  • review versions — what changed, when, and why.

📎 Analogy: like replacing a bunch of separate PowerPoint files with one Figma project with master components: everything in one place, consistent, and scalable.

💡 Tips for creating your PromptHub

  • Start with a simple structure: one folder per prompt plus a README
  • Keep change history and mark which versions are stable
  • Use descriptive names, like generate_product_card_v2
  • Add input/output examples to clarify usage
  • Use tags or statuses: draft, needs_review, ready

PromptHub is a step toward mature LLM work: you move from improvisation to prompt engineering, where each block is clear, tested, and can be embedded into a larger pipeline.

🔹 Obsidian: a personal knowledge base for prompts

If you work solo or in a small group, there’s no need to spin up a system based on Git or visual editors right away. Sometimes it’s more effective to use familiar note-taking tools, such as Obsidian — a powerful Markdown editor for building linked knowledge graphs.

For prompt engineering, Obsidian becomes your personal PromptHub, where each note is:

  • 💬 a separate prompt or part of it (instruction, template, context),
  • 🔗 linked to other prompts by topics or tasks,
  • 🧪 containing test cases and input-output examples,
  • 📌 documenting where and how the prompt was applied.

🧠 How it works

Create a Prompts folder and start filling it with notes. In each note:

  • A clear title: translate_friendly_b2c_ru_to_en.md
  • A block describing the task and the prompt’s goal
  • The Markdown code of the prompt itself
  • A section with parameters ({{input}}, {{tone}}, {{format}})
  • Examples: input / output
  • Links to related prompts, scenarios, or documentation

Thanks to bidirectional links, you can connect prompts to each other: for example, an email scenario prompt is linked with a CTA template, a “friendly yet formal” tone, and a “email structure” component.

📎 Analogy: like Zettelkasten — a system of atomic notes, each addressing a specific question or subtask. Instead of chaos, you get a structured knowledge network you can expand, refine, and reuse.

🔍 Why it’s convenient

  • Everything is stored locally in plain Markdown — easy to version or export.
  • You can add plugins: for rendering blocks, inserting JSON, tables, diagrams.
  • Works offline, fast and handy — especially for technical tasks.

💡 Tips

  • Make each note atomic — one prompt, one task.
  • Use tags to organize by topics, roles, formats (#translation, #b2c, #csv_output)
  • Attach test cases: what was input, what the model returned, what to fix.
  • Introduce indexing: e.g., 01_translation, 02_summary, to find things easily.

📎 Analogy: like a personal card catalog — you don’t just collect good solutions, you document their evolution, scope, and outcomes. Updated a prompt? Just edit the note. New task appeared? See if you can compose it from existing components.

🧪 Testing and updating prompts: like code

Working with LLMs isn’t set-and-forget. Even if a prompt works great today, behavior can change tomorrow: a new model version, temperature settings, or a slightly more complex scenario. That’s why testing and maintaining prompts is as essential as unit tests in programming.

🧬 Why it matters

Large language models aren’t deterministic. The same task can yield different results with minimal phrasing changes. Without a verification system, you risk unstable behavior in production.

📎 Analogy: Imagine a library whose behavior can change if you rephrase a function name. You need checks. You wouldn’t ship code without tests, right? Same with prompts.

🧩 How to set up prompt testing

Ideally, every prompt is accompanied by tests. This can be a CSV, YAML, or JSON with examples:

  • input (input)
  • variables (context, role)
  • expected result (expected_output)

Example:

prompt_id: product_summary_v2
tests:
  - input: "iPhone 15: powerful processor, new camera"
    expected_output: "Summary: iPhone 15 with a new chip and improved camera"

You can run these tests on the model manually or via an automated pipeline (e.g., in PromptLayer or your own CI).

🧠 How to track changes

If you use Git or PromptHub, prompt updates should go through pull request or review. This lets you:

  • compare old and new versions,
  • check whether cases broke,
  • discuss implications with the team.

If the model version changed — run old prompts through the new version, see which cases break. That helps identify fragile spots.

🛠 Tips for testing

  • Test edge cases: incomplete data, ambiguous wording, different languages.
  • Run tests on different model versions: e.g., GPT-4 and Claude 3.
  • Keep logs and outputs — helpful for regression (worked before, fails now).
  • Compare temperature and other parameters: sometimes instability is in generation, not the prompt.

📎 Analogy: like a CI/CD pipeline. You make a change — tests run, and you know for sure: it works or not. If a prompt breaks after a model update — you’ll learn from your logs, not from users.

🧠 Common mistakes

  • Everything in one prompt without block separation

    This quickly becomes unreadable and inflexible. Any change requires rewriting the entire prompt, and reuse is impossible.

  • No versioning: can’t tell what changed

    Without tracked changes, it’s hard to see which phrasing failed, hindering debugging and teamwork.

  • Results not reproducible (missing history)

    If you don’t save input, model parameters, and the output, you can’t reproduce a situation for analysis.

  • Reusing without justification: “why is this tone here?”

    Often a prompt is taken “by feel” from elsewhere without adapting to the current context, leading to extra instructions and unexpected style.

  • No tests: the model behaves unpredictably

    Without tests, you can’t be sure the prompt works as needed. Small changes can radically affect results.

❓FAQ

  • Can prompts be composed like code? Yes, with templating engines (e.g., Handlebars, Liquid) or JSON configurations.
  • How to decide what to extract into a component? If it repeats 2+ times across prompts — extract it.
  • How to version-control prompts? Use git or specialized tools like PromptLayer or DUST.

✅ Takeaways

In this lesson, you learned:

  • Why modularity is crucial in working with LLMs
  • How to create and use prompt components
  • How to organize a library in PromptHub or Obsidian
  • How to test and update prompts as your project grows

📌 In the next lesson — how to debug and profile reasoning prompts, run error analytics, and measure the quality of prompt interfaces.

На следующий урок