skills/dspy-weave/SKILL.md
Use W&B Weave for DSPy experiment tracking and observability. Use when you want to set up Weave, W&B, wandb, Weights & Biases, experiment dashboard, weave.op, or team collaboration for DSPy. Also used for weave setup, pip install weave, weave.init, wandb project, W&B experiment tracking, weave decorator, weave.op decorator, wandb dashboard, compare optimization runs, team experiment tracking.
npx skillsauth add lebsral/dspy-programming-not-prompting-lms-skills dspy-weaveInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide the user through setting up W&B Weave for tracing DSPy calls, tracking optimization experiments, and collaborating with team dashboards.
Weave is Weights & Biases' LLM observability and experiment tracking product. It provides cloud-hosted dashboards for tracing function calls, comparing optimization runs, and sharing results across teams.
@weave.op() decorator (not auto-instrument like Langtrace)Weave uses a manual decorator (@weave.op()) — you choose which functions to trace. Langtrace and Phoenix auto-instrument all DSPy calls. This gives Weave more control over what gets tracked but requires more setup.
Use Weave when:
Do NOT use Weave when:
/dspy-langtrace/dspy-phoenix/dspy-mlflowpip install weave
import weave
weave.init("my-dspy-project") # Creates project at wandb.ai
# You'll be prompted to log in on first run
# Or set WANDB_API_KEY environment variable
export WANDB_API_KEY="your-key" # From wandb.ai/settings
export WANDB_ENTITY="your-team" # Optional: team name
export WANDB_PROJECT="my-dspy-project" # Optional: project name
The @weave.op() decorator traces a function's inputs, outputs, latency, and cost:
import weave
import dspy
weave.init("my-dspy-project")
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini")) # or "anthropic/claude-sonnet-4-5-20250929", etc.
class QABot(dspy.Module):
def __init__(self):
self.retrieve = dspy.Retrieve(k=3)
self.answer = dspy.ChainOfThought("context, question -> answer")
def forward(self, question):
context = self.retrieve(question).passages
return self.answer(context=context, question=question)
bot = QABot()
@weave.op()
def handle_question(question: str) -> str:
"""Traced by Weave — inputs, outputs, and latency logged."""
result = bot(question=question)
return result.answer
# Every call is tracked at wandb.ai
answer = handle_question("How do refunds work?")
Decorate each function you want to trace:
@weave.op()
def retrieve_context(question: str) -> list[str]:
return dspy.Retrieve(k=3)(question).passages
@weave.op()
def generate_answer(context: list[str], question: str) -> str:
cot = dspy.ChainOfThought("context, question -> answer")
return cot(context=context, question=question).answer
@weave.op()
def handle_question(question: str) -> str:
context = retrieve_context(question)
return generate_answer(context, question)
# Weave shows the call tree: handle_question -> retrieve_context, generate_answer
Weave excels at comparing optimization runs. Wrap your optimization in @weave.op():
import weave
import dspy
from dspy.evaluate import Evaluate
weave.init("optimization-experiments")
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini")) # or "anthropic/claude-sonnet-4-5-20250929", etc.
@weave.op()
def run_optimization(optimizer_name: str, model: str, auto_setting: str):
"""Run and track an optimization experiment."""
lm = dspy.LM(model)
dspy.configure(lm=lm)
program = dspy.ChainOfThought("question -> answer")
if optimizer_name == "miprov2":
optimizer = dspy.MIPROv2(metric=metric, auto=auto_setting)
elif optimizer_name == "bootstrap":
optimizer = dspy.BootstrapFewShot(metric=metric)
optimized = optimizer.compile(program, trainset=trainset)
evaluator = Evaluate(devset=devset, metric=metric, num_threads=4)
score = evaluator(optimized)
# Save the artifact
path = f"experiments/{optimizer_name}_{model}_{auto_setting}.json"
optimized.save(path)
return {
"score": score,
"optimizer": optimizer_name,
"model": model,
"auto": auto_setting,
"artifact_path": path,
}
# Run experiments — each is tracked in Weave
run_optimization("miprov2", "openai/gpt-4o-mini", "light")
run_optimization("miprov2", "openai/gpt-4o-mini", "medium")
run_optimization("bootstrap", "openai/gpt-4o-mini", "n/a")
| Feature | W&B Weave | Langtrace | Arize Phoenix |
|---------|-----------|-----------|---------------|
| Instrumentation | Manual (@weave.op()) | Auto (one line) | Auto (plugin) |
| Setup effort | Decorator per function | One line | Two lines + launch |
| Cloud dashboard | Yes (wandb.ai) | Yes (app.langtrace.ai) | Yes (Arize platform) |
| Local/self-hosted | No | Yes (Docker) | Yes (px.launch_app()) |
| Team collaboration | Yes (built-in) | Basic | Basic |
| Experiment comparison | Yes (side-by-side) | No | No |
| Built-in evals | Basic | Basic | Yes (evals module) |
| Cost | Free tier + paid plans | Free tier + paid | Free (open source) |
| Best for | Teams on W&B, experiment tracking | DSPy-first auto-tracing | Local trace viewer + evals |
Want DSPy observability?
|
+- Team already uses W&B? -> Weave
+- Want auto-instrumentation (no decorators)? -> Langtrace (/dspy-langtrace)
+- Want local-only + built-in evals? -> Phoenix (/dspy-phoenix)
+- Need full ML lifecycle (registry, deploy)? -> MLflow (/dspy-mlflow)
After initializing Weave and adding @weave.op() decorators, run one traced call and confirm it appears in the dashboard:
# Quick smoke test
@weave.op()
def smoke_test(x: str) -> str:
return x.upper()
result = smoke_test("hello")
print(f"Check your project at https://wandb.ai — look for the smoke_test call")
If the call does not appear: check WANDB_API_KEY is set, confirm weave.init() was called before the decorated function, and verify network access to wandb.ai.
@weave.op() on the DSPy module class instead of the calling function. Weave decorators trace regular functions, not DSPy module classes. Decorate the function that calls the module, not the module itself. @weave.op() goes on handle_question(), not on QABot.weave.init() inside a function instead of at module level. weave.init() must run once at startup, before any @weave.op() decorated functions are called. Placing it inside a request handler creates a new project per call and fragments your traces.WANDB_API_KEY in deployment environments. Local development prompts for login interactively, but production (Docker, CI, serverless) needs the environment variable explicitly set. Always include WANDB_API_KEY in environment configuration for non-local setups.@weave.op() decorator.@weave.op() and DSPy decorators incorrectly. If combining with other decorators, @weave.op() should be the outermost decorator so it captures the full function execution including any inner decorator behavior.Install any skill:
npx skills add lebsral/DSPy-Programming-not-prompting-LMs-skills --skill <name>
/dspy-langtrace/dspy-phoenix/dspy-mlflow/ai-monitoring/ai-tracking-experiments/ai-do if you do not have it — it routes any AI problem to the right skill and is the fastest way to work: npx skills add lebsral/DSPy-Programming-not-prompting-LMs-skills --skill ai-dotools
See what is happening during optimizer.compile() instead of waiting blind. Use when you want to watch optimization progress, see scores as they come in, know if your optimizer is working, check if optimization is stuck, understand why optimization is taking too long, get live progress during compile, monitor convergence, detect overfitting during optimization, interpret optimization results, or pick the right tool for watching optimization. Also used for optimizer progress bar, is my optimizer doing anything, optimization seems stuck, how long will optimization take, watch GEPA run, watch MIPROv2 run, live optimization dashboard, optimizer not improving, scores not going up, optimization taking forever, see what optimizer is doing, debug slow optimization, optimization visibility, optimizer metrics, track compile progress, optimization observability.
testing
Use when you want the highest-quality prompt optimization DSPy offers — jointly optimizes instructions and few-shot demos, with auto=light/medium/heavy presets. Common scenarios - you want the best possible accuracy from prompt optimization, jointly tuning instructions and few-shot demonstrations, using auto presets for different compute budgets, or when COPRO or BootstrapFewShot alone are not reaching your accuracy target. Related - ai-improving-accuracy, dspy-copro, dspy-bootstrap-few-shot. Also used for dspy.MIPROv2, best DSPy optimizer, highest quality optimization, auto=light medium heavy, joint instruction and demo optimization, most powerful prompt optimizer, MIPROv2 vs COPRO vs BootstrapFewShot, which optimizer should I use, state of the art prompt optimization, when to use MIPROv2, optimize both instructions and examples, heavy optimization for production, best optimizer for accuracy.
testing
Use LangWatch for DSPy auto-tracing and real-time optimizer progress. Use when you want to set up LangWatch, langwatch.dspy.init, auto-tracing DSPy, real-time optimization dashboard, optimizer progress tracking, app.langwatch.ai, or DSPy optimizer dashboard. Also used for langwatch setup, pip install langwatch, langwatch trace, optimizer progress, real-time optimization, watch optimizer run, LangWatch self-hosted, langwatch docker, langwatch vs langtrace, langwatch autotrack_dspy.
data-ai
Use when you want to optimize instructions without few-shot examples — a lightweight alternative to COPRO when you do not have or do not want to use demonstrations. Common scenarios - optimizing instructions when you do not have or do not want to use few-shot demonstrations, lightweight instruction search as a first step, tasks where examples in the prompt confuse the model, or when you want fast instruction optimization without the cost of COPRO. Related - ai-improving-accuracy, dspy-copro, dspy-miprov2. Also used for dspy.GEPA, instruction optimization without demos, lightweight prompt optimization, optimize instructions only, no few-shot examples needed, GEPA vs COPRO, quick instruction search, when demonstrations hurt performance, zero-shot optimization, instruction-only optimizer, simplest instruction tuner, fast prompt optimization, skip few-shot and just tune instructions, optimize Pydantic field descriptions, GEPA structured output, GEPA does not optimize field desc.