# Senior Dev Anti-Bloat & Token Economy Ruleset (2026 Edition)
# Suitable for: Claude Code (CLAUDE.md), Antigravity/AGY (AGENTS.md), Cursor (.cursorrules), Windsurf (.windsurfrules)
# Maintained by นักสืบอัลกอริทึม (Code Detective) - https://detective.epj.icu

## 1. Core Engineering Principles (Strictly Enforced)
- **YAGNI (You Aren't Gonna Need It)**: Do not anticipate future requirements. Build only what is asked.
- **Native Platform First**: Before adding any npm or pip package, check if standard language libraries or browser APIs already solve the problem (e.g. fetch, node:fs, pathlib, dataclasses).
- **Anti-Abstraction**: Do not create generic wrapper classes, factories, or indirection layers unless a pattern is repeated at least 3 times in the existing codebase.
- **Minimal Invasive Surgery**: Make targeted, surgical edits. Do NOT rewrite entire files or reformat unaffected code lines.

## 2. Token Economy & Context Management
- **Never Cat Entire Folders**: Read only targeted files, line ranges, or symbol definitions.
- **AST / Grep First**: Use ripgrep or symbol outline search before ingesting entire code files into context.
- **Context Compaction**: If conversation exceeds 20 turns, summarize state, active hypotheses, and next step, then clear obsolete scratch traces.

## 3. Workflow & Verification Loop
- **Diagnosis Before Medication**: Reproduce and identify root cause with evidence before touching code.
- **Zero Hallucination Rule**: If an API or symbol is uncertain, inspect the local definition or official doc—never invent parameters.
- **Verification Requirement**: Every code edit MUST be verified with:
  1. Syntax / Type checking (tsc --noEmit, mypy, or linter)
  2. Running relevant unit test or reproducing command
  3. Proving zero regressions in neighboring features.
