Swiss Army Bench
(Installed and run as swissarmybench, alias sab.)
A desktop app for any tabular data: live tables, notebooks, SQL and analysis, in windows of its own
(PySide6, the pages drawn by Qt WebEngine) over a local Python server that runs while the app is open. You
push a DataFrame from Python and its table opens; the same pages open in a browser too, if you want a tab.
Everything stays on your machine: 127.0.0.1 only, a token on every data request, data in memory, nothing
sent anywhere.
What the Tables page does:
- Tables: scroll millions of rows (the server sends only the rows on screen). A header can
show its column's distinct count, blank percentage and a small histogram (the switch is in the
table's top-left corner, above the row numbers); its arrow button sorts on the server. Enter or
F2 on a cell opens its whole value. The horizontal scrollbar is always on screen.
- Excel-style selection: click or drag the row numbers to select rows, a header to select its
column, drag across cells for a block, the corner (or Ctrl+A) for everything; Shift extends,
Ctrl adds. The status bar shows Count, Average and Sum over the whole selection, loaded or not,
and Ctrl+C copies it as tab-separated text.
- Ribbon: the transformation tools grouped by what they act on: Table (filter, sort,
columns, group by, distinct, profile, analyze, export) and Column (sort, filter, rename,
remove, keep, clean, bucket, categorize, group by and profile, for the selected columns); a
cell's tools (keep or exclude rows with its value, view, copy) are on its right-click menu.
Ctrl+Shift+P lists every action of the page by name.
- Steps (like Power Query's applied steps): filter, sort, choose and rename columns, group
by, distinct, keep first rows, clean text, bucket, categorize and SQL. The table has the whole
page: a strip under its title counts the steps (a header sort among them), lists them on
hover with a remove button each, and offers Undo, Redo (Ctrl+Z, Ctrl+Y) and Clear; Edit steps opens
Table Transformations in a tab of its own, where each step can be edited, turned off or reordered, with row counts as it goes.
- Cell viewer: double-click a cell. JSON objects and arrays show as tables you can open one
layer at a time, markdown is formatted, and long text wraps.
- Text matching (the ribbon's Table row): Match case, Wildcards (
% only, as in SQL LIKE),
Trim, Empty = blank.
- Column profile: a popup from the Column row's Profile: statistics and value counts; click a
value to filter on it. Auto width fits every column (Table row) or the selected ones.
- SQL lives in your Python (DuckDB SQL does the transforming): every table has a read-only cell
in the Workbench notebook or script it belongs to, holding the table's steps as one DuckDB query
whose result is the table's own name (
orders = duckdb.sql("""...""").df()). The cell follows the
Tables page by itself and turns yellow (Out of date · Run) when the steps change; nothing runs by itself,
and running it twice never transforms a table twice. All tables sit at the top of the file in a
Tables group that folds to one line. Every cell has a number that never changes, @cell7 in a
comment links to it, and a cell that names a table starts with # uses orders @cell3. A SQL step
(Edit steps, Add a SQL step) is one guarded SELECT over the table entering it.
- HTML cells: a notebook or script cell that holds HTML and shows it as a design in a pane that
resizes: the HTML while you edit it, the design when you leave it. Its scripts run walled off from
the app and nothing loads from the internet.
{{ total }} is filled with a Python variable when
the cell runs (a value as text, a table as its first 50 rows); such a cell turns yellow (Out of
date · Run) when its HTML or a variable it names changes. In a notebook file it is a %%html cell.
- Streamlit apps, from widgets: a widget is a small Streamlit program kept in your library (56 come
with the app: buttons, inputs, tables, metrics, charts, text, filters, forms); its top-level values are its
properties, each with a mask (a colour picker, a table picker, a column picker, a date, a number with its
range). Widgets on the rail opens the Widgets window: write one with completion and help, Run it in
place. Canvas on the rail lays a page out: draw containers on a grid (snap to 1 px or to the grid's
cells), drag widgets in from the Widgets pane, set their properties; Play, Launch (a build kept in
the project's builds/), Export (a folder that runs on a hosted Streamlit app). Streamlit runs in the
project's own Python and is not installed with the app. App notebooks were replaced by widgets (2026-11-21).
- Tabs pop out: any Workbench tab pops out into a window of its own (its unsaved changes and kernel go
with it), and back.
- Projects: a folder that starts with the data.
data.ipynb is where you work on the tables and
variables; data.py is its export, and what your notebooks and pages import (from data import orders). The app's canvas exports pages/*.py the same way.
- Export as one Python script… / as one notebook… (a document's … menu): any notebook or
script as ONE self-contained file for a scheduler or an Azure Function: its connections, key vault
lookups and steps (as DuckDB SQL) written out, no Swiss Army Bench, no passwords, no rows.
python orders_report_automation.py checks its packages first (--install pips them), names every
setting it reads and where it came from, and has a main() for a timer trigger; an Azure Key Vault
is read by the function app's managed identity with the standard library. The notebook runs top to
bottom with nbconvert or papermill.
- New table from a query: the + after the last tab opens a SQL tray over a blank table.
A table name reads that table as its tab shows it (after its steps); Run turns the result into a
table of its own, with every tool a pushed table has. The tray stays on the tab, so Run again
rebuilds the table in place, and its own steps apply to the new rows.
- Copy transformations as SQL or Python (the steps window's Code tab, for a Python outside the
Workbench): the view's steps, SQL steps included, as one DuckDB
query over your own table by its variable name. Copy as SQL gives the query; Copy as
Python gives
import duckdb and one line, orders_view = duckdb.sql("""...""").df() (.pl()
for Polars, .to_arrow_table() for Arrow). The copy is run exactly as copied, in a fresh namespace holding only your table,
and compared with the table before it's offered; only verified code gets the Copy buttons.
- Relationships: Find relationships works out how every open table joins, from
the data: each join with its kind, the share of values that match, the orphans and why (names that
don't match, a text column of numbers, two-column keys and second paths are handled; small number
columns that overlap by accident are not suggested). Accept the joins, Check them against the
open tables to see which hold, and Save as a set…: a
.relationships.json file with a name,
description and tags, kept in your library's relationship-sets/ or in a shared folder (the blade
folders), where your coworkers' Relationships window lists it under Saved sets (rename, export and
delete from its menu). In use now manages the joins you use, forty imported foreign keys as easily
as four: tick rows (select all, shift-click a range), Delete selected, Run on / Run off
(whether a join is used), change a row's Kind or Run in place, filter by table or column, sort
by any column, group by From table; every change has one Undo in its toast. Deleting a connection
takes the relationships its tables held out of the ones in use (the toast says how many); saved sets
stay. With a project open, the ERD and In use now show only the tables the project uses (open,
its own, or named in its notebooks' and scripts' code) and a join only when both ends are; All
tables shows the rest, and the ERD says how many are not drawn.
- Analyze (its own page on the rail): a toolbar of every analysis and one guided form beside the board.
The table is already picked, the columns are picked for you as chips (only the ones that fit are offered,
the rest listed with why), one sentence says what will run, and the result lands on the board by itself.
Check this table suggests the three analyses that suit a table; Make it fit proposes the steps
that would (text read as numbers or dates, a yes/no column...), applied only on your click; each form
shows a made-up sample of the data it needs. The analyses hand off to each other. Odds:
how often each value shows up, and with an outcome, each value's odds of it against the rest ("West:
late 46% of the time, against 15% elsewhere: 4.85 times the odds"). Find predictors: every column
tested against a target by chi-square, ranked by strength, with the pairs that say the same thing.
Fit test and Outliers (below). Show the math on any result puts its proof on the Analyze board:
each formula with the result's own numbers, worked to the values shown. Every result can go to
Analyze, open on the Tables page, or go to the notebook as Python (
swissarmybench.stats, the same code the window ran). Regression: linear or
logistic (odds ratios), effects in words with ranges, what-if predictions, predicted and miss columns,
and the miss column for outliers of what the model cannot explain.
Time series: a metric per period from a date column, its trend, its season in words ("December
runs 31% above a typical month"), the periods that stand out (Show these rows), steps in the level and
how much one period predicts the next. Forecast: trend, season and steps carried forward with 80%
and 95% ranges, predictors each with their own future, and the miss it earns on held-back periods.
- Analyze as a report: results arrive as a readable note (with real tables) and a chart side by
side; drag cards to arrange them, edit any note, see it as letter or landscape pages, Print to PDF,
or Export markdown (one file, charts embedded as pictures, ready for an AI model). Right-click a
cell or a header to send a value, a row, a profile or distinct values; every details window has
Send to Analyze.
- Fit test and outliers (on the Analyze page): ask whether a column's values spread as expected (chi-square
against even shares, Benford's law on the first one or two digits, another open table's spread, or two
columns together), with the verdict in words and an effect size; or find the outliers in a column, by
amount (robust median fences, Tukey's quartiles or z-scores, within each vendor or month if you like)
or by frequency (a typo seen once, an amount copied forty times). Show these rows adds a step
that keeps just them; Exclude these, one that leaves them out.
- Key Finder: pick another open table (or every other one) and get the likely join columns:
each column pair that shares values, with the percent of each side's distinct values found in
the other, whether each side is unique (so which one looks like the key), and a score. Columns
whose longest value is over 128 characters are left out. Click a pair for sample shared values
and the values an inner join would drop.
- Export: CSV, delimited text, Excel or Parquet, with provenance and formula neutralization.
- Tabs, split and compare: every open table is a tab in one window (they wrap onto more rows, up
to 50). Right-click a tab for Compare with… (or drag a tab onto another) to see two side
by side; the key picker opens with the Key Finder already run and the key that is unique on both
sides ticked, and compare keeps both tables aligned row by row (outer, anti, cross, or diff: only
the rows and the columns that differ). A compare survives a reload. The ≡ button beside +
lists every table: open, closed (each with Open) and in your Python sessions.
- Analyze (on the rail): a dashboard of cards for any table: Vega-Lite charts, notes,
result tables, Mermaid diagrams, Plotly figures, and images. Every card
resizes from its corner on a 12-column grid, and what it draws fills it. Charts open large with
wheel zoom, and clicking a bar filters the table. The page loads nothing from the internet: figures
that need outside maps or pictures say so instead.
- Agent door (MCP): the agent sees what the page shows; its exports wait for the user's
Allow. Settings lists its activity and has a copyable prompt that installs the MCP in any agent.
- Connections (the Application row's Connections): your databases and files. Add one with a
form per type (SQL Server, PostgreSQL, Snowflake... 21 databases; a Power BI workspace, its datasets read with DAX;
a Dataverse environment, its tables read through the Web API and SQL on its SQL endpoint;
a CSV, workbook, Parquet or JSON file, or a folder of them; or your own Python, for anything
else), its password kept in the system keyring, Test connection before
saving. Then
conn = sab.connection("Warehouse") in any Python, or a whole SQL cell on it:
%%sql Warehouse in Jupyter or IPython.
- Blades and the catalog (its own tab, from Blades and catalog in the Application row): a blade is any
Python that reaches outside Python to load something (a database connection, a CSV or workbook,
an API, a vault). Save it once, then
conn = sab.blade("Warehouse") in any Python. Starters for
21 databases, 5 file patterns and 8 vaults; the save screen shows the packages a blade needs and
installs missing ones. A blade can fill the catalog: every schema, table and column of its
source with its type, as a searchable tree, readable by the agent so it can write SQL in the
source's own dialect.
- Jupyter and Python in the terminal are where code goes: drag a blade, table or column from the
Scripts page's Blades pane into a cell or an editor for its line, query or name.
- Themes: light, dark, high contrast light and high contrast dark, following the system by
default; Windows forced colors are supported. One zoom for the whole page, Analyze
included: Ctrl+= and Ctrl+-.
The design is Plans/swissarmybench-build-plan.md; what has
been checked against real versions is in docs/verified.md; decisions and
open notes are in docs/ideas.md.
New here? The Tour button (the question mark in the Application row) explains every word, table to
pack, by lighting up each one on the page.
Renamed from SwissArmyGrid
Swiss Army Bench was called SwissArmyGrid until this release. Everything has the new name: the package
and the wheel (swissarmybench), the import (import swissarmybench as sab), the commands
(swissarmybench, sab, swissarmybench-mcp, swissarmybench-context), the MCP server, the Claude Code
plugin and its skill (swissarmybench-use), the state folder
(~/.swissarmybench), the environment variables (SWISSARMYBENCH_*), the blade header
(# /// swissarmybench-blade) and the notebook metadata (swissarmybench).
The old names went in 0.0.32 (the owner's simplicity pass, 2026-11-21): import swissarmygrid, the
swissarmygrid, sag, swissarmygrid-mcp and swissarmygrid-context commands, the SWISSARMYGRID_*
variables, ~/.swissarmygrid (no longer moved: move it to ~/.swissarmybench by hand), the old notebook
metadata, blade header, keyring service and remembered page settings are no longer read.
The installers remove the old swissarmygrid uv tool before installing the new one; by hand, that is
uv tool uninstall swissarmygrid, then the install below. The GitHub repository is now DylanCodyBrown/SwissArmyBench (the old address redirects).