Skip to navigation

sw-tsdocs

View as MarkdownOpen in Claude

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.

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

CommandPurpose
sw-tsdocsThe index: what the SDK does and where to start
sw-tsdocs <topic>One area: concepts, files to read, examples, and API names
sw-tsdocs topicsEvery 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 initAdd a note about sw-tsdocs to the project’s AGENTS.md
sw-tsdocs helpPrint the usage text (-h and --help work too)
sw-tsdocs --versionThe 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:

GroupTopics
Build AI agentsquickstart, agents, prompts, tools, datamap, contexts, skills, prefabs, pgi, tutorials
Call control and APIsswml, relay, rest
Integrationslivewire, mcp, chat, bedrock
Run and testdeploy, 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

npx sw-tsdocs api <name>
name
stringRequired

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

npx sw-tsdocs examples [filter]
filter
string

Optional text that narrows the list of examples.

grep

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

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
integerDefaults to 100

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

show

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

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

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

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

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.

--dir
stringDefaults to .

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:

FileWhen
AGENTS.mdAlways. 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.mdOnly when the file already exists and doesn’t import @AGENTS.md.
.agents/skills/signalwire-sdk-typescript/SKILL.mdWith --skill.
.claude/skills/signalwire-sdk-typescript/SKILL.mdWith --skill.

Examples

# Index of the SDK
npx sw-tsdocs
# Print the installed SDK version
npx sw-tsdocs --version
# 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
# 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.
...
# 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
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

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