diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..498fd933 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,694 @@ +# Claude Agent Guidelines for Eryxon MES + +This document provides essential guidelines for AI agents (Claude) working on the Eryxon MES codebase. Following these rules ensures consistency, quality, and maintainability. + +--- + +## Agentic Workflow Rules + +### Autonomous Execution + +**Work autonomously without waiting for user input.** Continue executing tasks until: +- The goal is fully achieved within requirements +- Context length is exhausted +- A blocking error occurs that requires user intervention + +**Do NOT:** +- Stop to ask for confirmation on routine decisions +- Wait for user approval between steps +- Request clarification on well-defined tasks + +**DO:** +- Make reasonable decisions based on existing patterns +- Continue working through the entire task list +- Complete all requirements in a single session when possible + +### Scope Discipline + +**CRITICAL: Stay within the requested requirements.** + +- **Do NOT add new features** beyond what was explicitly requested +- **Do NOT refactor unrelated code** unless it directly blocks the task +- **Do NOT expand scope** with "nice to have" improvements +- **Do NOT create new patterns** when existing ones work +- **Do NOT add extra error handling, logging, or comments** beyond what's necessary + +**Example:** +``` +User: "Add a delete button to the jobs table" + +CORRECT approach: +- Add delete button +- Wire up delete mutation +- Add confirmation dialog +- Done + +INCORRECT approach: +- Add delete button +- Also add bulk delete (not requested) +- Refactor the whole table component (not requested) +- Add undo functionality (not requested) +- Update unrelated tests (not requested) +``` + +### Completion Focus + +Work until the goal is **fully achieved**: + +1. Read the requirements carefully +2. Create a mental or written checklist +3. Execute each item completely +4. Verify all requirements are met +5. Stop when done - do not gold-plate + +--- + +## Table of Contents + +- [Agentic Workflow Rules](#agentic-workflow-rules) +- [Core Principles](#core-principles) +- [Data Guidelines](#data-guidelines) +- [Localization Requirements](#localization-requirements) +- [Design System Compliance](#design-system-compliance) +- [Architecture & Modularity](#architecture--modularity) +- [Navigation & Menu Updates](#navigation--menu-updates) +- [Task Management](#task-management) +- [Code Quality Standards](#code-quality-standards) +- [File Structure Reference](#file-structure-reference) +- [Common Patterns](#common-patterns) + +--- + +## Core Principles + +### 1. Real Data Only - No Mocks + +**ALWAYS use real data from Supabase. NEVER create mock data, placeholder data, or hardcoded test values.** + +```tsx +// CORRECT - Always fetch from Supabase +const { data: jobs, isLoading } = useQuery({ + queryKey: ['jobs'], + queryFn: async () => { + const { data, error } = await supabase + .from('jobs') + .select('*') + .eq('tenant_id', tenantId); + if (error) throw error; + return data; + } +}); + +// INCORRECT - Never do this +const mockJobs = [ + { id: 1, name: 'Test Job' }, + { id: 2, name: 'Sample Job' } +]; +``` + +**Why:** Mock data creates inconsistencies, masks real data issues, and leads to bugs in production. + +### 2. Full Localization - No Hardcoded Strings + +**ALWAYS use translation keys from `src/i18n/locales/`. NEVER hardcode user-facing text.** + +```tsx +// CORRECT - Use translation hook +import { useTranslation } from 'react-i18next'; + +function Component() { + const { t } = useTranslation(); + return
{t('dashboard.activeWorkers', { count: 5 })}
+``` + +### What Must Be Localized + +- All UI labels and buttons +- Error messages and notifications +- Placeholder text +- Tooltips and hints +- Modal titles and content +- Form field labels +- Table column headers +- Status badges + +--- + +## Design System Compliance + +### CRITICAL: Read Before Any UI Work + +**Before writing any UI code, ALWAYS read:** +- `docs/DESIGN_SYSTEM.md` - Complete design guidelines +- `src/styles/design-system.css` - All CSS tokens and classes + +### Never Improvise Styles + +**ALWAYS use centralized design tokens and classes. NEVER write inline styles or custom CSS in page components.** + +```tsx +// CORRECT - Use design system classes ++ {t('newFeature.description')} +
+