refactor
Intelligent refactoring with LSP, AST-grep, parallel codebase analysis, test assessment, plan generation, and continuous verification.
Skill by tainn03
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/tainn03-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, productivity
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
refactor- Description
- Intelligent refactoring with LSP, AST-grep, parallel codebase analysis, test assessment, plan generation, and continuous verification. 6-phase deterministic workflow.
- License
- MIT
- Instructions
- 300 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Intelligent Refactor Command
## Usage
```
/refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]
Arguments:
refactoring-target: What to refactor. Can be:
- File path: src/auth/handler.ts
- Symbol name: "AuthService class"
- Pattern: "all functions using deprecated API"
- Description: "extract validation logic into separate module"
Options:
--scope: Refactoring scope (default: module)
- file: Single file only
- module: Module/directory scope
- project: Entire codebase
--strategy: Risk tolerance (default: safe)
- safe: Conservative, maximum test coverage required
- aggressive: Allow broader changes with adequate coverage
```
## What This Command Does
Performs intelligent, deterministic refactoring with full codebase awareness:
1. **Understands your intent** - Analyzes what you actually want to achieve
2. **Maps the codebase** - Builds a definitive codemap before touching anything
3. **Assesses risk** - Evaluates test coverage and determines verification strategy
4. **Plans meticulously** - Creates a detailed refactoring plan
5. **Executes precisely** - Step-by-step refactoring with LSP and AST-grep
6. **Verifies constantly** - Runs tests after each change to ensure zero regression
---
# PHASE 0: INTENT GATE (MANDATORY FIRST STEP)
**BEFORE ANY ACTION, classify and validate the request.**
## Step 0.1: Parse Request Type
| Signal | Classification | Action |
|--------|----------------|--------|
| Specific file/symbol | Explicit | Proceed to codebase analysis |
| "Refactor X to Y" | Clear transformation | Proceed to codebase analysis |
| "Improve", "Clean up" | Open-ended | **MUST ask**: "What specific improvement?" |
| Ambiguous scope | Uncertain | **MUST ask**: "Which modules/files?" |
| Missing context | Incomplete | **MUST ask**: "What's the desired outcome?" |
## Step 0.2: Validate Understanding
Before proceeding, confirm:
- [ ] Target is clearly identified
- [ ] Desired outcome is understood
- [ ] Scope is defined (file/module/project)
- [ ] Success criteria can be articulated
**If ANY of above is unclear, ASK CLARIFYING QUESTION.**
## Step 0.3: Create Initial Todos
IMMEDIATELY after understanding the request, create todos for all 6 phases.
---
# PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)
## 1.1: Launch Parallel Explore Agents (BACKGROUND)
Fire ALL of these simultaneously:
1. **Find the refactoring target**: All occurrences and definitions of [TARGET]. Report file paths, line numbers, usage patterns.
2. **Find related code**: All code that imports, uses, or depends on [TARGET]. Report dependency chains, import graphs.
3. **Find similar patterns**: Similar code patterns to [TARGET] in the codebase. Report analogous implementations, established conventions.
4. **Find tests**: All test files related to [TARGET]. Report test file paths, test case names, coverage indicators.
5. **Architecture context**: Architectural patterns and module organization around [TARGET]. Report module boundaries, layer structure, design patterns.
## 1.2: Direct Tool Exploration (WHILE AGENTS RUN)
While background agents are running, use direct tools:
### LSP Tools for Precise Analysis:
- `goto_definition` - Where is it defined?
- `find_references` - ALL usages across workspace
- `document_symbols` - File structure
- `workspace_symbols` - Search by name
- `diagnostics` - Current errors/warnings before we start
### AST-Grep for Pattern Analysis:
- `ast_grep_search` - Find structural patterns
- `ast_grep_replace` with `dryRun=true` - Preview refactoring
## 1.3: Collect Background Results
Collect all agent results and merge findings.
---
# PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)
Based on Phase 1 results, build:
```
## CODEMAP: [TARGET]
### Core Files (Direct Impact)
- path/to/file.ts:L10-L50 - Primary definition
- path/to/file2.ts:L25 - Key usage
### Dependency Graph
[TARGET]
imports from: module-a (types), module-b (utils)
imported by: consumer-1.ts, consumer-2.ts, consumer-3.ts
used by: handler.ts (direct call), service.ts (dependency injection)
### Impact ZonesFrom tainn03/oh-my-copilot, MIT.
More from tainn03/oh-my-copilot
- 0.471score
codegraph
tainn03
Supercharges code exploration with a pre-indexed semantic knowledge graph.
SkillCFreshness: CClaude Code +9 - 0.471score
copilot-memories
tainn03
Guides the AI to persist context across sessions using 3-layer memory architecture (User/Repo/Session) with decision tree.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 17, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/tainn03/oh-my-copilot
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from tainn03
- 0.471score
codegraph
tainn03
Supercharges code exploration with a pre-indexed semantic knowledge graph.
SkillCFreshness: CClaude Code +9 - 0.471score
copilot-memories
tainn03
Guides the AI to persist context across sessions using 3-layer memory architecture (User/Repo/Session) with decision tree.
SkillCFreshness: CClaude Code +9
Cite this page
refactor skill. Agent Mart. https://agentmart.dev/skills/tainn03-refactor (last updated 2026-10-24)