python-project-structure

Organizes Python projects with module architecture, public APIs, and directory layouts.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/scoots31/engineering-playbook --skill python-project-structure-scoots31
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-project-structure
Source: https://github.com/scoots31/engineering-playbook/tree/main/references/python-project-structure
Command: npx skills add https://github.com/scoots31/engineering-playbook --skill python-project-structure-scoots31

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases often grow into tangled files with unclear boundaries, making code hard to find, imports fragile, and changes unpredictable. This Skill provides concrete patterns for structuring projects so modules stay cohesive and public interfaces stay explicit. ## Core Features & Use Cases - Module Organization Patterns: Apply one-concept-per-file rules, flat directory structures, and layered or domain-driven architectures. - Explicit Public APIs: Define package interfaces with __all__ and clean __init__.py exports so consumers know exactly what is public. - Test Placement Strategies: Choose between colocated tests and parallel test directories with consistent conventions. - Use Case: When starting a new Python service, use this Skill to lay out src/, services/, models/, and tests/ directories with proper package initialization before writing any business logic. ## Quick Start Help me structure a new Python project with a clean module layout and explicit public APIs using all.

Frequently Asked Questions about python-project-structure

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

FAQPage Schema
How do I structure a Python project for a new application?

Use a src layout with your package containing subdirectories like services, models, and api, plus a top-level tests directory and pyproject.toml. Keep the structure flat and add nesting only for genuine sub-domains.

How do I define a public API for a Python package?

Define __all__ in each module's __init__.py listing exactly which names are public. Import the public classes and functions there so consumers can import directly from the package root.

Should Python tests be colocated with source files or in a separate directory?

Both approaches work; colocated tests make coverage gaps visible, while a parallel tests directory cleanly separates production and test code. Pick one convention and apply it consistently across the project.

Should I use relative or absolute imports in Python packages?

Use absolute imports like 'from myproject.services import UserService' for clarity and reliability. Relative imports can break when modules are moved or reorganized during refactoring.

When should I split a Python file into multiple modules?

Split when a file handles multiple unrelated responsibilities, grows beyond roughly 300-500 lines, or contains classes that change for different reasons. Each file should focus on a single concept.

When is a deep directory hierarchy appropriate in Python projects?

Deep nesting is rarely appropriate; prefer flat structures since deep hierarchies make imports verbose and navigation difficult. Add sub-packages only when a genuine sub-domain requires isolation.