composable-move-functions — Claude Code skill: what it does
composable-move-functions — a skill for Claude Code enforces conventions for Sui Move function signatures. It activates when designing public APIs, ordering parameters, and handling object returns for PTB composition.
Apache-2.0 616 installs ★ 25 updated 2026-11-12
npx skills add MystenLabs/skills --skill composable-move-functions -a claude-codeWhat composable-move-functions does
This skill guides the agent to author composable Move contracts compatible with Sui Programmable Transaction Blocks (PTBs). It bans the public entry pairing, requiring functions to be either composable public calls that return values or non-composable entry endpoints that handle transfers.
Signatures follow an exact argument sequence: target objects come first, followed by capabilities, primitive parameters, Clock, and ctx: &mut TxContext strictly at the end. Returning non-drop structs causes UnusedValueWithoutDrop errors under sui client call, requiring sui client ptb chaining or companion entry wrapper functions.
When available, the skill queries the Sui documentation MCP server at https://sui.mcp.kapa.ai to verify specific implementation details.
What it helps with
- prevent the invalid public entry visibility combination in Sui Move
- return newly minted assets to the caller instead of transferring them internally
- arrange function parameters in the required object-capability-primitive sequence
- adapt contract functions for chaining in Programmable Transaction Blocks
Example prompts for the agent
- Write a composable mint function for a Sui NFT that returns the object
- Fix the parameter order and visibility in this Move pool module
- Create an entry wrapper to transfer the result of create_thing for CLI calls
How to install composable-move-functions
1Skills CLI (Vercel)
npx skills add MystenLabs/skills --skill composable-move-functions -a claude-code2Manually: put the files in place
~/.claude/skills/composable-move-functions/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/composable-move-functions/
1Skills CLI (Vercel)
npx skills add MystenLabs/skills --skill composable-move-functions -a codex2Manually: put the files in place
.agents/skills/composable-move-functions/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add MystenLabs/skills --skill composable-move-functions -a cursor2Manually: put the files in place
.cursor/skills/composable-move-functions/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install MystenLabs/skills composable-move-functions2Manually: put the files in place
.github/skills/composable-move-functions/SKILL.md1Skills CLI (Vercel)
npx skills add MystenLabs/skills --skill composable-move-functions -a gemini-cli2Platform CLI
gemini skills install https://github.com/MystenLabs/skills --path composable-move-functionsManually: put the files in place
.devin/skills/composable-move-functions/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add MystenLabs/skills --skill composable-move-functions -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about composable-move-functions
How to install composable-move-functions in Claude Code?
Run npx skills add MystenLabs/skills --skill composable-move-functions -a claude-code. Alternatively, add the skill definition file to ~/.claude/skills/composable-move-functions/SKILL.md.
What does composable-move-functions do?
It guides the assistant to follow Sui Move standards, including object returns over internal transfers, parameter ordering, and PTB compatibility.
Why does the skill disallow public entry functions?
Combining public entry is redundant and restricts transaction composability. Functions must be either composable public utilities or standalone entry wrappers.
Source text
SKILL.md · Apache-2.0
---
name: composable-move-functions
description: Use when writing Move functions on Sui, especially public APIs. Applies to function visibility (public vs entry), parameter ordering, and return patterns. Use whenever designing function signatures or deciding whether functions should transfer objects or return them.
---
# composable-move-functions
> **MCP tool:** When available in your environment, also query the Sui documentation MCP server (`https://sui.mcp.kapa.ai`) for up-to-date answers. Use it for verification and for details not covered by these reference files.
## Overview
Sui transactions can chain multiple function calls in a single Programmable Transaction Block (PTB). Functions that transfer objects internally instead of returning them break this composability. This skill covers how to design functions that work well in PTBs.
All patterns sourced from https://move-book.com/guides/code-quality-checklist
## No `public entry`
Functions should be either `public` (composable, can be called from other modules and PTBs) or `entry` (transaction endpoint only). Never use `public entry` together.
```move
// WRONG — public entry is redundant and limits composability
public entry fun do_something() { }
// CORRECT — public for composable functions that return values
public fun mint(ctx: &mut TxContext): NFT { }
// CORRECT — entry for intentionally non-composable endpoints
entry fun mint_and_keep(ctx: &mut TxContext) { }
```
**When to use `entry`:** Only for convenience endpoints that are intentionally non-composable — functions that wrap a composable `public` function and handle transfers to sender.
## Return Objects, Don't Transfer Internally
Public functions should return values to the caller rather than transferring them to `ctx.sender()`. This makes them composable in PTBs — the caller decides what to do with the result.
```move
// WRONG — couples minting with transfer, can't compose
public fun mint_and_transfer(ctx: &mut TxContext) {
let nft = NFT { id: object::new(ctx) };
transfer::transfer(nft, ctx.sender());
}
// CORRECT — returns the object, caller decides
public fun mint(ctx: &mut TxContext): NFT {
NFT { id: object::new(ctx) }
}
// If you need a convenience entry point, add a separate entry wrapper:
entry fun mint_and_keep(ctx: &mut TxContext) {
let nft = mint(ctx);
transfer::transfer(nft, ctx.sender());
}
```
### CLI implication for returned values
Functions that return non-`drop` values cannot be invoked via `sui client call` — the CLI has no way to consume the returned value, causing an `UnusedValueWithoutDrop` error. Use `sui client ptb` instead, where you can chain `--assign` and `--transfer-objects` to handle the return value:
```bash
sui client ptb \
--move-call @pkg::module::create_thing --assign thing \
--transfer-objects "[thing]" @sender
```
If the function is called frequently from the CLI, consider providing a companion `entry` wrapper that transfers internally (as shown above).
This applies broadly:
- `add_liquidity` should return LP coins and remainder coins, not transfer them
- `remove_liquidity` should return both coins, not transfer them
- `swap` should return the output coin, not transfer it
- `borrow` should return the borrowed asset, not transfer it
## Parameter Ordering
Function parameters follow a strict order:
1. **Objects first** — the primary object being acted on
2. **Capabilities second** — authorization tokens like `AdminCap`
3. **Primitive values** — amounts, flags, addresses
4. **Clock** — always at the end (before ctx), exception to objects-first rule
5. **`ctx: &mut TxContext` last** — ALWAYS the final parameter, after all primitives and all other arguments
```move
// WRONG — cap before object, primitives mixed in
public fun authorize_action(
cap: &AdminCap,
value: u8,
app: &mut App,
ctx: &mut TxContext,
) { }
// CORRECT — object first, cap second, primitives third, ctx last
public fun authorize_action(
app: &mut App,
cap: &AdminCap,
value: u8,
ctx: &mut TxContext,
) { }
```
### Clock Exception
`Clock` goes near the end, just before `ctx`, even though it's an object:
```move
public fun timed_action(
app: &mut App,
cap: &AppCap,
value: u8,
clock: &Clock,
ctx: &mut TxContext,
) { }
```
## Quick Reference
| Pattern | Rule |
|---------|------|
| Visibility | `public` for composable, `entry` for endpoints. Never `public entry`. |
| Returns | Public functions return objects. Don't transfer to sender internally. |
| Entry wrappers | Separate `entry` function that calls `public` function + transfers. |
| Param order | Object → Capability → Primitives → Clock → TxContext |
© MystenLabs · Apache-2.0 · MystenLabs/skills