# CLI (skopik)

Install and use the skopik command-line tool to deploy Workers, tail logs, roll back releases, and invoke every MCP tool from your terminal.

`skopik` is Skopik Platform's single command-line tool. It talks exclusively to the control API: `/v1` routes for dedicated commands (`login`, `logout`, `whoami`, `deploy`, `rollback`, `logs`), and `/mcp` for every other platform operation.

## Installation

:::tabs
::tab npm
```bash
npm install -g @skopiklabs/platform
# Or run without installing:
npx @skopiklabs/platform --help
```
::tab Direct binary
```bash
# Linux x86_64
curl -fsSL https://api.platform.skopik.com/cli/x86_64-unknown-linux-musl/skopik -o skopik
chmod +x skopik

# macOS Apple Silicon
curl -fsSL https://api.platform.skopik.com/cli/aarch64-apple-darwin/skopik -o skopik
chmod +x skopik
```
:::

## Authentication & Environment Variables

`skopik login` prompts for an org API key and stores it locally. Use `skopik login --person` to sign in through the console as a user (required for managing org members, invites, and resource transfers).

| Variable | Description |
| --- | --- |
| `SKOPIK_API_KEY` | Overrides the stored API key for the current command. |
| `SKOPIK_API_URL` | Overrides the control API base URL (defaults to `https://api.platform.skopik.com`). |

> [!NOTE]
> Pass `--json` on any command to print the raw API JSON response instead of a formatted table — useful for scripts and CI pipelines.

## Core Commands

| Command | Purpose |
| --- | --- |
| `skopik login [--person] [--org ID] [--api-url URL]` | Store an org API key or start browser-approved person sign-in. |
| `skopik logout` | Clear stored credentials and end a person session. |
| `skopik whoami` | Display the active key or signed-in person and organizations. |
| `skopik deploy [options]` | Pack a directory, upload a deployment, and move an alias. |
| `skopik rollback [--worker NAME] [--alias ALIAS]` | Point an alias back to its previous deployment. |
| `skopik logs <worker> [--deployment ID]` | Stream live logs from a Worker until interrupted. |
| `skopik logs <worker> --since 2h [--until 1h] [--level error,warn] [--grep TEXT]` | Print the Worker's stored lines from then on, oldest first, then stream live. `--since` and `--until` take a duration back from now (`30m`, `2h`, `3d`) or an RFC 3339 time; `--until` ends there and does not stream. Lines are kept 7 days. |
| `skopik tools` | List every control API operation exposed as a CLI subcommand. |

## `skopik deploy` Flags

```bash
skopik deploy \
  --dir ./app \
  --worker api \
  --runtime node \
  --workspace payments \
  --alias production \
  --check /health
```

| Flag | Description |
| --- | --- |
| `--dir <path>` | Directory to pack (defaults to `.`). |
| `--worker <name>` | Target Worker name (created if missing; defaults to directory name). |
| `--runtime <runtime>` | `node`, `python`, `binary`, or `static` (defaults to `node`). |
| `--workspace <id-or-name>` | Assign the Worker to a Workspace, or `none` to unassign. |
| `--service <name>` / `--all` | Deploy one or all services defined in a root `skopik.json` (`--no-build` skips build commands). |
| `--alias <name>` | Alias to move (defaults to `production`). |
| `--branch <name>` | Map a git branch to `production` (if default branch) or a sanitized preview alias. |
| `--dry-run` | List the files that would be bundled without uploading. |
| `--check <path>` | Poll the new deployment URL until status `< 500` (up to 60s) before moving the alias. |

## Calling Any Platform Operation

Every MCP tool is automatically available as a `skopik` subcommand, either by its tool name or in `<noun> <verb>` form:

```bash
skopik list_workers
skopik create_queue --name jobs --worker api
skopik queues create --name jobs --worker api
skopik create_sandbox --help
```
