⚡0 XP🔥0

Capstone: Build Your Professional Prompt Library

Lesson 19 of 19 ⏱ 6 min read ✎ 2 exercises ❓ 3-question quiz ▶ Runs Python

Build a reusable, tested prompt library in Python - templates with metadata, validation, rendering, search, a quality checklist and export - and create 10 prompts for your own work.

The goal#

Professionals who use AI daily keep a prompt library - a collection of tested, reusable prompts for their most common tasks. In this capstone you will:

  1. Design a structure for library prompts (metadata + template + test inputs).
  2. Build a small Python prompt-library tool.
  3. Write and test 10 prompts for your own work or study.
हिंदी में समझें

इस capstone project में आप अपनी "prompt की लाइब्रेरी" बनाएंगे - यानी अपने रोज़ के कामों के लिए जाँचे-परखे, बार-बार इस्तेमाल होने वाले prompts का संग्रह।

जैसे एक अच्छे रसोइये के पास अपनी recipe book होती है - हर recipe जाँची हुई, साफ़ लिखी हुई, और कोई भी उसे follow कर सके - वैसे ही आपकी prompt library आपका और आपकी team का समय हर दिन बचाएगी।

Step 1: What a library prompt contains#

Field Example
name fee_reminder_sms
category office / teaching / coding / data / marketing
description Polite SMS reminding a student about a due fee
version 2
template Write a {tone} SMS under 160 characters reminding {name}...
output format Plain text, under 160 characters
test inputs 3-5 sets of realistic values, including an edge case
notes "v2: added 'no emojis' - v1 used too many"

Step 2: Build the tool#

Run this complete prompt library. Read it carefully - it uses classes, dictionaries, string formatting, validation and JSON from the Python course.

▶ Try it YourselfPython
Ctrl + Enter to run

The report shows which prompts are ready and what the others need - for example, explain_error needs a length limit, a format and test inputs.

Step 3: Improve a weak prompt#

Upgrade explain_error so it passes every check:

You are a patient Python trainer. Explain the error below to a beginner
in under 120 words, using this format:
1. What the error means (1-2 sentences)
2. Why it happened in this code
3. The corrected code
4. One tip to avoid it next time

<error>
{error}
</error>

<code>
{code}
</code>

Then add at least two test inputs (two different real errors), bump the version to 2, and re-run the report.

Step 4: Your 10 prompts#

Create library entries for your own work or study. Suggestions:

Category Prompt ideas
Office email reply, meeting minutes, report summary, notice in Hindi
Teaching lesson plan, quiz generator, worksheet levels, student feedback
Coding code review, explain code, write tests, debug error
Data Excel formula helper, SQL from schema, data cleaning plan
Marketing Instagram caption, course brochure section, WhatsApp broadcast
Career resume tailoring (truthful), interview practice, LinkedIn post

For each prompt:

  1. Write it using the R-C-T-C-O structure (Role, Context, Task, Constraints, Output).
  2. Use clear {placeholders}.
  3. Test it in an AI assistant with 3 different inputs.
  4. Fix problems, then save it with version, description and test inputs.

Step 5: Save and share#

Export your library to JSON so you can load it in other programs (or share it with your team):

with open("my_prompt_library.json", "w", encoding="utf-8") as f:
    f.write(lib.export_json())

Ideas to take this further:

  • Add a command-line menu: list, search, render, copy to clipboard.
  • Turn it into a small Flask web app your team can use.
  • Connect it to an AI API (previous lessons) so "render + send" happens in one step, and save the responses for review.

Course complete!#

You can now:

  • explain how LLMs work and why they make mistakes,
  • write clear, structured prompts with role, context, examples and formats,
  • use chain-of-thought, chaining and self-critique for complex work,
  • apply AI to coding, office work, data and teaching,
  • build system prompts, templates and API-powered automations,
  • use AI safely and responsibly.

Keep practising - the best prompt engineers are the ones who test, measure and refine every day.

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

The PromptTemplate class

Create class PromptTemplate(name, category, template, version=1) with:

  • placeholders() → sorted list of unique placeholder names (use string.Formatter)
  • render(**values) → filled prompt; raise ValueError("Missing: a, b") listing missing names (sorted, comma-separated) if any are missing
2

The PromptLibrary class

Create class PromptLibrary (use the PromptTemplate provided in the starter) with:

  • add(template) - store it by name
  • get(name) - return the template (raise KeyError if missing)
  • by_category(category) - sorted list of template names in that category
  • search(word) - sorted list of names whose name or template text contains word (case-insensitive)

Quick Quiz

Q1.

What makes a prompt "library-ready"?

Q2.

Why store metadata (category, version, description) with each template?

Q3.

What is the best way to improve a library prompt?