weasel-simplify
БесплатноБез исполняемых скриптовНе проверенSolidity code simplification and refactoring for clarity and maintainability. Triggers on weasel simplify, weasel refactor, or weasel clean up.
Об этом скилле
Weasel Simplify
Expert Solidity code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality.
When to Activate
- Developer wants to clean up code
- User asks to simplify or refactor
- User wants to improve readability
- After writing new code that could be cleaner
Two Modes
Developer Mode (Default)
User wants to modify their codebase for maintainability.
- Edit actual source files
- Run tests after changes
- Commit simplified code
Auditor Mode
User wants to understand complex code during audit.
- Create scratch/mental simplification for analysis
- NEVER modify files being audited
- Output simplified version to terminal or scratch file
- Original code stays untouched
Detection: If in audit context (weasel-analyzer was used, or user mentions "audit"), default to Auditor Mode.
When NOT to Use
- Unfamiliar codebase - Understand first (→ weasel-overview)
- Security-critical changes - If unsure about a pattern's purpose, don't touch it
- No tests available (Developer Mode only) - Can't verify behavior without tests
Core Principles
1. Preserve Functionality
Never change what the code does - only how it's written. All features, outputs, and behaviors must remain identical.
2. Security First
Never simplify in a way that introduces vulnerabilities:
- Don't remove reentrancy guards for "simplicity"
- Don't combine checks in ways that could be bypassed
- Don't remove access control for fewer lines
- Don't reorder CEI pattern
3. Clarity Over Brevity
Readable code > compact code:
- Avoid nested ternaries
- Use meaningful variable names
- Keep functions focused
4. Gas Aware
Don't "simplify" into more expensive code. Preserve:
- Storage caching patterns
- Unchecked blocks where safe
- Calldata over memory for read-only params
Workflow
Developer Mode
- Understand first - Read the code, understand WHY it's written this way
- Scope - What to simplify? (specific function, file, or recent changes)
- Check tests exist - If no tests, warn user before proceeding
- Analyze - Find complexity without touching security patterns
- Simplify - Apply transformations via Edit tool
- Test - Run tests to verify behavior preserved
- Report - Summarize changes made
Auditor Mode
- Understand first - Read the code and surrounding context
- Scope - What to simplify for analysis?
- Analyze - Identify complexity that obscures logic
- Output simplified version - Show in terminal or create scratch file
- DO NOT edit original files
- Note - "This is a simplified view for analysis. Original code unchanged."
Key Simplification Patterns
Pattern 1: Flatten Nesting → Early Returns
// Before: Deep nesting hides logic
function withdraw(uint256 amount) external {
if (amount > 0) {
if (balances[msg.sender] >= amount) {
if (!paused) {
balances[msg.sender] -= amount;
payable(msg.sender).transfer(amount);
}
}
}
}
// After: Guards at top, happy path clear
function withdraw(uint256 amount) external {
if (amount == 0) revert ZeroAmount();
if (balances[msg.sender] < amount) revert InsufficientBalance();
if (paused) revert ContractPaused();
balances[msg.sender] -= amount;
payable(msg.sender).transfer(amount);
}
Pattern 2: Extract Repeated Logic → Modifiers
// Before: Same checks in multiple functions
function deposit() external payable {
require(msg.value > 0, "Zero");
require(!paused, "Paused");
// ...
}
function withdraw(uint256 amt) external {
require(amt > 0, "Zero");
require(!paused, "Paused");
// ...
}
// After: DRY with modifiers
modifier whenNotPaused() {
if (paused) revert ContractPaused();
_;
}
modifier nonZero(uint256 value) {
if (value == 0) revert ZeroValue();
_;
}
function deposit() external payable whenNotPaused nonZero(msg.value) { ... }
function withdraw(uint256 amt) external whenNotPaused nonZero(amt) { ... }
Pattern 3: Name Complex Conditions
// Before: Hard to read
if (amount > 0 && amount <= max && !blocked[msg.sender] && block.timestamp >= start) { ... }
// After: Self-documenting
bool isValidAmount = amount > 0 && amount <= max;
bool isAllowedUser = !blocked[msg.sender];
bool hasStarted = block.timestamp >= start;
if (isValidAmount && isAllowedUser && hasStarted) { ... }
Other Opportunities
- Remove dead/commented code
- Replace require strings with custom errors (gas savings)
- Decompose long functions
- Improve variable/function names
- Remove redundant initializations (
uint256 x = 0→uint256 x)
What NOT to Simplify
Security patterns - preserve even if "verbose":
// KEEP: Reentrancy guard
function withdraw() external nonReentrant { ... }
// KEEP: CEI order (Checks-Effec
Установить weasel-simplify в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл weasel-simplify?
Solidity code simplification and refactoring for clarity and maintainability. Triggers on weasel simplify, weasel refactor, or weasel clean up.
Как установить скилл weasel-simplify?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл weasel-simplify запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic