Skip to content

Commit 5cc9ade

Browse files
authored
Merge pull request #3289 from hathach/add-agents-md
added AGENTS.md
2 parents 87523f2 + 97f814a commit 5cc9ade

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

AGENTS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Agent Handbook
2+
3+
## Shared TinyUSB Ground Rules
4+
- Keep TinyUSB memory-safe: avoid dynamic allocation, defer ISR work to task context, and follow C99 with two-space indentation/no tabs.
5+
- Match file organization: core stack under `src`, MCU/BSP support in `hw/{mcu,bsp}`, examples under `examples/{device,host,dual}`, docs in `docs`, tests under `test/{unit-test,fuzz,hil}`.
6+
- Use descriptive snake_case for helpers, reserve `tud_`/`tuh_` for public APIs, `TU_` for macros, and keep headers self-contained with `#if CFG_TUSB_MCU` guards where needed.
7+
- Prefer `.clang-format` for C/C++ formatting, run `pre-commit run --all-files` before submitting, and document board/HIL coverage when applicable.
8+
- Commit in imperative mood, keep changes scoped, and supply PRs with linked issues plus test/build evidence.
9+
10+
## Build and Test Cheatsheet
11+
- Fetch dependencies once with `python3 tools/get_deps.py [FAMILY]`; assets land in `lib/` and `hw/mcu/`.
12+
- CMake (preferred): `cmake -G Ninja -DBOARD=<board> -DCMAKE_BUILD_TYPE={MinSizeRel|Debug}` inside an example `build/` dir, then `ninja` or `cmake --build .`.
13+
- Make (alt): `make BOARD=<board> [DEBUG=1] [LOG=2 LOGGER=rtt] all` from the example root; add `uf2`, `flash-openocd`, or `flash-jlink` targets as needed.
14+
- Bulk builds: `python3 tools/build.py -b <board>` to sweep all examples; expect occasional non-critical objcopy warnings.
15+
- Unit tests: `cd test/unit-test && ceedling test:all` (or a specific `test_<module>`), honor Unity/CMock fixtures under `test/support`.
16+
- Docs: `pip install -r docs/requirements.txt` then `sphinx-build -b html . _build` from `docs/`.
17+
18+
## Validation Checklist
19+
1. `pre-commit run --all-files` after edits (install with `pip install pre-commit && pre-commit install`).
20+
2. Build at least one representative example (e.g., `examples/device/cdc_msc`) via CMake+Ninja or Make.
21+
3. Run unit tests relevant to touched modules; add fuzz/HIL coverage when modifying parsers or protocol state machines.
22+
23+
## Copilot Agent Notes (`.github/copilot-instructions.md`)
24+
- Treat this handbook as authoritative before searching or executing speculative shell commands; unexpected conflicts justify additional probing.
25+
- Respect build timing guidance: allow ≥5 minutes for single example builds and ≥30 minutes for bulk runs; never cancel dependency fetches or builds mid-flight.
26+
- Support optional switches: `-DRHPORT_DEVICE[_SPEED]`, logging toggles (`LOG=2`, `LOGGER=rtt`), and board selection helpers from `tools/get_deps.py`.
27+
- Flashing shortcuts: `ninja <target>-jlink|openocd|uf2` or `make BOARD=<board> flash-{jlink,openocd}`; list Ninja targets with `ninja -t targets`.
28+
- Keep Ceedling installed (`sudo gem install ceedling`) and available for per-test or full suite runs triggered from `test/unit-test`.
29+
30+
## Claude Agent Notes (`CLAUDE.md`)
31+
- Default to CMake+Ninja for builds, but align with Make workflows when users rely on legacy scripts; provide DEBUG/LOG/LOGGER knobs consistently.
32+
- Highlight dependency helpers (`tools/get_deps.py rp2040`) and reference core locations: `src/`, `hw/`, `examples/`, `test/`.
33+
- Run `clang-format` on all touched files to ensure consistent formatting.
34+
- Use `TU_ASSERT` for all fallible calls to enforce runtime checks.
35+
- Ensure header comments retain the MIT license notice.
36+
- Add descriptive comments for non-trivial code paths to aid maintainability.
37+
- Release flow primer: bump `tools/make_release.py` version, run the script (updates `src/tusb_option.h`, `repository.yml`, `library.json`), refresh `docs/info/changelog.rst`, then tag.
38+
- Testing reminders: Ceedling full or targeted runs, specify board/OS context, and ensure logging of manual hardware outcomes when available.

0 commit comments

Comments
 (0)