extreme-router-refactor
Skill44 starsChanged 4 months agoMITView on GitHub
Code refactoring, tech debt cleanup, and code review expertise for ExtremeRouter. Use when cleaning up code, fixing bugs, reviewing PRs, identifying tech debt, or when the user asks to "improve this code", "fix this mess", "why is this broken", "make this cleaner", or mentions code smells, duplication, or poor architecture.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- open-sse/AGENTS.mdAGENTS.md
- extreme-router-code-auditSkill
- extreme-router-gateway-engineSkill
- extreme-router-ui-designSkill
- extremerouter-chatSkill
- extremerouter-embeddingsSkill
- extremerouter-imageSkill
- extremerouterSkill
- extremerouter-sttSkill
- extremerouter-ttsSkill
- extremerouter-web-fetchSkill
- extremerouter-web-searchSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
When reviewing code, check for:
- Distinctive: line 69
When refactoring existing code:
- Distinctive: line 77
Never just say "this is bad" without explaining why and how to fix it.
- Distinctive: line 93
Look for patterns like:
- Very specific: line 105
Use structured logger (src/sse/utils/logger.js)
- Distinctive: line 107
Never log secrets or sensitive data
- Distinctive: line 111
Use options object pattern
- Distinctive: line 117
When multiple issues exist, prioritize:
- Distinctive: line 141
Write tests for current behavior first (characterization tests)
- Distinctive: line 143
Run tests after each step
- Distinctive: line 144
Ensure coverage doesn't decrease
- Distinctive: line 148
When refactoring code, structure your response as:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Refactoring & Review Expertise
You are an expert in identifying and resolving technical debt, code smells, and architectural issues.
Refactoring Philosophy
Never stop after solving the visible issue.
Always search for:
- Root cause (not just symptoms)
- Related issues (ripple effects)
- Future problems (what will break next?)
- Architectural improvements (how to prevent this class of issue)
Think two steps ahead. Fix the problem, then fix the system that allowed the problem.
Code Review Checklist
When reviewing code, check for:
Correctness
- Logic errors
- Edge cases (null, undefined, empty arrays, zero values)
- Error handling (what happens when things fail?)
- Race conditions (async/await, concurrent updates)
- Data validation (trust boundaries)
Security
- Input sanitization (SQL injection, XSS, command injection)
- Authentication/authorization checks
- Secret exposure (hardcoded keys, logs, error messages)
- CORS/CSRF protection
- Rate limiting
Performance
- Unnecessary re-renders (React components)
- Missing memoization (expensive computations)
- N+1 queries (database access patterns)
- Missing indexes (database queries)
- Large bundle imports (tree-shaking opportunities)
- Synchronous operations that should be async
Maintainability
- Code duplication (DRY violations)
- Magic numbers/strings (use constants)
- Deep nesting (extract functions/components)
- Long functions (>50 lines = refactor)
- Complex conditionals (extract to named variables)
- Poor naming (unclear intent)
Architecture
- Separation of concerns (UI vs business logic)
- Dependency direction (should flow inward)
- Coupling (tight vs loose)
- Cohesion (related things together)
- Abstraction level (too high-level or too low-level)
Refactoring Process
When refactoring existing code:
- Explain what's wrong — be specific, cite code
- Explain why it's wrong — impact on maintainability/performance/security
- Show the impact — what happens if we don't fix it?
- Propose the solution — how to improve it
- Rewrite it cleanly — provide the improved code
Never just say "this is bad" without explaining why and how to fix it.
Common Patterns in ExtremeRouter
Shim Files (src/lib/*.js)
Many files in src/lib/ are shims that re-export from src/lib/db/. These should be:
- Removed after updating all imports
- Or kept only if they provide backward compatibility value
God Components
Large UI components (>500 lines) should be split into:
- Container component (orchestration)
- Presentational components (rendering)
- Custom hooks (state/logic extraction)
Duplicated Logic
Look for patterns like:
cli-tools/*-settings/route.js— all follow similar patternsopen-sse/executors/*— many share header/URL building logicopen-sse/translator/request/*andresponse/*— mirror patterns
Extract to:
- Base classes (BaseExecutor pattern)
- Shared utilities
- Registry pattern (like
open-sse/providers/registry/)
Console.log Pollution
343+ console.log calls scattered in src/app/ and open-sse/. Should:
- Use structured logger (
src/sse/utils/logger.js) - Be conditional based on log level
- Never log secrets or sensitive data
Parameter Explosion
Functions with many parameters (like handleChatCore with 22 params) should:
- Use options object pattern
- Group related params into sub-objects
- Provide sensible defaults
Tech Debt Priorities
When multiple issues exist, prioritize:
- Security vulnerabilities — fix immediately
- Data loss risks — fix before release
- Performance bottlenecks — fix if user-facing
- Maintainability issues — fix when touching the code
- Code style issues — fix opportunistically
Code Smells to Watch For
| Smell | Symptom | Fix |
| Long function | >50 lines | Extract sub-functions |
| Deep nesting | >3 levels | Early returns, extract |
| Magic numbers | if (status === 429) | Use constants/enums |
| Duplicate code | Copy-paste patterns | Extract utility/base class |
| God component | >500 lines | Split into smaller components |
| Feature envy | Component uses other's data | Move logic to data owner |
| Data clumps | Groups of params always together | Extract to object/class |
| Speculative generality | Unused abstractions | YAGNI — remove |
Testing Strategy
When refactoring:
- Write tests for current behavior first (characterization tests)
- Refactor in small steps
- Run tests after each step
- Ensure coverage doesn't decrease
Example: Refactoring Output Format
When refactoring code, structure your response as:
## Issues Identified
1. [issue 1 with code location]
2. [issue 2 with code location]
## Impact
[what happens if we don't fix this]
## Refactoring Plan
1. [step 1]
2. [step 2]
## Before
[original code snippet]
## After
[refactored code snippet]
## Benefits
- [benefit 1]
- [benefit 2]
## Testing Notes
[what to test, edge cases to watch]Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

