Antigravity workspace rule for focused React 19 changes with typed components, minimal Zustand selectors, effect discipline and Testing Library checks.
.agents/rules/antigravity-react-development.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
# React Development Workflow
Applies to: React single-page or framework apps written in TypeScript that use Zustand for shared client state, Tailwind CSS for styling and Vitest with React Testing Library for tests.
Version baseline: checked against React 19.2, Zustand 5, Tailwind CSS 4 and TypeScript 5.9. Read `package.json` first. If the project is on React 18 or Zustand 4, follow the installed APIs (for example `forwardRef` instead of `ref` as a prop).
## When making changes
1. Read the component you are changing, its parent, its store slice and its test before editing. Find an existing component that already solves a similar problem and follow it.
2. Make the smallest change that fixes the request. Don't rename, reformat or "clean up" unrelated code in the same change.
3. Keep existing patterns (folder layout, naming, styling approach) unless the user asks for a refactor.
4. When behavior changes, update or add the test in the same change.
5. If a requirement is ambiguous (empty states, error copy, keyboard behavior), ask or state the assumption you made in your summary.
6. Explain any architectural decision (new store slice, new context, new dependency) in one or two sentences, with the alternative you rejected.
## Components
- Write function components with typed props. Default values belong in the parameter destructuring.
- In React 19, `ref` is a regular prop for function components, so don't add `forwardRef` to new code.
- Keep state as local as possible. Only lift it, or move it into Zustand, when two distant components need it.
- Do not mirror props into state or derive state in an effect. Compute derived values during render.
- Use semantic elements (`button`, `label`, `nav`, `ul`) before ARIA roles. Every input needs a label.
```tsx
type Props = {
title: string;
count: number;
onAction: () => void;
disabled?: boolean;
};
export function CounterCard({ title, count, onAction, disabled = false }: Props) {
const label = count === 1 ? '1 item' : `${count} items`;
return (
<section className="rounded-lg border p-4">
<h2 className="text-lg font-bold">{title}</h2>
<p className="text-sm text-gray-600">{label}</p>
<button
type="button"
onClick={onAction}
disabled={disabled}
className="mt-2 rounded bg-blue-600 px-3 py-1 text-white disabled:opacity-50"
>
Add
</button>
</section>
);
}
```
## Zustand
- Use one store per domain and keep actions inside the store.
- Select the smallest slice a component needs (`useCartStore((s) => s.count)`). When a selector returns a new object or array, wrap it with `useShallow`.
```ts
import { create } from 'zustand';
type CartState = {
count: number;
add: () => void;
reset: () => void;
};
export const useCartStore = create<CartState>()((set) => ({
count: 0,
add: () => set((s) => ({ count: s.count + 1 })),
reset: () => set({ count: 0 }),
}));
```
## Effects and performance
- Use effects only to sync with something outside React (subscriptions, timers, DOM APIs), and return a cleanup function.
- If the project enables React Compiler, don't add `useMemo`, `useCallback` or `React.memo` by default. Otherwise add them only for a measured problem or a referential-equality requirement, and say which.
## Tests
- Use Vitest with React Testing Library. Query by role and accessible name (`getByRole('button', { name: 'Add' })`) and drive the UI with `@testing-library/user-event`.
- Reset Zustand stores between tests (call the store's reset action in `beforeEach`).
- Test what the user sees and does, not internal state or implementation details.
## Verify before finishing
Run these when available in the project, and report the output:
- `npx tsc --noEmit`
- `npx vitest run`
- `npx eslint .` with `eslint-plugin-react-hooks` enabled
- Describe how you checked the UI manually, including keyboard-only use for interactive changes
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.
Antigravity
frontend
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
An Antigravity agent changes a cart counter in a React 19 + TypeScript app that keeps shared state in a Zustand store, styles with Tailwind and tests with Vitest and React Testing Library.
CartBadge shows '1 items' when one product is in the cart and the Add button stays clickable while a request runs. Fix the pluralization, disable the button while pending, and update tests. Files: src/components/CartBadge.tsx, src/stores/cart.ts, src/components/CartBadge.test.tsx.
Illustrative; not a recorded model run. The agent reads the component, store and test first; changes only CartBadge and its test; computes the label during render ('1 item' / 'N items') instead of adding state; adds a typed disabled prop with a default; selects only the needed slice from the Zustand store; updates tests to query getByRole('button', { name: 'Add' }) and assert the disabled state and both labels, resetting the store in beforeEach; reports tsc, vitest and eslint results and a keyboard check.Google describes Antigravity as its agentic development platform. Antigravity reads workspace rules from AGENTS.md or GEMINI.md and from Markdown files in .agents/rules/, with a trigger front matter field that sets when a rule is active. Global rules live under ~/.gemini/.
.agents/rules/antigravity-react-development.mdStarting point, not a tested configuration for your repository. Active when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
---
trigger: glob
globs: "**/*"
---
# React Development Workflow
Applies to: React single-page or framework apps written in TypeScript that use Zustand for shared client state, Tailwind CSS for styling and Vitest with React Testing Library for tests.
Version baseline: checked against React 19.2, Zustand 5, Tailwind CSS 4 and TypeScript 5.9. Read `package.json` first. If the project is on React 18 or Zustand 4, follow the installed APIs (for example `forwardRef` instead of `ref` as a prop).
## When making changes
1. Read the component you are changing, its parent, its store slice and its test before editing. Find an existing component that already solves a similar problem and follow it.
2. Make the smallest change that fixes the request. Don't rename, reformat or "clean up" unrelated code in the same change.
3. Keep existing patterns (folder layout, naming, styling approach) unless the user asks for a refactor.
4. When behavior changes, update or add the test in the same change.
5. If a requirement is ambiguous (empty states, error copy, keyboard behavior), ask or state the assumption you made in your summary.
6. Explain any architectural decision (new store slice, new context, new dependency) in one or two sentences, with the alternative you rejected.
## Components
- Write function components with typed props. Default values belong in the parameter destructuring.
- In React 19, `ref` is a regular prop for function components, so don't add `forwardRef` to new code.
- Keep state as local as possible. Only lift it, or move it into Zustand, when two distant components need it.
- Do not mirror props into state or derive state in an effect. Compute derived values during render.
- Use semantic elements (`button`, `label`, `nav`, `ul`) before ARIA roles. Every input needs a label.
```tsx
type Props = {
title: string;
count: number;
onAction: () => void;
disabled?: boolean;
};
export function CounterCard({ title, count, onAction, disabled = false }: Props) {
const label = count === 1 ? '1 item' : `${count} items`;
return (
<section className="rounded-lg border p-4">
<h2 className="text-lg font-bold">{title}</h2>
<p className="text-sm text-gray-600">{label}</p>
<button
type="button"
onClick={onAction}
disabled={disabled}
className="mt-2 rounded bg-blue-600 px-3 py-1 text-white disabled:opacity-50"
>
Add
</button>
</section>
);
}
```
## Zustand
- Use one store per domain and keep actions inside the store.
- Select the smallest slice a component needs (`useCartStore((s) => s.count)`). When a selector returns a new object or array, wrap it with `useShallow`.
```ts
import { create } from 'zustand';
type CartState = {
count: number;
add: () => void;
reset: () => void;
};
export const useCartStore = create<CartState>()((set) => ({
count: 0,
add: () => set((s) => ({ count: s.count + 1 })),
reset: () => set({ count: 0 }),
}));
```
## Effects and performance
- Use effects only to sync with something outside React (subscriptions, timers, DOM APIs), and return a cleanup function.
- If the project enables React Compiler, don't add `useMemo`, `useCallback` or `React.memo` by default. Otherwise add them only for a measured problem or a referential-equality requirement, and say which.
## Tests
- Use Vitest with React Testing Library. Query by role and accessible name (`getByRole('button', { name: 'Add' })`) and drive the UI with `@testing-library/user-event`.
- Reset Zustand stores between tests (call the store's reset action in `beforeEach`).
- Test what the user sees and does, not internal state or implementation details.
## Verify before finishing
Run these when available in the project, and report the output:
- `npx tsc --noEmit`
- `npx vitest run`
- `npx eslint .` with `eslint-plugin-react-hooks` enabled
- Describe how you checked the UI manually, including keyboard-only use for interactive changes
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Antigravity truncates any single rule file over 24,000 bytes, and global plus always_on rules share a 20,000-token budget, according to the docs. AGENTS.md (or GEMINI.md) in a workspace directory is one of the documented rule locations, and ~/.gemini/AGENTS.md works globally. Use .agents/rules/ when a rule should only apply in some situations.
Documentation checked 2026-11-05: Google Antigravity docs: RulesGoogle Antigravity home page
Cursor rules for Tailwind CSS v4: automatic class sorting, mobile-first breakpoints, CVA variants with merging, class-based dark mode via @custom-variant, and CSS-first @theme configuration.
Cursor rules for React with TypeScript: typed function components, React 19 ref-as-prop, hooks discipline, state ownership, error boundaries and measured performance work.
CLAUDE.md rules for React 19 with TypeScript covering typed components, derived state, compiler-aware memoization, useId-based accessibility and review checks.