---
name: shiplock
description: Publish, host, share or update a small web app (one HTML file) with a link, a built-in database, and separate view / add-only / edit links for different people. Use when the user wants to put an app online, share it with family, friends or a club, give someone read-only access, or change an app they already published.
---

# ShipLock: build, publish and share a small app

Server: https://shiplock.app

Say this to the user in one sentence the first time: "ShipLock puts an app you describe online with a link, and lets you choose who can look, who can add, and who can edit."

## No shell? Read this and skip the rest

If you can fetch pages but cannot run commands (a chat with web access): read https://shiplock.app/PROMPT.md, write the complete app as one HTML file in a single ```html block, and tell the user: "Open https://shiplock.app/?signin, sign in with your email, and drop this file on the dashboard. It asks who gets a link and what each link may do." If you can drive a browser, do that part yourself. Do not try to call the API from a page.

## 0. Look for an existing key

Check, in order: the file `~/.shiplock/key` (JSON: `{"url": "...", "token": "..."}`), then the environment variables `SHIPLOCK_URL` and `SHIPLOCK_TOKEN`. If you find one, skip to step 2. Never print the token back to the user.

## 1. First time: get a trial key (no sign-up, no website)

```bash
curl -s -X POST https://shiplock.app/api/trial
```

The reply has `token`, `expiresAt`, `limits` and `home` (a phone-style home screen of their apps: `home.url`, and `home.link`, which is shown only once). Save the key for next time, readable only by the user:

```bash
mkdir -p ~/.shiplock && chmod 700 ~/.shiplock
printf '{"url":"https://shiplock.app","token":"%s"}' "$TOKEN" > ~/.shiplock/key && chmod 600 ~/.shiplock/key
```

Then tell the user, plainly and briefly:
- You saved a key at `~/.shiplock/key`. It is theirs: it is what lets them update and control these apps. Do not share it or commit it to a repository.
- A trial has **3 apps, no photo or file uploads, and expires on <date from expiresAt>**. The page shows a countdown.
- Their home screen link (`home.link`): every app they make appears there, and adding that page to a phone's home screen gives one icon for all of them. Say it is shown once.

Then ask once, as an optional question: "Want to attach your email so you keep these apps after the trial?" If they say yes, send it with their key:

```bash
curl -s -X POST https://shiplock.app/api/trial/claim -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"email":"THEIR_EMAIL"}'
```

Read the `message` in the reply and say it. On a server with accounts it means a sign-in link is in their inbox: opening it makes their account and moves these apps into it, with no expiry, and the dashboard at https://shiplock.app is theirs from then on. Tell them the account starts on the Plus plan free for 30 days with no card, then the Free plan for good. Their trial key stops working at that point; new keys come from the dashboard (Agents & tokens).

If they say no, carry on. Do not ask again.

If `POST /api/trial` returns 404, this server does not offer trials. Ask the user for a `SHIPLOCK_TOKEN` from the server owner's dashboard (Agents & tokens).

## 2. Build the app

Read https://shiplock.app/PROMPT.md and follow it exactly: one self-contained HTML file, `window.SL` for data, roles decide what the page shows, build the DOM with `textContent`. Trials cannot store files, so do not build photo or file upload features; use text fields instead and say why.

## 3. Decide who gets in

Infer it from what the user said. Do not ask unless nothing is implied.
- Only me: no link. The app stays private.
- People can look but not change: a link with role `view` (for example `"Family:view"`).
- A group fills in a form, and only the owner sees the answers: a link with role `submit`.
- A shared list the group edits together: a link with role `edit` (for example `"House:edit"`). A 403 mentioning the admin scope means the account key was made without it: say that a new token under Agents & tokens with `admin` ticked fixes it, and publish with a `view` link for now.
- One named person ("my wife", "Grandma", an address): with an account key (not a trial), share by email instead of a link. `POST https://shiplock.app/api/apps/APP/grants` with JSON `{"kind":"email","email":"her@example.com","role":"edit"}`. She opens the app's address, types her email, and gets a sign-in link; once in, every app shared with her address opens without another one. A 403 mentioning the plan means the account is on Free: say so and fall back to a link. A 501 means this server sends no mail.

