Help us improve
Share bugs, ideas, or general feedback.
From north-starr
Analyzes code modules and files for refactoring opportunities, code smells, and architectural pattern violations in any language or framework. Useful for reviewing specific code quality or architecture.
npx claudepluginhub selcukyucel/north-starr --plugin north-starrHow this skill is triggered — by the user, by Claude, or both
Slash command
/north-starr:analyze-codeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Systematically analyze code for refactoring opportunities by checking against comprehensive checklists and architectural principles. This skill identifies code smells, architectural violations, design pattern misuse, and improvement opportunities in **any language or framework**.
Analyzes code quality via cleanup analysis (dead code, duplication, complexity) and multi-perspective reviews (maintainer, architect, user advocate, security, performance).
Discovers architectural friction — shallow modules, god files, duplication, coupling — and proposes structural refactors with competing interface options and a project-local RFC.
Analyzes code structure, complexity, and quality using cyclomatic and cognitive complexity metrics, detects code smells like long methods and god objects, and suggests refactoring strategies.
Share bugs, ideas, or general feedback.
Systematically analyze code for refactoring opportunities by checking against comprehensive checklists and architectural principles. This skill identifies code smells, architectural violations, design pattern misuse, and improvement opportunities in any language or framework.
Use this skill when the user requests:
Important: This skill analyzes specific modules or files, NOT the entire codebase. The user should specify the scope.
Identify what needs to be analyzed from the user's request:
Module-Level Analysis (directory with related files):
File-Level Analysis:
If the scope is unclear, ask the user to specify the module or file path.
Before analyzing, identify the project's technology stack:
.swift, .ts, .py, .go, .rs, .java, .kt, etc.)CLAUDE.md, .claude/rules/, .github/instructions/, or other project docs describing the architecture.eslintrc, .swiftlint.yml, pyproject.toml, etc.)This context shapes which checklist items are most relevant and what patterns to validate against.
Use appropriate tools to read the code being analyzed:
For Module Analysis:
Glob to find all source files in the module directoryRead to load each file in the moduleFor File Analysis:
Read to load the specific fileContext Gathering:
.claude/rules/ and .github/instructions/ for project-specific knowledgeLoad and apply the comprehensive refactoring checklist from references/refactoring-checklist.md.
How to use the checklist:
Read the checklist: Use the Read tool to load references/refactoring-checklist.md into context
Scan systematically: Go through each category relevant to the code type:
Document findings: For each issue found, note:
Severity Guidelines:
False Positive Avoidance: Only flag issues you are CERTAIN about from the visible code. If you cannot see the full context (e.g., an extension method defined in another file, the reason behind a keyword like nonisolated), do NOT flag it as a problem. When flagging potential issues in code you cannot fully verify (e.g., unused enum cases that may be used elsewhere), explicitly qualify with "verify before acting" language. Speculative future advice ("you could migrate to X someday") is NOT an issue — omit it. When assessing lifecycle/memory issues, consider whether the runtime already handles the scenario (e.g., a Task holding self strongly is not a "leak" if the task completes or is cancelled — it just extends lifetime). Do not flag working dependency imports as potential risks ("what if this dependency is removed someday").
Load and validate against architectural principles from references/architecture-patterns.md.
How to validate:
Read architecture guide: Use the Read tool to load references/architecture-patterns.md into context
Discover the project's architecture: Check CLAUDE.md, .claude/rules/, .github/instructions/, and project docs for declared boundaries, dependency rules, and conventions. Do NOT assume a specific architecture style — use whatever the project declares.
Identify the code's role: Determine what role this code plays within the project's own architecture. What module does it belong to? What is that module responsible for? What should it depend on?
Validate against universal principles:
Document violations: For each architectural violation, note:
Beyond checklist items, look for higher-level refactoring opportunities:
Extract and Consolidate:
Architectural Improvements:
Modern Language Adoption:
Performance Optimizations:
Score the analyzed code against the 7 Code Virtues (see skills/_references/virtues/code-virtues.md). This provides a positive quality assessment alongside the issue-based findings.
For each virtue, assign 1-5 stars based on evidence:
| Virtue | What to Measure | Evidence Sources |
|---|---|---|
| Working | Test coverage, CI status, known bugs | Test files, coverage reports, issue trackers |
| Unique | Duplication level, copy-paste patterns | Duplication analysis from Step 4 |
| Simple | Cyclomatic complexity, entity count, nesting depth | Complexity metrics from Step 4 |
| Clear | Naming quality, self-documenting structure, magic values | Code Clarity checks from Step 4 |
| Easy | How many files/layers a typical change touches | Grain analysis, coupling assessment |
| Developed | Type maturity, abstraction quality, API design | Architecture validation from Step 5 |
| Brief | Verbosity, boilerplate ratio, unnecessary code | Code Organization checks from Step 4 |
Scoring guide:
Evidence MUST be concrete: Each virtue's evidence cell must cite specific line numbers, metrics, or issue references — not vague prose. Bad: "Some complexity issues." Good: "save() at line 127 is 44 lines with 3 nesting levels; setupPlayerPerformances at line 207 uses imperative loop where filter() would suffice."
The scorecard highlights what to protect (high scores) as well as what to improve (low scores). This is especially valuable when prioritizing refactoring work — fix the lowest-scoring virtue that has the highest priority number first (Working before Unique before Simple, etc.).
Create a comprehensive, actionable report with the following structure.
Non-Negotiable Output Rules (the report MUST satisfy all of these):
file_path:line_number — never use step names or vague references instead of line numbers.CLAUDE.md, .claude/rules/, .github/instructions/, or project docs) and validate the code against those specific boundaries. If no project architecture docs exist, state that explicitly and validate against universal principles only.# Refactoring Analysis: [Module/File Name]
## Summary
- **Language/Framework**: [detected stack]
- **Total Issues Found**: [count]
- **Critical**: [count]
- **High**: [count]
- **Medium**: [count]
- **Low**: [count]
## Virtue Scorecard
| Virtue | Score | Evidence |
|-------------|-------|----------|
| Working | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Unique | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Simple | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Clear | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Easy | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Developed | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
| Brief | [★☆☆☆☆ - ★★★★★] | [brief evidence] |
**Lowest-priority virtue to fix first:** [virtue name — why]
## Critical Issues
### 1. [Issue Title]
**Category**: [Category from checklist]
**Severity**: Critical
**Location**: `[File]:[Line]`
**Description**: [What's wrong and why it's critical]
**Current Code**:
[Code snippet showing the issue]
**Suggested Fix**:
[Code snippet showing the solution]
**Impact**: [Why this matters]
---
## High Priority Issues
[Same format as Critical]
---
## Medium Priority Issues
[Same format as Critical]
---
## Low Priority Issues
[Same format as Critical]
---
## Architecture Validation
### Principle Compliance
- [ ] Single Responsibility: each unit has one clear purpose
- [ ] Dependency Direction: dependencies flow in the direction the project declares
- [ ] Boundary Compliance: module boundaries are respected
- [ ] Separation of Concerns: distinct concerns live in distinct modules
- [ ] Naming Conventions: consistent naming throughout
### Violations Found
[List any architectural violations with references]
---
## Refactoring Opportunities
### Extract to Shared Code
[List code that should be extracted with suggestions]
### Existing Solutions to Adopt
[List framework/library features that could replace custom code]
### Modernization Opportunities
[List areas where modern language/framework features could be adopted]
---
## Positive Observations
[List things done well - proper patterns, good practices, etc.]
---
## Recommended Action Plan
1. **Immediate** (Critical/High issues):
- [Action item]
- [Action item]
2. **Short-term** (Medium issues):
- [Action item]
- [Action item]
3. **Long-term** (Low issues + optimizations):
- [Action item]
- [Action item]
Be Specific:
Be Actionable:
Be Balanced:
Be Contextual:
Prioritize issues that:
For each finding:
refactoring-checklist.mdarchitecture-patterns.md.claude/rules/ and .github/instructions/ for project-specific knowledgeThis skill uses three reference documents:
refactoring-checklist.md: 15 categories covering universal refactoring opportunities
architecture-patterns.md: Universal architectural principles and validation methodology
skills/_references/virtues/code-virtues.md: The 7 Code Virtues positive quality framework
These references are loaded into context during analysis to ensure comprehensive and accurate findings.