Claude-skill-registry backend-structure-organizer
Organizes a flat backend directory structure into a clean, modular architecture with proper Python packages and updated import paths. Transforms a flat backend structure into a modular, organized architecture following Python best practices.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/backend-structure-organizer" ~/.claude/skills/majiayu000-claude-skill-registry-backend-structure-organizer && rm -rf "$T"
manifest:
skills/data/backend-structure-organizer/SKILL.mdsource content
Backend Structure Organizer
Organizes a flat backend directory structure into a clean, modular architecture with proper Python packages and updated import paths.
When to Use This Skill
This skill should be used when:
- Backend files are organized in a flat structure and need to be organized into logical modules
- Python backend code requires refactoring to follow package best practices
- Import statements need to be updated to reflect a new directory structure
- Documentation needs to be updated to reflect a new backend organization
Prerequisites
- Backend directory exists with Python files in flat structure
- Project uses Python with import statements that may need updating
- Git repository is initialized (for tracking changes)
Process Overview
Phase 1: Analysis and Setup
- Scan backend directory to identify all Python files
- Identify current structure and file locations
- Generate report of files to be moved and updated
- Create new organized directory structure:
- AI/ML agents and processingagents/
- Authentication modulesauth/
- Chatkit integration componentschatkit/
- Data handling and storage utilitiesdata/
- Database operations and managementdatabase/
- Database models and schema definitionsmodels/
- Business logic and service layerservices/
- Utility functions and helpersutils/
- Utility scriptsscripts/
- Test filestests/
Phase 2: File Movement
- Move files to appropriate directories based on their purpose:
- Agent-related files →
agents/ - Authentication files →
auth/ - Data processing files →
data/ - Database files →
database/ - Model files →
models/ - Service files →
services/ - Utility files →
utils/ - Scripts →
scripts/ - Tests →
tests/
- Agent-related files →
Phase 3: Import Updates
- Update import statements in all affected Python files to reflect new locations
- Handle both absolute and relative import patterns
- Verify all imports resolve correctly after updates
Phase 4: Package Setup
- Create
files in each new directory__init__.py - Ensure proper Python package structure
- Verify import resolution throughout codebase
Phase 5: Documentation Update
- Update README.md to include structure documentation
- Update requirements.txt if needed
- Update any configuration files referencing old paths
Common Import Pattern Updates
Main Application File (main.py) updates:
→from database importfrom database.database import
→from models importfrom models.models import
→from agent importfrom agents.agent import
→from vector_store importfrom data.vector_store import
→from rate_limiting importfrom utils.rate_limiting import
→from session_service importfrom services.session_service import
Chatkit Components updates:
→from models importfrom models.models import
→from session_service importfrom services.session_service import
→from agent importfrom agents.agent import
→from vector_store importfrom data.vector_store import
→from embeddings importfrom data.embeddings import
Data Processing Files updates:
→from database importfrom database.database import
→from models importfrom models.models import
→from vector_store importfrom data.vector_store import
→from embeddings importfrom data.embeddings import
Success Criteria
- All files organized into logical directories
- All import statements updated and resolving correctly
files created in each directory__init__.py- Application functionality preserved
- Structure documented in README.md
Validation Steps
- Verify all imports resolve without errors
- Run application to ensure functionality preserved
- Check that new directory structure is logical and maintainable
- Confirm documentation reflects new structure
Rollback Plan
If issues occur:
- Restore from git backup before changes
- Revert file movements
- Revert import statement changes
- Remove newly created directories