|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Repository-level standards for Codex, Copilot, and other AI coding agents. |
| 4 | + |
| 5 | +This file defines how agents must operate to produce production-ready code. |
| 6 | +If a subdirectory has stricter instructions, follow both; if they conflict, use the more restrictive rule. |
| 7 | + |
| 8 | +## Core Outcome |
| 9 | + |
| 10 | +All agent work must be: |
| 11 | + |
| 12 | +- Correct and behaviorally safe |
| 13 | +- Testable and reproducible |
| 14 | +- Secure by default |
| 15 | +- Backward-compatible unless explicitly approved |
| 16 | +- Reviewable through small, clear diffs |
| 17 | + |
| 18 | +## Documentation Location Policy (Mandatory) |
| 19 | + |
| 20 | +- All AI-generated docs must be placed under `AI-DOCs/`. |
| 21 | +- Do not add AI-generated docs under app/code directories such as `main/`, `src/`, `test/`, or package folders. |
| 22 | +- If a task needs documentation, create or update files in `AI-DOCs/` unless the user explicitly asks otherwise. |
| 23 | + |
| 24 | +## Documentation Naming Rules |
| 25 | + |
| 26 | +- Use `kebab-case` file names. |
| 27 | +- Prefix date when useful: `YYYY-MM-DD-topic.md`. |
| 28 | +- Keep one concern per file (design note, runbook, handoff, postmortem, etc.). |
| 29 | + |
| 30 | +## Engineering Standards |
| 31 | + |
| 32 | +### 1) Scope Discipline |
| 33 | + |
| 34 | +- Only change what is necessary for the request. |
| 35 | +- Do not refactor unrelated modules unless explicitly requested. |
| 36 | +- Keep each change atomic and explainable. |
| 37 | + |
| 38 | +### 2) API and Compatibility |
| 39 | + |
| 40 | +- Preserve public API behavior by default. |
| 41 | +- If a breaking change is required, document it clearly and provide migration guidance. |
| 42 | +- Avoid hidden behavioral changes in existing call paths. |
| 43 | + |
| 44 | +### 3) Security and Safety |
| 45 | + |
| 46 | +- Never hardcode secrets, keys, tokens, or credentials. |
| 47 | +- Validate and sanitize all external/user-controlled inputs. |
| 48 | +- Prefer fail-safe behavior on invalid state or malformed input. |
| 49 | +- Minimize attack surface: least privilege, least data exposure, least capability. |
| 50 | + |
| 51 | +### 4) Reliability and Error Handling |
| 52 | + |
| 53 | +- Avoid panics for recoverable runtime conditions. |
| 54 | +- Return structured errors with actionable context. |
| 55 | +- Do not silently swallow failures. |
| 56 | +- Keep retries bounded and deterministic. |
| 57 | + |
| 58 | +### 5) Performance and Scalability |
| 59 | + |
| 60 | +- Avoid obviously unbounded algorithms in hot paths. |
| 61 | +- Reuse existing components and avoid duplicate data transformations. |
| 62 | +- Consider memory overhead and serialization costs for large scenes/data. |
| 63 | + |
| 64 | +### 6) Readability and Maintainability |
| 65 | + |
| 66 | +- Prefer simple, explicit code over clever shortcuts. |
| 67 | +- Keep functions focused and names descriptive. |
| 68 | +- Add concise comments only where intent is not obvious from code. |
| 69 | + |
| 70 | +## Testing and Validation Standards (Mandatory) |
| 71 | + |
| 72 | +Before finalizing a change, run relevant checks for touched areas: |
| 73 | + |
| 74 | +- Formatting |
| 75 | +- Static/build checks |
| 76 | +- Tests |
| 77 | +- Example/integration command for user-facing features |
| 78 | + |
| 79 | +Minimum expectations: |
| 80 | + |
| 81 | +- Run project-standard commands where available (for example `cargo fmt`, `cargo check`, `cargo test`). |
| 82 | +- If full validation cannot run, report exactly: |
| 83 | + - which command failed or was skipped |
| 84 | + - why |
| 85 | + - residual risk |
| 86 | + |
| 87 | +## Change Management |
| 88 | + |
| 89 | +- Prefer incremental commits with focused intent. |
| 90 | +- Do not commit generated binaries or transient artifacts. |
| 91 | +- Keep diffs review-friendly and avoid noisy unrelated formatting churn. |
| 92 | + |
| 93 | +## Pull Request / Handoff Standard |
| 94 | + |
| 95 | +For significant changes, add/update a short handoff note in `AI-DOCs/` including: |
| 96 | + |
| 97 | +- What changed |
| 98 | +- Why it changed |
| 99 | +- How to test locally |
| 100 | +- Backward-compatibility notes |
| 101 | +- Known caveats and follow-ups |
| 102 | + |
| 103 | +## Definition of Done |
| 104 | + |
| 105 | +A task is done only when all are true: |
| 106 | + |
| 107 | +- Requested functionality is implemented end-to-end. |
| 108 | +- Quality gates have been run or limitations are explicitly documented. |
| 109 | +- Documentation and examples are updated when behavior/API changed. |
| 110 | +- No unintended artifacts are introduced into version control. |
| 111 | +- Result is ready for production review without hidden assumptions. |
0 commit comments