shadow-mode-deployment
БесплатноБез исполняемых скриптовНе проверенShadow and canary deployment of RAG pipeline changes: dual-execute new + old, offline LLM-judge comparison, gradual traffic ramp, auto-rollback guardrails…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Shadow Mode & Canary Deployment for RAG
Why Shadow Mode for RAG
Offline evaluation diverges from live traffic within weeks because:
- Query distribution shifts (product updates, seasonality).
- Corpus updates introduce content you never tested against.
- Judge LLM scores don't always match user satisfaction.
Shadow mode runs a candidate pipeline alongside production without affecting user-facing output. Only after shadow metrics match or beat baseline do you ramp real traffic.
Stages
| Stage | User Impact | Traffic to Candidate | Purpose |
|---|---|---|---|
| Shadow (dual-execute) | Zero (candidate output discarded) | 100% mirror | Latency + quality comparison |
| Dark canary | Zero (compared offline) | Mirror + log | LLM-judge A/B offline |
| Canary | Small | 1-5% | Real user signal |
| Gradual ramp | Growing | 10 / 25 / 50 / 100% | Confidence building |
| Bandit | Dynamic | Optimal allocation | Revenue / satisfaction maximisation |
Dual Execution Wrapper
import asyncio, time
from dataclasses import dataclass
@dataclass
class PipelineResult:
answer: str
contexts: list[str]
latency_ms: float
cost: float
async def serve(query: str, user_id: str, flags) -> PipelineResult:
shadow_enabled = flags.is_enabled("rag.shadow_v2", user_id=user_id)
if not shadow_enabled:
return await prod_pipeline.answer(query)
prod_task = asyncio.create_task(prod_pipeline.answer(query))
cand_task = asyncio.create_task(cand_pipeline.answer(query))
prod_result = await prod_task
async def log_shadow():
try:
cand_result = await asyncio.wait_for(cand_task, timeout=5.0)
await log_event({
"query": query, "user_id": user_id,
"prod": prod_result.__dict__,
"cand": cand_result.__dict__,
"ts": time.time(),
})
except asyncio.TimeoutError:
await log_event({"query": query, "user_id": user_id,
"cand_error": "timeout"})
asyncio.create_task(log_shadow())
return prod_result
Candidate latency and errors are logged without blocking the user.
Offline Comparison with an LLM Judge
from anthropic import Anthropic
import json
client = Anthropic()
JUDGE = """You compare two RAG answers to the same question and pick the
better one. Return JSON: {"winner": "A"|"B"|"tie", "reason": str}.
Question: {q}
Answer A: {a}
Answer B: {b}"""
def judge_pair(q, a, b):
msg = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=400,
messages=[{"role": "user", "content": JUDGE.format(q=q, a=a, b=b)}],
)
return json.loads(msg.content[0].text)
# Randomize A/B order per sample to avoid position bias
import random
def judge_shadow_log(entries):
results = {"prod_wins": 0, "cand_wins": 0, "ties": 0}
for e in entries:
if random.random() < 0.5:
v = judge_pair(e["query"], e["prod"]["answer"], e["cand"]["answer"])
mapping = {"A": "prod_wins", "B": "cand_wins", "tie": "ties"}
else:
v = judge_pair(e["query"], e["cand"]["answer"], e["prod"]["answer"])
mapping = {"A": "cand_wins", "B": "prod_wins", "tie": "ties"}
results[mapping[v["winner"]]] += 1
return results
Run daily over the previous day's shadow log; require cand_wins >= prod_wins with p < 0.05 (sign test) before promoting.
Feature Flags for Independent Components
RAG has several swappable components. Flag them independently so you can isolate which change caused a regression.
# LaunchDarkly example
import ldclient
ld = ldclient.get()
def build_pipeline(user):
retriever = HybridRetriever() if ld.variation(
"rag.retriever.hybrid", user, False) else DenseRetriever()
reranker_model = ld.variation(
"rag.reranker.model", user, "BAAI/bge-reranker-v2-m3")
reranker = CrossEncoder(reranker_model)
gen_model = ld.variation(
"rag.generator.model", user, "claude-sonnet-4-5-20250929")
return RAGPipeline(retriever, reranker, generator=gen_model)
Unleash equivalent:
from UnleashClient import UnleashClient
unleash = UnleashClient(url="https://unleash.example/api", app_name="rag-svc",
custom_headers={"Authorization": UNLEASH_TOKEN})
unleash.initialize_client()
if unleash.is_enabled("rag.reranker.v2", {"userId": user_id}):
reranker = new_reranker
Gradual Ramp
# Ramp config lives outside code
RAMP = {"rag.generator.claude45": [
{"day": 0, "pct": 1},
{"day": 1, "pct": 5},
{"day": 3, "pct": 25},
{"day": 5, "pct": 50},
{"day": 7, "pct": 100},
]}
Each step requires:
- Shadow judge win-rate >= 50% over last 24h.
- Latency p95 not worse by more than 10% vs baseline.
- Error rate not increased.
- Manual sign-off for the 50% -> 100% promotion (cheap insurance).
Auto-Rollback Guardrails
#
Установить shadow-mode-deployment в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл shadow-mode-deployment?
Shadow and canary deployment of RAG pipeline changes: dual-execute new + old, offline LLM-judge comparison, gradual traffic ramp, auto-rollback guardrails, multi-armed bandits, per-component feature flags (retriever, reranker, generator). USE WHEN: user mentions "shadow mode", "canary deployment", "dual execute", "shadow traffic RAG", "feature flags RAG", "multi-armed bandit", "auto rollback", "LaunchDarkly RAG", "Unleash RAG" DO NOT USE FOR: CI pre-merge eval - use `continuous-evaluation`; offline eval only - use `rag-evaluation`; drift detection - use `drift-detection`
Как установить скилл shadow-mode-deployment?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл shadow-mode-deployment запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub