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

# CLI Cheatsheet

> Quick reference for commonly used Squid CLI commands

The [`sqd` CLI tool](/en/cloud/reference/cli/installation) has [built-in aliasing](/en/cloud/reference/cli/commands-json) that picks up custom commands defined in `commands.json` in the project root.

All [squid templates](../make-an-indexer#templates) include a pre-populated `commands.json` file with handy scripts for common development tasks.

## Getting Help

View all available commands (including custom commands from `commands.json`):

```bash theme={"system"}
sqd --help
```

<Tip>
  Custom commands defined in `commands.json` will appear in the `SQUID COMMANDS`
  help section.
</Tip>

## Initial Setup

Before running the squid, install all project dependencies:

```bash theme={"system"}
npm i
```

## Building the Squid

Build your squid project:

```bash theme={"system"}
sqd build
```

Delete all build artifacts:

```bash theme={"system"}
sqd clean
```

## Running the Squid

<Note>
  The `sqd up` and `sqd down` commands assume that the `docker compose` command
  is supported and the Docker daemon is running. Modify the definitions in
  `commands.json` if `docker-compose` should be used instead.
</Note>

Start a local PostgreSQL database:

```bash theme={"system"}
sqd up
```

Stop and remove the local PostgreSQL database:

```bash theme={"system"}
sqd down
```

Run all services defined in `squid.yaml` locally:

```bash theme={"system"}
sqd run [PATH]
```

Start the GraphQL server (development mode):

```bash theme={"system"}
sqd serve
```

Start the GraphQL API server with caching and limits (production mode):

```bash theme={"system"}
sqd serve:prod
```

## Database Migrations

For detailed information, see [TypeORM Migration generation](../../reference/typeorm-migration).

Apply pending migrations:

```bash theme={"system"}
sqd migration:apply
```

Generate a migration for the schema defined in `schema.graphql`:

```bash theme={"system"}
sqd migration:generate
```

Clean the `db/migrations` folder:

```bash theme={"system"}
sqd migration:clean
```

## Code Generation

For more details, see [TypeORM Model generation](../../reference/typeorm-codegen).

Generate TypeORM entities from `schema.graphql`:

```bash theme={"system"}
sqd codegen
```

Generate data access classes from chain metadata:

```bash theme={"system"}
sqd typegen
```

<Info>
  Depending on the template, `sqd typegen` is aliased to a different typegen
  tool specific to the chain type. Run `sqd typegen --help` for details.
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="Development Flow" icon="diagram-project" href="../../design">
    Learn the general development workflow
  </Card>

  <Card title="Full CLI Reference" icon="book" href="/en/cloud/reference/cli/installation">
    Complete CLI documentation
  </Card>
</CardGroup>
