Imported from Archont561/create-monorepo (
packages/native/AGENTS.md). Install upstream withnpx skills add Archont561/create-monorepo --skill native. Copyright stays with the author.
AGENTS.md — packages/native
The native side of the monorepo: the npm packages live here, the Cargo workspace at the repo root. Orientation in README.md, current state in CONTEXT.md.
Rules
- The Cargo workspace root is the repo root (
/Cargo.toml) and must stay virtual — no[package]section. This directory holds only the npm packages (npm/*). - Never hand-edit
members.mnative add <name>creates the crate, its npm package, and re-syncs and sortsmembers. - One npm package per binding crate; a pure-Rust crate (
--pure) gets no npm package of its own — it is represented in the Turbo graph by the bridge nodecrates/package.json. - Binding crates stay thin:
#[napi]wrappers that delegate to pure crates. Logic lives in pure crates so it is testable without a Node runtime. - A Cargo path dep from a binding to a pure crate must be mirrored as
@<scope>/native-crates: workspace:*in the binding'spackage.json— runmnative syncafter editing Cargo deps instead of hand-editing both sides. - Never hand-edit
crates/package.jsonorcrates/turbo.json— they are generated (mnative sync/mnative add --pure/ setup rewrite them). - Every crate declares
[lints] workspace = truesounsafe_code = "forbid"is inherited, and inheritsversion,edition,licenseandrepositoryfrom[workspace.package]instead of restating them. crate-type = ["cdylib"]belongs on binding crates only.Cargo.lockat the repo root is committed — update it with the toolchain, never hand-edit. Never committarget/,npm/*/index.js,npm/*/*.node,*.wasmornpm/*-<platform>/— all are generated and gitignored.- Use
mnativerather than running cargo directly; it applies the workspace paths and keeps one invocation over every crate. The--pureflag scopes the cargo commands to the pure crates. - Never
#![deny(warnings)]in Rust source —-D warningsis a CI flag only. - Release-profile tuning (
lto,codegen-units,strip) lives once in the workspace[profile.release]— never in a crate.
Before marking a task done
-
mnative fmt:check -
mnative clippy -
mnative check -
mnative test - New crate has
[lints] workspace = true -
mnative syncleaves nothing to fix (Cargo↔npm edges in place) - No generated or build artefacts in the diff