mvp-ai's picture
|
download
raw
19.5 kB
# Agent entry: Miden v0.17
Read `docs/agent-first-v017.md` before proposing or changing an app. Read the workflow below, then the submodule's guidance and relevant installed skills.
This index supplements the workflow; it does not replace app validation gates.
## Release-matched context
- Project: `e941949b1cb244f1557ace1c58dca0dc7a898da8`.
- Frontend: `71fb5bb0a205224d04a7d0264fad2cecc8d4478d`.
- Miden channel: `project-template/miden-toolchain.toml` (0.17.0).
- Rust resolution: `project-template/Cargo.lock`; guest SDK: contract manifests.
- Browser resolution: `frontend-template/package.json` and `yarn.lock`.
- Rust/local-node patterns: `project-template/.claude/skills/`.
- Browser API context (read these installed guides before using SDK APIs):
- `frontend-template/node_modules/@miden-sdk/miden-sdk/AGENTS.md`
- `frontend-template/node_modules/@miden-sdk/react/AGENTS.md`
- `frontend-template/node_modules/@miden-sdk/vite-plugin/AGENTS.md`
- `frontend-template/node_modules/@miden-sdk/miden-wallet-adapter-base/AGENTS.md`
- Browser API skills: installed SDK packages, synced by frontend `prepare`.
That script tolerates sync errors; verify skills exist or run
`yarn miden-skills sync` explicitly before relying on them.
- Account upgrades: project `account-code-upgrades` skill; network journey
requires separate validation.
## Executable journey
Run `bash scripts/journey.sh doctor`; report missing prerequisites precisely.
`contracts` runs MockChain tests from the required integration working directory.
`frontend` runs browser unit tests and production build, not a browser journey.
`local` runs the included counter on an isolated fee-free Docker chain, recording
real commitments and final-state assertions; opt in with `MIDEN_ALLOW_LOCAL=1`.
`artifacts` copies freshly built packages; `testnet` requires explicit
`MIDEN_ALLOW_TESTNET=1` and uses only test tokens.
The project submodule has no `validate_local` binary. Use the root local stage
and `examples/local-counter/` for the counter acceptance flow. For another app,
read the local-node-validation skill and adapt the assertions. Never infer
local-node completion from MockChain or testnet evidence.
## Boundaries and completion
Plan before mutation; preserve submodule pins and user keys/stores. Never reset
an existing wallet/store to fix version errors. Use fresh disposable state.
Do not submit network transactions, start services, install global tools, or
publish/deploy without authorization for that stage. Keep local node/prover/
transport versions and genesis aligned. Follow the execution environment’s service-isolation policy.
Report each stage as passed, failed, not run, or blocked, with commands, versions
and evidence. Hooks do not establish wallet-extension, browser, local-node,
private-note transport or account-upgrade completion.
---
# Miden Agentic Template
This monorepo contains two Miden development templates as git submodules:
- `project-template/` -- Miden smart contracts (Rust SDK). Account components, note scripts, transaction scripts, and integration tests.
- `frontend-template/` -- Miden web frontend (React + TypeScript + @miden-sdk/react). Browser-based UI that interacts with Miden contracts.
Each sub-template has its own CLAUDE.md with detailed instructions, skills for domain-specific patterns, and hooks for automated verification. These load automatically when you start working in either directory.
## Usage Modes
This template supports two modes.
**Build a Miden dapp (primary).** Follow the build pipeline below: write contracts in `project-template/`, validate them with MockChain tests, gate on local-node validation, copy artifacts, then build the frontend in `frontend-template/`. Frontend work is gated on local-node validation passing. See `## Development Workflow` and `## Quick Reference`.
**Research, Q&A, application planning (additive).** Use the parent root as a Miden knowledge entry point: load skills from the sources documented in `## Skill Sources`, follow the per-mode guidance in `## Research and Q&A Workflows`. No build pipeline required to answer questions or plan an application. This mode is additive and does not exempt build agents from the `## Development Workflow` gates.
## Development Workflow
**Contracts first, validate against local node, then frontend.** Frontend work is gated on local-node validation passing.
1. Build smart contracts in `project-template/`
- Write account components, note scripts, and tx scripts in `project-template/contracts/`
- Contracts compile to `.masp` package files
2. Validate with MockChain tests
- Write and run MockChain integration tests in `project-template/integration/tests/`
- Validate state transitions, note lifecycle, and expected outputs
- Exit criteria: all MockChain tests pass with explicit assertions
3. Local-node validation **(GATE -- must pass before frontend)**
- Write Rust client binaries in `project-template/integration/src/bin/` that exercise the full contract flow against a local Miden node
- The project submodule’s `increment_count` targets testnet. The root `local` stage validates the counter on an isolated Docker chain.
- Follow the pinned local-node-validation skill when adapting this example to your app.
- Verify: transaction success/failure paths, state transitions, note lifecycle, clean node logs
- See the `local-node-validation` skill for the full checklist and setup guide
- Exit criteria: all state assertions pass, node logs are clean
4. Copy artifacts and deploy
- Deploy contracts to testnet using integration binaries
- Copy `.masp` files from `project-template/masm-output/` (or the contract's `target/` directory) into `frontend-template/public/packages/`
- The frontend loads these at runtime via the Miden SDK
5. Build the frontend in `frontend-template/`
- React components use `@miden-sdk/react` hooks to interact with contracts
- Mirror the validated Rust binary flow as closely as possible
- TDD workflow: write tests first, then implement
- Automated hooks verify type safety and test coverage on every edit
## Which Directory to Work In
| Task | Directory |
|------|-----------|
| Write or edit smart contracts | `project-template/contracts/` |
| Write or edit integration tests | `project-template/integration/tests/` |
| Validate contracts against local node | `project-template/integration/src/bin/` |
| Deploy contracts to testnet | `project-template/integration/src/bin/` |
| Write or edit frontend components | `frontend-template/src/` |
| Write or edit frontend tests | `frontend-template/src/__tests__/` |
## Automated Verification
Hooks run automatically on every file edit:
- Editing files in `project-template/contracts/` triggers `cargo miden build` on the modified contract
- Editing files in `frontend-template/src/` triggers TypeScript type checking and affected test runs
On task completion, a full verification runs: contract integration tests + frontend tests + typecheck + build.
## Quick Reference
**Build a contract:**
```
cargo miden build --manifest-path project-template/contracts/<name>/Cargo.toml --release
```
**Run contract integration tests:**
```
cd project-template/integration && cargo test -p integration --release --locked
```
**Local-node validation:**
Run `MIDEN_ALLOW_LOCAL=1 bash scripts/journey.sh local` for the root counter
validator. Follow the pinned local-node-validation skill for other app flows.
Record assertions and logs separately from MockChain and browser checks.
**Start frontend dev server:**
```
cd frontend-template && yarn dev
```
**Run frontend tests:**
```
cd frontend-template && npx vitest --run
```
## Skill Sources
Three skill sources are available to agents launched at the parent root. Every name below was verified against the actual `SKILL.md` file (submodules) or the live `0xMiden/agent-tools` GitHub directory listing.
**Precedence rule.** When the same skill exists in a submodule and in `agent-tools`, prefer the submodule version: it is tailored for the app-developer template context and may carry sections specific to this template's flow. Fall back to `agent-tools` only when the topic is not covered downstream.
### `project-template/.claude/skills/` (9 skills, app-developer)
| Skill | When to load it |
|---|---|
| `miden-concepts` | foundational Miden questions: actor model, accounts, notes, transactions, assets, privacy, P2ID/P2IDE/SWAP, Felt/Word semantics. |
| `rust-sdk-patterns` | writing or reviewing Miden contract code (`#[component]`, `#[note]`, `#[tx_script]`), storage, native functions, asset handling, P2ID output notes, cross-component calls. |
| `rust-sdk-pitfalls` | debugging contract code or asking about felt arithmetic, comparison ops, 4-Word arg limits, storage naming, no-std, P2ID roots, NoteType ctors, note-to-component boundaries, note input immutability. |
| `rust-sdk-testing-patterns` | writing MockChain integration tests: account / note creation, storage verification, multi-tx tests, output-note assertions, asset-bearing notes. |
| `rust-sdk-source-guide` | advanced multi-contract patterns or exploring `protocol`, `compiler`, `rust-sdk`, `tutorials` source repos. Documents Plan Mode and verification-driven dev for contract work. |
| `local-node-validation` | MockChain tests pass and the contract needs to be validated against a real local Miden node before the frontend phase. |
| `miden-client-cli` | installing or using the `miden client` CLI via midenup or direct `cargo install`; canonical command and config reference. Project-template only. |
| `account-code-upgrades` | upgrading existing accounts in v0.17: authority, direct client requests, network upgrade notes, configuration ordering, fees and validation. |
| `rust-client-patterns` | Rust client transaction requests, multisig authentication and state sync; also documents conventions for the upstream Rust client internals. |
### `frontend-template/.claude/skills/` (11 skills after install, app-developer)
**Ten of these are installed rather than committed.** They ship inside the
`@miden-sdk/*` npm packages and are written into `.claude/skills/` by the
`prepare` script during `yarn install`, which `setup.sh` already runs. So they
are there after a normal setup, exactly as before, but they now match the SDK
version the template pins, instead of being a snapshot that drifts as the SDK
moves. If the directory looks short, dependencies have not been installed yet;
`yarn miden-skills sync` refreshes it on demand.
`miden-concepts` is the exception and stays committed, because it describes the
protocol rather than the SDK and so is not published to npm.
| Skill | When to load it |
|---|---|
| `miden-concepts` | same triggers as the project-template version; prefer the project-template copy when both are available. |
| `react-sdk-patterns` | building a Miden frontend with `@miden-sdk/react`: MidenProvider, query hooks, mutation hooks, transaction stages, signer integration, utilities. |
| `signer-integration` | wiring Para, Turnkey, MidenFi wallet adapter, or building a custom signer (`SignerContextValue`). |
| `web-client-usage` | using the raw web SDK (`@miden-sdk/miden-sdk`) for things hooks do not cover: custom contracts, private-note transport, lazy init, `compile`, `keystore`, sync ordering. |
| `vite-wasm-setup` | configuring Vite for Miden: `midenVitePlugin()`, COOP/COEP headers, dev and production deployment headers, TypeScript compatibility. |
| `frontend-pitfalls` | debugging a frontend bug: WASM init race, recursive WASM access, COOP/COEP misconfig, BigInt mismatch, Bech32 network mismatch, IndexedDB state loss, auto-sync side effects, StrictMode double-init. |
| `testing-patterns` | writing Vitest + testing-library tests for Miden React components (`@miden-sdk/react` mock factory, fixtures, transaction-stage simulation). |
| `frontend-source-guide` | advanced frontend patterns or exploring `web-sdk` source for custom hooks, custom signers, raw `WasmWebClient` usage. |
| `chain-anchored-execution` | multisig proposals, offline co-signing, and transaction summary commitments. |
| `wallet-adapter-integration` | connecting through the MidenFi wallet adapter: provider wiring, the `WalletReadyState` lifecycle, the error taxonomy, and when to drive `MidenClient` directly instead. |
| `observability` | instrumenting SDK client operations with observer callbacks and understanding the emitted observations and optional telemetry integrations. |
### `0xMiden/agent-tools` (25 skills upstream, fallback)
Repository: `https://github.com/0xMiden/agent-tools`. Eight of its 25 skills are shared with the submodules above (use the submodule version per the precedence rule). The other 17 are upstream-only and not present in either submodule. Frontend and web-client skills now come from the SDK's npm packages.
**MASM family (13, upstream-only).** Reach for these whenever the topic is MASM authoring, formatting, or debugging.
- `cheap-masm-equivalents` -- MASM substitutions for common Rust or high-level patterns.
- `masm-formatting` -- orchestrator: capitalization (`UPPER_SNAKE_CASE` for Words, lower for felts), `(N)` span family, `Cycles:` section, chained `u32assert2` guards.
- `masm-inline-comments` -- inline `# => [...]` stack-state comments, lowercase, do-not-overcomment.
- `masm-doc-comments` -- procedure doc blocks: Description, Inputs, Outputs, Where, Panics if, Invocation.
- `masm-padding` -- `pad(N)` rules for `call` vs `exec`, stack depth floor of 16.
- `masm-constants` -- constant placement, error code organization, memory pointer naming.
- `masm-error-constants` -- stable error-code constants and assertion-message conventions.
- `masm-explicit-stack-inputs` -- explicit stack contracts for proc inputs and outputs.
- `masm-file-structure` -- section ordering for `.masm` files, header format.
- `masm-locals-over-globals` -- prefer locals and explicit stack flow over global memory.
- `masm-named-literals` -- replace unexplained numeric literals with named constants.
- `masm-proc-type-signatures` -- type-signature comments for MASM procedures.
- `masm-rust-constant-parity` -- keep MASM constants synchronized with Rust constants.
**Guardrail and hygiene skills (4, upstream-only).** Useful when reviewing generated code or avoiding recurring Miden mistakes.
- `advice-provider-hygiene` -- keep agent guidance source-grounded and current.
- `decouple-component-from-storage` -- separate component interfaces from storage implementation details.
- `felt-construction` -- correct `Felt` construction and non-canonical value handling.
- `u32-assert-before-u32-ops` -- assert before u32 operations so failures are explicit.
### Deployment
This step now covers **only** the MASM, Rust-SDK and slash-command surface. The
frontend and web-SDK skills no longer depend on it: they arrive with
`yarn install` in `frontend-template`, so a plain clone-and-`setup.sh` gets them
whether or not the step below has been run.
`agent-tools` is not bundled with this template. The cleanest path is to install it once at the user level so Claude Code auto-discovers both skills and slash commands across all projects:
```
git clone https://github.com/0xMiden/agent-tools.git ~/agent-tools
# Ensure user-level Claude Code surfaces exist (no-op if they already do)
mkdir -p ~/.claude/skills ~/.claude/commands
# Skills: link the skills directory into Claude Code's user-level skills
ln -sf ~/agent-tools/skills/* ~/.claude/skills/
# Slash commands: link the command files into Claude Code's user-level commands
ln -sf ~/agent-tools/commands/*.md ~/.claude/commands/
```
Skills and slash commands live in different upstream subdirectories (`agent-tools/skills/` vs `agent-tools/commands/`) and Claude Code discovers them from different user-level paths (`~/.claude/skills/` vs `~/.claude/commands/`), so both symlink lines are required: the skills link does not make commands available, and vice versa. The `mkdir -p` step guarantees both target directories exist on a fresh machine.
`agent-tools` skills and slash commands are only available if the user has run the install step or an equivalent. Guidance below that depends on `agent-tools` (the MASM family, the upstream-only guardrails, the slash commands in `## Optional Slash Commands`) is conditional on that install.
The web-SDK and React skills are **not** conditional: they install with the
frontend dependencies, so they are present after `setup.sh` regardless.
## Optional Slash Commands
Five cross-cutting slash commands from `0xMiden/agent-tools/commands/` are useful at the parent root. They install via the second symlink line in `## Skill Sources` (`agent-tools/commands/*.md` into `~/.claude/commands/`) and are only available if that step has been run.
| Command | When to invoke |
|---|---|
| `/review-plan <path>` | critical review of a design doc or implementation plan: consistency, feasibility, API quality, completeness, breaking changes, codebase alignment. |
| `/review-security <path>` | web3, WASM, Rust, TS security audit: input validation, key material, transaction safety, WASM boundary, state, RPC, supply chain. |
| `/tech-debt <focus>` | debt analysis with quantified impact and a prioritized remediation roadmap across both submodules. |
| `/deps-audit <focus>` | multi-language dependency scan covering Cargo and npm under one report. |
| `/pr-enhance <pr or req>` | PR description and review-checklist generator for a complex multi-submodule change. |
Skipped from this list (still installable, just not parent-routing relevant):
- `/tdd-cycle` -- single-language TDD orchestrator; better invoked at the submodule level.
- `/debug-trace` -- single-process debug-tooling setup.
- `/standup-notes` -- personal-productivity tool (Obsidian + Jira); no template relevance.
## Research and Q&A Workflows
Per-mode guidance for non-implementation work. These workflows do not exempt build agents from the `## Development Workflow` gates.
- **Q&A.** Load the most-relevant single skill plus `miden-concepts` (from `project-template/.claude/skills/`, the canonical copy) for grounding. Answer from the loaded skill content.
- **Architecture research.** Compose multiple skills across both submodules (for a wallet-integrated dapp, that is `miden-concepts` + `rust-sdk-patterns` + `react-sdk-patterns` + `signer-integration`). Reach for `agent-tools` when the topic is not covered, especially MASM-level topics.
- **Application planning.** Reference the `examples/miden-bank` app inside `0xMiden/tutorials` and the broader tutorials examples as canonical projects builders can study or extend.
- **Debugging existing Miden code.** Load the relevant `*-pitfalls` skill plus the matching `*-patterns` skill (`frontend-pitfalls` + `react-sdk-patterns`; `rust-sdk-pitfalls` + `rust-sdk-patterns`). For MASM-level debugging, fall back to the `agent-tools` MASM family.
- **Factuality is required.** Any answer in Q&A or research mode must be correct and grounded in source. If a question exceeds what the loaded skills cover, the agent must verify against the actual source repositories using `rust-sdk-source-guide` (for contract or Rust topics) or `frontend-source-guide` (for frontend or web SDK topics) -- those skills map the relevant repos (`protocol`, `compiler`, `rust-sdk`, `web-sdk`, `tutorials`). Speculation, "probably", or "should be" answers are not acceptable. Verify in source, or say "not covered, would need to check X".

Xet Storage Details

Size:
19.5 kB
·
Xet hash:
f166df8534108de44582d81a81b5c748668d56ddc5a3780e6d704088c1ec7e72

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.