From aa1c8b56a4f8245592e443c352f8c9b7ccc75ea0 Mon Sep 17 00:00:00 2001 From: takehiroman Date: Sat, 21 Mar 2026 10:34:50 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20SKILL.md=E3=82=92=E6=96=B0=E8=A6=8F?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E3=80=81=E3=83=AA=E3=83=9D=E3=82=B8?= =?UTF-8?q?=E3=83=88=E3=83=AA=E3=81=AE=E4=BD=9C=E6=A5=AD=E3=83=AB=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=A8=E3=82=A2=E3=83=BC=E3=82=AD=E3=83=86=E3=82=AF?= =?UTF-8?q?=E3=83=81=E3=83=A3=E3=82=92=E6=96=87=E6=9B=B8=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SKILL.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 SKILL.md diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..4b8974b --- /dev/null +++ b/SKILL.md @@ -0,0 +1,62 @@ +--- +name: splatoon-random-weapon +description: Use this skill when working in the splatoon-random-weapon repository. It covers the Preact + Vite frontend, the Hono API running on Cloudflare Pages Functions, and the D1/KV data flow used for random weapon selection and result history. +--- + +# Splatoon Random Weapon + +Use this skill for feature work, bug fixes, refactors, or reviews in this repository. + +## Repo map + +- `src/main.tsx`: frontend entry point. +- `src/app.tsx`: main UI flow. This is the first place to inspect for product behavior. +- `src/components/`: presentational UI components. +- `functions/api/[[route]].ts`: API entry point for Cloudflare Pages Functions. +- `functions/api/routes/weapon.ts`: D1-backed weapon endpoints. +- `functions/api/routes/result.ts`: KV-backed result endpoint. +- `wrangler.toml`: Cloudflare bindings for D1 (`DB`) and KV (`RANDOM_WEAPONS`). + +## Architecture + +- Frontend uses `preact`, `vite`, `tailwindcss`, and `swr`. +- API uses `hono` on Cloudflare Pages Functions under `/api`. +- The frontend builds a typed client with `hc('/')` and calls: + - `GET /api/weapons/random?count=` + - `GET /api/results` +- Local Vite dev proxies `/api` to `http://localhost:3000`. + +## Working rules for this repo + +- Treat `src/app.tsx` as the current source of truth for user-visible behavior. +- Keep frontend and API changes aligned. If you change an API response shape, update the typed client usage in `src/app.tsx` in the same task. +- Be careful with the boundary between real data and placeholders: + - `useSWR('results', ...)` fetches live result data from KV. + - `cards` in `src/app.tsx` are currently hardcoded sample history entries. + - Do not assume the rendered history UI is already wired to backend data. +- `src/constants/weapon.ts` appears to be legacy or unused. Confirm usage before editing it. +- `tsconfig.json` includes only `src`, even though the frontend imports types from `functions/`. If type changes behave strangely, inspect this include boundary first. +- `README.md` mentions `lefthook`, while `package.json` is configured for `husky` and `lint-staged`. Avoid assuming hooks are consistently installed. + +## Safe change workflow + +1. Read `src/app.tsx` and the relevant route files before editing. +2. Prefer the existing API shape and component patterns unless the task clearly requires a change. +3. For backend changes, verify the corresponding Cloudflare binding exists in `wrangler.toml`. +4. For frontend changes, check whether data is live or placeholder before wiring UI logic. +5. Run the narrowest useful verification available after edits. + +## Verification + +- Install dependencies: `npm install` +- Frontend dev server: `npm run dev` +- Lint scripts: `npm run lint:script` +- Lint styles: `npm run lint:style` + +If a task touches Cloudflare runtime behavior, note that local verification may also require a Pages/Workers dev setup that is not fully captured by current package scripts. + +## Known pitfalls + +- `functions/api/routes/weapon.ts` builds the SQL `LIMIT` clause from the query string directly. Be cautious when changing request handling there. +- `index.html` still has the default Vite title, so product polish tasks may need to update app metadata. +- `wrangler.toml` contains concrete binding IDs. Do not rotate or replace them casually. From 2051f19744879fd31dcc8edcb757dee183b4c598 Mon Sep 17 00:00:00 2001 From: takehiroman Date: Sat, 21 Mar 2026 10:35:43 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=E3=83=9C=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=ABdisabled=E3=83=97=E3=83=AD=E3=83=91=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81=E3=82=AB=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=AB=E3=82=B5=E3=83=96=E3=82=BF=E3=82=A4=E3=83=88?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Button.tsx | 10 ++++++++-- src/components/Card.tsx | 12 ++++++++++-- src/components/CardList.tsx | 9 ++++++++- src/components/SelectBox.tsx | 3 +++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 5c15bef..2c91922 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -3,12 +3,18 @@ import { h, FunctionComponent } from 'preact' type ButtonProps = { text: string onClick: () => void + disabled?: boolean } -export const Button: FunctionComponent = ({ text, onClick }) => { +export const Button: FunctionComponent = ({ + text, + onClick, + disabled = false, +}) => { return (