Analyze codebases to identify reusable code patterns, duplications, and implementation patterns for future development. Use when refactoring code, identifying technical debt, finding opportunities for abstraction, or documenting common patterns in a directory or module. Outputs pattern catalogs, refactoring suggestions, and reusable template code.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill code-pattern-extractor
Systematically analyze code in directories or modules to identify recurring patterns, code duplication, and implementation patterns that can be abstracted into reusable components, utilities, or design patterns.
Identify the code to analyze:
Use Glob to find relevant files:
**/*.js, **/*.py, **/*.go, etc.
Identify repeated code blocks that appear multiple times:
Look for:
Analysis criteria:
Find recurring implementation approaches:
Common patterns:
Example patterns to detect:
// Pattern: API call with error handling
async function fetchX() {
try {
const response = await fetch(url);
if (!response.ok) throw new Error();
return await response.json();
} catch (error) {
console.error(error);
return null;
}
}
Group identified patterns by type and impact:
Categories:
Pattern types:
Document each identified pattern:
Pattern entry format:
## Pattern: [Descriptive Name]
**Type**: [Utility/API/UI/Business Logic]
**Frequency**: [Number of occurrences]
**Impact**: [High/Medium/Low]
**Description**: [What the pattern does]
**Current implementations**:
- `file1.js:45-60` - [Brief context]
- `file2.js:120-135` - [Brief context]
- `file3.js:89-104` - [Brief context]
**Common variations**:
- [Variation 1 description]
- [Variation 2 description]
For each high-value pattern, provide refactoring recommendations:
Suggestion format:
### Refactoring: Extract [Pattern Name]
**Current state**: Pattern appears in [N] locations with [X]% code duplication
**Proposed solution**: Extract into [utility function/class/hook/module]
**Benefits**:
- Reduce code duplication by ~[N] lines
- Centralize logic for easier maintenance
- Improve testability
**Implementation approach**:
1. Create new file: `utils/[pattern-name].js`
2. Extract common logic with parameters for variations
3. Replace [N] occurrences with function calls
4. Add unit tests
**Estimated effort**: [Small/Medium/Large]
Create reusable template implementations for high-value patterns:
Template format:
/**
* [Pattern description]
*
* @param {type} param1 - [Description]
* @param {type} param2 - [Description]
* @returns {type} [Description]
*/
function patternTemplate(param1, param2) {
// Extracted common logic
// Parameterized variations
// Return standardized result
}
Include:
Organize findings into a comprehensive report:
# Code Pattern Analysis: [Directory/Module Name]
## Summary
- Files analyzed: [N]
- Patterns identified: [N]
- High-value patterns: [N]
- Estimated duplication: [N] lines
## Pattern Catalog
[List of all identified patterns with details]
## Refactoring Suggestions
[Prioritized list of refactoring opportunities]
## Template Code
[Reusable implementations for high-value patterns]
## Next Steps
[Recommended actions prioritized by impact]
Code duplication detection:
Implementation pattern detection:
Abstraction opportunities:
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
Comprehensive GitHub code review with AI-powered swarm coordination
Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.
Comprehensive truth scoring, code quality verification, and automatic rollback system with 0.95 accuracy threshold for ensuring high-quality agent outputs and codebase reliability.
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
GitHub CLI - manage repositories, issues, pull requests, actions, releases, and more from the command line.
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
Take arabelatso/code-pattern-extractor from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.