# Engineering Standards for This Workspace These are the working standards for this codebase. To produce production-grade code, follow them consistently: ## Pre-Work 1. THE "STEP 0" RULE: Dead code accelerates context compaction. Before ANY structural refactor on a file >300 LOC, first remove all dead props, unused exports, unused imports, and debug logs. Commit this cleanup separately before starting the real work. 2. PHASED EXECUTION: Never attempt multi-file refactors in a single response. Break work into explicit phases. Complete Phase 1, run verification, and wait for my explicit approval before Phase 2. Each phase must touch no more than 5 files. ## Code Quality 3. SENIOR-DEV STANDARD: Prefer thorough, structural solutions over the minimal change. Don't stop at "just what was asked" or "the simplest approach" when more is warranted. If architecture is flawed, state is duplicated, or patterns are inconsistent - propose and implement structural fixes. Ask yourself: "What would a senior, experienced, perfectionist dev reject in code review?" Fix all of it. 4. ALWAYS VERIFY BEFORE CLAIMING DONE: File writes can succeed even when the code does not compile. Do not report a task as complete until you have: - Run `npx tsc --noEmit` (or the project's equivalent type-check) - Run `npx eslint . --quiet` (if configured) - Fixed ALL resulting errors If no type-checker is configured, state that explicitly instead of claiming success. ## Context Management 5. SUB-AGENT SWARMING: For tasks touching >5 independent files, you MUST launch parallel sub-agents (5-8 files per agent). Each agent gets its own context window. This matters: sequential processing of large tasks guarantees context decay. 6. CONTEXT DECAY AWARENESS: After 10+ messages in a conversation, you MUST re-read any file before editing it. Do not trust your memory of file contents. Auto-compaction may have silently destroyed that context and you will edit against stale state. 7. FILE READ BUDGET: Each file read is capped at 2,000 lines. For files over 500 LOC, you MUST use offset and limit parameters to read in sequential chunks. Never assume you have seen a complete file from a single read. 8. TOOL RESULT BLINDNESS: Tool results over 50,000 characters are silently truncated to a 2,000-byte preview. If any search or command returns suspiciously few results, re-run it with narrower scope (single directory, stricter glob). State when you suspect truncation occurred. ## Edit Safety 9. EDIT INTEGRITY: Before EVERY file edit, re-read the file. After editing, read it again to confirm the change applied correctly. The Edit tool fails silently when old_string doesn't match due to stale context. Never batch more than 3 edits to the same file without a verification read. 10. NO SEMANTIC SEARCH: You have grep, not an AST. When renaming or changing any function/type/variable, you MUST search separately for: - Direct calls and references - Type-level references (interfaces, generics) - String literals containing the name - Dynamic imports and require() calls - Re-exports and barrel file entries - Test files and mocks Do not assume a single grep caught everything. 11. BE EXTREMELY THOROUGH. Don't make this up, base it on actual protocol/standard/data etc. specifications, double-check, don't hallucinate. Read entire files. ## Verification of Effect 12. PROVE THE FIX, NOT JUST THE BUILD. Compile-green, lint-clean, and well-structured are necessary but NOT sufficient — a change can pass every static check and still target the wrong code path. Before reporting any behavior-changing work complete, state its intended effect as a falsifiable claim and verify THAT effect: a focused test, a before/after repro, an on-device log/dmesg line, or an explicit control-flow trace from trigger to effect. Any claim of effect you put in a commit message, comment, or reply must be one you verified, not one that merely looks right. Where the real build is too costly to run per-edit (AOSP / native / multi-language), use the cheapest valid proxy and name it — `sh -n` for shell, `secilc`/`checkpolicy` for sepolicy, `cargo check` or per-module `tsc`, a single-module build, a static analyzer — and never silently downgrade "I verified the behavior" to "it looks correct." 13. COVER EVERY TRIGGER PATH WHEN GATING A BEHAVIOR. When a change blocks, gates, intercepts, short-circuits, or disables a behavior, first enumerate EVERY code path that reaches it, then confirm each is covered. Gating one entry point while another stays open is a silent miss that compiles, ships, and only surfaces at runtime. Rule 10 finds symbol references; this rule is about runtime trigger paths — trace the call graph from the behavior back to its callers, list the entry points, and gate them all. ## Quality Skill Gates and Comment Hygiene 14. MANDATORY QUALITY SKILLS: These skills are not optional helpers — invoke them at their trigger points, without being asked: - **verify-this** — after ANY behavior-changing work, before claiming it done (it enforces Rule 13's falsifiable-claim workflow). - **thermo-nuclear-code-quality-review** — after completing a substantive feature or refactor, before the final commit of that work. - **deslop** — on the changed files before committing any multi-file or multi-phase work. - **Domain skills for ROM/Android work**: when working in an AOSP/LineageOS/EvolutionX source tree or on a device, consult the matching skill BEFORE improvising commands — **android-build** / **lineageos** for tree setup, lunch/mka, device trees, repopick and vendor blobs; **android** for adb/logcat/dumpsys diagnostics; **android-fastboot** for flashing and partitions; **ghidra-mcp** (the MCP server — preferred: live decompile/disassembly queries, no batch exports) with **ghidra-headless** / **binary-analysis** as fallbacks for firmware and blob RE. The skills encode tree-specific pitfalls that generic knowledge gets wrong. Treat their findings as blocking: fix or explicitly justify each one before reporting completion. 15. NO COMMENT SLOP — NEVER DUPLICATE COMMENTS: Comment density and style must match the surrounding file. Specifically: - When moving or extracting code, MOVE its comment — never leave a copy behind and never paste the same comment in two places. One fact, one comment, one location. - Never write comments that restate the code, narrate the next line, describe what you changed, or argue the change is correct. That belongs in the commit message. - No banner/section-divider comments, no boilerplate docstrings on trivial private helpers. - A comment earns its place only by stating what the code cannot: an invariant, an external constraint, the provenance of a magic number, a proven-wrong alternative. - When editing a region that already contains such slop, delete it as part of the edit (Step-0 spirit, Rule 1).