# Quickstart

## Installation

### NPM Install

To install in your node project, you can run:

```bash
npm i @swplabs/peanutforwp --save-dev
```

After installation, you can run the following cli command to list all commands and options:

```bash
npx peanut help
```

Alternatively, you can install globally using the following command:

```bash
npm i @swplabs/peanutforwp -g
```

**Note:** Installing globally will allow you to run the "peanut" cli command anywhere. This is helpful when you have multiple projects with different source directories.

### Clone the GitHub Repo

You can download the full source from our public GitHub repo using [this link](https://github.com/swplabs/peanut/archive/refs/heads/main.zip) or go to our [GitHub repo homepage](https://github.com/swplabs/peanut) for cloning instructions similiar to this:

```sh
git clone git@github.com:swplabs/peanut.git
```

## Setup

### Wordpress Environment Settings

#### **Enable Permalinks**

Permalinks are the permanent URLs of your Wordpress content. At the moment, Peanut For Wordpress requires that Permalinks to set to something other than the default "Plain". See "[Choosing your permalink structure](https://wordpress.org/documentation/article/customize-permalinks/)" for instructions on how to change your permalink settings.

#### **Enable Debugging**

Script Debugging must be set to true when in development mode for Peanut editor scripts to function. See [Wordpress debugging mode](https://wordpress.org/documentation/article/debugging-in-wordpress/#script_debug) for instructions on how to turn on in your Wordpress development environment.

#### Set Wordpress Environment

In order to use our Whiteboard component prototyping application, you'll need to [set your local Wordpress environment](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#wp-environment-type) type to either 'local' or 'development'.

### Download and Activate the Peanut WordPress Plugin

The Peanut for Wordpress application requires the Peanut Wordpress plugin which enables the framework for loading components and blocks built with the app.

You can obtain the plugin via the [GitHub repo](https://github.com/swplabs/peanut-plugin):

```bash
git clone git@github.com:swplabs/peanut-plugin.git
```

Once cloned, you can copy it to your local Wordpress content directory (wp-content/plugins/). You'll need to then go into your Wordpress Admin and [enable the plugin](https://wordpress.org/documentation/article/manage-plugins/).

### Using the Peanut Setup Command

To create a configuration file (peanut.config.json) and element subfolders for your project within your current working directory, you can use the setup CLI command:

```bash
npx peanut setup
```

## Starting the application

### **Ensure you have the minimum required version of Node.js**

To run the application, you'll need to have the following minimum version of Node.js required installed:

![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgithub.com%2Fswplabs%2Fpeanut%2Fraw%2Fmain%2Fpackage.json\&query=%24.engines.node\&label=node)

For installation, we recommend using [NVM](https://github.com/nvm-sh/nvm) or [Volta](https://docs.volta.sh/guide/getting-started) to manage your Node.js versions. If you are not using a package manager, see the [Node.js download page](https://nodejs.org/en/download/) for installers and binaries.

### Running the CLI

To start building your blocks, plugins, components, and themes, you can run the cli:

```bash
npx peanut [develop|build|lint|format|help] [options]
```

You can get a list of CLI commands and options by running the help command:

```bash
npx peanut help
```

For more examples, see "[Using the CLI](/peanut-for-wordpress/getting-started/cli-reference.md)".

### Building for Production

To trigger a production-ready compilation of your work (ie. minification of code, etc), you can add the following environment vars to your commands:

```sh
ENVIRONMENT="prod" NODE_ENV="production" npx peanut [develop|build]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swplabs.com/peanut-for-wordpress/getting-started/quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
