buddy-mlir
AGENTS.md773 starsChanged 32 days agoApache-2.0View on GitHub
Buddy-MLIR is an MLIR-based compiler framework from DSLs to domain-specific architectures. It also builds LLMs (DeepSeek R1, Qwen, Whisper, ...) into .rax files that buddy-cli runs on CPUs (x86, RVV), the SpacemiT K3 and Tenstorrent devices. These rules hold for every task. Task-specific workflows are skills in .agents/skills/ (also visible to Claude Code through .claude/skills/). Models: python3 tools/buddy-codegen/build_model.py --spec <spec.json> --build-dir build ... (README.md, docs/CrossCompilingRaxFile.md, docs/K3DeepSeekR1.md). - tools/buddy-codegen/import_model.py imports buddy.compiler from <repo>/build/python_packages, whatever --build-dir is. After changing Python under frontend/,…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- hardware-targetsSkill
- llm-inference-optimizationSkill
- performance-optimizationSkill
- riscv-rvv-optimizationSkill
- upstream-prSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 2 are common, 0 are distinctive, and 1 is very specific to this project.
≈2
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 41
Do not modify the llvm submodule unless the task requires it.
- Common: line 45
Never commit secrets, host names, accounts or local paths of a developer machine or board.
- Common: line 47
Never ask for, read, store or pass passwords or other credentials (sudo included).
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Buddy-MLIR agent instructions
Buddy-MLIR is an MLIR-based compiler framework from DSLs to domain-specific
architectures. It also builds LLMs (DeepSeek R1, Qwen, Whisper, ...) into
.rax files that buddy-cli runs on CPUs (x86, RVV), the SpacemiT K3 and
Tenstorrent devices.
These rules hold for every task. Task-specific workflows are skills in
.agents/skills/ (also visible to Claude Code through .claude/skills/).
Build and test
# LLVM/MLIR (submodule llvm/): see README.md, "Build and Test LLVM/MLIR/CLANG"
cmake -G Ninja -S . -B build \
-DMLIR_DIR=$PWD/llvm/build/lib/cmake/mlir \
-DLLVM_DIR=$PWD/llvm/build/lib/cmake/llvm \
-DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=RELEASE \
-DBUDDY_MLIR_ENABLE_PYTHON_PACKAGES=ON \
-DPython3_EXECUTABLE="$(which python)"
ninja -C build
ninja -C build check-buddy # lit tests: run before every PRModels: python3 tools/buddy-codegen/build_model.py --spec <spec.json>
--build-dir build ... (README.md, docs/CrossCompilingRaxFile.md,
docs/K3DeepSeekR1.md).
tools/buddy-codegen/import_model.pyimportsbuddy.compilerfrom<repo>/build/python_packages, whatever--build-diris. After changing Python underfrontend/, rebuildbuild(ninja -C build) and delete<build-dir>/models/<model>/.buddy_import_donebefore rebuilding a model.
Rules
- Correctness first. Say whether a change keeps results bit for bit or
changes the numerics; a change of numerics needs a measured accuracy check
(see the
performance-optimizationskill). - Small, independently reviewable patches; no unrelated refactoring in an optimization PR. Update the docs and tests the change touches.
- Do not modify the
llvmsubmodule unless the task requires it. - Style: clang-format (C/C++) and ruff (Python) through pre-commit. Run it on
the changed files only (
pre-commit run --files ...);--all-filesrewrites unrelated files. - Never commit secrets, host names, accounts or local paths of a developer machine or board.
- Never ask for, read, store or pass passwords or other credentials (sudo included). When a step needs privileges, stop and give the developer the exact command to run.
Skills
| Task | Skill |
| Making anything faster (kernels, runtime, generated code), comparing against another framework | performance-optimization |
| LLM prefill / decode / KV cache / sampling performance, perplexity | llm-inference-optimization |
| RVV code generation: LMUL, register pressure, instruction choice | riscv-rvv-optimization |
| Facts about a specific chip (SpacemiT K3, Tenstorrent, ...) | hardware-targets |
| Preparing a commit or pull request | upstream-pr |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

