Switch language to العربية

CLAUDE.md

Global and project instructions. Define preferences, keyword triggers, and behavioral guidelines.

What is CLAUDE.md?

CLAUDE.md files provide instructions that Claude Code reads at the start of every session. They define your preferences, patterns, and behaviors.

Global Instructions

~/.claude/CLAUDE.md

Applied to all projects

Project Instructions

./CLAUDE.md

Project root, checked into git

Global CLAUDE.md Template

Define your personal preferences and keyword triggers for all projects.

~/.claude/CLAUDE.mdmarkdown
# Global Claude Code Instructions

## Preferences

- **Model**: Opus 4.5 (default)
- **Package Manager**: pnpm
- **Stack**: Next.js 15, React 19, Prisma 6, TypeScript 5, Tailwind CSS 4, shadcn/ui
- **Languages**: Arabic (RTL default), English (LTR)

---

## Keyword Triggers

When user mentions these keywords, reference the mapped tools:

### Workflow Keywords

| Keyword | Agents | Commands | MCPs |
|---------|--------|----------|------|
| `push` | git-github | /push | github |
| `deploy` | - | /deploy | vercel |
| `build` | build, nextjs | /build | - |

### Creation Keywords

| Keyword | Agents | Commands |
|---------|--------|----------|
| `component` | react, shadcn | /component |
| `page` | nextjs, architecture | /page |
| `api` | api, prisma | /api |

---

## Stack to Agent Mapping

| Technology | Primary Agent | Secondary Agent |
|------------|---------------|-----------------|
| **Next.js** | nextjs | architecture |
| **React** | react | react-reviewer |
| **TypeScript** | typescript | type-safety |
| **Prisma** | prisma | database-optimizer |
| **Tailwind** | tailwind | - |

---

## Behavior

When user mentions a keyword from the trigger tables:

1. **Reference the mapped agent(s)** before starting work
2. **Use relevant MCP tools** if available
3. **Apply skills** for validation/optimization
4. **Suggest relevant commands** when appropriate

Project CLAUDE.md Template

Project-specific instructions that override or extend global settings.

./CLAUDE.mdmarkdown
# CLAUDE.md

Project-specific instructions for this repository.

## Tech Stack

- **Framework**: Next.js 16 with App Router
- **Runtime**: React 19, Node.js runtime only
- **Database**: PostgreSQL with Prisma ORM 6
- **Authentication**: NextAuth v5 (beta)
- **Styling**: Tailwind CSS v4 with OKLCH

## Commands

```bash
pnpm dev              # Development server
pnpm build            # Production build
pnpm lint             # ESLint
pnpm prisma generate  # Generate Prisma client
```

## Architecture

### Mirror-Pattern

Every URL route produces **two directories**:
- `app/[lang]/abc/` — page.tsx, layout.tsx
- `components/abc/` — content.tsx, actions.ts, types.ts

### Component Hierarchy

```
UI → Atoms → Templates → Blocks → Micro → Apps
```

## Key Patterns

### Async Request APIs (Next.js 16)

```tsx
export default async function Page(props: {
  params: Promise<{ lang: string }>
}) {
  const { lang } = await props.params;
}
```

### Authentication

```tsx
// Server Component
import { currentUser } from "@/lib/auth";
const user = await currentUser();
```

Settings & Permissions

Control what tools Claude Code can use without asking.

.claude/settings.jsonjson
{
  "permissions": {
    "allow": [
      "Bash(pnpm add:*)",
      "Bash(mkdir:*)",
      "Bash(git:*)",
      "WebFetch(domain:ui.shadcn.com)",
      "WebFetch(domain:github.com)"
    ],
    "deny": [],
    "ask": []
  }
}

Best Practices

Keep It Scannable

Use tables and bullet points. Claude reads this every session.

Be Specific

Include exact commands, paths, and patterns for your workflow.

Layer Configs

Global for personal prefs, project for team standards.

Version Control

Commit project CLAUDE.md so team shares the same context.