# Deploy from CLI

The CLI pushes your local project to a preview, then deploys it to an environment, in a terminal or in [CI](/docs/concepts/project-lifecycle.md#git-and-cicd).

## Before you start

You need a project on your machine, pulled from Studio or made with `npm create veryfront`. See [Work locally](/docs/projects/local.md).

## Deploy from the terminal

**Code**

1. If the project isn't on Veryfront yet, create it and publish its preview. `up` links or creates the project and pushes `main`:

```bash
npx veryfront up
```

2. After you change files, update the preview:

```bash
npx veryfront push
```

3. Deploy to an environment:

```bash
npx veryfront deploy --env staging
```

4. Read the output. You should now see `Deployed … to staging` and the release's version.

In CI there is no browser to sign in with: set `VERYFRONT_API_KEY` to an [API key](/docs/authentication/api-keys.md) and run the same commands. `deploy` without `--env` targets production.

## With MCP

`my-project` stands for the project's slug, `projectSlug` in the folder's `.veryfront/project.json`.

1. Call `veryfront__list_deployments` with `"project_reference": "my-project"` after the deploy. Each deployment names its `environment_id` and `release_id`.
2. Call `veryfront__list_environments` with the same `project_reference`, and take the `id` of `staging`.
3. Call `veryfront__get_release` with the same `project_reference` and `"release_reference": "latest"`. It worked when the newest deployment has staging's `id` and this release's `id`.

## Next steps

* [Publish](/docs/deployment/publish.md)
* [Add an environment](/docs/runtime/add-environment.md)
