skill-folder-refactor

Refactor a named folder into subfolders and shared code without changing behavior.

5|Updated May 21, 2026
One-click install
npx skills add https://github.com/TrebuchetDynamics/pi-package-goal --skill skill-folder-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: skill-folder-refactor
Source: https://github.com/TrebuchetDynamics/pi-package-goal/tree/main/skills/skill-folder-refactor
Command: npx skills add https://github.com/TrebuchetDynamics/pi-package-goal --skill skill-folder-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

A folder refactor turns a messy, single-directory code layout into a maintainable topology without changing behavior, while keeping validation green across the entire rename/move/extract process.

Core Features & Use Cases

  • Behavior-preserving refactoring workflow: Refactor one explicitly named folder into coherent subfolders and shared modules using a move-only safety phase followed by controlled extraction and cleanup.
  • Objective-driven continuation: Treat the refactor as an active, multi-slice objective, continuing autonomously through remaining safe slices until the target topology is complete or blocked by validation/risk.
  • Safer engineering validation gates: Map the folder, identify public contracts, add or reuse focused tests when needed, and re-run narrow validation checkpoints after each slice to prevent regressions.
  • Shared-code extraction with proof: Extract shared modules only when duplicate call sites are proven and covered by tests or direct public-interface checks.

Quick Start

Ask Pi to refactor the folder named "services" into well-scoped subfolders with shared modules while keeping existing behavior identical and staying green on the most relevant tests.

Frequently Asked Questions about skill-folder-refactor

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

FAQPage Schema
How do I refactor a folder into subfolders without changing behavior?

Folder refactoring uses a move-only safety phase with narrow validation gates to restructure directories into subfolders and shared modules without changing behavior. It maps public contracts and re-runs focused tests after each slice to prevent regressions.

What is the safest way to extract shared code during a module boundary restructuring?

Shared code extraction is safest when proven by duplicate call sites and covered by tests or direct public-interface checks. The process extracts shared modules only after validation gates confirm the duplicate usage and maintain behavioral integrity.

How do I split a large directory into language-specific packages while keeping tests green?

Directory splits into language-specific packages require a move-only phase followed by controlled extraction, re-running narrow validation checkpoints after each step. This ensures tests remain green throughout the ongoing engineering workflow.

Can I use test-driven development to deduplicate code across module boundaries?

Test-driven development supports code deduplication across module boundaries by adding or reusing focused tests when needed. Validation gates confirm that extracted shared modules preserve existing behavior before completing the migration.

What are the limitations of autonomous folder refactoring?

Autonomous folder refactoring continues through safe slices until the target topology is complete or blocked by validation and risk. It requires an explicitly named folder and cannot proceed if narrow validation gates fail or public contracts break.

Does folder refactoring work with stateful continuation for large codebases?

Folder refactoring supports optional stateful continuation, treating the refactor as an active, multi-slice objective. It continues autonomously through remaining safe slices until the target topology is complete or blocked by validation and risk.