> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shoply.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# The Shoply CLI

> Work on a storefront's code on your own computer: clone it, see each save in a preview, publish it from the terminal

The code studio edits a storefront's files in the browser. The CLI lets you edit the same files on your own computer, in your own editor, with your own tools around them. Each file you save is sent to the storefront's draft, and buyers see nothing until you publish.

It works on storefronts that can be edited as code. A storefront from before its theme could be, is copied first: see [Storefronts](/guides/storefronts.md).

## Installing it

```sh theme={null}
npm install -g @shoplygg/cli
```

It needs [Node.js](https://nodejs.org) 20 or newer, and nothing else.

## Signing in

```sh theme={null}
shoply login
```

The CLI shows a code and opens the dashboard, which asks whether the code on the page is the one in your terminal. Check that it is, pick the store, and press **Yes, Approve**. You are asked to confirm it is you, as for any new API key.

The CLI is given an API key for that store that can read, change and publish its storefronts, and nothing else. It is listed under **Developers**, then **API Keys**, named after your computer, where you can revoke it like any other key. On your computer it is kept in your system's keychain (on macOS, and on Linux with `secret-tool`), or else in a file only you can read.

If you did not run `shoply login` yourself, press **No, Deny**. A sign-in you did not answer ends after ten minutes.

To work on more than one store, sign in to each. `shoply use <store>` picks which one commands work on, by the store's address name.

## Working on a storefront

```sh theme={null}
shoply clone
cd main-storefront
shoply dev
```

`shoply clone` lists the store's storefronts and copies the one you pick into a new folder. A storefront that has never been opened as code is given files of its own first, copied from its theme. Nothing buyers see changes.

`shoply dev` watches the folder. A moment after you save a file, it is sent to the storefront's draft, and a mistake in a template is said at once with its file and line. It prints a link to preview the draft on your store's own address; refresh it after a save to see the change. The link lasts an hour, and `dev` prints a fresh one before it runs out.

When the draft is ready:

```sh theme={null}
shoply publish
```

It sends anything not yet sent, then puts the draft live, its files and its design together, and makes the storefront the one buyers see. A mistake in a template stops it, and says where.

## The folder

| | |
| - | - |
| **`layout/`, `pages/`, `elements/`, `parts/`** | Templates, `.liquid` |
| **`assets/`** | The stylesheet and the script, `.css` and `.js` |
| **`locales/`, `config/`** | `.json` |
| **`.shoply/config.json`** | Which store and storefront this is. Commit it. |
| **`.shoply/state.json`** | What Shoply last had of each file. `clone` keeps it out of git. |

Anything else in the folder (a README, your own notes) is yours and is never sent. A file name is small letters, digits, hyphens and underscores. A file that came with the theme can be changed, but not deleted or renamed: delete one and the CLI puts it back.

## If the code studio changed it too

The CLI never saves over a change made somewhere else since you last pulled. It says which file, and you choose:

```sh theme={null}
shoply pull           # take what is on Shoply
shoply push --force   # send yours over it
```

`shoply status` says what you have changed, and which files changed on Shoply.

## Every command

| | |
| - | - |
| **`shoply login`** | Sign in through the dashboard, for one of your stores |
| **`shoply logout`** | Forget this computer's key. Revoke it under **API Keys** to end it everywhere. |
| **`shoply whoami`** | Which store you are signed in to |
| **`shoply use <store>`** | Switch between the stores you are signed in to |
| **`shoply storefronts`** | The store's storefronts, and which one is live |
| **`shoply clone [name]`** | Copy a storefront into a new folder. `--dir` names the folder. |
| **`shoply dev`** | Send each saved file to the draft, with a preview link |
| **`shoply status`** | What changed here, and on Shoply |
| **`shoply push`** | Send what you changed to the draft |
| **`shoply pull`** | Take the draft's files from Shoply. `--force` throws away what you changed. |
| **`shoply publish`** | Send what is left, then put the draft live. `--yes` does not ask first. |
| **`shoply open`** | Open the store. `--preview` opens the draft, `--dashboard` the **Storefronts** page. |

## What it uses

The CLI talks to Shoply through the API, with the key it was given: the storefront code routes, under [Storefront code](/api-reference/storefront-code/get-a-storefronts-code.md). A script of your own can do the same with a key that has the storefront permissions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.