Files
supabase/.agents/skills/test-the-docs/reference/sandbox-setup.md
Nik RichersandNik Richers 0322720743 docs: add test-the-docs skill and pm-the-docs universe lookup (#49913)
## I have read the CONTRIBUTING.md file.

YES

## What kind of change does this PR introduce?

Docs authoring skills / contributor enablement.

## What is the current behavior?

- The "Write the docs" bar asks for runnable examples, but skills stop
at lint/build (`/review-the-docs`) and do not execute inline MDX
snippets.
- Cross-repo product grounding depends on a single-repo read; there is
no skill guidance for `supabase/universe` when you have Supabase org
access.

## What is the new behavior?

- Adds `/test-the-docs` to run procedural snippets against a
Docker-isolated local stack (`supabase start` in a temp project), with
Verification table output.
- Teaches `/pm-the-docs` cross-repo product lookup
(`reference/universe-lookup.md`) with a capability gate: universe when
you have Supabase org access (or a local clone), otherwise a first-class
OSS public-search path. `ask-the-docs` stays docs-app only.
- Updates the checklist mirror, CONTRIBUTING skills table, and light
handoffs in `write-the-docs` / `review-the-docs`.

## Additional context

Vault "Write the docs" checklist updated separately; Linear document
needs a Claude-side delta sync after merge.

### Test plan

- [ ] Symlinks: `.claude/skills` is a Git symlink to
`../.agents/skills`; `.claude/skills/test-the-docs/SKILL.md` resolves
- [ ] No hardcoded personal absolute paths under `.agents/skills/`
- [ ] CONTRIBUTING lists skills including `/test-the-docs`
- [ ] `/pm-the-docs` references `universe-lookup.md` capability gate;
`/ask-the-docs` Related points there for product lookup
- [ ] OSS path: no universe clone / submodule init when `gh api
repos/supabase/universe` fails
- [ ] Docker up: dry-run `/test-the-docs` against one MDX page with
SQL/CLI (optional smoke)
- [ ] Docker down: skill documents graceful `deferred` (not silent skip)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added documentation guidance for testing runnable examples in an
isolated local environment.
- Added cross-repository product lookup guidance, including capability
checks and source tracking.
- Added verification report templates with standardized results and
environment details.

- **Documentation**
  - Expanded authoring, review, self-review, and contribution guidance.
- Improved safety instructions for local snippet testing, including
credential protection and cleanup.
- Updated repository layout, tooling, links, and workflow references for
documentation skills.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Nik Richers <nik@validmind.ai>
2026-09-04 00:34:45 +00:00

84 lines
6.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Sandbox setup
Containerized local execution for `/test-the-docs`. The **host** only starts Docker Compose and tears it down. Every MDX fence (shell, SQL, JS/TS, example-app builds) runs **inside** the disposable `runner` container — never as a host shell.
Assets live in [`../sandbox/`](../sandbox/): `compose.yaml`, `Dockerfile`, `run.sh`.
## Threat model and guardrails
| Layer | What it does |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host | `docker compose` lifecycle only (`run.sh up-*` / `down`). No fence execution. |
| Runner container | Executes fences as non-root `runner` (uid 1001). No `$HOME` mount. Work dir is `/work`; optional read-only `/examples`. |
| DinD (`stack` profile) | Privileged `docker:dind` runs an isolated Docker daemon. `supabase start` creates stack containers **inside DinD**. The runner shares DinD’s network namespace (`network_mode: service:dind`) so `127.0.0.1` healthchecks and client URLs work. Residual risk: privileged DinD; mitigate with ephemeral project names and `run.sh down`. |
| Examples profile | No DinD and no docker.sock — Node-only builds. |
This skill is for docs authors and reviewers verifying intended content. It is not unattended CI over arbitrary hostile input.
Guardrails:
- **Fences in-container only.** Never run MDX fences on the host shell. Use `./sandbox/run.sh exec` or `exec-timeout`.
- **Local stack only.** Reject snippets that target hosted or production Supabase projects.
- **No secrets in notes.** Never paste `PUBLISHABLE_KEY`, `SECRET_KEY`, `JWT_SECRET`, `ANON_KEY`, `SERVICE_ROLE_KEY`, `S3_PROTOCOL_ACCESS_KEY_ID`, `S3_PROTOCOL_ACCESS_KEY_SECRET`, or other keys into the verification report, PR body, or chat logs. Capture **URLs only** from `supabase status -o env`.
- **`curl` / `wget`.** Only to URLs from the filtered status capture (`API_URL`, `DB_URL`, `DATABASE_URL`), or to local endpoints the page under test documents. Mark other targets `deferred`.
- **`npm` / `npx` / `node`.** Only for `example-app` artifacts. Mount the app read-only at `/examples`, copy into `/work/example`, then `npm install && npm run build` (or the page’s documented build). Arbitrary `node -e`, remote `npx`, or Node from unrelated bash fences → `deferred`.
- **Prefer page commands.** Run documented steps from the MDX under test.
- **Fail closed** when Docker/Compose prerequisites for that artifact class are missing (see skill Phase 4).
## Host prerequisites (fail closed)
```bash
if [[ "$(id -u)" = "0" ]]; then
echo "error: refuse to run as root" >&2
exit 1
fi
command -v docker >/dev/null || { echo "error: docker not found" >&2; exit 1; }
docker info >/dev/null 2>&1 || { echo "error: Docker is not running" >&2; exit 1; }
docker compose version >/dev/null || { echo "error: docker compose not available" >&2; exit 1; }
```
The host does **not** need a global `supabase` CLI or Node for stack/example runs; those tools live in the runner image. If Docker/Compose is unavailable, mark artifacts that need the runner `deferred`.
`run.sh` creates temp work/output dirs world-writable (`chmod 0777`) so the non-root runner (`uid 1001`) can write into the host bind mounts.
## Lifecycle (`run.sh`)
From `.agents/skills/test-the-docs/sandbox/`:
```bash
# Optional: pin dirs / project name for the session
eval "$(./run.sh env)"
# Stack profile: DinD + runner → supabase init/start inside /work
./run.sh up-stack
# Capture URLs only inside the runner (never log credential fields)
./run.sh exec -- bash -lc '
eval "$(supabase status -o env | grep -E "^(API_URL|DB_URL|DATABASE_URL)=")"
echo "API_URL is set (value omitted from logs)"
'
# Run a fence with a deadline (process group killed on timeout)
./run.sh exec-timeout 60 -- bash -lc 'eval "$(supabase status -o env | grep -E "^(API_URL|DB_URL|DATABASE_URL)=")"; psql "$DB_URL" -c "select 1"'
# Examples profile (no DinD): mount the app, then build
TTD_EXAMPLE_DIR=/path/to/repo/examples/auth/hono ./run.sh up-examples
./run.sh exec-timeout 300 -- bash -lc 'cd /work/example && npm install && npm run build'
# Always tear down
./run.sh down
```
## Profiles
| Profile | Services | Isolation | Use when |
| ---------- | ----------------------- | -------------------------------- | --------------------------------------------- |
| `stack` | `dind` + `runner-stack` | Privileged DinD; fences off-host | SQL, CLI, client calls against local Supabase |
| `examples` | `runner` | No Docker daemon in-sandbox | `example-app` install/build only |
Do not start the stack unless the artifact needs it.
## Teardown
Always `./run.sh down` (stops `supabase` project containers when possible, `compose down -v`, removes temp work/output dirs). Leave Docker Desktop running for the next session.