# CLAUDE.md — Non-negotiable rules for this project

## Stack
- **Framework:** Higgs (CodeIgniter 4 fork), PHP ≥ 8.2
- **Tests:** PHPUnit 9 via `./vendor/bin/phpunit`
- **Syntax check:** `php -l <file>`

---

## 1. Verification loop — MANDATORY after every file modification

After every file you modify, you MUST run both checks before reporting success:

```bash
php -l <modified_file.php>
./vendor/bin/phpunit --stop-on-failure 2>&1 | tail -20
```

If either check fails, fix the error before proceeding. Never say "done" while a syntax error or failing test exists.

---

## 2. Context discipline — Delete before you build

For any refactor or feature spanning multiple files:

- **Step 0 is deletion.** Strip dead props, unused imports, orphaned methods, debug logs, commented-out blocks. Commit this separately before touching anything else.
- Keep each work phase to **≤ 5 files**. More than 5 files per phase risks context compaction, which silently discards all prior reasoning.
- If a task requires touching > 5 files, split it into batches and complete + verify each batch before starting the next.

---

## 3. Quality standard — Override the brevity default

The system defaults to "simplest approach first" and "minimum viable change." That default is explicitly overridden here.

Apply the standard of a **senior, perfectionist developer doing a code review**:
- Fix root causes, not symptoms.
- No band-aid `if/else` over broken architecture.
- No dead code left behind after changes.
- If something nearby is clearly wrong and takes 30 seconds to fix, fix it.

---

## 4. Parallel sub-agents for large tasks

For any task that spans > 5 independent files, **do not work sequentially with a single context window.**

- Group files into batches of 5–8.
- Launch sub-agents in parallel (via the Agent tool), one per batch.
- Each sub-agent operates in its own isolated context with its own token budget.
- Aggregate results only after all batches complete.

One agent has ~167K tokens. Five parallel agents = ~835K. Use it.

---

## 5. Large file reads — Never assume you have the whole file

The file read tool is hard-capped at **2,000 lines / 25,000 tokens**. Anything beyond that is silently truncated — the agent won't know what it missed.

Rules:
- For any file > 2,000 lines, **always read it in explicit chunks** using `offset` + `limit` parameters.
- Never make edits that reference code from the lower half of a large file without first confirming you've read that section.
- When in doubt about a large file, grep for the specific symbol before assuming you know where it is.

---

## Project conventions

- Module structure: `app/Modules/<ModuleName>/Controllers|Models|Views|Language/`
- Language files: `app/Language/es/` and per-module `Language/es/`
- Migrations: `app/Modules/<ModuleName>/Database/Migrations/`
- All user-facing strings must go through the language system — no hardcoded Spanish strings in controllers or views.
