Agent skill

Dspy Bootstrap Fewshot

by OmidZamani in OmidZamani/dspy-skills

A skill your agent uses for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.

MITAuto-check passedAI & LLM Engineering

Install Dspy Bootstrap Fewshot

skills CLI
$ npx skills add OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install OmidZamani/dspy-skills dspy-bootstrap-fewshot --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/OmidZamani/dspy-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/dspy-bootstrap-fewshot .claude/skills/dspy-bootstrap-fewshot && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
dspy-bootstrap-fewshot
GitHub stars
123
Token cost
~1.3k tokens
SKILL.md length
228 words
Files
2
Skills in repo
17
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.

  • Works in 4 steps: Setup → Define Program and Metric → Compile → …
  • BootstrapFewShot
  • SKILL.md covers Goal, When to Use, Related Skills and Inputs, plus 6 more sections
  • Runs Python scripts from its folder

What it does

Dspy Bootstrap Fewshot is an agent skill from OmidZamani/dspy-skills. Use for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `example.py`).

It sits in AI & LLM Engineering, covering Prompt engineering. The repository describes itself as: Collection of Claude Skills for DSPy framework - program language models, optimize prompts, and build RAG pipelines systematically. The licence is MIT.

When your agent uses it

  • BootstrapFewShot
  • Bootstrapped demonstrations
  • Teacher-model demos
  • Low-data DSPy prompt optimization

Example prompts

  • “/dspy-bootstrap-fewshot”

Requirements

  • Python 3
  • Pre-approved tools (allowed-tools): Read, Write, Glob, Grep

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Setup
  2. Define Program and Metric
  3. Compile
  4. Use and Save

What it can do on your machine

Read from SKILL.md and the folder at commit f5db3b7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • dspy.ai
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Dspy Bootstrap Fewshot loads about 1.3k tokens when it runs. Until then it costs about 34 tokens; SKILL.md has 228 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~34
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from OmidZamani/dspy-skills at commit f5db3b7, republished under its MIT licence (© OmidZamani). 228 words, ~1,279 tokens.

Download SKILL.mdSave it as .claude/skills/dspy-bootstrap-fewshot/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
dspy-bootstrap-fewshot
description
Use for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.
allowed-tools
Read, Write, Glob, Grep
version
1.0.0
dspy-compatibility
3.2.1
tags
optimizer

DSPy Bootstrap Few-Shot Optimizer

Goal

Automatically generate and select optimal few-shot demonstrations for your DSPy program using a teacher model.

When to Use

  • You have 10-50 labeled examples
  • Manual example selection is tedious or suboptimal
  • You want demonstrations with reasoning traces
  • Quick optimization without extensive compute

Inputs

InputTypeDescription
programdspy.ModuleYour DSPy program to optimize
trainsetlist[dspy.Example]Training examples
metriccallableEvaluation function
metric_thresholdfloatNumerical threshold for accepting demos (optional)
max_bootstrapped_demosintMax teacher-generated demos (default: 4)
max_labeled_demosintMax direct labeled demos (default: 16)
max_roundsintMax bootstrapping attempts per example (default: 1)
teacher_settingsdictConfiguration for teacher model (optional)

Outputs

OutputTypeDescription
compiled_programdspy.ModuleOptimized program with demos

Workflow

Phase 1: Setup
python
import dspy
from dspy.teleprompt import BootstrapFewShot

# Configure LMs
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
Phase 2: Define Program and Metric
python
class QA(dspy.Module):
    def __init__(self):
        self.generate = dspy.ChainOfThought("question -> answer")
    
    def forward(self, question):
        return self.generate(question=question)

def validate_answer(example, pred, trace=None):
    return example.answer.lower() in pred.answer.lower()
Phase 3: Compile
python
optimizer = BootstrapFewShot(
    metric=validate_answer,
    max_bootstrapped_demos=4,
    max_labeled_demos=4,
    teacher_settings={'lm': dspy.LM("openai/gpt-4o")}
)

compiled_qa = optimizer.compile(QA(), trainset=trainset)
Phase 4: Use and Save
python
# Use optimized program
result = compiled_qa(question="What is photosynthesis?")

# Save for production (state-only, recommended)
compiled_qa.save("qa_optimized.json", save_program=False)

Production Example

