# CLI only

## 1. Install the CLI

**npm**

```bash
npm install -g swytchcode
```

**Windows**

```powershell
irm https://cli.swytchcode.com/install.ps1 | iex
```

**macOS / Linux**

```bash
curl -fsSL https://cli.swytchcode.com/install.sh | sh
```

Use `swy` as a shorter alias for `swytchcode`.

## 2. Initialize Swytchcode in your project

Run:

```bash
swy init
```

This creates `.swytchcode/` and writes `tooling.json`, the file that tracks which integrations and tools your project trusts. It starts empty - the next steps fetch an integration and enable a tool from it.

## 3. Find and download an integration

To find and download an integration, run:

```bash
swy search github
swy get github
```

`swy search` looks up matching integrations in the remote registry, and `swy get github` downloads the GitHub integration bundle into `.swytchcode/integrations/`. This only fetches the bundle to disk - it doesn't touch `tooling.json` or enable anything yet.

Browse the full, up-to-date list of supported APIs at [swytchcode.com/apis](https://www.swytchcode.com/apis).

## 4. Enable a tool

```bash
swy add github.issues.create
```

This is shorthand for `swy add method github.issues.create`: it resolves the method from the bundle you just fetched into a concrete input/output schema and writes it into `tooling.json.tools` - the trust boundary that determines which tools can actually be executed.

## 5. Connect GitHub

When you want the CLI to access GitHub, run:

```bash
swy auth connect github
```

A browser window will open. Authorize GitHub.

You can verify the connection with:

```bash
swy auth status
```

## 6. Execute the tool

```bash
swy exec github.issues.create \
--repo my-org/my-repo \
--title "Login page bug"
```

Swytchcode validates the inputs against the tool's schema, then makes the request and returns a structured response. This is the same execution path used by MCP clients and runtime SDKs, so anything you `exec` here behaves identically wherever it's called from.

## Useful commands for working from the terminal

Since you're driving everything from the CLI directly, these are the commands you'll reach for most once the basics above are working - for exploring what's available, inspecting a tool before you run it, and checking on a project's health.

| Command | What it does |
|---------|--------------|
| `swy list methods` | List every method available from the integrations you've downloaded - useful for browsing what a bundle actually exposes before enabling anything. |
| `swy list tooling` | List only the tools currently enabled in `tooling.json` - what your project can actually execute right now. |
| `swy info <canonical_id>` | Show a tool's full input/output schema before you call it, e.g. `swy info github.issues.create`. |
| `swy discover " "` | Find a tool by describing what you want in plain English instead of guessing the canonical ID, e.g. `swy discover "create a github issue"`. |
| `swy exec <canonical_id> --dry-run` | Validate inputs and preview a call without sending the actual API request. |
| `swy audit stats` | See your local execution history - total runs, success rate, last run. |
| `swy doctor` | Diagnose your project - tooling, downloaded bundles, auth, and permissions. |

This is a small slice of the CLI surface. For every command, flag, and exit code, see the [CLI Reference](/reference/commands/).

## Where to go next

- [GitHub Issue Integration](https://github.com/swytchcodehq/swytchcode-examples/tree/main/github-issue-integration) - Dynamically raises GitHub issues using the Swytchcode CLI and Node SDK — ideal as an automation building block.
- [Stripe Subscriptions](https://github.com/swytchcodehq/swytchcode-examples/tree/main/Stripe-Subscriptions) - Subscription lifecycle modules for Stripe's webhook edge cases — payment recovery, cancellations, and upgrades.
- [CLI Overview](https://docs.swytchcode.com/cli/overview/) - Understand how the Swytchcode CLI works, its core concepts, and how it manages projects, integrations, authentication, and execution.
- [CLI Reference](https://docs.swytchcode.com/reference/commands/) - Explore every CLI command, available flags, and usage examples.
- [MCP Setup](https://docs.swytchcode.com/cli/mcp/) - Connect Swytchcode to AI coding assistants like Cursor, Claude Code, VS Code, and OpenClaw using the built-in MCP server.
