No slash command · from anofox-scenario
Enables what-if planning and sensitivity analysis on DuckDB tables using the anofox_scenario extension. Clone, fork, or sandbox tables into named plan variants, modify with SQL, and compare KPIs without touching real data.
Ships in anofox-scenario. 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.
Extension: anofox_scenario v2026.11.13 | DuckDB: v1.5.5+ and v2.0 | Install: INSTALL anofox_scenario FROM community; LOAD anofox_scenario;
A scenario is a named, Git-like branch of the tables in your database. Attach it as a catalog
and use plain SQL on it; only changed rows are stored, the real tables are never written.
Errors and edge cases: anofox-scenario-reference. Forecasting per scenario:
forecast.md.
Applying a variant to the real tables is a merge: follow anofox-scenario-safe-change and get
the user's yes first. Drop only scenarios created in this conversation, or after asking.
Decide these first; changing them later means new scenarios.
May untouched rows follow later base changes?
| Need | Create with | Base changes after creation | Cost |
|---|---|---|---|
| Quick what-if on a stable base | scenario_create('s') (delta, default) | show through, except on rows the scenario touched | one registry row |
| Variant that must not move while the base changes | mode := 'materialized' | invisible | copies every base table |
| Same isolation, base in DuckLake | base := '<attached ducklake>' | invisible (pinned to creation time) | none |
Keyless tables? Without a PRIMARY KEY, diffs compare whole rows. If the table has a
logical key, declare it at creation: key_columns := MAP {'demand': ['sku', 'month']}.
Variants of a variant? from_scenario := 'parent' branches; the branch copies the
parent's existing deltas, so K branches of a heavily edited parent cost K copies of its
delta. A branch cannot be materialized.
Very large edits (more than ~4M updated or deleted keys in one table) switch scans to
index lookups; see anofox_scenario_suppression_hash_limit in the reference.
scenario_create only registers. Reading and writing needs
ATTACH 'optimistic' AS opt (TYPE scenario); the string is the scenario name, not a file.opt.demand is the scenario's view; plain demand is
the real table. Avoid USE opt: the scenario_* functions then find no scenarios.opt.my_view evaluates a host view against the scenario, unless the view names
the catalog (mydb.main.demand): then it silently reads the real table.DDL operations are not permitted in scenarios): keep helper
tables in main or TEMP.scenario_diff(a, b, 'table'): old_value from a,
new_value from b; 'main' is the real table.DETACH before scenario_drop; drop branches before their parent.CREATE TABLE demand (
sku VARCHAR, region VARCHAR, month DATE, qty DECIMAL(12, 2),
PRIMARY KEY (sku, region, month));
INSERT INTO demand VALUES
('A', 'US', DATE '2026-01-01', 100), ('A', 'EU', DATE '2026-01-01', 80),
('B', 'US', DATE '2026-01-01', 50), ('B', 'EU', DATE '2026-01-01', 40),
('A', 'US', DATE '2026-02-01', 110), ('A', 'EU', DATE '2026-02-01', 85),
('B', 'US', DATE '2026-02-01', 55), ('B', 'EU', DATE '2026-02-01', 45);
CALL scenario_create('optimistic', 'US demand +10%');
CALL scenario_create('pessimistic', 'EU demand -20%, SKU B delisted in EU');
ATTACH 'optimistic' AS opt (TYPE scenario);
ATTACH 'pessimistic' AS pes (TYPE scenario);
INSERT, UPDATE, DELETE, TRUNCATE, MERGE INTO and INSERT ... ON CONFLICT all work,
with the base's constraints enforced.
UPDATE opt.demand SET qty = qty * 1.1 WHERE region = 'US';
UPDATE pes.demand SET qty = qty * 0.8 WHERE region = 'EU';
DELETE FROM pes.demand WHERE sku = 'B' AND region = 'EU';
Assumptions kept in a table apply as a join; a sensitivity sweep is one scenario per step:
CREATE TEMP TABLE uplift (region VARCHAR, factor DOUBLE);
INSERT INTO uplift VALUES ('US', 1.05), ('EU', 1.02);
CALL scenario_create('moderate', 'uplift table applied');
ATTACH 'moderate' AS mod (TYPE scenario);
UPDATE mod.demand SET qty = demand.qty * u.factor FROM uplift u WHERE demand.region = u.region;
Each attached scenario is a full, queryable version of the data, so a KPI comparison is a
UNION ALL of the same query over each variant, the base included:
SELECT variant, region, sum(qty) AS total_qty
FROM (
SELECT 'base' AS variant, * FROM demand
UNION ALL SELECT 'optimistic', * FROM opt.demand
UNION ALL SELECT 'pessimistic', * FROM pes.demand
)
GROUP BY ALL
ORDER BY region, variant;
Side by side, one column per variant:
PIVOT (
SELECT 'base' AS variant, * FROM demand
UNION ALL SELECT 'optimistic', * FROM opt.demand
UNION ALL SELECT 'pessimistic', * FROM pes.demand
) ON variant USING sum(qty) GROUP BY region ORDER BY region;
An existing KPI view works per variant when it names the table without a catalog:
CREATE VIEW demand_by_region AS SELECT region, sum(qty) AS total_qty FROM demand GROUP BY region;
SELECT 'optimistic' AS variant, * FROM opt.demand_by_region
UNION ALL SELECT 'pessimistic', * FROM pes.demand_by_region
ORDER BY region, variant;
Counts first (one row per changed table), then the rows:
SELECT * FROM scenario_diff_summary('pessimistic');
Against the real table (2 arguments): one row per changed key and column. Add LIMIT or a
filter for large changes.
SELECT * FROM scenario_diff('pessimistic', 'demand') ORDER BY ALL;
Columns: the key columns in their own types, change_type (added / removed /
modified), column_name (for modified), old_value, new_value (text).
Between two variants (3 arguments; old = first, new = second):
SELECT * FROM scenario_diff('optimistic', 'pessimistic', 'demand') ORDER BY ALL;
Diffs are table functions, so filter and aggregate them:
SELECT region, count(*) AS changed_cells
FROM scenario_diff('optimistic', 'demand')
WHERE change_type = 'modified'
GROUP BY region;
CALL scenario_create('optimistic_promo', from_scenario := 'optimistic');
ATTACH 'optimistic_promo' AS promo (TYPE scenario);
UPDATE promo.demand SET qty = qty + 20 WHERE sku = 'A' AND month = DATE '2026-02-01';
-- only the promo's own changes relative to its parent
SELECT * FROM scenario_diff('optimistic', 'optimistic_promo', 'demand');
A scenario with branches cannot be dropped or merged until its branches are dropped. To apply
the chosen variant, merge it (it carries its parent's changes): "Merging a branch" in
anofox-scenario-safe-change. To keep it as the approved plan: anofox-scenario-snapshot-audit.
SELECT name, mode, frozen, parent, merged_at, description FROM scenario_list() ORDER BY name;
After the user agrees which variants to discard:
DETACH promo;
CALL scenario_drop('optimistic_promo');
DETACH mod;
CALL scenario_drop('moderate');
Scenarios live inside the database file (__anofox_scenario schema): they survive a restart
and travel with the .duckdb file. Re-ATTACH them in each new session. Python and sharing:
the reference skill's behaviour.md.
ALTER TABLE ... ADD COLUMN) does reach every scenario.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub datazoode/anofox-scenario --plugin anofox-scenario4 skills in this plugin
/anofox-scenario-referenceSupplementary lookup for the anofox_scenario DuckDB extension, loaded alongside a workflow skill or when a scenario statement fails. Error message -> cause -> fix table; every signature and output column (scenario_create, scenario_list, scenario_diff, scenario_diff_summary, scenario_merge_preview, scenario_merge, scenario_freeze, scenario_unfreeze, scenario_drop, scenario_refresh, scenario_migrate); settings (telemetry opt-out, suppression hash limit, internal writes); which base edits a merge does not detect; transactions; ATTACH ... (TYPE scenario) and USE; keyless tables, views, row identity; which tables a scenario changed; using a scenario from Python; sharing one with a colleague. Not a workflow on its own: plan variants -> anofox-scenario-what-if, dry run and merge -> anofox-scenario-safe-change, approved versions -> anofox-scenario-snapshot-audit.
/anofox-scenario-safe-changeTry a data change on a sandbox copy of DuckDB tables with the anofox_scenario extension, review exactly what it would change, then apply it to the real tables, throw it away, or undo it later. Use for a dry run or preview of a bulk UPDATE / DELETE / MERGE, an ETL step, a backfill, a price change or a data fix; "test it on a copy / staging version first"; applying (merging) a scenario or a chosen plan variant to the real data; merge conflicts; undoing or rolling back a change applied by a scenario merge; SQL that already uses (TYPE scenario) or scenario_merge. Row data only: schema migrations (ADD COLUMN, new tables) cannot run inside a scenario because DDL is rejected; this skill says what to do instead. Not for comparing plan variants (anofox-scenario-what-if) or keeping approved, signed-off versions (anofox-scenario-snapshot-audit).
Other plugins' skills for the same job