Analyze Sui Move test coverage, identify untested code, write missing tests, and perform security audits. Includes Python tools for parsing coverage output and generating reports.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install sui-auto-test或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install sui-auto-test⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/sui-auto-test/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: sui-coverage description: Analyze Sui Move test coverage, identify untested code, write missing tests, and perform security audits. Includes Python tools for parsing coverage output and generating reports. ---
Analyze and automatically improve Sui Move test coverage with security analysis.
# Location of tools
SKILL_DIR=~/clawd/skills/sui-coverage
# Full workflow
cd /path/to/move/package
sui move test --coverage --trace
python3 $SKILL_DIR/analyze_source.py -m <module> -o coverage.md
cd <package_path>
sui move test --coverage --trace
python3 ~/clawd/skills/sui-coverage/analyze_source.py -m <module_name> -o coverage.md
Read the generated coverage.md to identify:
assert!() failure paths not testedif/else paths not takenFor each uncovered item, write a test:
#[test]
fun test_<function_name>() {
// Setup
let mut ctx = tx_context::dummy();
// Call the uncovered function
<function_name>(...);
// Assert expected behavior
}
#[test]
#[expected_failure(abort_code = <ERROR_CODE>)]
fun test_<function>_fails_when_<condition>() {
let mut ctx = tx_context::dummy();
// Setup state that triggers the assertion failure
<function_call_that_should_fail>();
}
#[test]
fun test_<function>_when_<condition_true>() { ... }
#[test]
fun test_<function>_when_<condition_false>() { ... }
sui move test --coverage --trace
python3 ~/clawd/skills/sui-coverage/analyze_source.py -m <module_name>
---
python3 ~/clawd/skills/sui-coverage/analyze_source.py --module <name> [options]
Options:
-m, --module Module name (required)
-p, --path Package path (default: .)
-o, --output Output file (e.g., coverage.md)
--json JSON output
--markdown Markdown to stdout
sui move coverage lcov
python3 ~/clawd/skills/sui-coverage/analyze.py lcov.info -f "<package>" -s sources/
Options:
-f, --filter Filter by path pattern
-s, --source-dir Source directory for context
-i, --issues-only Only show files with issues
-j, --json JSON output
sui move coverage bytecode --module <name> | python3 ~/clawd/skills/sui-coverage/parse_bytecode.py
---
// Source code:
public fun withdraw(balance: &mut u64, amount: u64) {
assert!(*balance >= amount, EInsufficientBalance); // ← This failure path
*balance = *balance - amount;
}
// Test for the failure path:
#[test]
#[expected_failure(abort_code = EInsufficientBalance)]
fun test_withdraw_insufficient_balance() {
let mut balance = 50;
withdraw(&mut balance, 100); // Should fail: 50 < 100
}
// Source code:
public fun classify(value: u64): u8 {
if (value == 0) {
0
} else if (value < 100) {
1
} else {
2
}
}
// Tests for all branches:
#[test]
fun test_classify_zero() {
assert!(classify(0) == 0, 0);
}
#[test]
fun test_classify_small() {
assert!(classify(50) == 1, 0);
}
#[test]
fun test_classify_large() {
assert!(classify(100) == 2, 0);
}
#[test]
fun test_full_lifecycle() {
let mut ctx = tx_context::dummy();
// Create
let obj = create(&mut ctx);
assert!(get_value(&obj) == 0, 0);
// Modify
increment(&mut obj);
assert!(get_value(&obj) == 1, 0);
// Destroy
destroy(obj);
}
---
When writing #[expected_failure] tests, use the error constant name:
// If the module defines:
const EInvalidInput: u64 = 1;
const ENotAuthorized: u64 = 2;
// Use in test:
#[expected_failure(abort_code = EInvalidInput)]
fun test_invalid_input() { ... }
// Or use the module-qualified name:
#[expected_failure(abort_code = my_module::EInvalidInput)]
fun test_invalid_input() { ... }
---
# 1. Analyze current coverage
cd ~/project/my_package
sui move test --coverage --trace
python3 ~/clawd/skills/sui-coverage/analyze_source.py -m my_module -o coverage.md
# 2. Review what's missing
cat coverage.md
# Shows:
# - decrement() not called
# - assert!(value > 0, EValueZero) failure not tested
# 3. Add tests to sources/my_module.move or tests/my_module_tests.move
# (write the missing tests)
# 4. Verify improvement
sui move test --coverage --trace
python3 ~/clawd/skills/sui-coverage/analyze_source.py -m my_module
# 5. Repeat until 100% coverage
---
When asked to improve test coverage:
Always commit test improvements:
git add sources/ tests/
git commit -m "Improve test coverage for <module>"
---
Writing tests = Understanding the contract = Finding vulnerabilities
When writing tests, actively look for these issues:
Questions to ask:
- Who can call this function?
- Should there be owner/admin checks?
- Can unauthorized users manipulate state?
Red flags:
- Public functions that modify critical state without checks
- Missing capability/witness patterns
Questions to ask:
- What happens at u64::MAX?
- What happens when subtracting from 0?
- Are arithmetic operations checked?
Test pattern:
#[test]
fun test_overflow_boundary() {
// Test with max values
}
Questions to ask:
- Can state be left in inconsistent state?
- Are all state changes atomic?
- Can partial failures corrupt data?
Red flags:
- Multiple state changes without rollback
- Shared objects without proper locking
Questions to ask:
- Can someone extract more value than deposited?
- Are there rounding errors that can be exploited?
- Flash loan attack vectors?
Red flags:
- Price calculations without slippage protection
- Unbounded loops over user-controlled data
Questions to ask:
- Can someone block legitimate users?
- Are there unbounded operations?
- Can storage be filled maliciously?
Red flags:
- Vectors that grow unbounded
- Loops over external data
When analyzing a module, generate a security report:
## Security Analysis: <module_name>
### Summary
- Risk Level: [Low/Medium/High/Critical]
- Issues Found: X
### Findings
#### [SEVERITY] Issue Title
- **Location:** Line XX
- **Description:** What the issue is
- **Impact:** What could happen
- **Recommendation:** How to fix
### Tested Edge Cases
- [ ] Overflow at max values
- [ ] Underflow at zero
- [ ] Unauthorized access attempts
- [ ] Empty/null inputs
- [ ] Reentrancy scenarios
...
安装 Sui Auto Test 后,可以对 AI 说这些话来触发它
Help me get started with Sui Auto Test
Explains what Sui Auto Test does, walks through the setup, and runs a quick demo based on your current project
Use Sui Auto Test to analyze Sui Move test coverage, identify untested code, write missi...
Invokes Sui Auto Test with the right parameters and returns the result directly in the conversation
What can I do with Sui Auto Test in my developer & devops workflow?
Lists the top use cases for Sui Auto Test, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/sui-auto-test/ 目录(个人级,所有项目可用),或 .claude/skills/sui-auto-test/(项目级)。重启 AI 客户端后,用 /sui-auto-test 主动调用,或让 AI 根据上下文自动发现并使用。
Sui Auto Test 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Sui Auto Test 可免费安装使用。请查阅仓库了解许可证信息。
Analyze Sui Move test coverage, identify untested code, write missing tests, and perform security audits. Includes Python tools for parsing coverage output and generating reports.
Sui Auto Test 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Sui Auto Test
Identifies repetitive steps in your workflow and sets up Sui Auto Test to handle them automatically