refactor-import-hygiene

Rewrite generic Python imports to namespace-qualified or aliased forms.

6|1|Updated Jan 5, 2026
Ready to run
npx skills add https://github.com/JordanGunn/skills --skill refactor-import-hygiene
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: refactor-import-hygiene
Source: https://github.com/JordanGunn/skills/tree/main/skills/refactor/import-hygiene
Command: npx skills add https://github.com/JordanGunn/skills --skill refactor-import-hygiene

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Audit Python imports to preserve semantic context and prevent shadowing after refactors. Prefer namespace-first imports over direct symbol imports for generic identifiers.

Core Features & Use Cases

  • Namespace-first imports: Keep imports qualified to preserve module context and readability.
  • Shadowing prevention: Minimize collisions with generic identifiers like Metadata, Config, and Payload.
  • Guided refactor assistance: Detect and propose changes from from X import Y to module-qualified usage or aliasing.

Quick Start

Run the hygiene checker to rewrite 'from X import Y' patterns to 'import X as alias' or to module-qualified usage and update callsites accordingly.

Frequently Asked Questions about refactor-import-hygiene

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

FAQPage Schema
How do I prevent namespace shadowing when refactoring Python imports?▼

Prevent namespace shadowing during Python import refactoring by detecting generic symbol imports and rewriting them to module-qualified usage or aliased imports. This preserves semantic context and stops identifier collisions across files.

Why does importing generic symbols like Config or Payload cause namespace leakage?▼

Importing generic symbols causes namespace leakage because direct imports strip module context, making identifiers like Config or Payload ambiguous. Rewriting to namespace-first imports or aliases maintains explicit module qualification and readability.

What is the best way to rewrite from X import Y statements to preserve module context?▼

The best way to rewrite from X import Y statements is replacing them with import X as alias or module-qualified usage, then updating callsites accordingly. This enforces import hygiene and keeps semantic context intact.

Can I audit my Python codebase for direct symbol imports that violate import hygiene rules?▼

Yes, you can audit a Python codebase for direct symbol imports by running the hygiene checker. It flags from X import Generic patterns and proposes compliant module-qualified or aliased alternatives to prevent shadowing.

When do I need to use module-qualified imports instead of direct symbol imports in Python?▼

Use module-qualified imports when refactoring Python codebases that involve generic identifiers like Metadata, Config, and Payload. This prevents shadowing and namespace leakage across files during structural code changes.