Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .agent/rules/commit_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
trigger: always_on
---

# Agent Commit Rules

The user requires all commit messages generated by the agent to follow a specific style and include a proper sign-off.

## Commit Message Style

Commit messages must be formatted with a subject line and a body, following this format:
```
<feature/subsystem>: <one line description>

<body>
```

* **`<feature/subsystem>`**: A short name or tag representing the feature or component being modified.
* **`<one line description>`**: A succinct one-line description of the change.
* **`<body>`**: A detailed description of the changes made in the commit. The body must be at least one sentence describing the changes.

## Sign-off

Every commit message must end with a `Signed-off-by:` line using the patch author's name and email (from the local git config):

```
Signed-off-by: <author name> <author email>
```
13 changes: 13 additions & 0 deletions .agent/rules/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Documentation Rules

The user expects all new features and in-code documentation to adhere to Doxygen standards.

## Doxygen Requirements

1. **Mandatory Documentation:** All new features, functions, and structures must include Doxygen comments describing their purpose, parameters, and return values.
2. **Clean Build:** Any in-code documentation added or modified must build with Doxygen without producing any new errors or warnings.
3. **Format:** Use standard Doxygen formatting tags (e.g., `@brief`, `@param`, `@return` or `\brief`, `\param`, `\return`). Ensure the styling matches the existing codebase conventions.

## Directory Documentation

When creating a new file or modifying an existing one, check if there is an `architecture.md` or `readme.md` (or `README.md`) file in the same directory. If present, evaluate whether the code changes require an update to these documentation files and make the necessary updates to keep them synchronized with the code.
22 changes: 22 additions & 0 deletions .agent/workflows/build_and_validate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
description: Build and validate new C code features
---

This workflow describes the process for building and validating any new C code features in the SOF repository.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

This workflow describes the process for building and validating any new C code features in the SOF repository.

Note: The QEMU build targets must be used for both building and testing.

USE THIS to build/test C code. REQUIREMENT: Always use QEMU targets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English is fine, I has the same thought but I asked the agent to craft these. So far so good, but we will need to get something that works with most agents.

Copy link
Member

@abonislawski abonislawski Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely it will work but they are not doing this efficiently if not prompted correctly.
It's not about doing this manually but instructing the agent correctly about what you expect in better AGENT.md file.
Like in the previous example filler words are simply waste of tokens.

Another example:

  1. Format: Use standard Doxygen formatting tags (e.g., @brief, @param, @return or \brief, \param, \return).

The only useful format info here: Use Doxygen formatting.

The tag examples here are completely unnecessary. The AI knows perfectly well what Doxygen tags are, and if by some miracle it didn't know, it would be completely useless anyway :)

Copy link
Member Author

@lgirdwood lgirdwood Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is doxygen and other languages have some options around the formatting syntax or keywords, so this did specify the existing keyword style used upstream. I'm going to re-ask for minimal tokens / max efficiency, lets see what it comes back with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @abonislawski regarding the fact that the descriptions are in a format directed more towards humans than agents. From my own experience I know that overly long instructions cause faster context overflow and the final result is worse. I don't feel competent to write how this should be done, so this is not a blocker for me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I did ask for brevity and efficiency, but in this case the agent knows best until further notice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting here - so I'm going to do the hybrid approach:

Both approaches have their advantages depending on the complexity of your project's rules and workflows:

  1. The .agents/ Directory (Recommended for scaling)
    Using a dedicated .agents/ directory (or .agent/, _agents/) is usually the better approach as your project grows, especially because it allows for structured workflows.

Pros:

Workflows Support: As an AI agent, I natively support reading step-by-step workflows placed inside .agents/workflows/. For example, you can have .agents/workflows/build-qemu.md or .agents/workflows/create-module.md.
Organization: You can split different concerns into multiple files (e.g., .agents/rules.md, .agents/pr-review.md) instead of having one massive document.
Granularity: It is easier to point the agent to a specific workflow file rather than asking it to search through a long single file.
2. The

AGENTS.md
File (Good for starting out)
A single

AGENTS.md
or RULES.md file in the root of your repository is a great way to start.

Pros:

