|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Workflow Requirements |
| 6 | + |
| 7 | +- **Always create a Linear ticket** for all work before starting |
| 8 | +- **Always create a new PR** for all changes - do not commit directly to main |
| 9 | + |
| 10 | +## Project Overview |
| 11 | + |
| 12 | +@seamapi/react is a React component library for Seam smart device management. It provides white-labeled UI components for device management, access codes, and thermostat controls. Components are available as React components and as native Web Components. |
| 13 | + |
| 14 | +## Tech Stack |
| 15 | + |
| 16 | +- **React 18+** with TypeScript |
| 17 | +- **Vite** for building elements bundle |
| 18 | +- **tsc/tsc-alias** for TypeScript compilation |
| 19 | +- **Vitest** with happy-dom for testing |
| 20 | +- **Storybook 7** for component development |
| 21 | +- **SCSS** for styling (compiled with Sass) |
| 22 | +- **@tanstack/react-query** for data fetching |
| 23 | +- **@seamapi/http** for Seam API communication |
| 24 | +- **@seamapi/react-query** for query hooks |
| 25 | + |
| 26 | +## Essential Commands |
| 27 | + |
| 28 | +```bash |
| 29 | +npm start # Start Storybook development (runs examples + storybook) |
| 30 | +npm run build # Build the library (JS + CSS + elements) |
| 31 | +npm test # Run tests with Vitest |
| 32 | +npm run test:watch # Run tests in watch mode |
| 33 | +npm run lint # Run ESLint + Prettier + Stylelint |
| 34 | +npm run format # Auto-fix linting issues |
| 35 | +npm run typecheck # Run TypeScript type checking |
| 36 | +npm run storybook # Run Storybook only |
| 37 | +npm run examples # Run example apps |
| 38 | +npm run generate # Generate icon components from SVGs in assets/icons |
| 39 | +``` |
| 40 | + |
| 41 | +## Project Structure |
| 42 | + |
| 43 | +``` |
| 44 | +src/ |
| 45 | +├── index.ts # Main export entry point |
| 46 | +├── hooks.ts # Hooks-only entry point |
| 47 | +├── elements.ts # Web Components entry point |
| 48 | +├── index.scss # Main stylesheet |
| 49 | +└── lib/ |
| 50 | + ├── seam/ |
| 51 | + │ ├── SeamProvider.tsx # Main context provider |
| 52 | + │ ├── components/ # UI components |
| 53 | + │ │ ├── AccessCodeDetails/ |
| 54 | + │ │ ├── AccessCodeTable/ |
| 55 | + │ │ ├── ConnectAccountButton/ |
| 56 | + │ │ ├── CreateAccessCodeForm/ |
| 57 | + │ │ ├── DeviceDetails/ |
| 58 | + │ │ ├── DeviceTable/ |
| 59 | + │ │ ├── EditAccessCodeForm/ |
| 60 | + │ │ └── SupportedDeviceTable/ |
| 61 | + │ ├── access-codes/ # Access code hooks |
| 62 | + │ ├── client-sessions/ # Session hooks |
| 63 | + │ ├── connected-accounts/ # Account hooks |
| 64 | + │ ├── devices/ # Device hooks |
| 65 | + │ └── thermostats/ # Thermostat hooks |
| 66 | + └── icons/ # Generated SVG icon components |
| 67 | +``` |
| 68 | + |
| 69 | +## Key Architecture Patterns |
| 70 | + |
| 71 | +### Component Structure |
| 72 | + |
| 73 | +Each component typically has: |
| 74 | + |
| 75 | +- `ComponentName.tsx` - Main component implementation |
| 76 | +- `ComponentName.element.ts` - Web Component wrapper |
| 77 | +- `ComponentName.stories.tsx` - Storybook stories |
| 78 | +- `ComponentName.test.tsx` - Component tests (optional) |
| 79 | + |
| 80 | +### Entry Points |
| 81 | + |
| 82 | +- `@seamapi/react` - Full library (components + hooks) |
| 83 | +- `@seamapi/react/hooks` - Hooks only (lighter bundle) |
| 84 | +- `@seamapi/react/elements` - Web Components bundle |
| 85 | + |
| 86 | +### Path Aliases |
| 87 | + |
| 88 | +- `lib/*` → `./src/lib/*` |
| 89 | +- `fixtures/*` → `./test/fixtures/*` |
| 90 | +- `@seamapi/react` → `./src/index.ts` |
| 91 | + |
| 92 | +## Code Style |
| 93 | + |
| 94 | +- ESLint with standard-with-typescript config |
| 95 | +- Prettier for formatting |
| 96 | +- Stylelint for SCSS |
| 97 | +- Import sorting via eslint-plugin-simple-import-sort |
| 98 | +- Require `.js` extensions in imports (ES modules) |
| 99 | +- Use inline type imports: `import { type Foo } from 'bar.js'` |
| 100 | +- All CSS classes are prefixed with `seam-` |
| 101 | + |
| 102 | +## Testing |
| 103 | + |
| 104 | +Tests use Vitest with happy-dom environment. Test fixtures are in `test/fixtures/`. |
| 105 | + |
| 106 | +```bash |
| 107 | +npm test # Run all tests |
| 108 | +npm run test:update # Update snapshots |
| 109 | +npm run test:ui # Open Vitest UI |
| 110 | +``` |
| 111 | + |
| 112 | +## Fake Seam Connect |
| 113 | + |
| 114 | +The project uses @seamapi/fake-seam-connect for deterministic testing and Storybook development. Seed data is in `.storybook/seed-fake.js`. |
| 115 | + |
| 116 | +## Publishing |
| 117 | + |
| 118 | +- Automatic releases via semantic-release based on Angular commit message conventions |
| 119 | +- Manual releases via GitHub Actions workflow dispatch |
0 commit comments