Petshare Setup
Use this skill when an agent is asked to spin up, fork, rebrand, deploy, or
modify this repository or a close derivative. The app is a self-hostable
React/Vite pixel-pet sharing surface: users upload Codex-compatible pet
packages, browse animated previews, download packages/GIFs, and join
multiplayer playground rooms.
This is a repo-scoped Codex skill. Keep it under
.agents/skills/petshare-setup/ so Codex can discover it from the repository.
First Read
Before editing, read:
README.md
docs/GETTING_STARTED.md
docs/PROVIDER_ADAPTERS.md
AGENTS.md
references/petshare-architecture.md when touching app behavior, uploads,
previews, animations, rooms, provider adapters, or deployment
references/security-boundary.md when publishing, documenting public setup,
reviewing exposure risk, or changing auth/moderation/provider surfaces
Non-Negotiables
- Keep changes literal to the request. Do not add fallbacks, backwards
compatibility, provider-specific public env vars, or unrelated hardening.
- Keep the browser public contract provider-neutral. Public build vars are only:
VITE_APP_API_BASE_URL, VITE_PUBLIC_APP_ORIGIN, VITE_REALTIME_URL,
VITE_REALTIME_PUBLIC_KEY, VITE_APP_NAME, VITE_APP_HANDLE,
VITE_APP_TAGLINE, and VITE_APP_REPO_URL.
- Never commit
.env, .env.local, API tokens, salts, database passwords,
provider account identifiers, generated migration exports, or local auth data.
- Use provider adapters as replaceable boundaries. Feature code under
src/
should not branch on provider names.
- Do not turn this skill into an abuse manual. Do not add copy-paste scripts,
unauthenticated client examples, raw room-event payload recipes, rate-limit
thresholds, bypass instructions, scraping loops, or moderation-evasion advice.
- For ports, follow
AGENTS.md: check a requested port before starting a
process, and never kill reserved ports unless explicitly asked.
Core Workflow
- Identify whether the task is setup, provider work, upload/asset work,
preview/GIF work, animation/playground work, multiplayer rooms, rebranding,
or security/publication review.
- Load only the reference file needed for that surface.
- Inspect current source before deciding; this repo has explicit adapter and
feature boundaries.
- Make the smallest code/doc changes that satisfy the user request.
- Run the relevant validation commands below.
- If publishing or handing off public code, run the exposure checks from
references/security-boundary.md.
Repository Map
src/domain/*: shared types, route parsing, API URLs, session storage,
gallery constants, pet kind/tag config, and sprite atlas constants.
src/app/*: SPA composition, route effects, API/session hooks, shell chrome,
modal composition, and cross-feature refresh/navigation.
src/uploads/*: file inputs, manifest parsing, slug normalization, upload
validation preview, generated share.png, generated preview.webp, and
POST /api/pets form assembly.
src/pets/*: gallery/detail pet surfaces, sprite previews, cursor preview,
metadata editing, tag/kind management, delete, share, and GIF export wiring.
src/downloads/*: package modal, install command UI, spritesheet fetch, GIF
encoding, and client-side blob download.
src/gallery/*: browse/search/filter/sort/pagination, creator pages,
collections, live room rail, and leaderboard.
src/playground/*: Three.js playground, sprite animation, room overlays,
realtime handlers, UI controls, minimap, chat, NPCs, ball, and trampoline.
src/realtime/providerClient.ts and src/realtime/roomChannel.ts: generic
frontend realtime exports.
src/realtime/adapters/*: current provider-specific realtime implementation.
adapters/cloudflare-worker/*: checked-in API, D1 schema, R2 storage,
Durable Object realtime, Worker Assets hosting, and Cloudflare deployment.
adapters/cloudflare-pages/*: optional crawler/social-share page functions
for static hosts.
scripts/*: public env validation and generated brand/social-card assets.
If a feature file starts absorbing unrelated behavior, extract into the matching
feature folder rather than adding another section to a large component.
Setup Path
npm install
cp .env.example .env.local
node scripts/check-public-build-env.mjs
npm run build
npm run dev
Vite defaults to http://127.0.0.1:5173.
The build validator fails if required public env vars are missing, malformed, or
if a VITE_* name looks secret-like. For provider/env changes, verify
.env.example, scripts/check-public-build-env.mjs, docs, and adapter config
agree exactly.
Validation Before Handoff
Always run:
npx tsc -b --pretty false
npm run build
When the Cloudflare adapter changed, also run:
npm run adapter:cloudflare:typecheck
For frontend/UI/playground changes, open the changed route in a real browser and
verify the interaction. For room changes, test at least one hosted room and one
joined room with two sessions. For upload changes, upload or seed one valid pet
and inspect detail, gallery preview, package download, GIF export, and
playground load.
Common Change Recipes
Spin Up A New Fork
- Clone, install, and copy
.env.example to .env.local.
- Set provider-neutral public env and brand env.
- Choose a backend provider.
- For Cloudflare, create Worker, D1, R2, and Durable Object resources; set
AUTH_SECRET and PET_STATS_SALT with Wrangler secrets; update only the
adapter config values that correspond to created resources.
- Run D1 migrations.
- Build and run the app.
- Register, sign out, sign in, upload one valid pet, open detail, open
playground, and open a room.
Add A New Backend Provider
- Add provider code under
adapters/<provider>/.
- Implement the same HTTP response shapes from
src/domain/types.ts.
- Implement the same upload asset contract and validation behavior.
- Add realtime code under
src/realtime/adapters/.
- Update only
currentClient.ts and currentRoomChannel.ts to point to the
new implementation after it satisfies the room interface.
- Keep docs provider-neutral except for the adapter-specific README.
Change The Sprite Atlas
- Update
src/domain/config.ts and src/playground/core/config.ts together.
- Update backend validation dimensions in
adapters/cloudflare-worker/src/api/validation.ts.
- Update preview generation and GIF export assumptions.
- Verify upload validation, gallery previews, detail previews, GIF export, solo
playground, and room playback.
Change Multiplayer Behavior
- Start from
src/realtime/roomTypes.ts and the RoomHandle contract.
- Update the provider adapter and all room handlers together.
- Keep event payloads serializable and small.
- Verify host, guest, leave/close, pet swap, chat, position, NPCs, toys, and
collection permanent rooms.
Change Uploads Or Asset Storage
- Keep
pet.json and spritesheet.webp as the package contract unless the
user explicitly changes it.
- Preserve generated
share.png and preview.webp as app assets.
- Update frontend generation, backend validation, storage writes, serializer
URLs, and download endpoint together.
- Verify upload error messages, validation card, detail route, share image,
preview strip, package zip, and room sprite loading.
Source: portons/codex-pet-share — distributed by TomeVault.
1---2name: portons-codex-pet-share-codex-pet-share3description: Petshare Setup4---56# Petshare Setup78Use this skill when an agent is asked to spin up, fork, rebrand, deploy, or9modify this repository or a close derivative. The app is a self-hostable10React/Vite pixel-pet sharing surface: users upload Codex-compatible pet11packages, browse animated previews, download packages/GIFs, and join12multiplayer playground rooms.1314This is a repo-scoped Codex skill. Keep it under15`.agents/skills/petshare-setup/` so Codex can discover it from the repository.1617## First Read1819Before editing, read:2021- `README.md`22- `docs/GETTING_STARTED.md`23- `docs/PROVIDER_ADAPTERS.md`24- `AGENTS.md`25- `references/petshare-architecture.md` when touching app behavior, uploads,26 previews, animations, rooms, provider adapters, or deployment27- `references/security-boundary.md` when publishing, documenting public setup,28 reviewing exposure risk, or changing auth/moderation/provider surfaces2930## Non-Negotiables3132- Keep changes literal to the request. Do not add fallbacks, backwards33 compatibility, provider-specific public env vars, or unrelated hardening.34- Keep the browser public contract provider-neutral. Public build vars are only:35 `VITE_APP_API_BASE_URL`, `VITE_PUBLIC_APP_ORIGIN`, `VITE_REALTIME_URL`,36 `VITE_REALTIME_PUBLIC_KEY`, `VITE_APP_NAME`, `VITE_APP_HANDLE`,37 `VITE_APP_TAGLINE`, and `VITE_APP_REPO_URL`.38- Never commit `.env`, `.env.local`, API tokens, salts, database passwords,39 provider account identifiers, generated migration exports, or local auth data.40- Use provider adapters as replaceable boundaries. Feature code under `src/`41 should not branch on provider names.42- Do not turn this skill into an abuse manual. Do not add copy-paste scripts,43 unauthenticated client examples, raw room-event payload recipes, rate-limit44 thresholds, bypass instructions, scraping loops, or moderation-evasion advice.45- For ports, follow `AGENTS.md`: check a requested port before starting a46 process, and never kill reserved ports unless explicitly asked.4748## Core Workflow49501. Identify whether the task is setup, provider work, upload/asset work,51 preview/GIF work, animation/playground work, multiplayer rooms, rebranding,52 or security/publication review.532. Load only the reference file needed for that surface.543. Inspect current source before deciding; this repo has explicit adapter and55 feature boundaries.564. Make the smallest code/doc changes that satisfy the user request.575. Run the relevant validation commands below.586. If publishing or handing off public code, run the exposure checks from59 `references/security-boundary.md`.6061## Repository Map6263- `src/domain/*`: shared types, route parsing, API URLs, session storage,64 gallery constants, pet kind/tag config, and sprite atlas constants.65- `src/app/*`: SPA composition, route effects, API/session hooks, shell chrome,66 modal composition, and cross-feature refresh/navigation.67- `src/uploads/*`: file inputs, manifest parsing, slug normalization, upload68 validation preview, generated `share.png`, generated `preview.webp`, and69 `POST /api/pets` form assembly.70- `src/pets/*`: gallery/detail pet surfaces, sprite previews, cursor preview,71 metadata editing, tag/kind management, delete, share, and GIF export wiring.72- `src/downloads/*`: package modal, install command UI, spritesheet fetch, GIF73 encoding, and client-side blob download.74- `src/gallery/*`: browse/search/filter/sort/pagination, creator pages,75 collections, live room rail, and leaderboard.76- `src/playground/*`: Three.js playground, sprite animation, room overlays,77 realtime handlers, UI controls, minimap, chat, NPCs, ball, and trampoline.78- `src/realtime/providerClient.ts` and `src/realtime/roomChannel.ts`: generic79 frontend realtime exports.80- `src/realtime/adapters/*`: current provider-specific realtime implementation.81- `adapters/cloudflare-worker/*`: checked-in API, D1 schema, R2 storage,82 Durable Object realtime, Worker Assets hosting, and Cloudflare deployment.83- `adapters/cloudflare-pages/*`: optional crawler/social-share page functions84 for static hosts.85- `scripts/*`: public env validation and generated brand/social-card assets.8687If a feature file starts absorbing unrelated behavior, extract into the matching88feature folder rather than adding another section to a large component.8990## Setup Path9192```bash93npm install94cp .env.example .env.local95node scripts/check-public-build-env.mjs96npm run build97npm run dev98```99100Vite defaults to `http://127.0.0.1:5173`.101102The build validator fails if required public env vars are missing, malformed, or103if a `VITE_*` name looks secret-like. For provider/env changes, verify104`.env.example`, `scripts/check-public-build-env.mjs`, docs, and adapter config105agree exactly.106107## Validation Before Handoff108109Always run:110111```bash112npx tsc -b --pretty false113npm run build114```115116When the Cloudflare adapter changed, also run:117118```bash119npm run adapter:cloudflare:typecheck120```121122For frontend/UI/playground changes, open the changed route in a real browser and123verify the interaction. For room changes, test at least one hosted room and one124joined room with two sessions. For upload changes, upload or seed one valid pet125and inspect detail, gallery preview, package download, GIF export, and126playground load.127128## Common Change Recipes129130### Spin Up A New Fork1311321. Clone, install, and copy `.env.example` to `.env.local`.1332. Set provider-neutral public env and brand env.1343. Choose a backend provider.1354. For Cloudflare, create Worker, D1, R2, and Durable Object resources; set136 `AUTH_SECRET` and `PET_STATS_SALT` with Wrangler secrets; update only the137 adapter config values that correspond to created resources.1385. Run D1 migrations.1396. Build and run the app.1407. Register, sign out, sign in, upload one valid pet, open detail, open141 playground, and open a room.142143### Add A New Backend Provider1441451. Add provider code under `adapters/<provider>/`.1462. Implement the same HTTP response shapes from `src/domain/types.ts`.1473. Implement the same upload asset contract and validation behavior.1484. Add realtime code under `src/realtime/adapters/`.1495. Update only `currentClient.ts` and `currentRoomChannel.ts` to point to the150 new implementation after it satisfies the room interface.1516. Keep docs provider-neutral except for the adapter-specific README.152153### Change The Sprite Atlas1541551. Update `src/domain/config.ts` and `src/playground/core/config.ts` together.1562. Update backend validation dimensions in157 `adapters/cloudflare-worker/src/api/validation.ts`.1583. Update preview generation and GIF export assumptions.1594. Verify upload validation, gallery previews, detail previews, GIF export, solo160 playground, and room playback.161162### Change Multiplayer Behavior1631641. Start from `src/realtime/roomTypes.ts` and the `RoomHandle` contract.1652. Update the provider adapter and all room handlers together.1663. Keep event payloads serializable and small.1674. Verify host, guest, leave/close, pet swap, chat, position, NPCs, toys, and168 collection permanent rooms.169170### Change Uploads Or Asset Storage1711721. Keep `pet.json` and `spritesheet.webp` as the package contract unless the173 user explicitly changes it.1742. Preserve generated `share.png` and `preview.webp` as app assets.1753. Update frontend generation, backend validation, storage writes, serializer176 URLs, and download endpoint together.1774. Verify upload error messages, validation card, detail route, share image,178 preview strip, package zip, and room sprite loading.179180---181> Source: [portons/codex-pet-share](https://github.com/portons/codex-pet-share) — distributed by [TomeVault](https://tomevault.io).182<!-- tomevault:4.0:skill_md:2026-06-19 -->