---
title: "CLI Overview"
description: "Use the Merfolk CLI to bring diagram work into scripts, repositories, and agent workflows."
---

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

# CLI Overview

The CLI is one way to work with the shared diagram workspace. Use it when diagram changes belong in a terminal workflow, a script, or a coding-agent task. Use the [web app](/web/overview) when people need to inspect the visual result, discuss it, or comment on the diagram itself.

## Start here

- [Install the CLI](/cli/installation) for terminal workflows.
- [Follow the CLI quickstart](/cli/quickstart) to create, inspect, and update a diagram.

## Command structure

All Merfolk commands follow the pattern:

```
merfolk <command> [subcommand] [arguments] [flags]
```

Top-level commands:

| Command    | Description                            |
| ---------- | -------------------------------------- |
| `login`    | Authenticate with your Merfolk account |
| `logout`   | Remove stored credentials              |
| `diagrams` | Create and manage Mermaid diagrams     |
| `skills`   | Install agent skills                   |

## The `--json` flag

Every command that produces output supports `--json`. When passed, the CLI prints structured JSON to stdout instead of human-readable text.

Use `--json` for scripting, piping into `jq`, or calling from coding agents.

```sh
merfolk diagrams list --json
```

Output is always a valid JSON object or array. Errors are printed to stderr as JSON with an `error` key.

## Exit codes

| Code | Meaning                                           |
| ---- | ------------------------------------------------- |
| `0`  | Success                                           |
| `1`  | General error (see stderr)                        |
| `2`  | Authentication required — run `merfolk login`     |
| `3`  | Not found — the requested resource does not exist |

Source: https://docs.merfolk.io/cli/overview/index.mdx
