repl-friendly-import-patching

Community

Fix Python imports in REPLs

Authortankygranny05
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill ensures that Python scripts can correctly import modules from parent or grandparent directories, even when run in interactive environments like PyCharm, IPython, or Jupyter notebooks where the __file__ variable might not be defined.

Core Features & Use Cases

  • Dynamic sys.path modification: Automatically adds project root directories to Python's import path.
  • REPL compatibility: Gracefully handles environments where __file__ is undefined, preventing import errors.
  • Use Case: You're developing a Python project with a structure like project_root/src/utils.py and project_root/scripts/my_script.py. This Skill allows my_script.py to import utils without manual path manipulation, whether run directly or in a Jupyter notebook.

Quick Start

Apply this Python code snippet at the beginning of your script to ensure imports from parent directories work correctly in any environment.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: repl-friendly-import-patching
Download link: https://github.com/tankygranny05/agent-box/archive/main.zip#repl-friendly-import-patching

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.