|
| 1 | +# AI Agent Guidelines for PHPantom |
| 2 | + |
| 3 | +This is a Rust-based PHP language server. Performance and memory |
| 4 | +efficiency are critical -- PHPantom is one of the fastest language |
| 5 | +servers available and it must stay that way. |
| 6 | + |
| 7 | +## Before Committing |
| 8 | + |
| 9 | +Always run these checks before considering any change complete: |
| 10 | + |
| 11 | +```bash |
| 12 | +cargo clippy -- -D warnings |
| 13 | +cargo clippy --tests -- -D warnings |
| 14 | +cargo fmt |
| 15 | +``` |
| 16 | + |
| 17 | +Clippy runs twice: once for library code, once including tests. Run |
| 18 | +`cargo fmt` after clippy, not before -- clippy fixes can affect |
| 19 | +formatting. |
| 20 | + |
| 21 | +## Contributing Guidelines |
| 22 | + |
| 23 | +Read and follow [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for the |
| 24 | +full set of CI checks, testing conventions, and code style rules. |
| 25 | + |
| 26 | +## Key Rules |
| 27 | + |
| 28 | +- **Performance is critical.** Every allocation, clone, and lock |
| 29 | + matters. Avoid unnecessary heap allocations, prefer `&str` over |
| 30 | + `String` where possible, and be mindful of hot paths. Do not |
| 31 | + introduce regressions in startup time or memory usage. |
| 32 | +- **Run the full lint pipeline.** `cargo clippy` and `cargo fmt` must |
| 33 | + pass with zero warnings before every commit. Do not skip this. |
| 34 | +- **Update the changelog.** When a change affects user-visible |
| 35 | + behaviour, add an entry under `## [Unreleased]` in |
| 36 | + `docs/CHANGELOG.md`. Write for end users, not developers. Include |
| 37 | + `Contributed by @username` with the GitHub username of the author. |
| 38 | +- **Reference issues in commits.** When fixing a GitHub issue, include |
| 39 | + `Closes #123` in the commit message body. |
| 40 | +- **Prefer single tests.** Run individual tests (`cargo test test_name`) |
| 41 | + rather than the full suite during development for faster feedback. |
| 42 | +- **Debug root causes.** When investigating a bug, determine the root |
| 43 | + cause rather than patching symptoms. |
| 44 | +- **Clean commit history.** Use atomic commits, each representing one |
| 45 | + logical change. No fixup or WIP commits. Use |
| 46 | + [conventional commits](https://www.conventionalcommits.org/) for the |
| 47 | + subject line (`feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, etc.). |
| 48 | + The commit body should explain *why* the change was made, not just |
| 49 | + what changed. Wrap the body at 80 characters. |
| 50 | +- **Comments only where they add value.** Don't add obvious or |
| 51 | + boilerplate comments. Do comment tricky logic, non-obvious design |
| 52 | + decisions, and workarounds. Follow existing conventions. |
| 53 | + All files must end with a newline. |
0 commit comments