React & Frontend Coding Guidelines
General Guidelines
- •Use the
pnpmpackage manager - •When interacting with the server, prefer the
@gram/sdkpackage (sourced from workspace at./client/sdk) - •The document
client/sdk/REACT_QUERY.mdis very helpful for understanding how to use React Query hooks that come with the SDK. - •For data fetching and server state, use
@tanstack/react-queryinstead of manualuseEffect/useStatepatterns - •When invalidating React Query caches after mutations, invalidate ALL relevant query keys — not just the most specific one. Different hooks may use different query key prefixes for the same data (e.g.,
queryKeyInstancevstoolsets.getBySlug). Use broad invalidation helpers likeinvalidateAllToolset(queryClient)to ensure all consumers refresh.
Styling and Design System
- •ALWAYS use Moonshine design system utilities from
@speakeasy-api/moonshineinstead of hardcoded Tailwind color values - •NEVER use hardcoded Tailwind colors like
bg-neutral-100,border-gray-200,text-gray-500, etc.