python-project-structure

Organize Python projects with src/, tests/, pyproject.toml, and __all__-based public APIs.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python project organization, module architecture, and public API design. Use when setting up new projects, organizing modules, defining public interfaces with all, or planning directory layouts.

Core Features & Use Cases

  • Define explicit public APIs with all for every module.
  • Create flat, maintainable directory structures with clear module boundaries.
  • Plan project skeletons for new Python packages, tests, and packaging.

Quick Start

Create a new Python project skeleton with src/, tests/, pyproject.toml, and an initial init.py plus an all-based public API surface.

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 to enforce clear module boundaries?

Defining a public API in Python modules uses the __all__ list to explicitly declare which objects are public. This mechanism enforces clear module boundaries by restricting exported names, keeping internal implementation private while exposing a stable, maintainable interface.

What is the best way to organize tests and packaging files in a Python project?

The best way to organize tests and packaging files is to adopt a standard layout with a src/ directory for code, a tests/ directory for test placement, and pyproject.toml for packaging decisions. This separation ensures scalable, maintainable project architecture.

How do I define explicit public interfaces using __all__ in a Python package?

To define explicit public interfaces using __all__, assign a list of string names to __all__ in your module's __init__.py. This dictates exactly what gets imported when users use wildcard imports, enforcing explicit module boundaries and clean public APIs.

Can I use this approach to reorganize an existing Python codebase with deep hierarchies?

Yes, you can reorganize an existing Python codebase by flattening deep hierarchies into a maintainable directory structure. By establishing clear module boundaries and defining explicit public interfaces with __all__, you refactor for better module cohesion and scalable architecture.

When should I not use a flat directory structure for my Python project?

You should avoid a flat directory structure when your Python project lacks distinct module boundaries or requires complex nested namespaces. If module cohesion is low and defining a clear public API with __all__ is impossible, a different packaging approach may be needed.