Skip to content
Back to skills

Stack Preview

ASecurity

Run the whole Vicoa stack (Postgres, backend, realtime server, web dashboard) from the current checkout and publish it at one public tunnel URL, so a branch can be reviewed from another machine or in the Vicoa app. Use when asked for a full-stack or end-to-end preview link of a Vicoa branch or PR, or when /live-preview is not enough because the dashboard needs a backend.

  • 552 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 5, 2026
developmentpythongobashdockergitapidatabasebackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 10, 2026

npx -y skills add vicoa-ai/vicoa --skill stack-preview --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stack Preview?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stack Preview
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vicoa-ai-stack-preview/badge)](https://www.skillsdirectory.com/skills/vicoa-ai-stack-preview)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stack-preview
description: Run the whole Vicoa stack (Postgres, backend, realtime server, web dashboard) from the current checkout and publish it at one public tunnel URL, so a branch can be reviewed from another machine or in the Vicoa app. Use when asked for a full-stack or end-to-end preview link of a Vicoa branch or PR, or when /live-preview is not enough because the dashboard needs a backend.
argument-hint: "[up | status | check | restart | down [--keep-db | --delete-db | --purge] | prune] [--env-file FILE] [--allow-signup]"
disable-model-invocation: true
allowed-tools: Read, Glob, Grep, Bash
---

# stack-preview

`/live-preview` tunnels one dev server. The Vicoa dashboard is not one: its
browser code calls the REST backend and holds a WebSocket to the agent-facing
server, so a tunnel to the web app alone cannot even sign in. This skill runs
every piece from the checkout and puts them behind **one** origin:

```
browser ──https──▶ tunnel ──▶ proxy :P ─┬─ /ws          → server   (uvicorn, realtime)
                                        ├─ /api/v1/...  → backend  (uvicorn, REST)
                                        └─ everything   → web      (next dev, hot reload)
                   backend + server ──▶ Postgres (throwaway Docker container)
```

One origin means one link to hand over, no CORS, and realtime works through the
tunnel. Everything binds `127.0.0.1`; only the tunnel is public.

The script is `scripts/stack-preview.sh` in this skill's directory. It previews
the git checkout of the **current directory** (a worktree is fine), or `--repo DIR`.

## 1. Start

```bash
<skill-dir>/scripts/stack-preview.sh up
```

It creates and migrates the database, opens the tunnel, starts server, backend
and web, seeds an owner account, closes sign-up, then checks the page, the API and
the WebSocket handshake **through the public URL**. About 30 s, longer on a
first web compile. The result is `* key: value` lines, the same contract as
`/live-preview`, so the Vicoa app opens the link in Live Preview.

- `status: error` means one of those public checks failed. Read the log it
  names under `state:`, fix the problem, `down`, `up`. Don't hand over a link
  that failed its own check.
- "a next dev server already serves apps/web": that server isn't yours. Don't
  stop it; ask the user.
- Running `up` again while the preview is up just prints its status.

Flags:

- `--env-file FILE`: `KEY=value` lines for backend and server, e.g. Stripe
  test keys, or a `PYTHONPATH` that adds an overlay package. The preview's own
  database, URLs and auth settings always win. Never pass a file that holds
  production credentials.
- `--allow-signup`: leave sign-up open (for reviewing the sign-up flow). By
  default it closes after seeding, because anyone with the link can reach the server.
- `--provider ngrok`: by default cloudflared is tried first, then ngrok.
- `--viewer`: also seed Bea, a second person. Pass it only when the user asks
  for a second account or the change needs one (sharing, permissions, team
  features); one account is the default.
- `--auth supabase`: only when the user asks to review the **mobile app**, which
  can only sign in with Supabase. Everything else uses the default (builtin),
  and every `up` without the flag is builtin again. It signs in with a hosted
  Supabase project instead of seeded accounts. Export
  `SUPABASE_URL` and `SUPABASE_ANON_KEY` first (`apps/mobile/env.json` has
  them). Identity only: the data stays in the preview's database. There are no
  Ada/Bea accounts, so seeds write rows for the person who signs in (find them
  in `users` by email after their first sign-in). Point the app at the preview
  in the debug branch of `apps/mobile/lib/custom_code/actions/vicoa_api_config.dart`
  (`https://<public_url>` and `wss://<public_url>/ws`), and never commit that file.

## 2. Seed what the change needs

A fresh database holds only Ada (`ada@example.com`, the owner); her password is
in the output. With `--viewer` it also holds Bea (`bea@example.com`), a second
person for sharing and permissions. If a running preview turns out to need Bea,
`down --keep-db` then `up --viewer` adds her and keeps the data (the URL
changes). An empty dashboard reviews nothing, so read the diff
(`git diff origin/main...`), list the screens and states it touches, and seed
those:

- Put seed scripts in the state dir (`state:` in the output), never in the repo.
- Prefer the API, acting as a real user:
  `curl -H "Authorization: Bearer $OWNER_TOKEN" "$PREVIEW_BACKEND/api/v1/..."`.
  This runs the same code the reviewer will use.
- Write rows directly only for things no endpoint creates (agent sessions and
  their messages, automation runs). A `.py` seed can import the models from
  `shared.database`. [reference/seed-example.py](reference/seed-example.py) is a
  working seed (project and tasks through the API, a session with messages
  through the database); copy it instead of reading the models.
- Session status `COMPLETED` means archived: default lists and share links
  hide it. For a session that looks finished, use `AWAITING_INPUT`.
- Run `stack-preview.sh seed FILE`. A `.py` runs in the backend venv with
  `PYTHONPATH` set; anything else runs under bash. Seeds get `PREVIEW_URL`,
  `PREVIEW_BACKEND`, `DATABASE_URL`, `OWNER_EMAIL/PASSWORD/TOKEN` and, with
  `--viewer`, the `VIEWER_*` equivalents. `stack-preview.sh env` prints the same exports for ad-hoc curl.
- Use invented data only. The link is public.

## 3. Check it the way the reviewer will

Before handing over the link, run the changed screens through a signed-in
headless browser at the public URL:

```bash
<skill-dir>/scripts/stack-preview.sh check /dashboard /dashboard/tasks   # a line per page + problems
<skill-dir>/scripts/stack-preview.sh check --script <state-dir>/flow.mjs # click through a flow
```

It signs in as Ada (`--as viewer`: Bea) and prints each page's status plus any
console errors, failed requests and 4xx/5xx responses; `404 /api/v1/billing/*`
is filtered out. For a flow, write only the interactions, in the state dir like
seeds (never in the repo). The file gets a signed-in page:

```js
export default async ({ page, go, shot }) => {
  await go('/dashboard/tasks');                  // goto + wait for the page to settle
  await page.getByText('Fix login').click();
  return await page.locator('main').last().innerText(); // printed as JSON; the dashboard nests two <main>
};
```

Assert on text and locators and return the values.

**No screenshots unless the user asks.** `shot()` does nothing and path runs
save nothing until you pass `--shot` (`--viewport 390x844` for a phone); crop with
`shot(name, { selector })`. An image costs far more to read than a line of text.

## 4. Hand over

Give the user the sign-in link (the `sign_in:` line, i.e. the public URL plus
`/sign-in`, such as `https://<name>.trycloudflare.com/sign-in`), so it opens
straight on the login form. Add the login (both, with `--viewer`), what you
seeded and where to click, and the stop command. Leave the preview running
until they say they're done.

While it runs: web edits hot-reload by themselves. After backend changes, run
`stack-preview.sh restart` (default: server and backend; or
`restart backend|server|web`). `restart` keeps the tunnel, so the link stays
valid. `down` then `up` gives a **new** URL; the data survives it only in the
main checkout or with `down --keep-db`.

## Stop

`stack-preview.sh down` stops every process the script started (checked by
recorded PID and start time). Side processes started with
`stack-preview.sh run NAME -- CMD...` (e.g. a `stripe listen` forwarding to
`127.0.0.1:$PREVIEW_BACKEND_PORT`) stop with it. What happens to the database
depends on the checkout:

- **A worktree** (the usual case): `down` deletes the database container with
  its volume, and the `postgres:16-alpine` image, so nothing is left in Docker.
  The image goes only when no other container uses it, running or stopped (the
  backend's compose file and integration tests use the same image); the next
  `up` pulls it again.
- **The main checkout**: `down` stops the container and keeps it, so the next
  `up` has the same data.
- `down --keep-db` / `down --delete-db` override that default either way.
- `down --purge`: delete the database and the state dir, which holds the
  account passwords, so the next `up` makes new ones.
- `down` still finds the container when the state dir is gone (a reboot
  empties `/tmp`).
- `prune` deletes stopped preview databases whose checkout no longer exists,
  e.g. a worktree that was removed without `down`. It never touches a running
  container or one whose checkout still exists.

## Rules

- The script's own Postgres container is the only database. Never point a
  preview at the shared dev database or at production.
- Don't start the backend by hand from `backend/`: `backend/.env` holds real
  credentials, and the backend reads `.env` from its working directory. The script
  runs Python with an empty environment from an empty directory, and blanks
  every key in `apps/web/.env*` for the web server.
- Stop things only with `down` or `restart`. Never pattern-kill: every Next dev
  server on the machine is titled `next-server`.

Ports, state files, every variable the script sets, and the traps it works
around: [reference/how-it-works.md](reference/how-it-works.md).

Files in this skill

  • SKILL.md6.1 KB
  • agents/openai.yaml255 B
  • reference/how-it-works.md5.9 KB
  • scripts/proxy.mjs3.3 KB
  • scripts/stack-preview.sh26.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.