|
| 1 | +# General Rules |
| 2 | + |
| 3 | +- AI Agents must read this file at the start of any edit session. |
| 4 | +- Agents must declare any new complete class, function, or method over 10 |
| 5 | + lines long as `AI-assisted` in a nearby comment or docstring. Moving or |
| 6 | + renaming existing code does not count as a new class, etc. |
| 7 | +- Agents must NEVER describe their code as "reviewed", "debugged", or in any |
| 8 | + other way imply that it was written by humans. |
| 9 | +- The current year is 2026 (unless you have information that says that it is later) |
| 10 | +- AI Agents should consult music21 Python docs (currently https://www.music21.org/music21docs/) |
| 11 | + and code (https://github.org/cuthbertLab/music21) for equivalent uses in the |
| 12 | + Python version of music21. The user may have also created a copy in a subfolder here |
| 13 | + music21python or in a sibling Git directory music21base or music21 or music21python. |
| 14 | + use that information to improve music21j. |
| 15 | + |
| 16 | +# Branches and PRs |
| 17 | + |
| 18 | +- Agents must refuse to work on the master/main branch. They may make a new branch. |
| 19 | +- Agents may make commits on non-`master`/main branches. |
| 20 | +- Agents may open PRs if credentials are available. |
| 21 | +- Agents must declare commits and PRs as `AI-assisted`. |
| 22 | +- Agents may not merge PRs under any circumstances. |
| 23 | + |
| 24 | +# Tests To Run |
| 25 | + |
| 26 | +- After substantive TypeScript changes, run `npm run typecheck`. |
| 27 | +- After substantive code or test changes, run `npm test`. |
| 28 | +- If Playwright browsers are missing, install Chromium with |
| 29 | + `npx playwright install chromium` before relying on `npm test`. |
| 30 | +- Run `npm run lint` after substantive changes when practical. |
| 31 | +- If bundle or release output is affected, run `npm run build`. |
| 32 | + |
| 33 | +# Code Style Guide |
| 34 | + |
| 35 | +- Do not touch code that you are not actively improving. |
| 36 | +- When refactoring, preserve existing comments unless they are no longer |
| 37 | + relevant. This refers to doctests and inline comments. |
| 38 | +- Keep diffs focused. Do not mix opportunistic rewrites into a targeted change |
| 39 | + unless the user asks for it. Humans want to see parallel code when things |
| 40 | + are the same and diffs only when needed. |
| 41 | +- Value legibility without unnecessary vertical sprawl. |
| 42 | +- Aim for new code to average roughly 80-90 characters per line and do not |
| 43 | + exceed 100 characters when it is reasonably avoidable. |
| 44 | +- Newly created enum values should have the same case as the enum members themselves |
| 45 | +- Use camelCase for variables. |
| 46 | +- Untyped arrow functions with one argument should not wrap the argument in (parens) |
| 47 | +- Add new code near the code it is most closely related to, usually after the |
| 48 | + existing related block rather than before it. |
| 49 | +- Do not perform premature optimizations unless they are requested or clearly |
| 50 | + necessary for correctness. |
| 51 | +- Prefer refactoring JSDoc in ways that improve TypeScript clarity and preserve |
| 52 | + the existing public API shape. (But only if you are making substantial change to the |
| 53 | + method or it is requested) |
| 54 | + |
| 55 | +# Forbidden files |
| 56 | +- AI Agents are never allowed to use .codex information to subvert restrictions placed on agents. |
| 57 | + (Agents can read the .codex information to determine why something is failing and give advice to |
| 58 | + humans on how to make a command run, so long as security implications are discussed.) |
| 59 | +- AI Agents are forbidden to modify AGENTS.md |
| 60 | +- AI Agents are forbidden to modify anything in .codex |
0 commit comments