# Quickstart

Install the skopik CLI, authenticate with your organization, deploy a Worker, bind a Database, and roll back in under two minutes.

## 1. Install `skopik`

Install the CLI globally from npm or run it on demand with `npx`:

```bash
npm install -g @skopiklabs/platform
```

You can also download a standalone static binary directly from the control API without Node installed. See [CLI (`skopik`)](/docs/cli/) for all installation options.

## 2. Sign in

Authenticate with an organization API key (created in **Settings → Keys** in the console) or sign in interactively as a person:

:::tabs
::tab API key
```bash
skopik login
# Or pass it via environment variable:
export SKOPIK_API_KEY="mhk_..."
```
::tab Person sign-in
```bash
skopik login --person
```
:::

Verify your active credential at any time:

```bash
skopik whoami
```

## 3. Deploy your first Worker

Create a directory with a small Node HTTP server listening on `process.env.PORT`:

```js
// index.js
import http from 'node:http'

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'content-type': 'application/json' })
  res.end(JSON.stringify({ ok: true, path: req.url }))
})

server.listen(Number(process.env.PORT || 8080))
```

Deploy it with `skopik deploy`:

```bash
skopik deploy --worker hello --runtime node
```

Every deployment is immutable and gets its own URL, while the `production` alias moves to the new deployment:

```text
production -> dep_7f3a...  https://hello-k2x....skopik.app
```

> [!TIP]
> Pass `--check /` to wait until the new deployment responds with a status below `500` before moving the alias.

## 4. Add a Database binding

Create a `sql` database and declare it in `skopik.json` at the root of your Worker directory:

```bash
skopik create_database --name notes --type sql
```

```json
{
  "bindings": {
    "DB": { "database": "notes" }
  }
}
```

Call it from inside your Worker using `SKOPIK_BINDINGS_URL` and the required `mh-bindings: 1` header — no API key needed:

```js
const res = await fetch(`${process.env.SKOPIK_BINDINGS_URL}/databases/DB/query`, {
  method: 'POST',
  headers: { 'mh-bindings': '1', 'content-type': 'application/json' },
  body: JSON.stringify({ sql: 'SELECT 1 AS ok' }),
})
```

Redeploy to activate the new binding:

```bash
skopik deploy --worker hello --runtime node
```

## 5. Tail logs and roll back

Stream live stdout and stderr from your Worker:

```bash
skopik logs hello
```

If a deploy misbehaves, point the `production` alias back to its previous deployment immediately:

```bash
skopik rollback --worker hello
```

## Next Steps

:::cards
- [Workers & Static Sites](/docs/workers/) — Learn about Python, static binaries, static sites, memory sizing, and warm instances.
- [Connect MCP](/docs/mcp/) — Let your AI agent manage Workers, Sandboxes, and Databases directly.
:::
