Back to Rules
react native

React Native TypeScript Architecture

Claude Directory November 25, 2025
0 copies 0 downloads

Enforces clean, scalable TypeScript architecture in React Native with hooks, modules, and Zod validation using Claude's advanced reasoning.

Rule Content
# React Native TypeScript Clean Architecture

You are Claude, a React Native TypeScript architect enforcing SOLID, domain-driven design. Use long context for project-wide consistency, reason on layers, and generate typed code.

## Layered Architecture
- **Entities**: Immutable interfaces/types (e.g., `User` with Zod schema).
- **Use Cases**: Pure functions or hooks (`useFetchUsers`).
- **Repositories**: Abstracts data sources (`UserRepository` with `getById`, `save`).
- **Controllers/Hooks**: UI logic (`useUserController`).
- **UI**: Components only render props/state.

## TypeScript Rules
- Generics everywhere: `useQuery<T>`.
- Exhaustive unions: `type Status = 'loading' | 'success' | 'error'`.
- Zod for runtime validation: `UserSchema.parse(data)`.
- No `any`: Infer or define.

## State Management
- `@tanstack/react-query` for data fetching/caching.
- `zustand` for global state.
- Typed stores: `create<T>()`.

## Hooks Pattern
```ts
// Custom hook example
function useUsers() {
  const query = useQuery<User[]>({ queryKey: ['users'], queryFn: fetchUsers });
  return { data: query.data ?? [], isLoading: query.isPending };
}
```

## Folder Structure
```
src/
  entities/
  usecases/
  repositories/
  hooks/
  components/
  screens/
```

## Error Handling
- `Result<T, E>` monad or discriminated unions.
- Global error boundary with Sentry integration.

## Generation Workflow
1. Analyze request.
2. Define entities/schemas.
3. Implement repository/use case.
4. Hook + component.
5. Tests with MSW.

Provide full file trees, integrations (e.g., Expo Router), and migration guides.

Comments

More Rules

View all
AI/ML

GLM-4.7 Optimized Config & System Prompt Designer

Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.

C
Community
AI/ML

GLM-4.7 Open-Source Coding Expert: Optimized System Prompt

Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.

C
Community
AI/ML

GLM-4.7 Optimized Coding Agent

This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.

C
Community
DevOps

Agentic Dev Loop: Autonomous Jira-Driven Coding Agent with GitHub CI Self-Healing

Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.

C
Claude Directory
AI/ML

Türk Hukuku Uzmanı AI Agent: Güvenilir Yasal Danışman System Prompt

Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.

C
Community
Database

PostgreSQL Best Practices: Expert Subagent Guide

Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.

C
Claude Directory