> ## Documentation Index
> Fetch the complete documentation index at: https://docs.terminal3.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Running the code samples in this guide

> How to actually get a TypeScript snippet from these docs into a runnable file, without it landing in your shell instead.

Every code block on this site tells you what to write, not how to get it into a file. This page is that missing step — read it once, then every "create a file and paste this in" or "append this to the bottom of" instruction elsewhere means exactly the pattern below.

**To create a new file:**

```bash theme={null}
cat > quickstart.ts << 'EOF'
// ...the code block from the page...
EOF
```

**To append to an existing file** (most snippets past the first one — they assume `t3n`/`tenantDid`/`wasmComponent` are already in scope from earlier in the same file):

```bash theme={null}
cat >> quickstart.ts << 'EOF'
// ...the code block from the page...
EOF
```

<Warning>
  **Copy the whole block, including the `cat` line and the closing `EOF` — never just the code in between.** Pasting only the TypeScript directly at your shell prompt doesn't write a file at all; bash tries to *run* each line as a command instead. `import { T3nClient, ... }` becomes an attempt to run a program called `import`, `T3nClient,` becomes an unknown command, and every `{`/`(` produces a `syntax error near unexpected token`. If you see a wall of `command not found` / `syntax error` lines that look nothing like a TypeScript error, this is almost always what happened — nothing was written, so just redo the full block.
</Warning>

<Note>
  **The delimiter must be quoted — `<< 'EOF'`, not `<< EOF`.** TypeScript's non-null assertion operator (`process.env.T3N_API_KEY!`) contains a bare `!`, and bash's interactive history expansion treats an unquoted `!` as "repeat a previous command," failing with `-bash: !: event not found`. Quoting the delimiter turns off expansion for everything inside the block. This bites people even *inside* a correctly-shaped `cat << EOF` if the quotes were dropped — always `'EOF'`.
</Note>

<Accordion title="Alternative: turn off history expansion for the whole session">
  If you'd rather not think about quoting every time, disable the feature that causes it, once per shell session:

  ```bash theme={null}
  set +H
  ```

  After that, `<< EOF` and `<< 'EOF'` behave identically for the rest of the session, and pasting a bare `!` anywhere no longer triggers `event not found`. This doesn't fix the separate "pasted at the prompt instead of into a heredoc" mistake above — only quoting (or a heredoc at all) does that.
</Accordion>

Before running anything, it's worth a quick sanity check that the file actually contains what you think it does — especially after a paste that might have gone wrong:

```bash theme={null}
tail -20 quickstart.ts
```

Then run it the same way every page in this guide expects:

```bash theme={null}
npx tsx quickstart.ts
```
