# AGENTS.md - Developer Guidelines for Craze-Data-check ## Ruflo Standard Operating Procedure (SOP) **MANDATORY: Follow these steps for every user instruction.** 1. **Retrieve (Semantic Memory)**: Before starting, run `ruflo memory search -q ""` to find relevant historical patterns or previous solutions. 2. **Verify (Security)**: Use `ruflo security defend -i ""` to ensure the instruction is safe and follows security protocols. 3. **Execute (Agent Swarm)**: For complex tasks (refactors, multi-file changes), consider spawning specialized agents with `ruflo agent spawn -t `. 4. **Version Control**: Use `agentic-jujutsu` for managing concurrent changes or if a lock-free approach is needed. 5. **Record (Learning)**: After completion, record the outcome with `ruflo memory store --key "" --value ""` to improve future performance. --- ## Build, Lint, and Test Commands ### Development ```bash npm run dev # Start dev server on port 3000 npm run build # Production build npm run preview # Preview production build npm run clean # Remove dist folder ``` ### Linting & Type Checking ```bash npm run lint # TypeScript type check only (tsc --noEmit) ``` Note: No test framework configured. To add tests, install Vitest or Jest. --- ## Code Style Guidelines ### General Principles - Use TypeScript for all new code - Prefer functional components with hooks over class components - Keep components focused and modular - Use meaningful variable and function names ### Imports (order top to bottom) 1. React (`react`) 2. External libraries (`lucide-react`, `xlsx`, etc.) 3. Internal components (`./components/...`) 4. Internal lib/utils (`./lib/...`) 5. Types (`./types`) ```typescript import React, { useState, useMemo } from 'react'; import { Search, Filter, Edit2 } from 'lucide-react'; import { ExcelRow, COLUMNS } from '../types'; import { cn } from '../lib/utils'; ``` ### TypeScript Conventions - Use explicit types for props and function parameters - Use `any` sparingly; prefer union types or interfaces - Define column indices in a centralized `COLUMNS` object (see `src/types.ts`) ```typescript interface ProductDescriptionsProps { data: ExcelRow[]; onEdit: (index: number) => void; } export const COLUMNS = { ARTICLE_NO: 0, ARTICLE_NAME: 2, LINE: 7, }; ``` ### Naming Conventions | Element | Convention | Example | |---------|------------|---------| | Components | PascalCase | `ProductDescriptions`, `MatrixView` | | Functions | camelCase | `handleFileUpload`, `formatCellValue` | | Variables | camelCase | `activeModule`, `paginatedData` | | Constants | UPPER_SNAKE_CASE | `ARTICLE_NO`, `MAX_UPLOAD_SIZE` | | Interfaces | PascalCase | `AppState`, `ExcelRow` | | Types | PascalCase | `TabType`, `SortDirection` | ### React Patterns - Destructure props in function signature - Use `useMemo` for expensive computations - Use `useCallback` for event handlers passed to child components - Keep `useState` calls at the top of component ### Error Handling - Use TypeScript's type system for runtime safety - Use optional chaining (`?.`) and nullish coalescing (`??`) - Validate file uploads with proper type checks ### UI/Styling - Use Tailwind CSS for all styling - Use `cn()` utility from `lib/utils` for conditional classes - Follow existing color scheme (slate, blue, green, red for status) - Use `lucide-react` for icons ```typescript