From guardrails
Guardrail for efficient refactoring. IDEs use AST-based semantic refactoring (instant, atomic, accurate). AI uses text-based pattern matching (slower, sequential, error-prone for structural changes). This skill provides decision criteria for when to delegate to IDE vs proceed with AI. Consult before: renames across files, moving packages, changing signatures, extracting interfaces, or any multi-file coordinated structural change.
How this skill is triggered — by the user, by Claude, or both
Slash command
/guardrails:ide-handoffThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill teaches you when to STOP and delegate structural refactoring to the user's IDE, versus when to proceed with AI-based editing.
This skill teaches you when to STOP and delegate structural refactoring to the user's IDE, versus when to proceed with AI-based editing.
IDEs use Abstract Syntax Tree (AST) semantic refactoring:
AI uses text-based pattern matching:
STOP and generate a handoff document when you're about to:
Moving files or directories that require import path updates across the codebase.
Examples:
pkg/old/ → internal/new/src/components/Button/ → src/ui/Button/IDE advantage: Drag-and-drop with automatic import updates
Changing the name of a symbol that's referenced throughout the codebase.
Examples:
UserService to AccountServicegetData() to fetchData()config to settings across modulesIDE advantage: Single rename operation with preview, all references updated atomically
Adding, removing, or reordering parameters on functions called from multiple locations.
Examples:
ctx context.Context as first parameterfunc Process(data []byte) to func Process(ctx context.Context, data []byte, opts Options)IDE advantage: Signature change with automatic call site updates
Creating an interface from an existing implementation.
IDE advantage: Automatic interface extraction with method selection
Replacing function calls or variable references with their definitions.
IDE advantage: Safe inlining with usage analysis
If the same structural change needs to happen across many files, IDE refactoring is more efficient.
Continue with AI-based editing when:
Before making edits that touch 5+ files with similar changes, ask:
Is this a rename/move/signature change?
Would an IDE do this with a menu command or keyboard shortcut?
Am I generating new code or modifying logic?
Is the same substitution pattern repeated across files?
When stopping for handoff, generate a document with this structure:
# IDE Refactoring Handoff
## What Needs to Change
[Describe the structural change needed]
## Why This is Better in IDE
[Brief explanation of why IDE is more efficient for this specific change]
## IntelliJ/GoLand Steps
1. [Step-by-step instructions using IntelliJ/GoLand]
2. [Include keyboard shortcuts: Shift+F6 for rename, F6 for move, etc.]
3. [Mention Refactor menu location]
## VSCode Steps
1. [Step-by-step instructions using VSCode]
2. [Include keyboard shortcuts: F2 for rename, etc.]
3. [Mention relevant extensions if needed]
## Validation
```bash
# Run these after IDE refactoring:
git diff --stat
[language-specific test command]
[language-specific build command]
[Describe what AI work will continue after the structural refactoring is complete]
## Detecting Refactoring as Side Effect
**IMPORTANT:** Refactoring often emerges as a side effect, not an explicit user request.
**Example scenario:**
- User asks: "Add infrastructure controller binary"
- You think: "I should restructure cmd/ first..."
- **STOP!** This restructuring is IDE territory
**Before starting ANY task that involves restructuring:**
1. Identify if structural changes are needed
2. If yes, create handoff document FIRST
3. User executes IDE refactoring
4. THEN proceed with the original task
## Quick Reference: IDE Keyboard Shortcuts
### IntelliJ/GoLand
| Action | Shortcut |
|--------|----------|
| Rename | Shift+F6 |
| Move | F6 |
| Change Signature | Cmd/Ctrl+F6 |
| Extract Interface | Refactor menu |
| Inline | Cmd/Ctrl+Alt+N |
| Safe Delete | Alt+Delete |
### VSCode
| Action | Shortcut |
|--------|----------|
| Rename Symbol | F2 |
| Move/Rename File | Right-click → Rename |
| Go to References | Shift+F12 |
## Examples of Good Handoffs
### Example 1: Package Move
**User request:** "Move the user package to internal/domain"
**Response:** "This is a package move operation - IDE semantic refactoring will handle this much more efficiently. Let me create a handoff document..."
### Example 2: Type Rename
**User request:** "Rename Config to Settings throughout the codebase"
**Response:** "This is a cross-file rename operation. IDE's rename refactoring will update all references atomically. Here's the handoff..."
### Example 3: Implicit Refactoring
**User request:** "Add a new API endpoint for user preferences"
**Your analysis reveals:** Need to reorganize handlers/ first
**Response:** "Before adding the endpoint, I notice the handlers need reorganization. This structural change is best done in your IDE. Let me create a handoff for that first, then I'll add the endpoint..."
npx claudepluginhub jskswamy/claude-plugins --plugin guardrailsPerforms safe, incremental refactoring with test verification at each step. Supports targeting specific files/functions, sweeping complexity hotspots across a project, and extracting methods, classes, or modules.
Performs safe refactoring: extract functions/components/hooks/modules/classes, rename/move/restructure symbols/files, inline code, detect dead code/smells using test-driven methods.
Safely restructure code in an isolated git worktree with test-preserved, incremental transformations