# Ghosty checks — the checks on every PR

> What Ghosty checks on every pull request an agent opens (dependencies, Semgrep, migrations, OpenAPI contract, smoke, Lighthouse, security), where each one runs, which ones block the merge and how to add them to your repo.

URL: https://www.ghosty.studio/en/docs/factory/ghosty-checks

When an agent writes the code, the usual checks (CI, tests, a human reading the diff) fall short: an agent can make up a package that doesn't exist, edit its own tests to pass them, or ship a route that only crashes behind the real proxy. **Ghosty checks** cover those gaps. Everything is open source and free; you pay no external service.

## What gets checked

| Check | What it looks for | Blocks the merge? |
|---|---|---|
| Secrets | Keys or tokens in the diff, before pushing | Yes, blocks the push |
| Push checks | That the agent didn't touch tests or CI to pass them | You decide the merge |
| Ghosty Review | Verified serious bugs and issue compliance | No (informs) |
| Security | OWASP/CWE/STRIDE pass inside Ghosty Review (🔒 with its CWE) | Like a verified bug |
| Preview | That the PR boots with your variables | Informs |
| Smoke | Every route against the preview: no 5xx, no rejected submissions | Yes |
| Lighthouse | Performance, accessibility, best practices and SEO of the preview | No (informs) |
| Dependencies | Packages that don't exist, typosquats, install scripts, high CVEs (OSV-Scanner) | Yes |
| SAST | Semgrep CE on what changed only | Yes, on ERROR findings |
| Migrations | Risky Postgres migrations (squawk) | Yes |
| OpenAPI contract | Changes that break your clients (oasdiff) | Yes |
| Bundle | How much the download grew | No (informs) |
| Patch coverage | How much of the new code is tested (diff-cover) | No (informs) |

Any check that doesn't apply to your repo (no migrations, no OpenAPI) passes with "not applicable".

## Where each one runs

