> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# sw-tsdocs

> Read the SDK's version-matched documentation, API signatures, and examples from the installed package.

[ref-swaig-test]: /docs/server-sdks/reference/typescript/agents/cli/swaig-test

The `sw-tsdocs` command prints the documentation that ships inside the
`@signalwire/sdk` package: concept guides, API signatures read from the
package's type declarations, examples, and tutorials. Because it reads the
installed package, its answers match the SDK version you have. People and
coding agents can both use it to look up an API without leaving the terminal.

```bash
npx sw-tsdocs [<topic> [name] | <command> ...]
```

Run it in a project that depends on `@signalwire/sdk`. With no arguments it
prints an index of what the SDK does and where to start.

## Commands

| Command                       | Purpose                                                    |
| ----------------------------- | ---------------------------------------------------------- |
| `sw-tsdocs`                   | The index: what the SDK does and where to start            |
| `sw-tsdocs <topic>`           | One area: concepts, files to read, examples, and API names |
| `sw-tsdocs topics`            | Every topic, one line each                                 |
| `sw-tsdocs api <name>`        | Signature, JSDoc, and members of an SDK name               |
| `sw-tsdocs examples [filter]` | Examples with descriptions and paths                       |
| `sw-tsdocs grep <regex>`      | Search the installed docs and examples                     |
| `sw-tsdocs show <file>`       | Print an installed doc                                     |
| `sw-tsdocs path [file]`       | Where the docs are, or one file's full path                |
| `sw-tsdocs init`              | Add a note about `sw-tsdocs` to the project's `AGENTS.md`  |
| `sw-tsdocs help`              | Print the usage text (`-h` and `--help` work too)          |
| `sw-tsdocs --version`         | The installed SDK version (`-V` works too)                 |

A word that isn't a topic or command is tried as an SDK name, then as a doc
name, and is treated as `api <name>` or `show <name>` when it matches.

## Topics

`sw-tsdocs <topic>` prints the topic's concepts, the installed docs to read,
related examples, and the API names to look up next. The topics are:

| Group                 | Topics                                                                                                     |
| --------------------- | ---------------------------------------------------------------------------------------------------------- |
| Build AI agents       | `quickstart`, `agents`, `prompts`, `tools`, `datamap`, `contexts`, `skills`, `prefabs`, `pgi`, `tutorials` |
| Call control and APIs | `swml`, `relay`, `rest`                                                                                    |
| Integrations          | `livewire`, `mcp`, `chat`, `bedrock`                                                                       |
| Run and test          | `deploy`, `security`, `config`, `testing`, `cli`                                                           |

**`topic`** `string`

One of the topic names above.

---

**`name`** `string`

Optional, and read only by the `skills` topic: a built-in skill name, such
as `weather_api`, to print that skill's description and parameters.

---

## Parameters

### api

```bash
npx sw-tsdocs api <name>
```

**`name`** `string` — required

An SDK class, function, or member, such as `AgentBase` or
`FunctionResult.connect`. Prints the source location, the signature, and the
JSDoc. When several names match, the first is printed and the rest are listed
under "Other matches". Exits `1` when no name matches, and suggests similar
names.

---

### examples

```bash
npx sw-tsdocs examples [filter]
```

**`filter`** `string`

Optional text that narrows the list of examples.

---

### grep

```bash
npx sw-tsdocs grep <regex> [--code] [--limit N]
```

**`regex`** `string` — required

A case-insensitive regular expression, searched across the installed docs
and examples. Exits `1` when nothing matches.

---

**`--code`** `flag`

Search the SDK's code as well.

---

**`--limit`** `integer` — default: 100

The most matches to print. Must be `1` or more.

---

### show

```bash
npx sw-tsdocs show <file> [--toc | --section <heading>]
```

**`file`** `string` — required

An installed doc. A partial name works when it matches one file; when it
matches several, the command lists them and exits `1`.

---

**`--toc`** `flag`

Print the doc's headings with line numbers instead of its text. Cannot be
combined with `--section`.

---

**`--section`** `string`

Print only the section whose heading contains this text.

---

### path

```bash
npx sw-tsdocs path [file]
```

**`file`** `string`

Optional. Without it, prints the directory the documentation is installed
in. With it, prints the full path of each matching file.

---

### tutorials

```bash
npx sw-tsdocs tutorials
```

The `tutorials` topic lists the three tutorials that ship with the package and
the lesson files to read: a voice agent that answers questions from Wikipedia,
a reservation line built with Programmatically Governed Inference, and a
multi-agent sales tutorial. Print a lesson with `sw-tsdocs show <file>`.

### init

```bash
npx sw-tsdocs init [--dir <project>] [--skill] [--print]
```

Adds a note to the project that tells coding agents to use `sw-tsdocs` before
writing SignalWire code. The note covers running `sw-tsdocs`, checking
signatures with `sw-tsdocs api`, reading the `pgi` topic before building an
agent that takes real actions, and testing with [`swaig-test`][ref-swaig-test].

**`--dir`** `string` — default: .

The project directory. It must exist, or the command exits `2`.

---

**`--skill`** `flag`

Also write an Agent Skills `SKILL.md`.

---

**`--print`** `flag`

Print the note to standard output and write nothing.

---

`init` writes these files, each reported as `created`, `updated`, or
`unchanged`:

| File                                                | When                                                                                                                                                                                                                    |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AGENTS.md`                                         | Always. The note sits between `<!-- @signalwire/sdk: begin -->` and `<!-- @signalwire/sdk: end -->` markers, so running `init` again updates it in place. A new file starts with a `# Notes for coding agents` heading. |
| `CLAUDE.md`                                         | Only when the file already exists and doesn't import `@AGENTS.md`.                                                                                                                                                      |
| `.agents/skills/signalwire-sdk-typescript/SKILL.md` | With `--skill`.                                                                                                                                                                                                         |
| `.claude/skills/signalwire-sdk-typescript/SKILL.md` | With `--skill`.                                                                                                                                                                                                         |

## Examples

```bash
# Index of the SDK
npx sw-tsdocs

# Print the installed SDK version
npx sw-tsdocs --version
```

```bash
# One area, then a built-in skill's parameters
npx sw-tsdocs contexts
npx sw-tsdocs skills weather_api

# Look up an API
npx sw-tsdocs api FunctionResult.connect
```

```text
# method FunctionResult.connect

Source: /path/to/project/node_modules/@signalwire/sdk/dist/FunctionResult.d.ts:198

connect(destination: string, final?: boolean, fromAddr?: string): this

Connect the call to another destination with an inline SWML `connect`
document, emitted with `transfer: "true"` or `"false"` beside it.
...
```

```bash
# Find examples and search the docs
npx sw-tsdocs examples simple
npx sw-tsdocs grep 'swaig-test' --limit 5

# Read part of a doc
npx sw-tsdocs show cli-guide --toc
npx sw-tsdocs show cli-guide --section "Running It"

# Add the note to AGENTS.md and write skill files
npx sw-tsdocs init --skill
```

```text
created: /path/to/project/AGENTS.md
created: /path/to/project/.agents/skills/signalwire-sdk-typescript/SKILL.md
created: /path/to/project/.claude/skills/signalwire-sdk-typescript/SKILL.md
```

## Exit codes

| Code | Meaning                                                                                               |
| ---- | ----------------------------------------------------------------------------------------------------- |
| `0`  | Success                                                                                               |
| `1`  | A name, doc, or search pattern wasn't found, or a doc name matched several files                      |
| `2`  | Usage error: an unknown option or word, a missing argument, or a project directory that doesn't exist |