--- name: new description: End-to-end workflow for building a new Terrae component from scratch argument-hint: [component-name] --- # Create New Component Skill End-to-end workflow for building a new Terrae component from scratch. Covers all 8 outputs: - Component source - Registry - Exports - Documentation - Examples - Sidebar - Components page - Changelog Component structure, patterns, responsiveness, and performance rules are in `.claude/rules/react/component.md`. ## All Outputs | # | Output | File(s) | | --- | --------------------- | ------------------------------------------------------ | | 1 | Component source file | `src/registry/map/{name}.tsx` | | 2 | Barrel export | `src/registry/map/index.tsx` (update) | | 3 | Registry entry | `registry.json` (update) | | 4 | Example file(s) | `src/app/docs/_components/examples/{name}-example.tsx` | | 5 | Documentation page | `src/app/docs/{slug}/page.tsx` | | 6 | Sidebar navigation | `src/app/docs/_components/docs-sidebar.tsx` (update) | | 7 | Components listing | `src/app/docs/components/page.tsx` (update) | | 8 | Changelog entry | `src/app/docs/changelog/page.tsx` (update) | ## Instructions When the developer requests a new component: ### Step 1: Gather Requirements Ask for: - Component name (e.g., `MapHeatmap`, `MapPolygon`) - Core functionality - Whether it needs compound components (like `MarkerContent`, `MarkerPopup`) - Category: `"core"` or `"features"` (most components are features) - Lucide icon for the sidebar and components page - Whether it exposes a control hook (e.g., `useHeatmapControl`) If there are multiple valid implementation approaches (e.g., Mapbox layers vs DOM overlay, canvas vs CSS animations, GeoJSON source vs custom rendering), present the options with trade-offs and let the developer choose before writing code. ### Step 2: Create the Component File and Export Follow the map component rules in `.claude/rules/react/component.md` for the component structure, template, patterns, and barrel export. - Location: `src/registry/map/{component-name}.tsx` - Use kebab-case for file names (e.g., `heat-map.tsx`) - Export from `src/registry/map/index.tsx` ### Step 3: Add Registry Entry Update `registry.json` by adding an entry to the `items` array. Follow this structure: ```json { "name": "heat-map", "type": "registry:ui", "title": "Map Heatmap", "description": "Short description of the component.", "dependencies": ["mapbox-gl"], "devDependencies": ["@types/mapbox-gl"], "registryDependencies": ["https://www.terrae.dev/map.json"], "files": [ { "path": "src/registry/map/heat-map.tsx", "type": "registry:ui", "target": "components/ui/map/heat-map.tsx" } ] } ``` ##### Key rules: - `name` uses kebab-case with ``prefix (e.g.,`heat-map`) - `registryDependencies` always includes `["https://www.terrae.dev/map.json"]` (the core `Map` component that all other components depend on) - Add extra `dependencies` only if the component needs packages beyond `mapbox-gl` - Components that don't need `mapbox-gl` directly can have empty `dependencies` (e.g., watermark) ### Step 4: Create Example File(s) Location: `src/app/docs/_components/examples/{name}-example.tsx` Use kebab-case for the file name. The basic example should demonstrate the simplest usage of the component. ```typescript import { Map, MapHeatmap } from "@/registry/map" export const HeatmapExample = () => { const accessToken = process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN || "" return (
First, make sure you have the base map component installed:
Then install the heatmap component:
MapHeatmap component for
visualizing data density on the map. Supports customizable color ramps, radius control,
and intensity adjustment.
>
),
href: "/docs/heatmap",
},
```
##### Key rules:
- Add under `components` for new components, `features` for new features, `fixes` for bug fixes, `properties` for new props
- The `description` uses JSX with inline `` tags for component names
- Always include `href` linking to the docs page
### Step 9: Review with User
Before finalizing, show all changes:
- The component source code
- The barrel export addition
- The registry entry
- The example file(s)
- The documentation page
- The sidebar entry
- The components page entry
- The changelog entry