Skip to main content

Getting Started

The Castle CLI lets you create, preview, edit, and save Castle decks from local files.

Prerequisites​

Install Node.js from nodejs.org. Use the LTS version.

Check that Node.js and npm are available:

node --version
npm --version

Install​

Install the CLI with npm:

npm install -g castle-cli

Check the installation:

castle --help

Create A Deck​

Create a local deck project:

castle init my-deck --title "My Deck"

Start the local preview:

castle serve my-deck --open

castle serve prints a local preview URL and keeps running in the foreground. Leave it running while you work.

After editing files, restart the preview:

castle restart

To inspect script output and errors:

castle logs

Save To Castle​

Save the local deck to Castle:

castle save-deck my-deck

If you are not logged in, the CLI prints a login URL and opens it in your browser. New decks are saved as unlisted decks by default.

Get An Existing Deck​

Get an existing deck by deck ID:

castle get-deck <deck-id> my-deck

Then preview it locally:

castle serve my-deck --open

After making local changes, run castle save-deck my-deck to save them back to Castle.

Update From castle-cli Before 2.0.0​

If you already have castle-cli installed from before version 2.0.0, run the install command again to update it:

npm install -g castle-cli

Project directories created by castle-cli versions before 2.0.0 should be recreated with the new CLI. Move or remove the old local directory, then get the deck again:

mv my-deck my-deck-old
castle get-deck <deck-id> my-deck
castle serve my-deck --open