These instructions are derived from doc/contribute/ and apply to all AI-assisted contributions to the Zephyr RTOS repository.
main branch via GitHub Pull Requests.All new files must use Apache 2.0 and include SPDX headers at the very top using the file's native comment syntax:
SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors SPDX-License-Identifier: Apache-2.0
The copyright statement may refer to the individual or organization who authored the contribution but “Copyright The Zephyr Project Contributors” is always the preferred form.
External code under a license other than Apache 2.0 requires TSC + governing board approval before integration.
Signed-off-by line — only humans may add this; AI agents should not add Signed-off-by tags unless explicitly requested by humans.Do not add a Co-authored-by tag to commit messages.
When AI tools are used, add an attribution tag in the commit message:
Assisted-by: [Agent Name]:[Model Version] [Tool1] [Tool2]
Example:
Assisted-by: Claude:claude-opus-4.6 coccinelle
Basic tools (git, gcc, make, editors) should not be listed.
Follow the Linux kernel coding style with these Zephyr-specific rules:
snake_case for all code and variable names.if, else, do, while, for, and switch bodies — even single-line blocks./* */ for comments; // is not allowed./** */ for Doxygen API documentation.0b...).UART not uart, CMake not cmake.k_ (kernel), sys_, net_, bt_, i2c_, etc.typedef names and tag names must be globally unique identifiers.All new code must comply with the Zephyr MISRA-C subset. Key required rules:
malloc, calloc, etc.).uint8_t, int32_t, etc.) instead of bare int, char.inline or static functions over function-like macros.u or U suffix to all unsigned integer constants.l suffix in literals.help text: one tab + two extra spaces.# Comment (space after #).if / endif blocks.| Subtree | Symbol format | Prompt format |
|---|---|---|
| Drivers | {DRIVER_TYPE}_{DRIVER_NAME} | {Driver Name} {Driver Type} driver |
| Sensors | SENSOR_{SENSOR_NAME} | {Sensor Name} sensor driver |
| Samples | SAMPLE_... | — |
| Tests | TEST_... | — |
| Boards | BOARD_... | — |
| SoCs | SOC_FAMILY_..., SOC_SERIES_..., or SOC_... | — |
menuconfig (not config) for enabling symbols that have sub-options.if block keyed to the enabling symbol.add_library, not ADD_LIBRARY.if(...) not if (...).target_sources() and similar calls.option, set(... CACHE ...)).ON, OFF).CMAKE_SOURCE_DIR, CMAKE_BINARY_DIR) — never hardcode paths..rst)./** */ block comments.doc/contribute/documentation/guidelines.rst for formatting details.Every commit message must follow this format:
[area]: [summary of change] [Commit message body] Signed-off-by: Your Full Name <your.email@example.com>
[area]: [summary])[area] identifies the subsystem or context being changed. Examples:doc: — documentation changesdrivers: foo: — changes to the foo driverBluetooth: shell: — Bluetooth shell changesnet: ethernet: — Ethernet networking changesdts: — treewide devicetree changes.github: — CI/tooling configuration changesgit log FILE on a file you're changing and follow existing conventionsgit commit -s to add automaticallyAuthor: fieldSigned-off-by — only the human submitter may sign offCo-authored-by tag to commit messagesTo close a GitHub issue automatically on merge, add to the commit or PR description:
Fixes #[issue number]
Or cross-repo:
Fixes zephyrproject-rtos/zephyr#[issue number]
| Directory | Contents |
|---|---|
arch/ | Architecture-specific kernel and SoC code |
boards/ | Board configurations |
doc/ | Documentation sources |
drivers/ | Device drivers |
dts/ | Devicetree source files |
include/ | Public API headers |
kernel/ | Architecture-independent kernel code |
lib/ | Library code (minimal libc, etc.) |
samples/ | Sample applications |
scripts/ | Build and test tooling |
subsys/ | Subsystems (networking, BT, USB, FS, …) |
tests/ | Tests and benchmarks |
soc/ | SoC-specific code and configuration |