nav-simplify
БесплатноЗапускает вложенные скриптыНе проверенSimplify and refine code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code. Auto-invoke…
от qf-studio★ 358 звёзд на GitHubОб этом скилле
Navigator Code Simplification Skill
Simplify recently modified code for clarity, consistency, and maintainability while preserving exact functionality. Based on Anthropic's internal code-simplifier pattern.
Core Principle
Clarity over brevity. Functionality preserved absolutely.
You are an expert code simplification specialist. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior.
When to Invoke
Auto-invoke after:
backend-endpointskill completesfrontend-componentskill completesdatabase-migrationskill completes- Any implementation task with code changes
Manual invoke when user says:
- "simplify this code"
- "review for clarity"
- "clean up recent changes"
- "refactor for readability"
- "simplify modified files"
DO NOT invoke if:
- No code was modified (docs-only changes)
- User explicitly says "skip simplification"
- Files are configuration only (JSON, YAML)
Execution Steps
Step 1: Identify Modified Code
Option A: Git-based detection (preferred)
# Get files modified in current session/commits
git diff --name-only HEAD~3 -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.py' '*.go' '*.rs' 2>/dev/null || \
git diff --name-only --cached -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.py' '*.go' '*.rs' 2>/dev/null || \
git diff --name-only -- '*.ts' '*.tsx' '*.js' '*.jsx' '*.py' '*.go' '*.rs'
Option B: User-specified scope
If user mentions specific files or directories, use those instead.
Option C: Recent conversation context
Analyze conversation for files that were written/edited in this session.
Step 2: Load Simplification Configuration
Check for project-specific configuration:
if [ -f ".agent/.nav-config.json" ]; then
python3 -c "import json; c=json.load(open('.agent/.nav-config.json')); s=c.get('simplification',{}); print('auto_apply=' + str(s.get('auto_apply', False)).lower()); print('enabled=' + str(s.get('enabled', True)).lower())"
fi
Default configuration:
{
"simplification": {
"enabled": true,
"trigger": "post-implementation",
"scope": "modified",
"model": "opus",
"skip_patterns": ["*.test.*", "*.spec.*", "*.md", "*.json", "*.yaml"],
"max_file_size": 50000,
"auto_apply": false,
"preserve_comments": true
}
}
Autonomous context check (CRITICAL)
After loading config, determine the invocation mode:
Autonomous (no human in the loop):
- Invoked from
nav-loopVERIFY or COMPLETE phase - Invoked from
nav-workflowCOMPLETE phase NAV_AUTONOMOUS=1env var set- Triggered by autonomous-completion protocol
Interactive (human reviewing):
- Direct user request ("simplify this code")
- Mid-implementation manual invocation
Decision matrix:
auto_apply |
Context | Action |
|---|---|---|
true |
autonomous | Apply directly (Step 7 silent) |
true |
interactive | Apply directly, show summary |
false |
autonomous | SKIP simplification entirely — emit warning, return to caller. Never pause an autonomous flow waiting for approval. |
false |
interactive | Show diff per file, prompt for approval |
When skipping in autonomous-mode-with-false, emit:
⚠️ nav-simplify skipped: auto_apply=false but invoked autonomously.
To enable: set simplification.auto_apply=true in .agent/.nav-config.json
To disable cleanly: set simplification.enabled=false
Step 3: Read Project Standards
Load from CLAUDE.md (required):
Read(file_path: "CLAUDE.md")
Extract coding standards:
- Preferred patterns (function vs arrow, explicit returns)
- Naming conventions
- Import ordering
- Error handling patterns
- Framework-specific guidelines
Step 4: Analyze Each File
For each modified file, analyze for simplification opportunities:
Complexity Indicators (look for):
- Deep nesting (> 3 levels)
- Long functions (> 50 lines)
- Redundant code patterns
- Unclear variable names
- Nested ternary operators
- Over-abstraction
- Dead code
- Inconsistent patterns
Run analysis:
PLUGIN_DIR="${CLAUDE_PLUGIN_ROOT:-$(cat "${NAVIGATOR_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}/navigator}/plugin-root" 2>/dev/null)}"
[ -d "$PLUGIN_DIR/skills" ] || PLUGIN_DIR="$HOME/.claude/plugins/marketplaces/navigator-marketplace"
# Pass --scoring roi to enable cost/benefit gating (default: complexity,
# legacy behavior).
python3 "$PLUGIN_DIR/skills/nav-simplify/scripts/code_analyzer.py" --file "$file" --scoring roi
Step 4.5: ROI Gate (when scoring.mode = "roi")
If simplification.scoring.mode is "roi" in .agent/.nav-config.json (or --scoring roi was passed), the analyzer emits benefit_score, cost_score, roi_score, and a gate_action field. Honor the gate:
gate_action |
Behavior |
|---|---|
skip |
Skip this file. Emit a one-line reason with ROI math. Continue to next file. |
suggest |
Force interactive mode for this file regardless of auto_apply. |
Установить nav-simplify в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepВложенные файлы
FAQ
Что делает скилл nav-simplify?
Simplify and refine code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code. Auto-invoke after implementation skills or on-demand.
Как установить скилл nav-simplify?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nav-simplify запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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