foundry-refactor

Refactor code across files using LSP-based reference analysis.

4|Updated Dec 3, 2025
One-click install
npx skills add https://github.com/foundry-works/claude-foundry --skill foundry-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundry-refactor
Source: https://github.com/foundry-works/claude-foundry/tree/main/skills/foundry-refactor
Command: npx skills add https://github.com/foundry-works/claude-foundry --skill foundry-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cross-file symbol refactoring is error-prone and time-consuming. This skill provides a safe, LSP-powered workflow that analyzes references before making changes, ensuring updates propagate correctly and reducing drift.

Core Features & Use Cases

  • Safe rename operations with complete reference updates
  • Extract function/method with reference updating
  • Move symbol across files with import updates
  • Optional dead code cleanup based on reference analysis
  • Works within a spec-driven development workflow (planning, verification, and journaling)

Quick Start

To use this skill, initiate a refactor task (rename, extract, or move) in a project with LSP support and the Claude Code environment, then follow the prompts to scope, validate references, execute changes, and verify results.

Frequently Asked Questions about foundry-refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely rename a symbol across multiple files?

Safe cross-file rename requires LSP-based analysis to find all references before propagating symbol changes. This approach validates references first, ensuring updates propagate correctly across files and reducing drift.

What is the best way to extract a function and update its references?

Extracting a function safely uses LSP guidance to identify references and update them during the extraction. This ensures the newly extracted method or function is wired correctly across the codebase without manual searching.

How do I move a symbol to another file and update imports?

Moving a symbol across files requires updating all import statements and references in the target and source files. LSP analysis finds affected locations to execute the move and update imports comprehensively.

Do I need LSP support to perform cross-file refactoring?

Yes, LSP tooling is required. Cross-file refactoring relies on documentSymbol, findReferences, and goToDefinition capabilities to analyze the codebase and ensure safe, comprehensive reference updates before applying changes.

Can I clean up dead code when refactoring symbols?

Optional dead code cleanup is supported during refactoring. After moving or renaming symbols, reference analysis identifies unused code, allowing you to safely remove it within the spec-driven workflow.

What is a spec-driven refactoring workflow?

A spec-driven refactoring workflow structures changes through planning, verification, and journaling phases. It uses mcp-based task journaling to track each step, ensuring LSP-guided symbol changes are validated and recorded.