python-project-structure

Organize Python project layouts and define module public interfaces.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide a repeatable, opinionated approach to organizing Python projects so code is discoverable, public interfaces are explicit, and refactors are predictable.

Core Features & Use Cases

  • Explicit guidance for defining module public APIs and using all to separate public surfaces from internals.
  • Patterns for flat versus nested layouts, package initialization, layered architecture, and domain-driven organization.
  • Test placement strategies with trade-offs between colocated tests and parallel test directories; useful when starting a new library, reorganizing a legacy codebase, or preparing a package for publication.

Quick Start

Provide a recommended directory layout, init exports, import style, and test placement for a new Python package named myproject.

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 clear public API?

Structure a Python project by using an explicit directory layout and defining module public APIs with __all__ to separate public surfaces from internal implementations. This approach ensures code is discoverable and refactors remain predictable across libraries and applications.

What is the best way to organize tests in a Python package?

Organize tests in a Python package by choosing between colocated test directories alongside source modules or parallel test directories at the project root. Each test placement strategy offers distinct trade-offs for import styles and module architecture discoverability.

How do I use __init__.py to define explicit module exports?

Use __init__.py to define explicit module exports by leveraging the __all__ variable to list public interfaces, which cleanly separates the public API surface from internal package architecture and prevents unintended access to private modules.

When should I use a flat versus nested layout for Python project structure?

Use a flat layout for simple Python project structures to reduce import complexity, and choose a nested layout for layered architecture or domain-driven organization. Flat layouts suit small libraries, while nested layouts support complex package initialization workflows.

Can I get recommendations for refactoring legacy Python module architecture?

Yes, you can get concrete recommendations for refactoring legacy Python module architecture by evaluating current import styles, defining explicit public interfaces, and reorganizing directory structures without modifying the underlying source code.