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

# CLI in CI

Use the LittleDemo CLI from scripts and CI jobs.

CI should use an API key, not the browser device flow.

## Basic setup

```bash
npm install -g @littledemo/cli
export LITTLEDEMO_API_KEY=ld_live_xxx

littledemo whoami
```

## Generate without waiting

```bash
littledemo demos create \
  --project "$LITTLEDEMO_PROJECT_ID" \
  --prompt "Refresh the onboarding overview" \
  --template guided-tour \
  --no-wait
```

## Demo video in every PR

The recommended path is to generate the workflow from your repo:

```bash
littledemo setup --pr-demos --yes
```

That creates `.github/workflows/littledemo-pr-demo.yml`. Add `LITTLEDEMO_API_KEY` as a repo secret, and either pass `--project proj_...` during setup or add `LITTLEDEMO_PROJECT_ID` as a repo secret. The generated workflow records same-repo, non-draft PRs and skips fork PRs by default.

The [PR demo guide](/guides/pr-demo-videos) covers the generated workflow and the reusable GitHub Action (`seangeng/littledemo/action@v1`). Or do it directly:

```bash
npx --yes @littledemo/cli record http://localhost:3000 \
  --upload --project "$LITTLEDEMO_PROJECT_ID" \
  --prompt "PR demo" --yes --json > result.json
```

## Upload a PR recording

Use this after Playwright, Chrome DevTools, or another local recorder writes a video artifact.

```bash
littledemo demos upload ./artifacts/pr-demo.mp4 \
  --project "$LITTLEDEMO_PROJECT_ID" \
  --prompt "Show the PR changes" \
  --title "PR demo $GITHUB_SHA" \
  --json > littledemo-upload.json
```

The JSON output includes `shareUrl`, `embedUrl`, and `videoUrl` for a follow-up PR comment step.

## Prefer webhooks for deploy refreshes

If you only need to refresh existing demos after deploys, use the project webhook endpoint. It is simpler and does not require a live API key in that job.

```bash
curl -X POST "https://littledemo.com/api/v1/webhooks/projects/$LITTLEDEMO_PROJECT_ID/refresh" \
  -H "X-Webhook-Secret: $LITTLEDEMO_WEBHOOK_SECRET"
```