# AI Agent Rules - Live_RC (Linux/Node.js) ## Environment & Tech Stack - **OS:** Linux (Ubuntu/Debian architecture) - **Runtime:** Node.js v22/v24 LTS, npm 10+ - **Core:** Vanilla JavaScript, HTML5, SQLite (`data/rc_timing.sqlite`) - **Tests:** Native Node.js test runner (`npm test`) - **Binaries:** GLIBC 2.39+ compatible tools in `AMMC/linux_x86-64/` ## Critical Token & Kvot Optimization 1. **Compact Output Only:** NEVER rewrite or output whole files (e.g., `server.js` or `src/app.js`). Only output the exact lines, functions, or unified diffs that change. 2. **Git Hygiene:** Use `git status` or `git diff --stat` to inspect the workspace. Do not pipe huge `git diff` outputs into the context window. 3. **Ignore Data & Binaries:** Completely ignore the `data/` directory, `logs/`, and `AMMC/` binaries. Do not scan them. ## Linux Runtime Commands Always use these exact Linux commands for management: - Start Background: `npm start` - Start Foreground (Debug): `npm run start:fg` - Stop Server: `npm stop` - Check Status: `npm run status` - Run Tests: `npm test` (Runs on isolated temporary port) ## Code & Git Conventions - **Commits:** Conventional Commits (e.g., `fix(lap): repair split calculations`, `feat(audio): add linux sound trigger`). - **File System:** Ensure `chmod +x` commands are suggested if modifying scripts under `scripts/` or `AMMC/`. - Always respect frontend `localStorage` to backend SQLite synchronization. ## Feature Generation Rules (Kvot-räddare för nya funktioner) When implementing a NEW feature or module: 1. **Architecture Blueprint First:** Do NOT write the code immediately. Output a 3-bullet-point layout explaining *where* the new logic goes (e.g., frontend state, backend API route, or SQLite schema change). Wait for human confirmation. 2. **Draft Modular Skeleton:** Output only the function definitions, routes, or component names with empty bodies (stubs) first. 3. **Fill Code Incremental:** Implement the feature in small, separate code blocks (max 30 lines at a time). Never generate frontend, backend, and database changes in a single massive response. 4. **Use Existing Utilities:** Always check `server.js` and `src/app.js` for existing helper functions (like DB queries, WebSocket broadcasts, or audio hooks) instead of writing new ones from scratch.