0xmiden/agent-tools/masm-padding
Claude Code and agent skill by 0xmiden/agent-tools
- community
Checking that the SKILL.md file is still in the repository.
Enforce stack padding conventions for Miden Assembly (.masm) procedures based on invocation type. Use when editing, reviewing, or creating .masm procedures, especially those with Invocation annotations.
Install
npx vskill@latest install 0xmiden/agent-tools/masm-paddingSKILL.md
MASM Padding Conventions
Overview
Padding requirements differ based on procedure invocation type:
| Invocation | Padding Required | Input/Output Elements | |
|---|---|---|---|
call | Explicit padding in comments | Exactly 16 | |
exec | No explicit padding | No requirement |
Stack Depth Floor: 16
Miden VM enforces a minimum operand-stack depth of 16 elements (MIN_STACK_DEPTH = 16 in the VM core). When an operation would naively shrink the stack below 16, the VM auto-fills the missing positions with zeros via the overflow-table mechanism. The actual depth stays exactly 16; only the visible content shrinks.
This invariant applies at the entry boundary of:
callprocedures,- note scripts and transaction scripts (entered via
dyncallat depth 16).
It does NOT apply to mid-chain exec procedures, which share the caller's stack and can drop the visible count below 16 by consuming caller elements (see Danger Zone).
Tracking the floor in inline comments
When the naive math would put the stack below 16, the # => tracker must reflect the actual auto-padded depth, not the naive count.
Not:
This shows up most often at the start of note scripts that don't use their input arguments:
Call Procedures
Procedures invoked with call must have explicit padding in:
- Doc comments (
#!) for Inputs/Outputs - Inline comments (
#) showing stack state
Doc Comment Format
Use pad(N) notation where N + other elements = 16:
Inline Comment Format
Track padding through the procedure:
Exec Procedures
Procedures invoked with exec should NOT have explicit padding:
Why No Padding for Exec
exec procedures share the caller's stack directly. Explicit padding would be misleading because:
- The actual stack may have additional elements from the caller
- The procedure may consume caller's stack elements
Danger Zone
If an exec procedure's stack falls below the specified stack elements, it will consume stack items from its caller, potentially leading to unexpected behavior. This is a bug and should be fixed by ensuring the procedure maintains sufficient stack depth and avoiding dropping more stack elements than available.
Example of Dangerous Behavior
Intermediate States
Inside a procedure, the stack may temporarily exceed 16 elements:
These extra elements must be explicitly dropped before the procedure returns (directly or via called procedures).
Debugging Stack Depth
Use the event-based procedures in miden::core::debug to inspect VM state. These are ordinary procedure calls: they emit print events whenever invoked, affect the program being executed, and consume cycles (print_stack costs 3 cycles). Remove them from production programs.
Validation Checklist
For all invocation types:
- [ ] Inline
# =>trackers reflect the post-auto-pad depth (never below 16) at boundaries that enforce the floor (call, note scripts, tx scripts) - [ ] No
miden::core::debugprocedure call is left in production MASM
For call procedures:
- [ ] Inputs doc comment shows exactly 16 elements with
pad(N) - [ ] Outputs doc comment shows exactly 16 elements with
pad(N) - [ ] Inline comments use
# =>format withpad(N)notation - [ ] All intermediate states track the full stack including padding
For exec procedures:
- [ ] No
pad(N)in Inputs/Outputs doc comments - [ ] No explicit padding in inline stack state comments
- [ ] Verify stack never drops below safe depth
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 repositoryCheckingskills/masm-padding/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/agent-tools/masm-padding)