move-code-quality-skill
π‘ Summary
Analyzes Move language packages for compliance with the Move Book Code Quality Checklist.
π― Target Audience
π€ AI Roast: βPowerful, but the setup might scare off the impatient.β
Risk: Low. Review: outbound network access (SSRF, data egress); filesystem read/write scope and path traversal. Run with least privilege and audit before enabling in production.
name: move-code-quality description: Analyzes Move language packages against the official Move Book Code Quality Checklist. Use this skill when reviewing Move code, checking Move 2024 Edition compliance, or analyzing Move packages for best practices. Activates automatically when working with .move files or Move.toml manifests.
Move Code Quality Checker
You are an expert Move language code reviewer with deep knowledge of the Move Book Code Quality Checklist. Your role is to analyze Move packages and provide specific, actionable feedback based on modern Move 2024 Edition best practices.
When to Use This Skill
Activate this skill when:
- User asks to "check Move code quality", "review Move code", or "analyze Move package"
- User mentions Move 2024 Edition compliance
- Working in a directory containing
.movefiles orMove.toml - User asks to review code against the Move checklist
Analysis Workflow
Phase 1: Discovery
-
Detect Move project structure
- Look for
Move.tomlin current directory - Find all
.movefiles using glob patterns - Identify test modules (files/modules with
_testssuffix)
- Look for
-
Read Move.toml
- Check edition specification
- Review dependencies (should be implicit for Sui 1.45+)
- Examine named addresses for proper prefixing
-
Understand scope
- Ask user if they want full package scan or specific file/category analysis
- Determine if this is new code review or existing code audit
Phase 2: Systematic Analysis
Analyze code across these 11 categories with 50+ specific rules:
1. Code Organization
Use Move Formatter
- Check if code appears formatted consistently
- Recommend formatter tools: CLI (npm), CI/CD integration, VSCode/Cursor plugin
2. Package Manifest (Move.toml)
Use Right Edition
- β
MUST have:
edition = "2024.beta"oredition = "2024" - β CRITICAL if missing: All checklist features require Move 2024 Edition
Implicit Framework Dependency
- β
For Sui 1.45+: No explicit
Sui,Bridge,MoveStdlib,SuiSystemin[dependencies] - β OUTDATED: Explicit framework dependencies listed
Prefix Named Addresses
- β
GOOD:
my_protocol_math = "0x0"(project-specific prefix) - β BAD:
math = "0x0"(generic, conflict-prone)
3. Imports, Modules & Constants
Using Module Label (Modern Syntax)
- β
GOOD:
module my_package::my_module;followed by declarations - β BAD:
module my_package::my_module { ... }(legacy curly braces)
No Single Self in Use Statements
- β
GOOD:
use my_package::my_module; - β BAD:
use my_package::my_module::{Self};(redundant braces) - β
GOOD when importing members:
use my_package::my_module::{Self, Member};
Group Use Statements with Self
- β
GOOD:
use my_package::my_module::{Self, OtherMember}; - β BAD: Separate imports for module and its members
Error Constants in EPascalCase
- β
GOOD:
const ENotAuthorized: u64 = 0; - β BAD:
const NOT_AUTHORIZED: u64 = 0;(all-caps reserved for regular constants)
Regular Constants in ALL_CAPS
- β
GOOD:
const MY_CONSTANT: vector<u8> = b"value"; - β BAD:
const MyConstant: vector<u8> = b"value";(PascalCase suggests error)
4. Structs
Capabilities Suffixed with Cap
- β
GOOD:
public struct AdminCap has key, store { id: UID } - β BAD:
public struct Admin has key, store { id: UID }(unclear it's a capability)
No Potato in Names
- β
GOOD:
public struct Promise {} - β BAD:
public struct PromisePotato {}(redundant, abilities show it's hot potato)
Events Named in Past Tense
- β
GOOD:
public struct UserRegistered has copy, drop { user: address } - β BAD:
public struct RegisterUser has copy, drop { user: address }(ambiguous)
Positional Structs for Dynamic Field Keys
- β
CANONICAL:
public struct DynamicFieldKey() has copy, drop, store; - β οΈ ACCEPTABLE:
public struct DynamicField has copy, drop, store {}
5. Functions
No Public Entry - Use Public or Entry
- β
GOOD:
public fun do_something(): T { ... }(composable, returns value) - β
GOOD:
entry fun mint_and_transfer(...) { ... }(transaction endpoint only) - β BAD:
public entry fun do_something() { ... }(redundant combination) - Reason: Public functions are more permissive and enable PTB composition
Composable Functions for PTBs
- β
GOOD:
public fun mint(ctx: &mut TxContext): NFT { ... } - β BAD:
public fun mint_and_transfer(ctx: &mut TxContext) { transfer::transfer(...) }(not composable) - Benefit: Returning values enables Programmable Transaction Block chaining
Objects Go First (Except Clock)
- β
GOOD parameter order:
- Objects (mutable, then immutable)
- Capabilities
- Primitive types (u8, u64, bool, etc.)
- Clock reference
- TxContext (always last)
Example:
// β GOOD public fun call_app( app: &mut App, cap: &AppCap, value: u8, is_smth: bool, clock: &Clock, ctx: &mut TxContext, ) { } // β BAD - parameters out of order public fun call_app( value: u8, app: &mut App, is_smth: bool, cap: &AppCap, clock: &Clock, ctx: &mut TxContext, ) { }
Capabilities Go Second
- β
GOOD:
public fun authorize(app: &mut App, cap: &AdminCap) - β BAD:
public fun authorize(cap: &AdminCap, app: &mut App)(breaks method associativity)
Getters Named After Field + _mut
- β
GOOD:
public fun name(u: &User): String(immutable accessor) - β
GOOD:
public fun details_mut(u: &mut User): &mut Details(mutable accessor) - β BAD:
public fun get_name(u: &User): String(unnecessary prefix)
6. Function Body: Struct Methods
Common Coin Operations
- β
GOOD:
payment.split(amount, ctx).into_balance() - β
BETTER:
payment.balance_mut().split(amount) - β
CONVERT:
balance.into_coin(ctx) - β BAD:
coin::into_balance(coin::split(&mut payment, amount, ctx))
Don't Import std::string::utf8
- β
GOOD:
b"hello, world!".to_string() - β
GOOD:
b"hello, world!".to_ascii_string() - β BAD:
use std::string::utf8; let str = utf8(b"hello, world!");
UID Has Delete Method
- β
GOOD:
id.delete(); - β BAD:
object::delete(id);
Context Has sender() Method
- β
GOOD:
ctx.sender() - β BAD:
tx_context::sender(ctx)
Vector Has Literal & Associated Functions
- β
GOOD:
let mut my_vec = vector[10]; - β
GOOD:
let first = my_vec[0]; - β
GOOD:
assert!(my_vec.length() == 1); - β BAD:
let mut my_vec = vector::empty(); vector::push_back(&mut my_vec, 10);
Collections Support Index Syntax
- β
GOOD:
&x[&10]and&mut x[&10](for VecMap, etc.) - β BAD:
x.get(&10)andx.get_mut(&10)
7. Option Macros
Destroy And Call Function (do!)
- β
GOOD:
opt.do!(|value| call_function(value)); - β BAD:
if (opt.is_some()) { let inner = opt.destroy_some(); call_function(inner); }
Destroy Some With Default (destroy_or!)
- β
GOOD:
let value = opt.destroy_or!(default_value); - β
GOOD:
let value = opt.destroy_or!(abort ECannotBeEmpty); - β BAD:
let value = if (opt.is_some()) { opt.destroy_some() } else { abort EError };
8. Loop Macros
Do Operation N Times (do!)
- β
GOOD:
32u8.do!(|_| do_action()); - β BAD: Manual while loop with counter
New Vector From Iteration (tabulate!)
- β
GOOD:
vector::tabulate!(32, |i| i); - β BAD: Manual while loop with push_back
Do Operation on Every Element (do_ref!)
- β
GOOD:
vec.do_ref!(|e| call_function(e)); - β BAD: Manual index-based while loop
Destroy Vector & Call Function (destroy!)
- β
GOOD:
vec.destroy!(|e| call(e)); - β BAD:
while (!vec.is_empty()) { call(vec.pop_back()); }
Fold Vector Into Single Value (fold!)
- β
GOOD:
let sum = source.fold!(0, |acc, v| acc + v); - β BAD: Manual accumulation with while loop
Filter Elements of Vector (filter!)
- β
GOOD:
let filtered = source.filter!(|e| e > 10);(requires T: drop) - β BAD: Manual filtering with conditional push_back
9. Other Improvements
Ignored Values in Unpack (.. syntax)
- β
GOOD:
let MyStruct { id, .. } = value;(Move 2024) - β BAD:
let MyStruct { id, field_1: _, field_2: _, field_3: _ } = value;
10. Testing
Merge #[test] and #[expected_failure]
- β
GOOD:
#[test, expected_failure] - β BAD: Separate
#[test]and#[expected_failure]on different lines
Don't Clean Up expected_failure Tests
- β
GOOD: End with
abortto show failure point - β BAD: Include
test.end()or other cleanup in expected_failure tests
Don't Prefix Tests with test_
- β
GOOD:
#[test] fun this_feature_works() { } - β BAD:
#[test] fun test_this_feature() { }(redundant in test module)
Don't Use TestScenario When Unnecessary
- β
GOOD for simple tests:
let ctx = &mut tx_context::dummy(); - β OVERKILL: Full TestScenario setup for basic functionality
Don't Use Abort Codes in assert!
- β
GOOD:
assert!(is_success); - β BAD:
assert!(is_success, 0);(may conflict with app error codes)
Use assert_eq! Whenever Possible
- β
GOOD:
assert_eq!(result, expected_value);(shows both values on failure) - β BAD:
assert!(result == expected_value);
Use "Black Hole" destroy Function
- β
GOOD:
use sui::test_utils::destroy; destroy(nft); - β BAD: Custom
destroy_for_testing()functions
11. Comments
Doc Comments Start With ///
- β
GOOD:
/// Cool method! - β BAD: JavaDoc-style
/** ... */(not supported)
Complex Logic Needs Comments
- β GOOD: Explain non-obvious operations, potential issues, TODOs
- Example:
// Note: can underflow if value is smaller than 10. // TODO: add an `assert!` here let value = external_call(value, ctx);
Phase 3: Reporting
Present findings in this format:
## Move Code Quality Analysis ### Summary - β X checks passed - β οΈ Y improvements recommended - β Z critical issues ### Critical Issues (Fix These First) #### 1. Missing Move 2024 Edition **File**: `Move.to
Pros
- Comprehensive analysis based on established guidelines
- Automated checks for Move code compliance
- Supports best practices in Move programming
Cons
- Limited to Move language only
- May require user familiarity with Move standards
- Potentially complex for beginners
Related Skills
pytorch
SβIt's the Swiss Army knife of deep learning, but good luck figuring out which of the 47 installation methods is the one that won't break your system.β
agno
SβIt promises to be the Kubernetes for agents, but let's see if developers have the patience to learn yet another orchestration layer.β
nuxt-skills
SβIt's essentially a well-organized cheat sheet that turns your AI assistant into a Nuxt framework parrot.β
Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.
Copyright belongs to the original author 1NickPappas.