- **Smoke and Lighthouse** run by Ghosty against the PR preview and show up as «Ghosty · Smoke». To declare which routes to test, add to `.ghosty/dev.md`:

  ```yaml
  ---
  smoke: [/, /book, /login]
  ---
  ```

  Without the list, `/` is tested. Five routes at most. It also opens with GET the pages and API routes the PR touches (from its diff): one answering 5xx blocks the merge with its message («GET /api/me → 503: …»), and browser errors (exceptions, console, 5xx requests) leave the check neutral with the route and the message.

  To test the **main feature** and not just the home page, declare its steps as a list; each one must answer 2xx. With `e2e:` Ghosty runs your e2e tests inside the preview box, against the app already running there (`BASE_URL` and `PLAYWRIGHT_BASE_URL` point to it); if they fail, they block the merge:

  ```yaml
  ---
  smoke:
    - /dashboard
    - POST /api/crear/agui {"prompt":"Contact form"}
    - POST /login form:email=demo@example.com&next=/
  e2e: npm run test:e2e
  ---
  ```

  The smoke **never invents a write** (POST, PUT, PATCH, DELETE): it only runs the ones you declare, with their body and Content-Type (`{…}` goes as JSON; `form:a=1&b=2` as a form; no body, no body). If the PR changes a write action or handler and there's no declared step, the check is neutral «the PR changes POST /x and there's no smoke step: declare one» with the line ready to paste.

  The smoke runs **signed in** if your app adopted [identity in previews](/en/docs/factory/identity-in-previews) (`X-Ghosty-Identity`): Ghosty signs a service identity with `sub: "ghosty-smoke"` and `email: "smoke@ghosty.studio"`. Without it, an app with login only tests what's public.

  If something crashes, Ghosty repeats that same step against production (`production: https://…` in the frontmatter, the repo's GitHub «Website» or the `fly.toml` app). If it fails there too, it's not from this PR: the check is neutral «Also fails on main (not from this PR)» and it's worth opening a separate task. Only regressions turn it red.
- **Dependencies, SAST, migrations, contract, bundle and coverage** run in your CI with the reusable workflow from [blissito/ghosty-dev](https://github.com/blissito/ghosty-dev). Public repo: on GitHub (`ubuntu-latest`). Private repo: on your space's CI box if it has one; otherwise on GitHub.

## Add them to your repo

In **Development**, open a task → **Checks**. If your repo doesn't have them, the **«Add to repo»** card opens a PR with `.github/workflows/ghosty-checks.yml`. Merge it and they run from the next PR on. By hand it's eight lines:

```yaml
name: ghosty-checks
on: pull_request
permissions:
  contents: read
jobs:
  ghosty-checks:
    uses: blissito/ghosty-dev/.github/workflows/checks.yml@v1
    with:
      runs-on: '"ubuntu-latest"'
```

Via API: `GET /api/v2/me/dev-runs/{id}/checks` tells whether they're installed and `POST` opens the PR.

## Talk to the agent writing the code

The task lives in its GitHub issue (the [ghosty-dev](https://github.com/blissito/ghosty-dev) log). Whatever you ask the agent, from anywhere, is posted as an issue comment and reaches whoever is writing it, in the cloud or in a terminal:

- **In the task's conversation**: type, or drop images and files.
- **On GitHub**: comment `@ghosty …` on the issue or the PR. If you have write access to the repo, the comment gets 👀 once it arrives.
- **Via API**: `POST /api/v2/me/dev-runs/:id` with `{"op":"tell","note":"…"}`.
- **If an agent is writing it in a terminal** (Claude Code, Cursor, Codex with `ghosty-dev`): `ghosty-dev wait <n> --watch` wakes it with your request and `ghosty-dev asks <n>` shows it. In Development that task shows "in their terminal" and opens on GitHub. From the terminal, the agent uses Ghosty's tools with the `ghosty` CLI (`ghosty login`).

What happens depends on where the task is: if it's working, it picks it up on its next step. If it was waiting for you, it resumes. If the PR was waiting on CI or review, it goes back to "working" on the same branch and the previous commit is not merged. If it's closed, it's not accepted. The agent writes with its own model and skills, but inside the task it only sees the task (not your other chats or memories), and your phone only rings when the stage changes: needs you, ready to merge, merged or failed.

## A preview on every PR

Every (non-draft) PR in a repo connected to a room of your workspace gets its own preview automatically, like Vercel or Netlify, no matter who wrote it: a Ghosty agent in the cloud, one in your terminal with ghosty-dev, or a person. Each push rebuilds it on the new commit, and its state shows in the PR's «Ghosty · Preview» check. It takes one of your workspace's slots; if they're all busy it waits in line and starts by itself when one frees up. Closing the PR shuts it down.

## A PR opened by hand

A PR opened by hand or from a terminal doesn't need to go through Development: it gets its preview and review on its own (see «A preview on every PR»). If you want a Ghosty agent to keep writing it on its own branch, use `POST /api/v2/me/dev-runs` with `{"repo":"…","pr":73,"writer":"cloud"}` (or `ghosty dev run <repo> --pr 73 --writer cloud`).

## When it depends on another PR

If the agent needs something from another PR in the same repo that isn't merged yet, it doesn't ask you: it declares the wait (`dev_run_wait_for`) and the task shows **«Waiting for #N»**, in gray, asking nothing of you. As soon as that PR is merged, the agent brings main into its branch and carries on by itself. If the PR is closed without merging, then it asks you. If you don't want to wait, tell it what to do and it resumes. The API returns `phase: "blocked"` with `blockedBy: { pr, url }`.

## The task sheet

Every cloud task has a sheet: status, preview, CI, review, smoke, commit, branch, PR and open requests. Ghosty posts it as a pinned «👻 Ficha del pendiente» comment on the PR and the issue and edits it in place on every change. The preview also shows up as a deployment of the commit, with GitHub's «View deployment» button. The link asks for your Ghosty session, so it never exposes a key.

It's the same sheet the coding agent receives, the one you see in Ghosty and the one the API returns (`ficha` in `GET /api/v2/me/dev-runs/{id}?detail=1`). An agent in your terminal reads it with `ghosty-dev show`.

## Where you see them

The task's **Checks** tab starts with the **review** of the current commit: its findings with severity and `file:line` (the source is the PR's «Ghosty Review» check), each with «Fix it» or «Leave it», which reach the agent as one more request. Below it, Lighthouse, one card per merge gate (CI, smoke, review, evidence) and, in two columns, the smoke routes and the CI checks with failures first. If the smoke fails, the agent gets what failed and fixes it on its own.

## The box's network

The box where the agent writes should only reach what your repo needs: GitHub, package registries and Node, Prisma and Playwright downloads, plus the hosts already in your variables (your remote database, your APIs). If it uses anything else, declare it in `.ghosty/dev.md`:

```yaml
---
network: [api.stripe.com, cluster0.abc.mongodb.net]
---
```

Today it runs in **audit**: nothing is blocked, it only records which domains the box reached outside the list, and **Checks** shows them under «Box network». That way a malicious package or a trap instruction can't ship your variables to someone else's server without you seeing it.

## After the merge

The task header follows your base branch deploy: «Deploying…» with a link to the run, «In production» with a link to your site (the repo's homepage) or «Deploy failed» with the log.
