/persona-sim:persona-simfrom persona-sim
Simulates feedback from census-grounded virtual human populations for product/copy testing, opinion prediction, and social sandbox experiments. Supports panel scoring, SGO gradient ranking, and persuadable-middle analysis.
Ships in persona-sim. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Simulate feedback from census-grounded virtual populations. Five layers, each independently replaceable:
L5 Scenario adapters (product-feedback-sim / vote-predict / social-sandbox) thin wrappers
L4 Simulation engine (sim_engine.py — SGO: panel -> score -> persuadable middle -> anchored gradient)
L3 LLM router (llm_router.py — config-driven; default Haiku 4.5 + prompt cache; Sonnet for gradient)
L2 Persona sampler (sampler.py — unified sample_personas(n, filters, source, mode))
L1 Persona store (~/.claude/data/personas/ + manifest.json)
Dependencies and config live outside the skill under ~/.claude/data/personas/ so sharing the skill never leaks keys. See SETUP.md for the full walk-through. Short version:
mkdir -p ~/.claude/data/personas
cp ~/.claude/skills/persona-sim/data/config.example.json ~/.claude/data/personas/config.json
cp ~/.claude/skills/persona-sim/data/manifest.json ~/.claude/data/personas/manifest.json
# Edit config.json — set `provider` and fill api_key / base_url for your chosen block
python3 -m venv ~/.claude/data/personas/.venv
~/.claude/data/personas/.venv/bin/pip install -r ~/.claude/skills/persona-sim/requirements.txt
Always invoke with the venv interpreter:
~/.claude/data/personas/.venv/bin/python <script>
sim_engine.panel_score()sim_engine.sgo()panel_score() + segment breakdownsgo() with anchored counterfactual probesfrom persona_sim import sampler, sim_engine
# Sample 30 targeted personas (streaming — no local download needed)
panel = sampler.sample_personas(
n=30,
filters={"occupation_isco": "software", "age": (22, 55)}, # see filter semantics below
source="nemotron_usa",
mode="stream",
)
# Single-version scoring
result = sim_engine.panel_score(panel, target="Copy or product description here")
# -> {"n", "results", "aggregate": {"histogram", "median", "iqr", "entropy",
# "multi_modal", "disagreement_flag", "by_gender", "by_age", "by_region"},
# "warning": "Simulation only..."}
# SGO gradient — rank candidates by how much they shift the persuadable middle
ranked = sim_engine.sgo(
panel,
target="original version",
candidates=["variant A", "variant B"],
goal="maximize paid conversions",
)
# -> {"base", "persuadable_middle", "ranking": [{"candidate", "avg_score_lift", ...}]}
sample_personas(filters={...}) interprets values by Python type:
| Filter value | Match behavior |
|---|---|
(low, high) tuple of numbers | inclusive range (low <= rv <= high) |
[...] list | membership (rv in list) |
"substring" string | case-insensitive substring in str(rv) — great for free-text occupation_isco |
| other (int/str literal) | equality |
Missing field on row (rv is None) → row rejected.
Default adults_only=True injects age=(18, 120) unless you pass your own age filter. Nemotron data includes children with synthetic professional_persona fields — always filter them out for work/product panels.
_persona_card puts Nemotron's long professional_persona narrative FIRST; demographics are a footnote.disagreement_flag. High variance = signal, not noise._anchored_delta_one in sim_engine.py.warning field.Smoke-tested on Nemotron-USA + Haiku 4.5:
| Panel | Filter | Median | IQR | Persuadable middle |
|---|---|---|---|---|
| Generic (n=5) | none | 2 | — | 0/5 |
| Software devs (n=30) | occupation_isco~"software", age (22,55) | 7 | (7, 8) | 19/30 |
Same product, different panel → median shifts from 2 to 7. Personas play roles faithfully; single dissenter at 3 had concrete reasoning. SGO has enough signal when targeting is correct.
Active provider set in ~/.claude/data/personas/config.json → provider field. Three shapes supported:
anthropic (native) — Anthropic SDK with ANTHROPIC_API_KEY; supports prompt cachinganthropic with base_url override — for custom Anthropic-compatible gateways (enterprise proxies, Vertex-routed gateways, etc.)openai (gateway-compatible) — OpenRouter, vLLM, Together, Groq, etc.Escalate to gradient_model (default Sonnet 4.5) for:
See data/config.example.json for template config blocks.
MVP runs entirely on HF streaming — no local copy needed. Only fetch when you're running many panels and want the speed:
~/.claude/data/personas/.venv/bin/python -m persona_sim.fetch nemotron_usa
manifest.json per-dataset default_mode:
local → prompts to download on first usestream → direct HF streaming (default for MVP)ask → shows license + manual-download URLredistribute: false entries (most Nemotron / PersonaHub / WVS / CGSS) are NEVER bundled when sharing the skill — each user fetches them per license terms.
lib/bias_audit.py tests whether LLM personas reproduce four known human biases:
| Probe | What it measures | Human typical | LLM typical |
|---|---|---|---|
| framing | Tversky-Kahneman gain/loss reframe | +0.25 to +0.50 shift | ~0 (none) |
| acquiescence | agree-bias on symmetric statements | +0.10 to +0.20 excess | ~0 (logical) |
| order | primacy/recency on option list | 0.05-0.15 TV distance | <0.03 |
| authority | "experts say" prefix shift | +0.10 to +0.20 | +0.00 to +0.05 |
Results flagged with calibration warnings. Run before publishing any survey-style prediction.
Task(subagent_type="general-purpose",
prompt=f"Run persona_sim.panel_score on ids {ids[0:50]}, target={target!r}. Return distribution only.")
Main agent aggregates per-slice distributions to avoid context bloat.
references/chinese_pipeline.md) but not implemented — see that file for the 3-source recipe (census + WVS + LLM narrative).demo_corr suite requires persona income field (not in Nemotron); currently skips that dimension.lib/{fetch,sampler,llm_router,sim_engine,aggregator,bias_audit,ipf}.py — core layersprompts/persona_system.md — narrative-first system prompt with anti-agreeable guardrailsprompts/sgo_gradient.md — anchored counterfactual templateeval/run_eval.py + eval/*.json — 6-suite score card (gss_20q, bfi44, test_retest, diversity, demo_corr, bias_audit)references/methodology.md — Park 2024, Santurkar, SGO, CoBRA, Tjuatja synthesisreferences/datasets.md — dataset inventory + field mapsreferences/chinese_pipeline.md — scaffold for Chinese persona synthesisscripts/smoke_test.py, scripts/smoke_test2.py — minimal working examplesSETUP.md — venv + config bootstraprequirements.txt — pinned depsdata/manifest.json — dataset registry (safe to share)data/config.example.json — sanitized LLM config templatecd ~/.claude/skills/persona-sim
~/.claude/data/personas/.venv/bin/python eval/run_eval.py \
--suite gss_20q,bfi44,test_retest,diversity,demo_corr,bias_audit \
--n 30
# -> eval/reports/score_card_YYYYMMDD.json
Target: overall >= 0.75. If any dimension fails, that dimension is the highest-priority edit target for the next iteration.
Three thin scenario wrappers ship alongside the core. They route into persona-sim's API with opinionated defaults for common use cases:
product-feedback-sim — SGO ranking for product/copy/pricing candidatesvote-predict — categorical opinion prediction with IPF post-stratificationsocial-sandbox — what-if experiments with open-ended narrative clusteringEach has its own SKILL.md with a full recipe.
SETUP.md (opens in a new tab)data/config.example.json (opens in a new tab)data/manifest.json (opens in a new tab)eval/__init__.py (opens in a new tab)eval/anes_demo_corr.json (opens in a new tab)eval/bfi44.json (opens in a new tab)eval/gss_20q.json (opens in a new tab)eval/run_eval.py (opens in a new tab)prompts/persona_system.md (opens in a new tab)prompts/sgo_gradient.md (opens in a new tab)references/chinese_pipeline.md (opens in a new tab)references/datasets.md (opens in a new tab)references/methodology.md (opens in a new tab)requirements.txt (opens in a new tab)scripts/smoke_test.py (opens in a new tab)scripts/smoke_test2.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yrzhe/claude-skills --plugin persona-sim4 skills in this plugin
/product-feedback-simGet structured feedback on a product, copy, pricing, or feature from a simulated panel of target users. Use when the user wants to rank A/B candidates, find persuadable-middle users, or compute a semantic gradient before shipping. Triggers on 产品反馈模拟, A/B 排序, SGO 梯度, persuadable middle, 50 个虚拟用户打分, 看看目标用户怎么想./social-sandboxRun a what-if social experiment — inject a policy, event, or information shock and observe how a simulated population responds. Use for hypothesis generation (not ground truth) on questions like "what if minimum wage doubled", "how would users react if we added feature X", "which demographics push back first". Triggers on 社会实验, 沙盒模拟, what-if, 如果 X 发生了会怎样, 反事实模拟, counterfactual experiment./vote-predictPredict how a target population would vote, respond to a policy, or react to a political message. Use when the user wants a distribution (not a winner-take-all answer) across demographic segments, with calibration disclaimers. Triggers on 投票预测, 民意模拟, policy response, 政策反应, 选举模拟, 民意分布, 某群体怎么看.Other plugins' skills for the same job