diff --git a/README.md b/README.md
index 09b1a2a..7bfb928 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,8 @@ content/docs/
The navigation validation tests run with `pnpm test`. They verify tool roots, declared pages, and document frontmatter.
+Use [native Fumadocs code tabs](https://www.fumadocs.dev/docs/next/markdown#tab-groups) for interchangeable examples. Give consecutive fences a `tab="..."` label and set `tab-group="package-manager"` on the first fence of each npm/pnpm/Yarn installation group so the selected manager is shared and remembered. Keep sequential commands, inputs and outputs in separate blocks.
+
## Interactive Throughline examples
Selected Throughline guides render the published `@0xbuff/throughline@0.0.2` React player. The overview leads with a multi-system checkout recovery trace; introductory pages retain smaller teaching examples. Sources are kept in `src/lib/throughline-demos.ts`; MDX pages use ``. The component is registered in `src/components/mdx.tsx`. Its compiler, player and namespaced CSS load in a separate module only when a demo is rendered. All other 0xBUFF tool documentation remains independent of Throughline.
diff --git a/content/docs/assay/getting-started.mdx b/content/docs/assay/getting-started.mdx
index 689e32b..7acb3a2 100644
--- a/content/docs/assay/getting-started.mdx
+++ b/content/docs/assay/getting-started.mdx
@@ -9,15 +9,15 @@ This guide takes you from installation to a working text comparison.
Assay requires Node.js 24 or later and ECMAScript modules (ESM). TypeScript declarations are included.
-```sh
+```sh tab="npm" tab-group="package-manager"
npm install @0xbuff/assay
```
-```sh
+```sh tab="pnpm"
pnpm add @0xbuff/assay
```
-```sh
+```sh tab="yarn"
yarn add @0xbuff/assay
```
diff --git a/content/docs/assay/observations.mdx b/content/docs/assay/observations.mdx
index 01e8701..19443ae 100644
--- a/content/docs/assay/observations.mdx
+++ b/content/docs/assay/observations.mdx
@@ -228,9 +228,17 @@ The review observation must bind to the bundle's artifact digest and match the p
}
```
-For model attribution, use:
+Choose the reviewer field for the source of the feedback:
-```ts
+```ts tab="Human"
+reviewer: {
+ kind: "human",
+ reviewerId: "reviewer-1",
+ reviewerVersion: "v1",
+}
+```
+
+```ts tab="Model"
reviewer: {
kind: "model",
providerId: "provider",
diff --git a/content/docs/throughline/compatibility.mdx b/content/docs/throughline/compatibility.mdx
index 704c012..e79d9a3 100644
--- a/content/docs/throughline/compatibility.mdx
+++ b/content/docs/throughline/compatibility.mdx
@@ -9,16 +9,32 @@ These guides describe **`@0xbuff/throughline@0.0.2`**, published November 8, 202
## Installation and requirements
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/throughline@0.0.2
~~~
+~~~sh tab="pnpm"
+pnpm add @0xbuff/throughline@0.0.2
+~~~
+
+~~~sh tab="yarn"
+yarn add @0xbuff/throughline@0.0.2
+~~~
+
For the optional React player:
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install react@^19 react-dom@^19
~~~
+~~~sh tab="pnpm"
+pnpm add react@^19 react-dom@^19
+~~~
+
+~~~sh tab="yarn"
+yarn add react@^19 react-dom@^19
+~~~
+
| Requirement | v0.0.2 support |
| --- | --- |
| Node.js | **24 or newer** for Node-hosted tooling |
diff --git a/content/docs/throughline/getting-started.mdx b/content/docs/throughline/getting-started.mdx
index f8bab39..52b4219 100644
--- a/content/docs/throughline/getting-started.mdx
+++ b/content/docs/throughline/getting-started.mdx
@@ -13,10 +13,18 @@ Use an ESM project and **Node.js 24 or newer** for Node-based execution. React i
## 1. Install Throughline
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/throughline@0.0.2
~~~
+~~~sh tab="pnpm"
+pnpm add @0xbuff/throughline@0.0.2
+~~~
+
+~~~sh tab="yarn"
+yarn add @0xbuff/throughline@0.0.2
+~~~
+
Keep this exact version and commit your package lockfile so the examples match the installed API.
## 2. Compile a trace
@@ -70,10 +78,18 @@ The code above and this player describe the same sequence of states. Use **Next*
Install React 19 and React DOM 19 if your project does not already include them:
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install react@^19 react-dom@^19
~~~
+~~~sh tab="pnpm"
+pnpm add react@^19 react-dom@^19
+~~~
+
+~~~sh tab="yarn"
+yarn add react@^19 react-dom@^19
+~~~
+
Import the player and its CSS. In an application, import the stylesheet once in your root entry.
~~~tsx
diff --git a/content/docs/throughline/index.mdx b/content/docs/throughline/index.mdx
index 9628c50..8053075 100644
--- a/content/docs/throughline/index.mdx
+++ b/content/docs/throughline/index.mdx
@@ -20,10 +20,18 @@ This checkout scenario follows a lost provider reply, an unknown payment outcome
Install the package:
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/throughline@0.0.2
~~~
+~~~sh tab="pnpm"
+pnpm add @0xbuff/throughline@0.0.2
+~~~
+
+~~~sh tab="yarn"
+yarn add @0xbuff/throughline@0.0.2
+~~~
+
Compile a trace:
~~~ts
diff --git a/content/docs/throughline/markdown-mdx.mdx b/content/docs/throughline/markdown-mdx.mdx
index b97ee9a..b84a4bc 100644
--- a/content/docs/throughline/markdown-mdx.mdx
+++ b/content/docs/throughline/markdown-mdx.mdx
@@ -116,10 +116,18 @@ export function remarkValidateThroughline() {
Install the remark visitor and types if needed:
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install -D unist-util-visit @types/mdast
~~~
+~~~sh tab="pnpm"
+pnpm add -D unist-util-visit @types/mdast
+~~~
+
+~~~sh tab="yarn"
+yarn add -D unist-util-visit @types/mdast
+~~~
+
Then register the validator in your existing Fumadocs MDX options; **preserve the other plugins**:
~~~ts
diff --git a/content/docs/throughline/react-player.mdx b/content/docs/throughline/react-player.mdx
index dd1f21b..817e00e 100644
--- a/content/docs/throughline/react-player.mdx
+++ b/content/docs/throughline/react-player.mdx
@@ -9,10 +9,18 @@ description: Render compiled traces with controls, captions, keyboard navigation
## Install and render
-~~~sh
+~~~sh tab="npm" tab-group="package-manager"
npm install @0xbuff/throughline@0.0.2 react@^19 react-dom@^19
~~~
+~~~sh tab="pnpm"
+pnpm add @0xbuff/throughline@0.0.2 react@^19 react-dom@^19
+~~~
+
+~~~sh tab="yarn"
+yarn add @0xbuff/throughline@0.0.2 react@^19 react-dom@^19
+~~~
+
~~~tsx
import { compile } from "@0xbuff/throughline";
import { ThroughlinePlayer } from "@0xbuff/throughline/react";
diff --git a/content/docs/throughline/styling.mdx b/content/docs/throughline/styling.mdx
index a318f16..dfb6251 100644
--- a/content/docs/throughline/styling.mdx
+++ b/content/docs/throughline/styling.mdx
@@ -17,9 +17,15 @@ Load it once, usually in your application entry or root stylesheet. The compiler
## Set the theme
-~~~tsx
+~~~tsx tab="System"
+~~~
+
+~~~tsx tab="Light"
+~~~
+
+~~~tsx tab="Dark"
~~~
diff --git a/scripts/code-tabs.test.mjs b/scripts/code-tabs.test.mjs
new file mode 100644
index 0000000..f2a944f
--- /dev/null
+++ b/scripts/code-tabs.test.mjs
@@ -0,0 +1,70 @@
+import assert from "node:assert/strict";
+import { readFile, readdir } from "node:fs/promises";
+import { join } from "node:path";
+import test from "node:test";
+
+const root = "content/docs";
+const expected = new Map([
+ ["assay/getting-started.mdx", ["@0xbuff/assay"]],
+ ["throughline/getting-started.mdx", ["@0xbuff/throughline@0.0.2", "react@^19 react-dom@^19"]],
+ ["throughline/index.mdx", ["@0xbuff/throughline@0.0.2"]],
+ ["throughline/compatibility.mdx", ["@0xbuff/throughline@0.0.2", "react@^19 react-dom@^19"]],
+ ["throughline/react-player.mdx", ["@0xbuff/throughline@0.0.2 react@^19 react-dom@^19"]],
+ ["throughline/markdown-mdx.mdx", ["-D unist-util-visit @types/mdast"]],
+]);
+
+function fences(source) {
+ return [...source.matchAll(/^(\x60{3}|~{3})([^\n]*)\n([\s\S]*?)^\1[ \t]*$/gm)]
+ .map((match) => ({ meta: match[2], body: match[3].trim(), start: match.index, end: match.index + match[0].length }));
+}
+
+test("package installation alternatives are adjacent native code tabs", async () => {
+ const seen = new Set();
+ for (const product of await readdir(root, { withFileTypes: true })) {
+ if (!product.isDirectory()) continue;
+ for (const file of await readdir(join(root, product.name))) {
+ if (!file.endsWith(".mdx")) continue;
+ const name = product.name + "/" + file;
+ const source = await readFile(join(root, name), "utf8");
+ const blocks = fences(source);
+ const found = [];
+ for (let i = 0; i < blocks.length; i++) {
+ const first = blocks[i];
+ const match = first.body.match(/^npm install (.+)$/);
+ if (!/^sh(?:\s|$)/.test(first.meta) || !match) {
+ if (/^sh(?:\s|$)/.test(first.meta)) assert.doesNotMatch(first.body, /^(?:pnpm add|yarn add) /, name + ": orphan package tab");
+ continue;
+ }
+ const args = match[1];
+ const pnpm = blocks[i + 1];
+ const yarn = blocks[i + 2];
+ assert.equal(first.meta, 'sh tab="npm" tab-group="package-manager"', name);
+ assert.equal(pnpm?.meta, 'sh tab="pnpm"', name);
+ assert.equal(yarn?.meta, 'sh tab="yarn"', name);
+ assert.equal(pnpm.body, "pnpm add " + args, name);
+ assert.equal(yarn.body, "yarn add " + args, name);
+ assert.match(source.slice(first.end, pnpm.start), /^\s*$/, name);
+ assert.match(source.slice(pnpm.end, yarn.start), /^\s*$/, name);
+ found.push(args);
+ i += 2;
+ }
+ assert.deepEqual(found, expected.get(name) ?? [], name);
+ if (found.length) seen.add(name);
+ }
+ }
+ assert.deepEqual([...seen].sort(), [...expected.keys()].sort());
+});
+
+test("reviewer and player theme alternatives are native tab groups", async () => {
+ for (const [path, labels] of [
+ ["assay/observations.mdx", ["Human", "Model"]],
+ ["throughline/styling.mdx", ["System", "Light", "Dark"]],
+ ]) {
+ const source = await readFile(join(root, path), "utf8");
+ const blocks = fences(source).filter((block) => /\btab="/.test(block.meta));
+ assert.deepEqual(blocks.map((block) => block.meta.match(/\btab="([^"]+)"/)?.[1]), labels);
+ for (let i = 1; i < blocks.length; i++) {
+ assert.match(source.slice(blocks[i - 1].end, blocks[i].start), /^\s*$/, path);
+ }
+ }
+});