一键导入
masm-file-structure
Enforce file structure and section ordering for Miden Assembly (.masm) files. Use when editing, reviewing, or creating .masm files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Enforce file structure and section ordering for Miden Assembly (.masm) files. Use when editing, reviewing, or creating .masm files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when writing kernel, account, or note MASM code that reads from or writes to the advice provider (advice stack / advice map) — validate advice data.
Use when writing or reviewing MASM hot paths — prefer the cheaper equivalent instruction: `neq.0` over `push.0 gt` for non-zero checks, `cdrop` over an `if/else` selecting between two values, `dup.N` over `loc_load` for a value still on the stack, `eqw` over hand-rolled element-wise word comparison, `u32gt`/`u32lt` over generic `gt`/`lt` on known-u32 operands.
Use when writing a GENERIC MASM storage utility (one that operates over a caller-chosen slot or map) inside a reusable account component — receive the slot id as a parameter so the utility works against any slot, not one hard-coded one.
Use when constructing a `Felt` from a numeric value in Rust — avoid silently producing a non-canonical Felt that no longer equals the original input.
Critical pitfalls and safety rules for Miden frontend development. Covers WASM initialization, concurrent access crashes, COOP/COEP headers, BigInt handling, Bech32 network mismatches, IndexedDB state loss, auto-sync side effects, Vite configuration, and React rendering race conditions. Use when reviewing, debugging, or writing Miden frontend code.
Guide for advanced Miden frontend development using source repo exploration. Covers AI development practices (Plan Mode, verification-driven development, context engineering, sub-agents) and maps the Miden web-sdk source repository for discovering advanced patterns. Use when building complex applications beyond basic hook usage, implementing custom signers, working with WasmWebClient directly, or troubleshooting SDK internals.
基于 SOC 职业分类
| name | masm-file-structure |
| description | Enforce file structure and section ordering for Miden Assembly (.masm) files. Use when editing, reviewing, or creating .masm files. |
MASM files follow a consistent top-level section order. Use section headers with the long separator line:
# SECTION NAME
# =================================================================================================
use statements only; no section headerpub type / type definitions (use pub type when referenced cross-module)const ... = event(...) definitions; appears in kernel/event-emitting modules, after Constants (or after imports when no constants section) and before the procedure sections# PROCEDURES section holding all procedures when a module does not separate API from internals. This is a common form in source (about as many files use a lone # PROCEDURES as use the split below), e.g. standards/notes/p2id.masm, standards/data_structures/double_word_array.masm, standards/data_structures/array.masm, and shared_modules/account_id.masm. (Kernel account.masm is not this form: it uses # PROCEDURES followed by a separate # HELPER PROCEDURES section.)# PUBLIC INTERFACE section (pub proc that form the module API) followed by a # HELPER PROCEDURES section (procedures used internally, mostly non-pub)—used only when a module explicitly separates its API from its internals. Note that pub proc may still appear under # HELPER PROCEDURES when a helper is re-exported or unit-tested.The module, constant, type, and procedure names below are illustrative (not a copy of any one source file); the section layout, type shapes, and import namespaces match v0.15 source.
use example::leaf::config
use example::leaf::utils
use miden::core::mem
use miden::core::word
# TYPE ALIASES
# =================================================================================================
pub type DoubleWord = struct { word_lo: word, word_hi: word }
pub type MemoryAddress = u32
# CONSTANTS
# =================================================================================================
const PROOF_DATA_PTR = 0
const CLAIM_PROOF_DATA_WORD_LEN = 134
# ERRORS
# =================================================================================================
const ERR_BRIDGE_NOT_MAINNET = "mainnet flag must be 1 for a mainnet deposit"
const ERR_LEADING_BITS_NON_ZERO = "leading bits of global index must be zero"
# PUBLIC INTERFACE
# =================================================================================================
#! Main entry point. Computes the leaf value and verifies it.
#!
#! Inputs: [LEAF_DATA_KEY, PROOF_DATA_KEY, pad(8)]
#! Outputs: [pad(16)]
#!
#! Invocation: call
pub proc verify_leaf_root
exec.get_leaf_value
exec.verify_leaf
end
# HELPER PROCEDURES
# =================================================================================================
#! Loads leaf data and computes the leaf value.
#!
#! Inputs: [LEAF_DATA_KEY]
#! Outputs: [LEAF_VALUE[8]]
#!
#! Invocation: exec
proc get_leaf_value(leaf_data_key: word) -> DoubleWord
...
end
#! Verifies leaf against Merkle proof.
#!
#! Inputs: [LEAF_VALUE[8], PROOF_DATA_KEY]
#! Outputs: []
#!
#! Invocation: exec
proc verify_leaf
...
end
A module that does not separate its API from its internals collapses the two procedure sections into a single # PROCEDURES header instead—e.g. standards/notes/p2id.masm, whose # PROCEDURES section holds both pub proc main and pub proc new with no public/helper split.
The order of the
# CONSTANTSand# ERRORSsubsections is not fixed in the v0.15 source: some files place errors first (e.g. the agglayerbridge_in,bridge_config, andeth_addressmodules), others place non-error constants first (e.g. manymiden-standardscomponents such assignature,guardian,multisig). Both orders ship even within the same directory (standards/notes/mint.masmis constants-first whilestandards/notes/p2id.masmis errors-first). Either order is acceptable—just keep the two grouped separately rather than interleaved.
Type aliases are conventionally defined before constants, and v0.15 source is overwhelmingly type-first (e.g.
eth_address.masm,types.masm, kernelapi.masm/memory.masm). This is a convention, not an absolute: a component may place local-memory constants before a type alias—e.g.standards/data_structures/double_word_array.masmdefines itsSLOT_ID_PREFIX_LOC/SLOT_ID_SUFFIX_LOC/INDEX_LOCconstants ahead of its in-moduletype DoubleWord. Prefer type-first; don't treat const-before-type as an error.
Types referenced cross-module must be marked
pub type(v0.15 requirespubfor any constant, procedure, or type referenced from another module). Every cross-module type alias in v0.15 source ispub type; only the in-moduletype DoubleWordindouble_word_array.masmis non-pub. The# EVENTSsubsection holdsconst NAME = event("...")definitions and appears in kernel/event-emitting modules. Where a constants section is present it sits after constants and before the procedure sections (e.g. the kernelaccount,output_note,link_map, andprologuemodules); in modules with no constants section it follows the imports directly (e.g. the kernelmainmodule andprotocol/auth.masm, where# EVENTSis the first content section).
use per line; group by module/namespace. A blank line MAY separate import groups by namespace (as the kernel main/api/note/prologue/epilogue modules do), but keeping the whole block unseparated is equally common and dominant in source (e.g. the agglayer modules); the Example Structure above follows the unseparated form. Do not put a blank line between use statements within the same group. Use the bare top-level namespace, e.g. use agglayer::bridge::bridge_config and use miden::core::word—there is no miden::agglayer:: prefix. Imports normally form a single block at the top; a few source files (e.g. standards/notes/mint.masm, agglayer/bridge/bridge_out.masm) interleave a stray use near the related constants—prefer the single top block, but this is not treated as an error.DoubleWord, MemoryAddress) conventionally before constants. v0.15 source is overwhelmingly type-first, though a component may place local-memory constants ahead of a type alias (e.g. double_word_array.masm)—so prefer type-first but don't treat const-before-type as a violation. Mark a type pub type when it is referenced from another module (v0.15 requires pub for cross-module references); a non-pub type used only within its own module is valid.ERR_* in a dedicated errors subsection. The order of the errors subsection relative to the non-error constants is not fixed in source; it may come before or after, so don't treat either order as a hard rule. Just don't interleave them.const NAME = event("...") definitions in an # EVENTS subsection. It sits after the constants section when one is present, otherwise directly after the imports, and always before the procedure sections.# PROCEDURES section (a common form in v0.15 source, e.g. standards/notes/p2id.masm, standards/data_structures/double_word_array.masm, standards/data_structures/array.masm, shared_modules/account_id.masm). Split into # PUBLIC INTERFACE and # HELPER PROCEDURES only when the module deliberately separates API from internals. (A module may also keep a # PROCEDURES header for its main procedures and add a separate # HELPER PROCEDURES section, as kernel account.masm does.)pub proc; these are the module’s API. Order by importance or call flow.pub. May include pub proc helpers (e.g. a get_leaf_value that is used internally, re-exported, or exercised in unit tests).# EVENTS section)# PROCEDURES section for all proceduresmiden::agglayer:: prefix)pub type# EVENTS subsection after constants (or after imports if no constants section) and before procedures# PROCEDURES section, OR split into # PUBLIC INTERFACE (pub proc) before # HELPER PROCEDURES when the module separates API from internals# SECTION NAME and # ===... separator