No slash command · from anofox-scenario
Provides a safe workflow for previewing, applying, and rolling back data changes on DuckDB tables using the anofox_scenario extension. Handles dry runs, bulk UPDATE/DELETE/MERGE, ETL steps, backfills, merge conflicts, and undo operations.
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
Run the change in a scenario, check it, read the diff, preview the merge, then apply it in
one step, or drop the scenario and nothing happened. Errors, transactions and edge cases:
anofox-scenario-reference. Record, undo, keyless, DuckLake and schema changes:
recipes.md.
Before scenario_merge, before choosing 'ours' or 'theirs', and before scenario_drop
or scenario_unfreeze: show the user the summary, the preview counts and the conflicts, name
the scenario and what it will do to which tables, and wait for a yes (unless they already
asked for exactly that). A committed merge has no undo button; see "Undo" in
recipes.md.
Decide these first; changing them later means a new scenario.
ALTER / CREATE inside a scenario fails with DDL operations are not permitted in scenarios. For a migration that adds a column and backfills it, see
"Schema changes" in recipes.md; tell the user this before starting.base := 'lake', merge
rules in recipes.md).key_columns := MAP {'ledger': ['entry_no']}. Keyless
merges detect fewer base edits.scenario_merge_preview(s) lists every action and flags conflicts, with
no side effects. The default on_conflict := 'abort' fails on the first conflict and
changes nothing.merged_at set (scenario_list()),
delta empty, a second merge fails. Its diff is empty afterwards, so save a record first.scenario_merge returns
0, 0, 0 and the scenario stays open and unfrozen, merged_at NULL.CREATE TABLE products (id INTEGER PRIMARY KEY, name VARCHAR NOT NULL, price DECIMAL(10,2) CHECK (price > 0));
INSERT INTO products VALUES (1, 'Widget', 9.99), (2, 'Gadget', 24.50), (3, 'Gizmo', 4.75), (4, 'Doohickey', 12.00);
-- staging data from an import, to be upserted
CREATE TABLE price_import (id INTEGER, name VARCHAR, price DECIMAL(10,2));
INSERT INTO price_import VALUES (2, 'Gadget', 26.00), (3, 'Gizmo', 4.75), (5, 'Thingamajig', 7.50);
CALL scenario_create('price_import_2026_03', 'upsert price_import, retire Doohickey');
ATTACH 'price_import_2026_03' AS dry (TYPE scenario);
MERGE INTO dry.products p
USING price_import s ON p.id = s.id
WHEN MATCHED AND p.price <> s.price THEN UPDATE SET price = s.price
WHEN NOT MATCHED THEN INSERT VALUES (s.id, s.name, s.price);
DELETE FROM dry.products WHERE name = 'Doohickey';
The base's NOT NULL, CHECK, PRIMARY KEY and UNIQUE constraints apply to the merged
state, so a change that would break them fails here, in the dry run.
SELECT count(*) AS products, min(price) AS min_price, max(price) AS max_price FROM dry.products;
Per table, then per action and conflict (cheap, however large the change):
SELECT * FROM scenario_diff_summary('price_import_2026_03');
SELECT table_name, action, conflict, count(*) AS n
FROM scenario_merge_preview('price_import_2026_03')
GROUP BY ALL ORDER BY ALL;
Then details, bounded: conflicts first, a sample of the rest. A diff has one row per changed column, a keyless preview one row per copy; list everything only for small changes.
SELECT * FROM scenario_merge_preview('price_import_2026_03') WHERE conflict LIMIT 100;
SELECT id, change_type, column_name, old_value, new_value
FROM scenario_diff('price_import_2026_03', 'products')
ORDER BY id
LIMIT 100;
Put this to the user before merging:
'ours' / 'theirs') the user chose;SELECT * FROM scenario_merge('price_import_2026_03');
It returns tables_changed, rows_applied, conflicts_resolved. The base now holds the
change, and the scenario shows merged_at:
SELECT * FROM products ORDER BY id;
SELECT name, frozen, merged_at IS NOT NULL AS merged FROM scenario_list();
Remove it when done, after asking (DETACH is needed before a drop, not before a merge):
DETACH dry;
CALL scenario_drop('price_import_2026_03');
CALL scenario_create('retire_gizmo');
ATTACH 'retire_gizmo' AS rg (TYPE scenario);
DELETE FROM rg.products WHERE id = 3;
BEGIN;
SELECT * FROM scenario_merge('retire_gizmo');
SELECT count(*) FROM products; -- 3: check before anyone else sees it
ROLLBACK; -- or COMMIT
SELECT count(*) FROM products; -- 4 again: the merge is undone
After the ROLLBACK the scenario can be merged again later.
CALL scenario_create('bad_idea');
ATTACH 'bad_idea' AS bad (TYPE scenario);
UPDATE bad.products SET price = price * 100;
DETACH bad;
CALL scenario_drop('bad_idea'); -- the base was never touched
| Conflict | When |
|---|---|
| insert over an existing key | the scenario inserts a key that now exists in the base |
| update of a vanished row | the scenario updates a row the base has deleted since |
| drift | the base row of a key the scenario updated or deleted changed since the scenario's reference: its copy (materialized), the pinned snapshot (DuckLake), or the row at the scenario's first touch (delta) |
| keyless copy count | keyless table, delta scenario: the base holds fewer copies of a row than the scenario deletes (the base edited or deleted it) |
on_conflict | Effect |
|---|---|
'abort' (default) | the merge fails and changes nothing |
'ours' | the scenario wins: a conflicting insert replaces the base row, an update of a deleted row inserts it again; keyless: deletes the copies that remain |
'theirs' | the base wins for conflicting keys; keyless: deletes nothing for that row; the rest is applied |
Keyless inserts have no key to conflict on and apply under every policy, so a keyless row the scenario changed can end up in both versions.
-- doc-snippets: new session
CREATE TABLE stock (sku VARCHAR PRIMARY KEY, qty INTEGER);
INSERT INTO stock VALUES ('A', 10), ('B', 20);
CALL scenario_create('restock');
ATTACH 'restock' AS r (TYPE scenario);
INSERT INTO r.stock VALUES ('C', 5);
UPDATE r.stock SET qty = 25 WHERE sku = 'B';
DETACH r;
-- meanwhile someone adds 'C' to the real table
INSERT INTO stock VALUES ('C', 7);
SELECT key, action, conflict FROM scenario_merge_preview('restock') ORDER BY key;
C is flagged. After the user picks who wins:
SELECT * FROM scenario_merge('restock', on_conflict := 'theirs');
SELECT * FROM stock ORDER BY sku; -- B = 25 from the scenario, C = 7 kept from the base
Drift: someone edits a row the scenario changed, after the dry run:
-- doc-snippets: new session
CREATE TABLE item (id INTEGER PRIMARY KEY, name VARCHAR, price INTEGER);
INSERT INTO item VALUES (1, 'old name', 10);
CALL scenario_create('reprice');
ATTACH 'reprice' AS rp (TYPE scenario);
UPDATE rp.item SET price = 11;
UPDATE item SET name = 'new name'; -- base edit after the dry run
SELECT key, action, conflict FROM scenario_merge_preview('reprice'); -- conflict = true
SELECT * FROM scenario_merge('reprice', on_conflict := 'theirs');
SELECT * FROM item; -- (1, 'new name', 10)
Policies decide per row, not per column: 'ours' would write (1, 'old name', 11) and undo
the rename. To keep both edits, redo the change in a new scenario over the current base.
To apply one variant out of several (anofox-scenario-what-if), merge the scenario that holds
the full intended state: a branch contains its parent's changes. Afterwards drop the branch,
then its ancestors. Do not merge an ancestor again: its changes are in the base already, so
every one of them is a conflict (inserts as existing keys, updates and deletes as drift).
Worked example with the ancestor's preview: recipes.md, "Merging a branch".
A branch of a materialized parent: base edits to rows it only inherited from the parent are not detected (reference skill, "Base edits a merge does not detect").
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
4 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-snapshot-auditApproved, signed-off versions and audit trails with the anofox_scenario DuckDB extension: freeze an approved plan, budget or forecast so later base changes cannot alter it, capture an approved what-if variant, show what changed since sign-off, log who corrected or revised it and why, pin a version to a DuckLake snapshot, migrate a legacy v0.1 scenario database. Use when the user says approved, signed off, sign-off, baseline, frozen, locked, "as of" a date, "the version from March", audit trail or compliance record. Not for exploring new variants (anofox-scenario-what-if) or applying changes to the real tables (anofox-scenario-safe-change).
Other plugins' skills for the same job
npx claudepluginhub datazoode/anofox-scenario --plugin anofox-scenario