cleanup · superclaude-org — команда для Claude Code: что делает и как установить
Команда cleanup находит мёртвый код, удаляет неиспользуемые импорты и приводит структуру проекта в порядок без риска сломать публичный интерфейс.
MIT ★ 23 950 обновлён 2026-09-27
.claude/commands/cleanup.mdЧто делает cleanup
Команда анализирует проект в пять шагов: сканирует дерево файлов, выбирает подходящую роль (архитектор, контроль качества или безопасность), правит код, проверяет тестами сохранение функциональности и выдаёт итоговый отчёт. Неиспользуемые импорты, пустые блоки и конструкции без единого вызова она стирает сразу. Если же функция потенциально вызывается извне или входит в публичный API, команда спросит подтверждение у разработчика.
В работе задействуются встроенные инструменты чтения и редактирования (Read, Grep, Glob, Edit, MultiEdit), а также трекинг через TodoWrite. При наличии серверов sequential и context7 инструмент подключает их для глубокого планирования и фреймворковых шаблонов, но при их отсутствии переходит на стандартные рассуждения модели и документацию из веба.
Какие задачи решает
- удалить неиспользуемые импорты и пустые блоки
- найти и вычистить мёртвый код с нулевым числом ссылок
- реорганизовать файлы и папки без поломки зависимостей
Примеры запросов агенту
- /sc:cleanup src/ --type
code --safe - /sc:cleanup --type
imports --preview - /sc:cleanup --type
all --interactive
Как установить cleanup
Вручную: положить файлы
.claude/commands/cleanup.mdВызов — /cleanup. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/cleanup.mdВызов — /prompts:cleanup. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/cleanup.prompt.mdВручную: положить файлы
.gemini/commands/cleanup.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о cleanup
Как установить cleanup в Claude Code?
Сохраните файл команды по пути .claude/commands/cleanup.md.
Что делает команда cleanup?
Она сканирует проект, удаляет мёртвые функции и неиспользуемые импорты, проверяя зависимости, чтобы не нарушить работу тестов и внешнего API.
Обязательно ли настраивать MCP-серверы sequential и context7?
Нет, они служат рекомендованным дополнением: если серверы не настроены, команда автоматически переключается на встроенные инструменты и поиск по документации.
Исходный текст
cleanup.md · MIT
--- name: cleanup description: "Systematically clean up code, remove dead code, and optimize project structure" category: workflow complexity: standard mcp-servers: [sequential, context7] personas: [architect, quality, security] --- # /sc:cleanup - Code and Project Cleanup ## Triggers - Code maintenance and technical debt reduction requests - Dead code removal and import optimization needs - Project structure improvement and organization requirements - Codebase hygiene and quality improvement initiatives ## Usage ``` /sc:cleanup [target] [--type code|imports|files|all] [--safe|--aggressive] [--interactive] ``` ## Behavioral Flow 1. **Analyze**: Assess cleanup opportunities and safety considerations across target scope 2. **Plan**: Choose cleanup approach and activate relevant personas for domain expertise 3. **Execute**: Apply systematic cleanup with intelligent dead code detection and removal 4. **Validate**: Ensure no functionality loss through testing and safety verification 5. **Report**: Generate cleanup summary with recommendations for ongoing maintenance Key behaviors: - Multi-persona coordination (architect, quality, security) based on cleanup type - Framework-specific cleanup patterns via Context7 MCP integration - Systematic analysis via Sequential MCP for complex cleanup operations - Safety-first approach with backup and rollback capabilities ## MCP Integration - **Sequential MCP**: Auto-activated for complex multi-step cleanup analysis and planning - **Context7 MCP**: Framework-specific cleanup patterns and best practices - **Persona Coordination**: Architect (structure), Quality (debt), Security (credentials) - **Availability fallback**: The MCP servers named here are preferred tooling, not hard requirements — when one is not installed, degrade gracefully (native reasoning in place of Sequential, official docs via web lookup in place of Context7, native tools otherwise) instead of routing work to absent servers. ## Tool Coordination - **Read/Grep/Glob**: Code analysis and pattern detection for cleanup opportunities - **Edit/MultiEdit**: Safe code modification and structure optimization - **TodoWrite**: Progress tracking for complex multi-file cleanup operations - **Task**: Delegation for large-scale cleanup workflows requiring systematic coordination ## Key Patterns - **Dead Code Detection**: Usage analysis → safe removal with dependency validation - **Import Optimization**: Dependency analysis → unused import removal and organization - **Structure Cleanup**: Architectural analysis → file organization and modular improvements - **Safety Validation**: Pre/during/post checks → preserve functionality throughout cleanup ## Examples ### Safe Code Cleanup ``` /sc:cleanup src/ --type code --safe # Conservative cleanup with automatic safety validation # Removes dead code while preserving all functionality ``` ### Import Optimization ``` /sc:cleanup --type imports --preview # Analyzes and shows unused import cleanup without execution # Framework-aware optimization via Context7 patterns ``` ### Comprehensive Project Cleanup ``` /sc:cleanup --type all --interactive # Multi-domain cleanup with user guidance for complex decisions # Activates all personas for comprehensive analysis ``` ### Framework-Specific Cleanup ``` /sc:cleanup components/ --aggressive # Thorough cleanup with Context7 framework patterns # Sequential analysis for complex dependency management ``` ## Boundaries **Will:** - Systematically clean code, remove dead code, and optimize project structure - Provide comprehensive safety validation with backup and rollback capabilities - Apply intelligent cleanup algorithms with framework-specific pattern recognition **Will Not:** - Remove code without thorough safety analysis and validation - Override project-specific cleanup exclusions or architectural constraints - Apply cleanup operations that compromise functionality or introduce bugs ## AUTO-FIX VS APPROVAL-REQUIRED **Auto-fix (applies automatically)**: - Unused imports removal - Dead code with zero references - Empty blocks removal - Redundant type annotations **Approval Required (prompts user first)**: - Code with indirect references - Exports potentially used externally - Test fixtures/utilities - Configuration values **Safety Threshold**: - If code has ANY usage path, prompt user - If code affects public API, prompt user - If unsure, prompt user
© SuperClaude-Org · MIT · SuperClaude-Org/SuperClaude_Framework
Похожие слэш-команды
Все слэш-команды по теме «Код-ревью и рефакторинг» →Сначала — cleanup от других авторов.