# AUDIT PROTOCOL: FRONTEND SOLIDJS

**Target Stack:** TypeScript, SolidJS, Vite
**Context:** Lean Code Philosophy
**Executor:** AI Agent / LLM

---

## 1. PRIME DIRECTIVE: LEAN CODE

Every line of code must verify its existence against:

1.  **Value**: Does this add direct user or business value?
2.  **Necessity**: Can this be done simpler? (KISS)
3.  **Uniqueness**: Is this logic repeated? (DRY)
4.  **Relevance**: Is this "Just in Case" code? (YAGNI) -> **DELETE IT**.

---

## 2. REACTIVITY & STATE

### 2.1 Signals vs Effects

- **Rule**: Prefer Derived Signals (`createMemo` / function getters) over `createEffect` for synchronous updates.
- **Violation**: Using `createEffect` to update signal B when signal A changes.
- **Fix**: Define B as `const B = () => A() * 2;`.

### 2.2 Store Usage

- **Rule**: Use `createStore` for complex nested state (objects/arrays).
- **Violation**: Nested Signals or manually updating object properties in a Signal.

### 2.3 Cleanup

- **Rule**: Verify `onCleanup` is used for events/timers.
- **Violation**: `setInterval` without a corresponding clear in `onCleanup`.

---

## 3. COMPONENT ARCHITECTURE

### 3.1 Single Responsibility

- **Rule**: Components must do one thing.
- **Violation**: A component that handles data fetching, complex UI logic, and multiple distinct views.

### 3.2 Size Limits

- **Warning**: > 150 lines.
- **Critical**: > 250 lines.
- **Fix**: Extract sub-components or moving logic to hooks/primitives.

### 3.3 Prop Drilling

- **Rule**: Avoid passing props through more than 2 layers.
- **Fix**: Use Context API for deep state.

---

## 4. STYLING & GENERAL

### 4.1 Styling Consistency

- **Rule**: Adhere to the project's chosen strategy (Tailwind OR CSS Modules).
- **Violation**: Mixing Tailwind classes with inline `style={{ ... }}` objects.

### 4.2 Zombie Code

- **Rule**: No commented-out code.
- **Fix**: Delete it.

### 4.3 Logging

- **Rule**: No `console.log` in production code.
- **Fix**: Remove or use a logger utility that disables in production.

### 4.4 Health Endpoint

- **Rule**: /health.json con versión dinámica (generado en build desde package.json).
- **Violation**: No hay forma de verificar versión en producción.

---

## 5. AUDIT EXECUTION

1.  **Scan** `src/` recursively.
2.  **Identify** violations of the rules above.
3.  **Score** the codebase (0-100). < 80 is FAILED.
4.  **Report** findings in the standard format.
