بنقرة واحدة
code-maintenance
// Refactoring and cleanup - improving code structure, removing dead code, eliminating duplication, or pre-merge cleanup. Use when code is hard to maintain, has dead code or debug artifacts, or needs pre-merge polishing.
// Refactoring and cleanup - improving code structure, removing dead code, eliminating duplication, or pre-merge cleanup. Use when code is hard to maintain, has dead code or debug artifacts, or needs pre-merge polishing.
Automatic quality control, linting, and static analysis procedures. Use when validating code changes for syntax correctness and project standards. Triggers on keywords: lint, format, check, validate, types, static analysis.
Fix a GitHub issue end-to-end - from reading the issue, understanding requirements, implementing the fix, writing tests, and creating a commit. Use when given a GitHub issue number or URL to resolve.
Optimize code for readability, performance, maintainability, and security across Bash, Python, and Rust. Use when asked to improve code quality, optimize performance, add type safety, or refactor for idioms.
Create, debug, and optimize GitHub Actions workflows with security best practices. Use when asked to "create workflow", "fix workflow", "add CI", or needs help with GitHub Actions.
Review code changes (diffs, PRs, patches) and provide structured, actionable feedback on correctness, maintainability, and test coverage. Use when the user asks for a code review, requests feedback on a patch/PR, or wants an assessment of changes.
Craft immersive, high-performance premium web experiences with advanced motion, typography, and architectural craftsmanship. Use when building award-level landing pages, interactive portfolios, or components requiring top-tier visual polish.
| name | code-maintenance |
| description | Refactoring and cleanup - improving code structure, removing dead code, eliminating duplication, or pre-merge cleanup. Use when code is hard to maintain, has dead code or debug artifacts, or needs pre-merge polishing. |
| allowed-tools | Bash(git:*), Bash(rg:*), Bash(ruff:*), Bash(npx:*), Read, Write, Edit, Glob, Grep |
Refactoring (structure) and cleanup (removal). Behavior preserved. Gradual evolution.
| Scenario | Mode | Focus |
|---|---|---|
| Code hard to maintain | Refactor | Extract, simplify, apply SOLID principles |
| Dead code, debug artifacts | Cleanup | Remove dead code, flag uncertain items |
| Pre-merge, production prep | Cleanup | Lint pass, verify tests, remove TODOs |
Search for code smells and cleanup targets:
<code_smells>
| Smell | Detection | Fix |
|---|---|---|
| Long method (>50 lines) | Line count | Extract method |
| Duplicated code | Search for similar blocks | Extract shared function |
| Dead code | No references, unreachable | Delete (git has history) |
| Magic numbers | Literal values in logic | Named constants |
| Nested conditionals (>3 levels) | Indentation depth | Guard clauses, early returns |
| God class/function | Too many responsibilities | Split by concern |
</code_smells>
<cleanup_targets>
| Category | Remove | Flag (don't auto-remove) |
|---|---|---|
| Dead code | No refs, commented-out, unreachable | Reflection/dynamic calls |
| Debug artifacts | print(), console.log(), debugger | Structured logging calls |
| Imports | Unused imports | Wildcard imports |
| Comments | Obvious, outdated comments | "Why" explanations |
</cleanup_targets>
ruff check --fix, eslint --fix, etc.Verify absent: hardcoded credentials, API keys, PII in test fixtures
Verify present: env vars for secrets, .gitignore entries for sensitive files
Before:
def process_order(order):
# 50 lines of validation
# 30 lines of pricing
# 20 lines of notification
After:
def process_order(order):
validate_order(order)
total = calculate_pricing(order)
notify_customer(order, total)
Search: rg "def legacy_handler" --files-with-matches
Check: rg "legacy_handler" src/ -> 0 references outside definition
Action: Delete function and its tests (git preserves history)
Search: rg "console\.log|debugger" src/ --count
Found: 12 console.log statements across 5 files
Action: Remove all, replace with structured logger where appropriate