caelum0x 2704587868 feat: five task skills (create project, auth, storage, RLS, branch-per-PR), v0.2.0, LICENSE
Mirrors agents/plugin from caelum0x/scribase: five new one-task skills
covering the most common agent requests, a bumped plugin version, a
license and privacy policy URL for directory submission, and a sync of the
general scribase skill with the X-launch-post addition it was missing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-11 14:21:52 +03:00

100 lines
3.8 KiB
Markdown

---
name: scribase-branch-per-pr
description: Give one pull request its own live Scribase database branch — a copy-on-write fork with its own URL and keys, linked to the PR with a status comment — then merge or clean it up when the PR closes. Use when the user asks for a preview database per PR, branch-per-PR, a staging database for a pull request, "give this PR its own database", or mentions CI needing an isolated backend per branch.
---
# Scribase: one branch per pull request
A branch is a copy-on-write fork of production with its own URL and
publishable key — cheap to create, safe to throw away, and the natural
isolation unit for a PR's tests and preview deploy.
## 1. On PR open: fork and link it
```
branches.create { name: "pr-<number>", data: "sanitized", ttl_hours: 72 }
```
`data: "sanitized"` copies production's shape with anonymized data — the
right default for a PR a reviewer or CI will actually read; use
`schema_only` for an empty-but-correct schema, or `snapshot` only if the
user explicitly wants exact production data on a branch (then treat it as
sensitive). The call waits and returns the branch's live URL and
publishable key.
Then link it to the PR so GitHub/GitLab shows status and the console shows
the PR:
```
branch.link_pull_request {
organization_id, project_id,
branch_id: "pr-<number>",
provider: "github", repository: "<owner>/<repo>", number: <pr-number>
}
```
CLI equivalent (also writes `.scribase/branches/pr-<number>.env` with the
public URL and key, nothing secret):
```bash
scribase branch create "$ORG" "$PROJECT" "pr-$NUMBER" --data sanitized --ttl 72h
scribase branch pr "$ORG" "$PROJECT" "pr-$NUMBER" github "$OWNER/$REPO" "$NUMBER"
scribase branch url "$ORG" "$PROJECT" "pr-$NUMBER"
```
Point CI's test run and any preview deploy at that branch's URL and
publishable key, never at production.
## 2. On every push to the PR: apply pending migrations to its branch only
```bash
scribase migrate "$ORG" "$PROJECT" "pr-$NUMBER" --dir supabase/migrations --apply
```
If the linter blocks a migration (missing RLS, a lock-heavy `ALTER`), that
is the PR's CI failing for a real reason — do not bypass it; see the
`scribase-write-rls-policy` skill for the fix.
## 3. On PR merge: merge the branch into production, with a human's go-ahead
Never merge into production without the explicit approval this step asks
for; "the PR was approved on GitHub" is not the same approval.
```
branches.merge { branch: "pr-<number>", apply: false } # dry run: show the plan and conflicts first
```
Show the plan and wait. Only after the user approves for this specific
branch:
```
branches.merge { branch: "pr-<number>", apply: true, confirm: true }
```
CLI: `scribase branch diff "$ORG" "$PROJECT" production "pr-$NUMBER"` then
`scribase branch merge "$ORG" "$PROJECT" production "pr-$NUMBER"` (add
`--dry-run` first). For a change that touches RLS or table shape, run the
full `scribase-safe-change` skill instead of a plain merge — it adds the
pre-merge backup and the RLS isolation proof this shortcut skips.
## 4. On PR close (merged or not): delete the branch
A branch nobody deletes is a cost and a stale credential sitting around
forever. Delete it whether the PR merged or was closed unmerged:
```
branches.delete { branch: "pr-<number>", confirm: true }
```
CLI: `scribase branch delete "$ORG" "$PROJECT" "pr-$NUMBER" --yes`. Branches
also carry a TTL (`ttl_hours` from step 1) as a backstop, so a PR left open
for longer than that is not permanently exposing a live branch — but delete
it on close anyway rather than relying on the TTL.
## 5. Report back
After step 1, tell the user the branch's URL/key were written to
`.scribase/branches/pr-<number>.env` and the PR now shows its status
comment. After step 3, report what was merged and the operation id. Never
include a secret key value in any report.