python
import dspy
from dspy.teleprompt import BootstrapFewShot
from dspy.evaluate import Evaluate
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class ProductionQA(dspy.Module):
    def __init__(self):
        self.cot = dspy.ChainOfThought("question -> answer")
    
    def forward(self, question: str):
        try:
            return self.cot(question=question)
        except Exception as e:
            logger.error(f"Generation failed: {e}")
            return dspy.Prediction(answer="Unable to answer")

def robust_metric(example, pred, trace=None):
    if not pred.answer or pred.answer == "Unable to answer":
        return 0.0
    return float(example.answer.lower() in pred.answer.lower())

def optimize_with_bootstrap(trainset, devset):
    """Full optimization pipeline with validation."""
    
    # Baseline
    baseline = ProductionQA()
    evaluator = Evaluate(devset=devset, metric=robust_metric, num_threads=4)
    baseline_score = evaluator(baseline)
    logger.info(f"Baseline: {baseline_score:.2%}")
    
    # Optimize
    optimizer = BootstrapFewShot(
        metric=robust_metric,
        max_bootstrapped_demos=4,
        max_labeled_demos=4
    )
    
    compiled = optimizer.compile(baseline, trainset=trainset)
    optimized_score = evaluator(compiled)
    logger.info(f"Optimized: {optimized_score:.2%}")
    
    if optimized_score > baseline_score:
        compiled.save("production_qa.json", save_program=False)
        return compiled
    
    logger.warning("Optimization didn't improve; keeping baseline")
    return baseline

Best Practices

  1. Quality over quantity - 10 excellent examples beat 100 noisy ones
  2. Use stronger teacher - GPT-4 as teacher for GPT-3.5 student
  3. Validate with held-out set - Always test on unseen data
  4. Start with 4 demos - More isn't always better

Limitations

  • Requires labeled training data
  • Teacher model costs can add up
  • May not generalize to very different inputs
  • Limited exploration compared to MIPROv2

Official Documentation

© OmidZamani, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/dspy-bootstrap-fewshot of OmidZamani/dspy-skills.

  • SKILL.md
  • example.py

Open the folder on GitHubat commit f5db3b7

Compare with similar skills

Dspy Bootstrap Fewshot next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Dspy Bootstrap Fewshot compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Dspy Bootstrap Fewshot this skillOmidZamani/dspy-skills123—~1.3kAutomated safety check: PassMIT
Agent Prompt Quality Barmastra-ai/mastra29k—~2kAutomated safety check: PassCustom licence
Prompt Engineer Toolkitborghei/Claude-Skills891—~1.6kAutomated safety check: PassMIT
Prompt LabMathews-Tom/armory329—~2.1kAutomated safety check: PassMIT
Metacognitive Prompt LibraryGarethManning/education-agent-skills840—~4.3kAutomated safety check: PassCustom licence
Hospital Margin Forensicshh-health-AI/healthcare-equity101—~837Automated safety check: PassMIT

Similar skills

  • Agent Prompt Quality Bar

    mastra-ai/mastra

    Universal quality bar and final audit rubric for any agent system prompt.

    29k GitHub stars~2k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Prompt Engineer Toolkit

    borghei/Claude-Skills

    Prompt engineering frameworks for building, testing, versioning, and evaluating prompts: chain-of-thought, few-shot, regression testing, and rubrics.

    891 GitHub stars~1.6k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • Prompt Lab

    Mathews-Tom/armory

    LLM prompt engineering: analyzes failure modes, generates variants (direct, few-shot, CoT), designs rubrics, produces test suites.

    329 GitHub stars~2.1k tokensUpdated 5 days ago
    AI & LLM EngineeringAuto-check passed
  • Metacognitive Prompt Library

    GarethManning/education-agent-skills

    Build a library of metacognitive prompts targeting planning, monitoring, or evaluation for a specific task.

    840 GitHub stars~4.3k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed
  • Hospital Margin Forensics

    hh-health-AI/healthcare-equity

    This skill should be used when the user asks about "hospital margins", "cost reports", "HCRIS", "payer mix", "occupancy", "uncompensated care", "hospital capex capacity", "will hospitals buy", or…

    101 GitHub stars~837 tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed
  • Prompt Improver

    severity1/claude-code-prompt-improver

    This skill enriches vague prompts with targeted research and clarification before execution.

    1.9k GitHub starsUsed in 1 repo~1.7k tokens
    AI & LLM EngineeringAuto-check passed

