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

# /setup

> Agent-guided setup for wiring Migma into an existing app.

Use `/setup` when you want an AI coding agent to add Migma to an existing app.

It is agent-guided. The agent still reviews and edits your codebase, then uses Migma to create or reuse emails and wire safe server-side sends.

In Migma, the main entry is **Create → Set up Migma with agent**. That dialog copies the `/setup` handoff prompt with skill/plugin install paths, sender/domain status, agent auth guidance, and backend wiring steps.

<Info>
  **For agents:** Fetch the complete documentation index at `https://docs.migma.ai/llms.txt` to discover all available pages before exploring further.
</Info>

## Use it from Migma

<Steps>
  <Step title="Open Create">
    Click **Set up Migma with agent** next to the composer send button.
  </Step>

  <Step title="Copy for AI">
    Migma prepares a prompt for Claude Code, Codex, Cursor, or any skills-compatible agent.
  </Step>

  <Step title="Paste into your agent">
    The prompt asks the agent to install the setup skill or plugin only after you approve it.
  </Step>

  <Step title="Approve scoped access">
    The agent uses [agent registration](/agent-registration) first. Use a fallback API key only when agent registration is unavailable.
  </Step>
</Steps>

Use [Agent Handoff](/agents/agent-handoff) for the full Create, Publish, API setup, and canvas handoff map.

## Add Migma to your agent

Use the plugin when your agent supports it. It installs the `setup`, `migma`, and `migma-public-api` skills together.

### Claude Code

Install the plugin:

```bash theme={null}
claude plugin marketplace add MigmaAI/migma-skills
claude plugin install migma@migma-plugins
```

Or install only the setup skill:

```bash theme={null}
npx skills add MigmaAI/migma-skills --skill setup -a claude-code
```

To install across all supported agents on this machine:

```bash theme={null}
npx skills add MigmaAI/migma-skills -g
```

### Codex

Install the plugin from the terminal:

```bash theme={null}
codex plugin marketplace add MigmaAI/migma-skills
codex plugin add migma@migma-plugins
```

You can also open `/plugins` in Codex, search for Migma, and install it from the plugin list after adding the marketplace.

### Cursor

Open **Cursor → Settings → Plugins**, paste `https://github.com/MigmaAI/migma-skills`, then install Migma.

Or install only the setup skill:

```bash theme={null}
npx skills add MigmaAI/migma-skills --skill setup -a cursor
```

### Other agents

If your agent supports skills, install the setup workflow:

```bash theme={null}
npx skills add MigmaAI/migma-skills --skill setup
```

If it supports MCP but not skills, connect [MCP](/mcp-server). MCP gives the agent Migma tools, but the `setup` skill is still the better path for codebase audit and backend wiring instructions.

### Terminal install

Use this when you want the CLI and all skills together:

```bash theme={null}
curl -fsSL https://install.migma.ai/setup | sh
```

Or install each part:

```bash theme={null}
curl -fsSL https://install.migma.ai/cli | sh
curl -fsSL https://install.migma.ai/skills | sh
```

## What setup does

1. Audits existing email providers, templates, receipts, invites, campaigns, lifecycle jobs, queues, and webhooks.
2. Resolves the correct Migma brand/project.
3. Lists existing Migma emails and reuses matches.
4. Creates missing emails with prompts grounded in trigger files, recipients, variables, subject copy, and CTAs.
5. Stores each returned `emailId`, subject, sender, and matching app trigger in server-side config or constants.
6. Wires sends only in trusted backend paths.
7. Adds a dry-run or smoke test that verifies each trigger selects the right `emailId` without sending duplicates.

## API access

Use a Migma API key server-side:

```env theme={null}
MIGMA_API_KEY=<set outside chat>
MIGMA_FROM=hello@brand.migma.email
MIGMA_FROM_NAME=Brand
```

Get a key from [Settings → Developers → API Keys](https://migma.ai/settings?tab=api-keys), or let the agent use [agent registration](/agent-registration) at `https://api.migma.ai/auth.md`.

## REST fallback

If plugin or skill install is unavailable, use REST.

| Task                 | Endpoint                                          |
| -------------------- | ------------------------------------------------- |
| List brands/projects | `GET /v1/projects`                                |
| List existing emails | `GET /v1/projects/emails?projectId=<projectId>`   |
| Create emails        | `POST /v1/projects/emails/generate`               |
| Poll generation      | `GET /v1/projects/emails/{conversationId}/status` |
| Fetch one email      | `GET /v1/emails/{emailId}`                        |
| Send                 | `POST /v1/sending`                                |

Base URL: `https://api.migma.ai`

Auth header: `Authorization: Bearer $MIGMA_API_KEY`

## Guardrails

* Keep API keys and send calls server-side.
* Do not put Migma secrets in browser code.
* Ask before installing packages, calling Migma APIs, creating emails, or sending tests.
* Test before live sends.
* Add idempotency before transactional sends.
* Do not send cold email or email unsubscribed contacts.
* If the app is frontend-only, stop after audit/email creation and add a backend prerequisite before wiring sends.

## Which tool to use

| Surface       | Use it for                                                                       |
| ------------- | -------------------------------------------------------------------------------- |
| `setup` skill | App audit, email mapping, backend send wiring                                    |
| Migma plugin  | Packaging `setup`, `migma`, and public API guidance for agents                   |
| CLI           | Terminal workflows: generate, fetch, edit, send-test, send, campaign, export     |
| MCP           | Migma-side actions from MCP clients: list, generate, fetch, edit, send, campaign |
| REST or SDK   | Production app integration                                                       |

Related docs: [Agent Handoff](/agents/agent-handoff), [Skills](/skills), [CLI](/cli), [MCP](/mcp-server), [Authentication](/authentication), [Agent registration](/agent-registration).
