Git-like branching skills for the anofox_scenario DuckDB extension — what-if planning with scenario variants, dry-running changes and merging them back, frozen snapshots and audit trails, plus a semantics and error reference.
anofox-scenario gives you Git-like branches over your DuckDB tables. Change data in a
branch, see exactly what changed, then keep it or throw it away — without ever copying the
table or touching the original.
INSTALL anofox_scenario FROM community;
LOAD anofox_scenario;
-- Given any existing table, e.g. forecast(id, region, qty).
-- Branch it. Nothing below modifies the real `forecast` table.
CALL scenario_create('optimistic', 'demand +10%');
ATTACH 'optimistic' AS opt (TYPE scenario);
UPDATE opt.forecast SET qty = qty * 1.1 WHERE region = 'US';
SELECT * FROM opt.forecast; -- the what-if world
SELECT * FROM forecast; -- the real world, untouched
SELECT * FROM scenario_diff('optimistic', 'forecast'); -- exactly what differs
That's the whole idea. Only the rows you actually change are stored, so a scenario over a
100-million-row table costs you the rows you touched — not a copy.
🤖 Built for AI pair-programming. anofox-scenario ships an installable
Claude Code plugin whose skills follow the
ways people use scenarios — what-if planning, dry-running a change before merging it,
freezing an approved plan — so your assistant writes correct branching, diff and merge SQL
from a plain-English request. Install with
/plugin marketplace add DataZooDE/anofox-scenario → /plugin install anofox-scenario@anofox-scenario.
Is this for you?
A good fit if you want to model what-ifs on data that fits on one machine, test a change
before applying it, keep several named variants of a dataset side by side, or hand someone a
single file containing both a baseline and the alternatives. Typical uses:
S&OP and demand planning — model demand shifts, supply disruptions, or price changes
Budget planning — keep optimistic, pessimistic, and baseline variants side by side
Data validation — try an ETL or migration change in a branch before applying it for real
Audit trails — freeze an approved plan as a point-in-time record you can diff against later
Not a fit if you need multiple people writing to the same scenario concurrently, you're
working at data-lake scale across a cluster, or you need to change the schema inside a
branch — DDL in scenarios is rejected by design.
Installation
Requires DuckDB v1.5.5 or later; builds are published for DuckDB v2.0.1 and v1.5.6 from the same
source (see docs/UPDATING.md).
INSTALL anofox_scenario FROM community;
LOAD anofox_scenario;
Build from source instead
git clone --recurse-submodules https://github.com/DataZooDE/anofox-scenario.git
cd anofox-scenario
GEN=ninja make
make test
The extension is built at
build/release/extension/anofox_scenario/anofox_scenario.duckdb_extension.
Quick Start
1. Create a Scenario
LOAD anofox_scenario;
CREATE TABLE products (id INTEGER PRIMARY KEY, name VARCHAR, price DECIMAL(10,2));
INSERT INTO products VALUES (1, 'Widget', 9.99), (2, 'Gadget', 24.50);
-- Register a scenario for what-if analysis
CALL scenario_create('price_increase', 'Analyzing 10% price increase impact');
2. Make Modifications
A scenario is an attached catalog — you edit it with ordinary SQL, and the base
table is never written to.
ATTACH 'price_increase' AS pi (TYPE scenario);
UPDATE pi.products SET price = price * 1.1 WHERE id = 1;
INSERT INTO pi.products VALUES (3, 'Doohickey', 5.00);
DELETE FROM pi.products WHERE id = 2;
SELECT count(*) FROM products; -- 2, base untouched
SELECT count(*) FROM pi.products; -- 2, merged view (1 updated, 1 added, 1 removed)
3. Compare Changes
SELECT * FROM scenario_diff('price_increase', 'products');