The role is enforced by the server, so the page cannot be tricked into more.

Add `-F icon=🍳` (one emoji) to the deploy so the app has a tile icon on the owner's home screens; otherwise one is guessed from the name.

With an owner's key (admin scope, not a trial), `-F home=Grandma -F homeRole=view` puts the app on the home screen called Grandma, making that screen if there is none. The reply's `home` has the screen's `url` and, the first time, its `link` to give Grandma (shown once). Use it when the user says who the app is for ("make Grandma a recipe app"). A trial's apps land on the trial's own screen without asking.

## 4. Publish (or update)

Write the HTML to a file, then upload it. Use a short `slug` that names the app. Add `-F update=1` and the same slug to publish a new version of an app they already have, instead of making a second one:

```bash
curl -s -F file=@app.html -F name="Recipes" -F slug=recipes -F update=1 -F link="Family:view" \
  -H "Authorization: Bearer $TOKEN" https://shiplock.app/api/deploy
```

Never paste the HTML into a tool call when a shell is available; upload the file. The reply has `url`, `version` and, if you asked for one, a `link.url` to share.

To list their apps: `curl -s -H "Authorization: Bearer $TOKEN" https://shiplock.app/api/apps` (each has an `id`, `name`, `slug` and `version`).

## 4b. Change an app that already exists

Every publish keeps the old version, so nothing is lost. Do not rebuild from memory: fetch what is live, change that, publish it back. `APP` is the app's `id` from the list.

```bash
# 1. get the live source
curl -s -H "Authorization: Bearer $TOKEN" https://shiplock.app/api/apps/APP/versions/live/source -o app.html
# 2. edit app.html, then publish it as the next version, with a short note of what changed
curl -s -F file=@app.html -F appId=APP -F note="added a Done column" -H "Authorization: Bearer $TOKEN" https://shiplock.app/api/deploy
```

Other things you can do, all with the same key:

| Want | Command |
|---|---|
| History | `GET https://shiplock.app/api/apps/APP/versions` (newest first; `live: true` marks the one people see) |
| An old version's source | `GET https://shiplock.app/api/apps/APP/versions/3/source` |
| What changed | `GET "https://shiplock.app/api/apps/APP/diff?from=2&to=live&format=unified"` (`from` and `to` are version numbers or `live`; leave them out for "previous to live"; drop `format` for JSON ops) |
| Go back | `POST https://shiplock.app/api/apps/APP/rollback` with JSON `{"version": 2}` |

Before a big change, show the user the diff (`format=unified`) in a few words: "this adds X and removes Y". After publishing, say the new version number and that the previous one is a roll back away. If they do not like it, roll back instead of re-editing. A rolled-back version is never deleted, so they can go forward again too.

The dashboard's **Ask your AI** button copies an app's source into a prompt. When the user pastes one of those, return the complete file, not a snippet, and remind them the dashboard shows the diff before publishing.

## 5. Tell the user

- The app link, and the share link with its role in plain words ("anyone with this link can look; nobody can change it").
- If the reply has `home.link`, the home screen link and who it is for.
- That the share link is shown only once: if it is lost, make a new one.
- On a trial: how many days are left, and that apps are removed a week after the trial ends unless they have claimed their own ShipLock.
- Apps written by an AI can have bugs. Suggest they open it and try it before sending it widely.

## Limits to respect

- A trial key can deploy, list and share its own apps (view, add-only and edit links). It cannot see anyone else's, delete, make an app public, share by email, or use home screens: those need an account key with the admin scope.
- If a request fails, read the `error` field in the reply and say it in plain words. Do not retry in a loop.
