refactor

Refactor Python code while preserving behavior within layered architectures.

1|Updated Mar 5, 2025
One-click install
npx skills add https://github.com/niksavis/burndown-chart --skill refactor-niksavis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/niksavis/burndown-chart/tree/main/.github/skills/refactor
Command: npx skills add https://github.com/niksavis/burndown-chart --skill refactor-niksavis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a structured and safe approach to refactoring existing code, ensuring that behavior is preserved while improving code quality and maintainability.

Core Features & Use Cases

  • Behavior Preservation: Focuses on structural improvements without altering the program's external behavior.
  • Layered Architecture Adherence: Guides refactoring to respect the defined architectural layers (callbacks/, data/, ui/, visualization/).
  • Safe Workflow: Employs a step-by-step process with validation gates to minimize risks.
  • Use Case: When a Python function becomes too long or complex, use this skill to extract parts of it into smaller, more manageable helper functions within the correct architectural layer.

Quick Start

Use the refactor skill to extract a method from the file 'example.py'.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I refactor Python code to fix large modules and duplication without breaking existing behavior?

Behavior-preserving refactoring improves code maintainability by applying structured extraction, splitting, and renaming techniques to large modules and duplicated code without altering the program's external behavior.

What is the best way to extract a helper function while maintaining a layered architecture?

To extract helper functions while maintaining layered architecture, follow a step-by-step workflow with validation gates that places extracted methods into the correct architectural layer to preserve structural rules and stability.

Can I use structured refactoring to enforce architectural rules in a Python project?

Yes, structured refactoring enforces architectural rules in Python projects by guiding code improvements to respect defined architectural layers and running validation checks like circular import smoke tests to ensure code quality.

How do I run circular import smoke tests after splitting a Python module?

Run circular import smoke tests after splitting a Python module by using the validation gates within the safe refactoring workflow to ensure newly extracted and split modules do not introduce circular dependencies.

What are the limitations of behavior-preserving refactoring for unclear naming?

The limitation of behavior-preserving refactoring for unclear naming is that it focuses strictly on structural improvements and architectural compliance, applying renaming techniques to improve maintainability without altering the underlying program logic.