More from OmidZamani/dspy-skills

All 17 skills in this repo
  • Skill Perfection

    OmidZamani/dspy-skills

    A skill your agent uses when you need to QA audit and fix a plugin skill file.

    123 GitHub stars~1.6k tokensUpdated 3 mo ago
    Auto-check passed
  • Dspy Haystack Integration

    OmidZamani/dspy-skills

    A skill your agent uses for integrating DSPy with Haystack, optimizing Haystack prompts, improving retrieval pipelines, and extracting DSPy prompts.

    123 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed
  • Dspy Adapters Multimodal

    OmidZamani/dspy-skills

    A skill your agent uses for DSPy adapter selection, JSONAdapter, XMLAdapter, ChatAdapter, native function calling, structured outputs, and multimodal inputs like dspy.Image or dspy.Audio.

    123 GitHub stars~864 tokensUpdated 3 mo ago
    Auto-check passed
  • Dspy Advanced Module Composition

    OmidZamani/dspy-skills

    A skill your agent uses for composing DSPy modules with Ensemble, MultiChainComparison, ensemble voting, sequential pipelines, and multi-program workflows.

    123 GitHub stars~2.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Dspy Better Together

    OmidZamani/dspy-skills

    A skill your agent uses for BetterTogether, prompt plus weight optimization, fine-tuning sequences, and strategy chains like p - w - p.

    123 GitHub stars~756 tokensUpdated 3 mo ago
    Auto-check passed
  • Dspy Custom Module Design

    OmidZamani/dspy-skills

    A skill your agent uses for creating custom DSPy modules, extending dspy.Module, reusable components, stateful modules, serialization, and module testing.

    123 GitHub stars~1.9k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Dspy Bootstrap Fewshot

What does Dspy Bootstrap Fewshot do?

A skill your agent uses for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization. Dspy Bootstrap Fewshot is an agent skill from OmidZamani/dspy-skills. Use for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.

When should I use Dspy Bootstrap Fewshot?

Dspy Bootstrap Fewshot fits situations like: bootstrapFewShot; bootstrapped demonstrations; teacher-model demos; low-data DSPy prompt optimization.

How do I install Dspy Bootstrap Fewshot in Claude Code?

Run `npx skills add OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot -a claude-code`. Or copy the skill folder (skills/dspy-bootstrap-fewshot in OmidZamani/dspy-skills) into .claude/skills/dspy-bootstrap-fewshot in your project. Claude Code loads it when a task matches its description.

How do I install Dspy Bootstrap Fewshot in Codex?

Run `npx skills add OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot -a codex`. Or copy the skill folder (skills/dspy-bootstrap-fewshot in OmidZamani/dspy-skills) into .agents/skills/dspy-bootstrap-fewshot in your project. Codex loads it when a task matches its description.

Can I use Dspy Bootstrap Fewshot in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/dspy-bootstrap-fewshot, .gemini/skills/dspy-bootstrap-fewshot, .github/skills/dspy-bootstrap-fewshot and .opencode/skills/dspy-bootstrap-fewshot in your project.

What does Dspy Bootstrap Fewshot need to run?

Going by SKILL.md and its folder, Dspy Bootstrap Fewshot needs Python for the scripts in its folder. Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Glob, Grep.

Does Dspy Bootstrap Fewshot access the network?

SKILL.md names 2 domains. As links in the text: dspy.ai and github.com. This is read from the text; nothing was executed.

Is Dspy Bootstrap Fewshot safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Dspy Bootstrap Fewshot use?

Dspy Bootstrap Fewshot is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Dspy Bootstrap Fewshot use?

About 1.3k tokens (SKILL.md is roughly 5.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Dspy Bootstrap Fewshot?

Skills that share tags, products or a category with Dspy Bootstrap Fewshot: Agent Prompt Quality Bar (mastra-ai/mastra, 29k stars), Prompt Engineer Toolkit (borghei/Claude-Skills, 891 stars), Prompt Lab (Mathews-Tom/armory, 329 stars) and Metacognitive Prompt Library (GarethManning/education-agent-skills, 840 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Dspy Bootstrap Fewshot?

OmidZamani (a GitHub user) maintains it in OmidZamani/dspy-skills, which has 123 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on June 23, 2026.

Source: OmidZamani/dspy-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.