Simplicity: It is just one file containing all the high-level directives, codestyles, and rules.
Visibility: It is immediately obvious to any human developer (or AI) looking at the root of the standard repository.
My Recommendation for SOF
For a complex project like Sound Open Firmware (SOF), a hybrid approach or migrating to an .agents/ directory is typically best:

.agents/rules.md: For your general codestyle, Doxygen, and commit rules.
.agents/workflows/: To house specific, executable markdown workflows like how to run xtensa-build-zephyr.py or sof-qemu-run.sh step-by-step.


**Note:** The QEMU build targets must be used for both building and testing. The user requires the build must be error and warning free and the ztests must all pass.

// turbo-all
1. Build the new C code feature using the `xtensa-build-zephyr.py` script.
```bash
source ../.venv/bin/activate
./scripts/xtensa-build-zephyr.py qemu_xtensa
```

2. Validate the feature with a ztest run using the `sof-qemu-run.sh` script.
```bash
source ../.venv/bin/activate
./scripts/sof-qemu-run.sh build-qemu_xtensa
```

3. Ensure that all new features and functions have appropriate Doxygen comments and that the Doxygen documentation builds without errors or warnings.
22 changes: 22 additions & 0 deletions .agent/workflows/module_development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
description: Develop and validate new audio processing modules
---

This workflow describes the expected steps to create and validate a new audio processing module within the SOF repository.

// turbo-all
1. **(Optional)** Generate the module skeleton using the `sdk-create-module.py` script.
```bash
# Run the script with relevant arguments to create a new module template
./scripts/sdk-create-module.py --name <module_name> --version <version>
```

2. Develop the module logic within the generated skeleton.

3. Validate the module by executing the module within the host testbench. This ensures that the module functions as expected outside of full system simulations.
```bash
# Configure and run the testbench against the developed module
./scripts/host-testbench.sh -l <path_to_module_library>
```

4. Document the new module using Doxygen comments. Validate that the Doxygen build completes without errors or warnings. Add a README.md for the module.
19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Sound Open Firmware (SOF) Agent Workflows and Rules

This document outlines the rules AI agents must follow when checking out branches, writing code, documenting features, and running the development environment. Follow these rules carefully:

## Development Standards

### Commitment and Sign-off Rules
* **Commit Subject:** Must follow the format `feature: descriptive title`.
* **Commit Body:** Should describe the changes in detail in the commit message body.
* **Sign-off:** All commits must be signed off by the developer (`Signed-off-by: Name <email>`) using the identity from the local git config.

### Documentation Requirements
* **Doxygen Comments:** Any new C code or features must include Doxygen comments.
* **Documentation Builds:** Integration of new code must not introduce any new Doxygen errors or warnings. Code additions should be verified against a clean documentation build.
* **Architectural Consistency:** When adding or updating a file, any `architecture.md` or `README.md` in the same directory must be reviewed. The agent is responsible for ensuring documentation stays in sync with code logic changes.

### Codestyle and Linting
* **Standard:** Use `clangd` instead of `checkpatch` for codestyle verification.
* **Rationale:** `checkpatch` is prone to confusion with assembly and non-standard C; `clangd` provides better integration with IDEs and AI tools and is easier to maintain.
7 changes: 5 additions & 2 deletions scripts/sdk-create-module.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,12 @@ def main():
print("--- SOF SDK New Module Creator ---")

# Argument Validation ---
if len(sys.argv) != 2:
if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']:
print("Usage: sdk-create-module.py <new_module_name>")
sys.exit(0)
elif len(sys.argv) != 2:
print("\n[ERROR] Invalid number of arguments.")
print("Usage: sdk_create_module.py <new_module_name>")
print("Usage: sdk-create-module.py <new_module_name>")
Comment on lines +365 to +370
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage text hard-codes the script name. If the script is renamed, invoked via a symlink, or run as python scripts/sdk-create-module.py, the printed usage can become misleading. Prefer building the usage string from os.path.basename(sys.argv[0]) (or similar) so it always matches the invoked command.

Copilot uses AI. Check for mistakes.
sys.exit(1)

# Configuration --- paths are with respect to script dir
Expand Down
Loading