# CLI Overview

The Swytchcode CLI is the primary interface between your AI agent and real-world APIs. It provides a consistent way to discover integrations, configure your project, and execute API requests safely.

Whether you're using Cursor, Claude Code, Windsurf, Codex, or building your own AI application, every execution eventually passes through the CLI.

Instead of allowing an AI model to generate raw HTTP requests, Swytchcode routes every request through the CLI, where it can be validated, authenticated, and executed according to your project's configuration.

---

## Why use the CLI?

Large language models are designed to reason about tasks, not to interact directly with production APIs.

The CLI acts as the execution layer between your AI agent and external services.

It is responsible for:

- Initializing Swytchcode inside a project
- Discovering available integrations
- Downloading API definitions
- Managing the tools available to AI agents
- Validating request inputs
- Applying project policies
- Handling authentication
- Executing API requests
- Returning structured responses

Because every request passes through the same execution path, developers get consistent behavior across editors, AI frameworks, and runtime SDKs.

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

---

## How the CLI fits into your workflow

Most projects follow the same lifecycle.

```text
Install CLI
│
▼
Initialize Project
│
▼
Fetch Integrations
│
▼
Enable Tools
│
▼
Inspect Tool
│
▼
Execute
```

Each step builds on the previous one.

You initialize a project, install the integrations you need, enable the tools your AI agent is allowed to use, and then execute those tools whenever your application or coding assistant requests them.

---

## What the CLI creates

When you initialize a project, Swytchcode creates a local project directory that stores everything required for execution.

```text
.swytchcode/
├── tooling.json
├── integrations/
│ ├── manifest.json
│ └── ...
└── policies.json (optional)
```

These files define:

- which integrations are installed
- which tools are available
- which environment is active
- what policies should be enforced

You normally won't edit every file manually, but understanding their purpose makes it much easier to debug and customize your project.

---

## Core CLI workflow

Although Swytchcode includes many commands, most developers use the same workflow every day.

### 1. Initialize a project

Create the local Swytchcode project.

```bash
swy init
```

---

### 2. Fetch integrations

Download the API definitions you want to use.

```bash
swy get github
```

---

### 3. Enable tools

Allow specific methods or workflows inside your project.

```bash
swy add github.pull_request.list
```

---

### 4. Inspect a tool

View the inputs and schema before execution.

```bash
swy info github.pull_request.list
```

---

### 5. Execute

Run the tool through the Swytchcode execution layer.

```bash
swy exec github.pull_request.list
```

---

## How execution works

Every execution follows the same lifecycle.

```text
CLI Request
│
▼
Resolve Tool
│
▼
Validate Input
│
▼
Evaluate Policies
│
▼
Authenticate
│
▼
Execute API
│
▼
Return Response
```

This flow is identical whether the request comes from Cursor, Claude Code, OpenAI SDK, LangGraph, CrewAI, or another supported integration.

---

## CLI command groups

The CLI contains several categories of commands.

| Category | Purpose |
|----------|---------|
| Project | Initialize and manage a Swytchcode project |
| Authentication | Sign in and manage connected integrations |
| Integrations | Search for and download API integrations |
| Tools | Enable, inspect, and discover available tools |
| Execution | Execute methods and workflows |
| MCP | Connect AI editors and coding assistants |
| Diagnostics | Verify project health and troubleshoot issues |

Each category has its own documentation with examples and reference material.

---

## When should you use the CLI?

Use the CLI whenever you want to:

- Connect an AI coding assistant to production APIs
- Execute tools from the terminal
- Configure project permissions
- Manage API integrations
- Inspect tool schemas
- Run an MCP server
- Debug execution issues

Even if you're building a custom AI application with the JavaScript or Python Runtime SDK, the CLI remains the underlying execution engine.

---

## Next Steps

- [Authentication](https://docs.swytchcode.com/cli/authentication/) - Connect your Swytchcode account and securely manage provider credentials.
- [Projects](https://docs.swytchcode.com/cli/projects/) - Learn how to initialize and configure Swytchcode projects.
- [Execute Tools](https://docs.swytchcode.com/cli/exec/) - Understand how tool execution, policies, and authentication work together.
- [MCP Server](https://docs.swytchcode.com/cli/mcp/) - Expose your trusted tools to AI coding assistants.
- [CLI Reference](https://docs.swytchcode.com/reference/commands/) - Browse all available CLI commands and options.
