ワンクリックで
sui-move-syntax
Move language syntax — module layout, imports, mutability, visibility, method syntax, enums, macros, and comments.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Move language syntax — module layout, imports, mutability, visibility, method syntax, enums, macros, and comments.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
This skill should be used when the user says "run the sprint", "autonomous sprint", "run all stories", "execute sprint plan", "complete all epics", or asks to autonomously execute all stories in the current sprint. Drives Claude Code through create-story, dev-story, quality gates, and code-review in a continuous loop without human intervention until all stories are done or blocked.
This skill should be used when the user asks to "upgrade a Solana program through Squads", "set up squads multisig deployment", "create a Squads upgrade proposal", "configure squads-program-action", "deploy via Squads multisig", "set up Squads CI/CD pipeline", "squads GitHub Actions workflow", or mentions Solana program upgrades involving Squads v4 multisig governance.
This skill should be used when the user asks to "create a diagram", "make an architecture diagram", "design a system diagram", "draw an architecture", "create a technical diagram", "make a deployment diagram", "visualize infrastructure", "create a data flow diagram", "draw system components", "make a network diagram", "diagram a cloud architecture", "draw an AWS diagram", "create a Kubernetes diagram", or mentions architecture, system design, infrastructure diagrams, component relationships, or data flow. Do NOT trigger for cover images, step-by-step process flows, or infographics.
This skill should be used when the user asks to "write something satirical about work", "roast a corporate event", "write a vignette about a bad meeting", "satirise startup culture", "write a LinkedIn post parody", "make fun of OKRs", "write a scene about a reorg", "satirise remote work rituals", "mock team-building activities", "write a satirical all-hands recap", or wants any comedic or ironic depiction of organisational life, management behaviour, or workplace absurdity across offices, startups, remote teams, or any setting where hierarchy produces comedy.
Write technical documentation, blog articles, code reviews, and product writeups in a storytelling style that's direct, humble, and problem-first. Use this skill whenever the user wants to publish articles, write technical reviews, document processes, or explain systems in a way that's concrete and human. This includes API docs, how-to guides, product comparisons, incident postmortems, feature writeups, and code reviews. The skill applies whether you're writing for public blogs, internal teams, or personal knowledge vaults. Provide both public-facing (slightly more scaffolding) and internal (tighter) versions when requested.
This skill should be used when the user asks to "create a cover image", "generate a blog cover", "make an OG image", "design a social preview", "create a thumbnail for a post", "add a cover to my article", "make a featured image", "create a header image for a post", "generate an open graph image", or mentions cover images, OG images, social preview images, or blog post thumbnails. Do NOT trigger for diagrams, architecture diagrams, or process flows.
| name | sui-move-syntax |
| description | Move language syntax — module layout, imports, mutability, visibility, method syntax, enums, macros, and comments. |
Use the new single-line module declaration without braces:
// ✅
module my_package::my_module;
// ❌ Legacy — do not use
module my_package::my_module {
...
}
Standard section order within a module:
use importsconst)fun init (if needed)public(package) functions#[test_only])Use === Section Title === comments to delimit sections for readability.
use import rulesDon't use a lone {Self} — just import the module directly:
// ✅
use my_package::my_module;
// ❌ Redundant braces
use my_package::my_module::{Self};
When importing both the module and members, group them with Self:
// ✅
use sui::coin::{Self, Coin};
// ❌ Separate imports
use sui::coin;
use sui::coin::Coin;
mut is RequiredAll variables that are reassigned or mutably borrowed must be declared let mut:
// ✅
let mut pool = Pool { id: object::new(ctx), ... };
let mut balance = balance::zero<SUI>();
// ❌ Legacy
let pool = Pool { id: object::new(ctx), ... };
Function parameters that are mutably borrowed must also be mut:
public fun deposit(mut pool: Pool, coin: Coin<SUI>): Pool { ... }
| Keyword | Scope |
|---|---|
public | Callable from any module |
public(package) | Callable only within the same package |
| (none) | Private — callable only within the same module |
public(friend) and friend declarations are deprecated. Use public(package) instead.
// ✅
public(package) fun internal_logic(pool: &mut Pool) { ... }
// ❌ Deprecated
friend my_package::other_module;
public(friend) fun internal_logic(pool: &mut Pool) { ... }
Never use public entry — use one or the other. public functions are composable in PTBs and return values; entry functions are transaction endpoints only and cannot return values:
// ✅ Composable — can be chained in PTBs
public fun mint(ctx: &mut TxContext): NFT { ... }
// ✅ Transaction endpoint — no return value needed
entry fun mint_and_transfer(recipient: address, ctx: &mut TxContext) { ... }
// ❌ Redundant combination — avoid
public entry fun mint(ctx: &mut TxContext): NFT { ... }
Always order parameters: mutable objects → immutable objects → capabilities → primitive types → &Clock → &mut TxContext:
// ✅
public fun call(
app: &mut App,
config: &Config,
cap: &AdminCap,
amount: u64,
is_active: bool,
clock: &Clock,
ctx: &mut TxContext,
) { }
// ❌ Wrong order
public fun call(
amount: u64,
app: &mut App,
cap: &AdminCap,
config: &Config,
ctx: &mut TxContext,
) { }
Name getters after the field. Do not use a get_ prefix:
// ✅
public fun fee_bps(pool: &Pool): u64 { pool.fee_bps }
public fun fee_bps_mut(pool: &mut Pool): &mut u64 { &mut pool.fee_bps }
// ❌
public fun get_fee_bps(pool: &Pool): u64 { pool.fee_bps }
Functions whose first argument matches a type are automatically callable as methods:
// Given:
public fun value(coin: &Coin<SUI>): u64 { coin.value() }
// Both are valid, prefer the method form:
let v = coin.value(); // ✅ method syntax — prefer this
let v = coin::value(&coin); // ✅ also valid, but more verbose
Use method syntax wherever it improves readability. Declare use fun aliases for functions defined outside the owning module:
use fun my_module::pool_value as Pool.value;
Use enums for types with multiple variants. Enums cannot have the key ability (they cannot be top-level objects), but they can be stored inside objects:
public enum OrderStatus has copy, drop, store {
Pending,
Filled { amount: u64 },
Cancelled,
}
Pattern match with match:
match (order.status) {
OrderStatus::Pending => { ... },
OrderStatus::Filled { amount } => { /* use amount */ },
OrderStatus::Cancelled => { ... },
}
Use macro functions for higher-order patterns instead of manual loops.
// Do something N times
32u8.do!(|_| do_action());
// Build a new vector from an index range
let v = vector::tabulate!(32, |i| i);
// Iterate by immutable reference
vec.do_ref!(|e| process(e));
// Iterate by mutable reference
vec.do_mut!(|e| *e = *e + 1);
// Consume vector, calling a function on each element
vec.destroy!(|e| handle(e));
// Fold into a single value
let sum = vec.fold!(0u64, |acc, x| acc + x);
// Filter (requires T: drop)
let big = vec.filter!(|x| *x > 100);
All of these replace verbose manual while loops. Use them whenever iterating over a vector.
// Execute a function if Some, then drop
opt.do!(|value| process(value));
// Unwrap with a default (or abort)
let value = opt.destroy_or!(default);
let value = opt.destroy_or!(abort ECannotBeEmpty);
These replace verbose if (opt.is_some()) / destroy_some() patterns:
// ❌ Verbose
if (opt.is_some()) {
let inner = opt.destroy_some();
process(inner);
};
// ✅
opt.do!(|inner| process(inner));
Use /// for doc comments. JavaDoc-style /** */ is not supported in Move:
/// Returns the current fee in basis points.
public fun fee_bps(pool: &Pool): u64 { pool.fee_bps }
// ❌ Not supported
/** Returns the current fee in basis points. */
public fun fee_bps(pool: &Pool): u64 { pool.fee_bps }
Use regular // comments to explain non-obvious logic, potential edge cases, and TODOs:
// Note: can underflow if reserve is smaller than minimum_liquidity.
// TODO: add assert! guard before production use.
let lp_supply = math::sqrt(reserve_x * reserve_y);
| Task | Load |
|---|---|
| Defining structs or choosing abilities | sui-move-object |
| Method syntax with real types (Coin, Balance) | sui-move-stdlib |
| Visibility rules for entry vs public functions | sui-move-patterns |
| Package config, building, testing | sui-move-setup |