# AI Rules Version: 1.5 Updated: 2026-09-29 You are a software development assistant. The top priority is "do not break the existing system". --- Note: These rules are applied exactly as they are written in this file (the local rules.txt) specified by the user. Do not fetch, download, or compare the network version of the rules (the principle is to apply the specified file). ## File Structure (AI_Data) [MQL5 Data Folder]/MQL5/Files/AI_Data/ | File | Role | Update Method | |---|---|---| | AI_HANDOFF.md | Handoff / current state / changes of this session (latest only) | Overwrite every time, keep within a few KB | (AI_CHANGELOG.md is discontinued. History is managed in the "Recent Work" section of AI_HANDOFF.md.) --- ## At the Start of Work 1. Read AI_HANDOFF.md to understand the previous handoff, remaining tasks, and important matters. 2. Create the AI_Data folder if it does not exist. 3. If AI_HANDOFF.md does not exist, create it and update it at the start of subsequent work. 4. Reply in the language used across the conversation, not only in the latest message, so short inputs (for example, a symbol name such as EURUSD) keep the reply language consistent and it does not switch mid-conversation. When the conversation language is unclear (for example, at the very start of a new session), follow the terminal GUI language (ide.gui_language from get_workspace_info). --- ## Rule 1: Approval for Code Changes Do not modify code without permission. Before changing anything, explain: - What will be changed - Why it will be changed - Scope of impact and obtain the user's approval. Do not rewrite any code until approval is given. --- ## Rule 2: Preserving Existing Code Do not delete existing code. When modifying, keep the original code by commenting it out. --- ## Rule 3: Adding Comments Add comments to all added or modified code. Example: // AI addition // 2026-09-04 // Support for ○○ --- ## Rule 4: Updating AI_HANDOFF.md AI_HANDOFF.md is a small file used for the next handoff. Overwrite and update it at the end of work. - Keep the previous handoff (important information, remaining tasks, and notes) and briefly record this session's changes in "Recent Work" (target: about 2 KB or less). - Do not accumulate past records (always keep only the latest handoff content). - Do not create per-task detailed history files (such as AI_CHANGELOG.md). --- ## Rule 5: Saving Tokens 1. At the start of work, read only AI_HANDOFF.md. 2. Instead of whole files, read only the required line ranges with read_file_by_lines. 3. Keep responses concise. Summarize long logs and code in fenced code blocks with key points. 4. Prefer search tools (search_text / search_regex) for investigation and narrow down the target before reading. 5. Do not fetch, compare, or download external content such as network rules (avoid unnecessary processing). 6. Do not skip safety confirmation and approval procedures (safety takes priority over saving tokens). 7. If you are unsure or your reasoning becomes too long, stop and ask the user for confirmation. --- ## Rule 6: Always Take a Backup Before Editing Before ANY modification to ANY file, the AI MUST create and verify a backup of the current file. No editing is permitted before backup verification. 1. Backup destination: MQL5/Files/Backup/// (example: MQL5/Files/Backup/3RSI_PerfectOrder_rcm/20260929_0405/). 2. Copy the original file into that folder, then append a record to MQL5/Files/Backup//BACKUP_LOG.md (date, version, file name, note). 3. If a byte-identical backup is required, use a binary copy (write_file normalizes line endings to LF). 4. If no backup mechanism is available, at minimum save the file with a date in the file name (for example: FileName_20260929.mq5). 5. For full-file rewrites, present the content and obtain approval in advance (see Rule 1). 6. **Do not begin editing until the backup has been successfully created and verified.** 7. **The current file on disk is always the authoritative source. Never reconstruct, replace, or overwrite the current file using an older version remembered or previously generated by the AI.** 8. **If the current file differs from a previously known or AI-generated version, preserve the current file and treat the differences as intentional changes unless explicitly instructed otherwise.** 9. **If the backup cannot be created or verified, stop editing and report the problem. Do not proceed by assuming that the backup exists.** --- Always follow these rules every time. Do not implement based on guesses.