0xmiden/compiler/rust-sdk-source-guide
Claude Code and agent skill by 0xmiden/compiler
- community
Checking that the SKILL.md file is still in the repository.
Guide for advanced Miden smart contract development using source repo exploration. Covers AI development practices (Plan Mode, verification-driven development, context engineering, sub-agents) and maps Miden source repositories for discovering advanced patterns. Use when building complex multi-contract applications, novel note flows, or anything beyond basic SDK patterns.
Install
npx vskill@latest install 0xmiden/compiler/rust-sdk-source-guideSKILL.md
Advanced Miden Development: Source-Guided Context Engineering
Development Approach
1. Plan Mode First
For any non-trivial smart contract application, start in Plan Mode before writing code.
- Explore Miden source repos to understand existing patterns
- Design the account/note architecture and present it to the user before implementing
- Identify which standard components can be reused vs what needs to be custom
- Map out the note flow: which accounts exist, what notes flow between them, what storage each needs
Rule of thumb: if the task involves more than one contract or a pattern not covered by the basic skills, plan first.
2. Verification-Driven Development
This is the single highest-leverage practice for AI-assisted Miden development.
Build loop: After every contract edit, run cargo miden build --manifest-path contracts/<name>/Cargo.toml --release from the project root (adjust the path to your contract layout). With the midenup miden wrapper, run miden build --release from the contract directory instead: miden build --manifest-path ... alone does not select that contract from the workspace root. The output is a .masp package written under <target_dir>/<profile>/. If your project has a build hook configured, it may run this automatically. If the build fails:
- Read the error message
- Translate obvious SDK/compiler errors first:
.as_u64()->.as_canonical_u64()Recipient::compute(...)->note::build_recipient(...)Value->StorageValue<T>StorageMap->StorageMap<K, V>active_note::get_assets()->active_note::get_initial_assets()- a trait method that a note or tx script cannot reach -> it is missing
#[account_procedure]
- Search the source repos for a working example of the pattern that failed
- Adapt the working pattern to your use case
- Rebuild
Test loop: Write tests alongside contracts. Run full repo checks with cargo test — or make test if the repo ships a GNU Makefile. In the protocol repo the test target runs cargo nextest run --profile default --cargo-profile test-dev --features concurrent,testing,std (siblings: test-dev, test-release / testr, test-docs, lint, clippy, format, doc). cargo make test needs a Makefile.toml configuring cargo-make; among the referenced repos only the compiler ships one — protocol, the client and the VM each ship a GNU Makefile and no Makefile.toml, while the compiler ships a Makefile.toml and no GNU Makefile. When tests fail:
- Check the error — is it a build error, a runtime assertion, or a proof failure?
- For assertion failures: check felt arithmetic (modular wrapping), storage slot naming, and whether the call is legal in its runtime context (
output_note::createis account-context-only;incr_nonce()is auth-procedure-only) - For unexpected behavior: compare your code against the closest working example in source repos
Never submit code that doesn't compile and pass tests. The verification loop is your quality guarantee.
3. Context Engineering with Source Repos
The basic skills (rust-sdk-patterns, rust-sdk-testing-patterns, miden-concepts, rust-sdk-pitfalls) cover standard patterns. For anything beyond those patterns, Miden's source repositories are the knowledge base.
How to use source repos effectively:
- Don't load entire repos into context. Use sub-agents to explore — they search, read relevant files, and summarize findings without filling the main conversation context.
- Read source files only when you need a specific answer (progressive disclosure)
- Look for working examples first, then adapt. Working code that compiles is more reliable than documentation.
- When you find a useful pattern in source, extract just what you need — the exact API call, the exact data layout, the exact test setup.
- Start API questions at
compiler/sdk/sdk/MIGRATION.md. Its## Unreleasedsection is the authoritative, hand-written list of what changed on the Rust contract surface, with before/after code for each break.compiler/sdk/CHANGELOG.mdis the companion. For an exact signature, go tocompiler/sdk/base-sys/src/bindings/*.rs.
Using sub-agents for exploration:
- Launch an explore sub-agent with a specific question: "Find how the basic-wallet component creates an output note and moves an asset into it (
compiler/examples/basic-wallet/src/lib.rs)" - The sub-agent searches, reads the relevant files, and returns a focused summary
- Your main context stays clean for implementation
4. Iterative Multi-Stage Development
Break complex applications into stages. Complete each before starting the next:
- Design (Plan Mode) — Architecture, note flows, storage design
- Implement accounts — Component structs, storage, methods
- Implement notes — Note scripts, cross-component calls, input parsing
- Implement tx scripts — Initialization, admin operations
- Write tests — MockChain setup, multi-step execution, state verification
- Integrate — Connect pieces, end-to-end test
When stuck at any stage: search the source repos for a similar working pattern. Adapt it, don't guess.
Which Version Is Which
These are five independent release lines. Keep the client, protocol, and VM types aligned:
| Line | Crates | Version | MSRV | |
|---|---|---|---|---|
| Contract SDK (guest) | miden, miden-base, miden-base-macros, miden-base-sys, miden-stdlib-sys, miden-sdk-alloc | project manifests use the 0.15 series (0.15.0) | Rust 1.99 + nightly 2026-09-01, target wasm32-wasip2 | |
| Compiler / build tool | compiler workspace, midenc, cargo-miden | 0.11.0 in the current checkout; use a matching toolchain or locally built cargo-miden | Rust 1.99 | |
| Protocol | miden-protocol, miden-standards, miden-testing, miden-tx, miden-tx-batch, miden-block-prover, miden-agglayer | 0.18.0 | see each crate | |
| Client | miden-client, miden-client-sqlite-store | 0.18.0 from crates.io; resolved versions in Cargo.lock | see each crate | |
| VM / package crates | miden-assembly, miden-assembly-syntax, miden-core, miden-core-lib, miden-crypto, miden-mast-package, miden-processor, miden-project, miden-prover | 0.36.x | see each crate |
Follow the local manifests: contract crates use miden = { version = "0.15" } and matching miden-sdk-build-script-support = { version = "0.15" }. The integration crate uses protocol/standards/testing 0.18.0, VM/package crates in the 0.36 series, and the released client crates 0.18.0 from crates.io. Read both integration/Cargo.toml and Cargo.lock before changing version requirements; the lockfile records the resolved crate versions.
Keep the build tool out of the integration crate's dependency graph. The current project builds contracts out of process with midenup / cargo-miden via build_project_in_dir(...), then tests those packages with the client, standards, and miden-testing libraries resolved in Cargo.lock.
Miden Source Repository Map
Clone these repos alongside your project for reference. Claude will explore them when needed for advanced patterns.
--depth 1 is intentionally omitted so you can check out other refs later if needed. For exact client parity, use the release tag matching the client version recorded in the project's Cargo.lock.
compiler/ — The Rust-to-MASM Compiler and the Guest SDK
Contains the SDK that powers the #[component_storage], #[component], #[account_procedure], #[auth_script], #[account], #[note], #[note_script] and #[tx_script] macros.
- `compiler/examples/` — exactly 12 working example projects, and the most reliable reference for
"how do I write X":
| Example | Shows | |
|---|---|---|
compiler/examples/counter-contract/ | account component with StorageMap, #[account_procedure], full miden-project.toml | |
compiler/examples/basic-wallet/ | asset in/out, output_note::create wrapped as an account procedure | |
compiler/examples/storage-example/ | StorageValue + StorageMap<Word, AssetAmount>, miden::generate!() + bindings::export! over a hand-written WIT interface | |
compiler/examples/auth-component-no-auth/ | minimal #[auth_script] auth component, incr_nonce() | |
compiler/examples/auth-component-rpo-falcon512/ | signature-checking auth component, transaction-summary hashing | |
compiler/examples/p2id-note/ | typed #[note] struct decoded from note storage, #[account(basic_wallet::BasicWallet)] wrapper | |
compiler/examples/p2ide-note/ | manual active_note::get_storage() parsing, BlockNumber timelock comparison | |
compiler/examples/counter-note/ | note script calling a component through generated bindings, with no #[account(..)] wrapper | |
compiler/examples/basic-wallet-tx-script/ | #[tx_script], advice-provider input loading, calling wallet procedures | |
compiler/examples/collatz/, compiler/examples/fibonacci/, compiler/examples/is-prime/ | plain compute programs, no account context |
There is no faucet example here. For faucet reference use protocol/crates/miden-standards/src/account/faucets/fungible/mod.rs (the FungibleFaucet component) or the compiler's own compiler/tests/integration/src/sdk/base/faucet.rs binding test.
- `compiler/sdk/` — the guest SDK and the authoritative API reference. Whitelisted
for exploration:
compiler/sdk/sdk/MIGRATION.md— start here; the## Unreleasedsection is the current contract-surface
change list with before/after code
compiler/sdk/CHANGELOG.mdcompiler/sdk/base-sys/src/bindings/— the exact signature of every kernel binding
(active_account.rs, native_account.rs, active_note.rs, input_note.rs, output_note.rs, note.rs, faucet.rs, tx.rs, types.rs)
compiler/sdk/base/src/types/storage.rs—StorageValue/StorageMap/WordKey/WordValuecompiler/sdk/base-macros/src/— macro behaviour and, importantly, the exact error messages
(component_macro/mod.rs, component_macro/storage.rs, component_macro/sibling.rs, foreign_account.rs, note.rs, script.rs, wit_world.rs)
- `compiler/tests/integration-network/src/mockchain/` — end-to-end multi-contract MockChain flows
(counter contract under three auth components, FPI in many shapes, asset transfer), including the live storage-slot-name strings in compiler/tests/integration-network/src/mockchain/support/helpers.rs.
WARNING: Do NOT explore the compiler's own internals — compiler/codegen/, compiler/hir/, compiler/hir-analysis/, compiler/hir-transform/, compiler/frontend/, compiler/midenc-compile/, compiler/midenc-session/ — they are implementation details that will confuse the agent and lead to incorrect code. The one narrow exception is compiler/frontend/wasm/src/component/ when you need the exact wording of a call-boundary (16-felt) diagnostic.
Explore when: Writing any new contract type, checking an exact binding signature, or finding working code for a pattern not covered by skills.
protocol/ — Protocol Layer and Standard Library
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingextra/templates/project/.claude/skills/rust-sdk-source-guide/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/0xmiden/compiler/rust-sdk-source-guide)