Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Project structure · More

Python package and CLI project structure

Opens with credits

A command line tool published to PyPI, laid out the way the Python Packaging User Guide and uv recommend: a src layout, one pyproject.toml for metadata and every tool, a thin Typer CLI over plain, testable modules, and releases uploaded by GitHub Actions with trusted publishing. The example is mdlinks, a tool that finds broken links in Markdown files. For students who have written Python scripts and want to ship one that strangers can pip install.

Curated by Tauseef FayyazIntermediate135 files and foldersPython 3.11 to 3.14 (3.15 tested as a pre-release), uv 0.12 with the uv_build backend, Typer 0.27Checked October 2026
Explore the filesPick any file to see what it is, why it exists and when you add it.

How it grows

Each stage opens the explorer there

  1. 1Day 1What the scaffold and your first hour give you14 files and folders
  2. 2GrowingWhat a real app with features and tests adds+58 files and folders
  3. ProductionWhat running it for real users adds+26 files and foldersOpens with credits
  4. ExpertWhat a team needs to keep it healthy for years+37 files and foldersOpens with credits

How it is organised

  • Use the src layout: code lives in `src/mdlinks/`, so tests run against the installed package and catch files missing from the wheel.
  • One pyproject.toml holds the package metadata, dependencies and the settings for pytest, Ruff, mypy and coverage. One file to read when CI and your laptop disagree.
  • The CLI is a thin shell: it parses flags, calls plain functions, prints results and picks an exit code. The logic never prints, never calls `sys.exit()` and is usable from Python code.
  • Decide your public API on purpose: the names in `__all__` are a promise, everything else (and every module starting with `_`) can change freely.
  • Exit codes and machine-readable output (`--format json`) are part of your contract with scripts and CI. Change them only in a major release.
  • Runtime dependencies are few and loosely pinned (`>=`), because users install your package next to theirs. Exact pins belong in uv.lock, which is for your development and CI only.
  • Test in layers: many fast unit tests, CLI tests through CliRunner, and one end to end test that installs the built wheel. Property, snapshot and benchmark tests come when the tool has users.
  • Release from CI only, with trusted publishing: no PyPI token on any laptop, and every file on PyPI traceable to the workflow run that built it.

At the top of the project

Open one in the explorer for the full story

Learn more on Sefism

Roadmaps, cheat sheets and projects that go with Python package and CLI.

See 10 more
Checked against 19 official sources, October 2026. If something has changed, the docs win.Show sources

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com