# CLI

Build and run Wisp projects from your terminal — describe a project, work on the current one, pull code, push changes, publish and follow logs.

The `wisp` command line tool lets you build with Wisp's assistant from your terminal, and keep a local folder in sync with a project so you can edit with your own editor and tools.

## Install and sign in

```bash
npm install -g wispfn     # or run it with: npx wispfn
wisp login                # opens your browser to sign in
```

`wisp login` shows a short code and opens your browser. Check that the code matches, choose a workspace and press **Authorize** — the CLI receives an API key and saves it. Nothing to copy or paste.

- On a remote machine or over SSH, use `wisp login --no-browser` and open the printed link on any device.
- The CLI's key appears in **Settings → API keys** as "CLI · <your machine>"; revoke it there any time.
- In CI, skip the browser: create a key in Settings → API keys and pass it with `wisp login --key wisp_sk_…`, or set `WISP_API_KEY`.

## Build from the terminal

Describe what you want, in quotes:

```text
$ wisp new "currency converter using a public exchange-rate API"
✓ new project · now the current project
› thinking…
› project named "FX API"
+ created  GET /convert  convert.js · 38 lines
✓ tested   /convert → 200
✓ draft v1 deployed

  Created GET /convert. Try it: curl "https://fx-api.fn.wispfn.com/convert?test&from=USD&to=EUR&amount=10"

→ draft: https://fx-api.fn.wispfn.com/convert?test
→ "wisp publish" makes draft v1 live at https://fx-api.fn.wispfn.com

$ wisp publish
✓ published v1 → live  fx-api.fn.wispfn.com
```

Then keep going in plain words — each request changes the **current project**:

```bash
wisp "add api-key auth to every function"
wisp "cache /convert for 10 minutes"
```

- `wisp new "<description>"` creates a project, builds it with Wisp's assistant and makes it the current project. Add `--language python` (it asks in a terminal otherwise) or `--name N`. Without a description it creates an empty project.
- `wisp "<request>"` sends a request to the current project, or starts a new project when there is none. Single words are treated as commands, so a typo never reaches the assistant.
- When Wisp needs a secret, such as an API key for a third-party service, the CLI asks for it with hidden input, stores it encrypted, and continues. Values never pass through the assistant.
- Each request uses [AI credits](/plans-and-credits#ai-credits), like a chat message.

## The current project

Commands act on the **current project** unless you say otherwise. The CLI picks it in this order:

1. `--project <id|address|name>` on the command.
2. The project linked to the folder you're in (its `wisp.json`).
3. The project you last created with `wisp new`, linked with `wisp init` or picked with `wisp use`.

```bash
wisp use                  # show the current project
wisp use order-status     # switch to another project (id, address or name)
wisp projects             # list projects; ● marks the current one
```

The `WISP_PROJECT` environment variable overrides the saved current project.

## Link a folder

```bash
mkdir fx-api && cd fx-api
wisp init                 # links the current project and pulls its code
wisp dev                  # push on every save, follow the log
```

`wisp init <project>` links a specific project instead; with no current project, `wisp init --name my-api` creates one. `wisp init` and `wisp pull` write the project like this:

```text
wisp.json          project id and functions (http, method, visibility, mcp, schedule, cache, schemas…)
functions/*.js|py  one file per function; before.js / after.js run around every HTTP function
lib/*.js|py        library modules
```

## Everyday commands

| Command | What it does |
| --- | --- |
| `wisp new ["<description>"] [--name N] [--language L]` | Start a project, built from the description, and make it current |
| `wisp "<request>"` | Ask Wisp to build or change the current project |
| `wisp use [<project>]` | Show or switch the current project |
| `wisp dev` | Push on every save and follow the invocation log |
| `wisp status` | Show what `push` would send |
| `wisp push [--prune] [--publish]` | Send local changes as a new draft (`--prune` deletes what you removed) |
| `wisp pull [--force]` | Refresh local files from the draft |
| `wisp publish [<version>]` | Publish the draft, or roll back to a version |
| `wisp versions` | Version history |
| `wisp invoke <function> [--live] [-X METHOD] [-p /sub] [-q k=v] [-H 'k: v'] [-d body \| -d @file]` | Call an function (the draft by default; private ones too) |
| `wisp logs [-n 50] [-f] [-e function] [--live\|--test] [--errors] [--grep text]` | Read or follow the log |
| `wisp config` | List variables and secrets |
| `wisp config set NAME value [--secret] [--description D]` | Set a variable or secret |
| `wisp config rm NAME` | Delete one |
| `wisp purge [<function>]` | Clear the edge cache |
| `wisp projects [--json]` | List projects |
| `wisp clone [--name N]` | Copy the project |
| `wisp open` | Open the project in the browser |
| `wisp whoami` / `wisp logout` | Account |

Add `--project <id|address|name>` to any command to target another project, and `--json` for machine-readable output.

## Pull never overwrites your work

`wisp pull` remembers what it last wrote. If you changed a file locally since, it stops instead of overwriting it; use `--force` to replace your local copy.

## In CI

```yaml
- run: npx wispfn push --publish
  env:
    WISP_API_KEY: ${{ secrets.WISP_API_KEY }}
```

Give the CI key only the scopes it needs (`projects:read`, `functions:write` and `projects:deploy`).
