# Checkly Project Setup

Follow these steps in order to set up a new Checkly monitoring project.

## Step 0 — Pre-flight checks

Before starting, verify:

1. **Node.js** is installed (`node --version`). Checkly CLI requires Node.js 22.13.0 or later.
2. **npm** is available (`npm --version`).
3. The current working directory is the right location for the project (or create/navigate to it).

If any pre-flight check fails, help the user fix it before proceeding.

## Step 1 — Choose a setup method

Ask the user which setup method they prefer:

- **Option A: Initialize with CLI** — Run `npx checkly init` to set up Checkly in the project. The CLI handles skill installation, dependencies, configuration, and optionally creates demo checks. This is the fastest way to get started.
- **Option B: AI-first** — Generate the project structure and checks from scratch using this skill. Best when the user already knows what they want to monitor and prefers a tailored setup.

### Option A: Initialize with CLI

Run the following command:

```bash
npx checkly init
```

The CLI will guide you through skill installation, configuration, and dependency setup. Once finished, setup is complete.

### Option B: AI-first

Continue with the following steps:

#### Step 1: Install dependencies

**Install the Checkly dependency**

Check if `npx checkly --version` works. If not, run `npm install --save-dev checkly`.

#### Step 2: Install the Checkly agent skill

The skill carries the conventions the rest of this setup depends on: when to use the CLI versus the Checkly MCP server, keeping both on the same account, never picking an account for the user, the confirmation protocol for writes, and the output stream and exit code conventions. Installing it now also leaves the project ready for the next session.

The install writes a file into the user's repository, so ask first and never install it silently:

**Do you want to install the Checkly agent skill into this project?**

- **yes** — run `npx checkly skills install --target <platform>`, where `<platform>` is the agent you are running in: `amp`, `antigravity`, `claude`, `cline`, `codex`, `continue`, `cursor`, `devin`, `gemini-cli`, `github-copilot`, `goose`, `kilo-code`, `kiro`, `mistral-vibe`, `opencode`, `roo`, `windsurf` or `zed`. Use `--path <dir>` instead when the user names a directory. Always pass one of the two: without them the command only prints the available flags unless it has an interactive terminal. If a skill file already exists, the command says so and writes nothing; only re-run it with `--force` once the user agrees to overwrite.
- **no** — continue the setup without it. Run `npx checkly skills` for the current action list (it needs no install and no authentication), and keep in mind that the conventions above live only in the skill file, not in this reference. Offer `npx checkly skills install` again whenever the user wants them.

If the skill was installed, read it before moving on, so the remaining steps follow its rules.

#### Step 3: Gather the project requirements

Ask the user the following questions to determine the setup:

1. **What do you want to monitor?** (multiple selections allowed)
   - **Uptime monitoring** — Monitor URLs for availability and response times
   - **API checks** — Validate API endpoints with custom assertions
   - **Browser checks** — Run Playwright scripts to test user flows
   - **Multistep API checks** — Chain multiple API requests into a single check
   - **Playwright Check Suites** — Reuse your existing Playwright project for synthetic monitoring

   Remember the selection for later steps when creating checks.

2. **How do you want to get alerted?** (multiple selections allowed)

Run `npx checkly skills configure alert-channels` to access up-to-date information on alert channel options and setup.

3. **Where do you want to store your monitoring configuration?**
   - **__checks__** — create all resources and `check.ts` files in a separate `__checks__` directory
   - **next to the resource** — place the `check.ts` files next to page routes, api endpoints etc.


#### Step 4 — Check your account plan

Before writing checks, verify what your account can do:

```bash
npx checkly account plan --output json
```

This shows your entitlements, limits, and available locations. Use this data when creating the config:

- **Only use locations** from `locations.all` where `available` is `true`. Using unavailable locations will cause deploy failures.
- **Check feature availability** before configuring constructs like private locations, advanced alert channels, or higher-frequency schedules.
- **Respect metered limits** — the `quantity` field shows maximums for each metered feature.

If a feature the user wants is disabled, share its `upgradeUrl` only when the response includes one. A disabled entitlement without an upgrade URL is unavailable.

Run `npx checkly skills manage plan` for the full reference.

#### Step 5 — Create the config file

Run the following command to retrieve the configure skill reference:

```bash
npx checkly skills configure
```

Use the output to create a `checkly.config.ts` (or `checkly.config.js` if the user chose JavaScript) in the project root.

Adjust the `checkMatch` property according to previous selection. Use only locations verified as available in the previous step.

Set `repoUrl` to this repository's own remote:

1. Run `git remote get-url origin`.
2. Convert it to an `https://` URL (`git@github.com:owner/repo.git` → `https://github.com/owner/repo`). Drop any credentials and the trailing `.git`.
3. Set the result as `repoUrl`. If there is no remote, leave `repoUrl` out.

Never copy the `repoUrl` from the example config.

Present the generated configuration to the user and ask if it looks correct. Allow the user to make changes.

Congratulate the user on completing the config. Now it's time to test the configuration and turn everything into monitoring!

#### Step 6: Log in to Checkly CLI

To use the Checkly CLI the user needs to be logged in. Run the following command:

```bash
npx checkly whoami
```

If the user is logged in, verify the information and if it's the correct account.

If the user is NOT logged in, run the login yourself unless the user prefers API keys:

- **Option A: `npx checkly login`** — Works for agents. It prints a JSON `action_required` line with a URL and a short code and exits: give both to the user, then run `npx checkly login --wait`, which returns once they have approved. With several accounts it stops at a `select_account` line listing them; ask the user which one and run `npx checkly login --account-id <id>`. Details are in the skill's "Logging in as an agent" section. Any authenticated command starts this flow on its own when no credentials are stored. To pin this project to one account, put `CHECKLY_ACCOUNT_ID=<id>` (without `CHECKLY_API_KEY`) in its `.env`.
- **Option B: Environment variables** — For CI/CD, or when the user prefers keys: they set `CHECKLY_API_KEY` and `CHECKLY_ACCOUNT_ID` (API keys are created at https://app.checklyhq.com/accounts/settings/user/api-keys). Once both are set, re-run `npx checkly whoami` to verify.

#### Step 7: Summarize and test the new monitoring configuration

Read the generated `checkly.config.ts` (or `checkly.config.js`) and summarize the configured checks, locations, and frequencies.

Run the following command to test the new monitoring setup:

```bash
npx checkly test
```

If the command passed, congratulate the user and ask them what they want to do next!

Share more Checkly CLI options and ask if they want to deploy their new monitoring setup using `npx checkly deploy`.
