This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
GitAnimals is a monorepo that allows users to raise virtual pets through GitHub activity. Built with Turborepo, pnpm workspace, and features multiple client applications.
Monorepo Structure:
apps/web- Next.js 14 web application (main frontend)apps/admin- Remix admin dashboardapps/webview- Vite + React Router webview for mobile integrationapps/webview-history- Legacy Next.js webview (being migrated)packages/ui/panda- Component library using PandaCSSpackages/ui/icon- Icon componentspackages/ui/token- Design tokenspackages/api- Shared API client with interceptorspackages/lib/*- Shared libraries (react, react-query, dayjs)packages/util/*- Utility packages (common, typescript)
Key Technologies:
- Styling: PandaCSS with Shadow Panda preset for component styling
- State Management: Tanstack Query v5 (server state), Jotai & Zustand (client state)
- Authentication: NextAuth.js (web), token-based auth (webview)
- UI Components: Radix UI primitives + custom PandaCSS components
- Package Manager: pnpm v9.0+ with workspace configuration
- Build System: Turborepo for orchestration
Root-level commands (run from project root):
# Development servers
pnpm dev:web # Start web app dev server (Next.js)
pnpm dev:admin # Start admin app dev server (Remix)
pnpm dev:webview # Start webview dev server (Vite)
# Build commands
pnpm build:web # Build web application
pnpm build:admin # Build admin application
pnpm build:webview # Build webview application
# Analysis & Quality
pnpm analyze:web # Bundle analyzer for web app
pnpm lint # Lint all workspaces
pnpm format # Format code with Prettier
# UI Development
pnpm sb:panda # Start Storybook for UI componentsWorkspace-specific commands:
# Web app (apps/web)
pnpm --filter @gitanimals/web prepare # PandaCSS codegen
pnpm --filter @gitanimals/web type-check # TypeScript validation
pnpm --filter @gitanimals/web lint:fix # Fix ESLint issues
# Webview app (apps/webview)
pnpm --filter @gitanimals/webview dev # Vite dev server on port 3000
pnpm --filter @gitanimals/webview type-check # TypeScript validation
# UI components (packages/ui/panda)
pnpm --filter @gitanimals/ui-panda storybook # Start StorybookComponent Architecture:
- UI components in
packages/ui/panda/src/components/ - Each component has:
Component.tsx,Component.stories.tsx,index.ts - PandaCSS styling with design tokens from
packages/ui/token
Import Patterns:
- Workspace dependencies use
workspace:*protocol - UI components imported from
@gitanimals/ui-panda - Shared utilities from
@gitanimals/util-common
State Management:
- Server state: Tanstack Query v5 with
queryOptionspattern insrc/apis/ - Client state: Jotai for atomic state, Zustand for stores
- Auth state managed through NextAuth.js
Tanstack Query v5 Best Practices:
- Always use
queryOptionsfactory pattern for reusable query definitions - Group related queryOptions into a single exported object
- Use
useQuerydirectly with queryOptions in components (no custom hooks needed) - Example pattern:
// src/apis/user/queries.ts import { queryOptions } from '@tanstack/react-query'; export const USER_QUERY_KEYS = { all: ['user'] as const, detail: (userId: string) => ['user', userId] as const, list: () => ['user', 'list'] as const, }; // Define queryOptions factories const getUserOptions = (userId: string) => queryOptions({ queryKey: USER_QUERY_KEYS.detail(userId), queryFn: () => fetchUser(userId), enabled: !!userId, }); const getUserListOptions = () => queryOptions({ queryKey: USER_QUERY_KEYS.list(), queryFn: fetchUserList, }); // Export grouped queryOptions export const userQueryOptions = { getUser: getUserOptions, getUserList: getUserListOptions, }; // Usage in component import { useQuery } from '@tanstack/react-query'; import { userQueryOptions } from '@/apis/user/queries'; function UserProfile({ userId }: { userId: string }) { const { data: user } = useQuery(userQueryOptions.getUser(userId)); const { data: users } = useQuery(userQueryOptions.getUserList()); // ... } // Usage in Server Components (prefetching) await queryClient.prefetchQuery(userQueryOptions.getUser('123'));
- Benefits:
- Type safety with auto-completion
- Reusability in components, prefetching, SSR
- Easier testing and mocking
- Centralized query key management
- No need for custom hooks unless adding extra logic
Styling Approach:
- PandaCSS with
styled-systemgeneration - Shadow Panda preset for enhanced component styling
- Responsive design using PandaCSS conditions (mobile/desktop)
- Design tokens centralized in
packages/ui/token
- Web app: Next.js built-in testing, Storybook for components
- Mobile app: Jest with jest-expo preset
- Linting: ESLint with custom configs per workspace
- Type checking: TypeScript with shared configs in
packages/typescript-config
turbo.json- Build pipeline configurationpnpm-workspace.yaml- Workspace definitionapps/*/panda.config.ts- PandaCSS configuration per apppackages/ui/panda/src/theme/- Design system tokens and styles
The build system has specific dependency chains:
- Most builds depend on
^buildand^prepare preparetasks generate PandaCSS styled-system- Admin uses different output patterns (dist/) vs others (.next/)
- Always run
panda codegenafter theme changes - UI component changes require Storybook restart
- Mobile app uses Expo SDK ~53.0.17 with React Native 0.79.5
- Web app uses Next.js App Router with internationalization (next-intl)