Skip to content
Back to skills

Python Packaging

ASecurity

Package Python projects with pyproject.toml, build wheels, configure test and lint tools, and prepare index publishing.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 22, 2026
ai-agentspythonrustgobashfastapiflaskdockertestingapibackend

Works with

  • cursor
  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned October 22, 2026

npx -y skills add alivirgo/Major-AI-Skills --skill python-packaging --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Packaging?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Packaging
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alivirgo-python-packaging/badge)](https://www.skillsdirectory.com/skills/alivirgo-python-packaging)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: python-packaging
description: "Package Python projects with pyproject.toml, build wheels, configure test and lint tools, and prepare index publishing."
category: development
risk: safe
source: self
source_type: self
date_added: "2026-08-26"
tags: ["python", "packaging", "pyproject", "pytest", "wheels", "claude"]
tools: ["claude", "cursor", "gemini", "codex"]
---

# Python Packaging AI Skill Guide

## Overview & Engine Architecture

Modern Python projects declare metadata and tool config in `pyproject.toml`, prefer `src/` layouts to avoid accidental imports of the working tree, and isolate deps in virtualenvs or uv/poetry lockfiles. Agents build with `build`/`hatchling`, test with pytest, and never publish secrets or unpinned prod apps without a lock strategy.

```
pyproject.toml
   |
  build backend (hatchling/setuptools)
   |
  sdist + wheel
   |
pip/uv install -> site-packages
```

## When to use this skill

- Creating installable libraries or CLI packages
- Migrating from legacy `setup.py`-only projects
- Standardizing lint/test/type gates
- Preparing a release to PyPI or a private index

## Operational directives

1. Put package code under `src/<name>/` so tests import the installed package.
2. Declare dependencies in `[project]` / optional dependency groups - not ad-hoc README lists only.
3. Use a lockfile for applications (`uv.lock`, poetry.lock); libraries pin ranges carefully.
4. Keep version single-sourced (dynamic version or bump policy).
5. Run tests against the built wheel in CI for release tags.

## Minimal `pyproject.toml`

```toml
[project]
name = "inventory-kit"
version = "0.1.0"
description = "Inventory helpers"
readme = "README.md"
requires-python = ">=3.11"
dependencies = []

[project.optional-dependencies]
dev = ["pytest>=8", "ruff>=0.6", "mypy>=1.11"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ruff]
line-length = 100
```

## Commands

```bash
python -m venv .venv
# Windows: .venv\Scripts\activate
source .venv/bin/activate
pip install -e ".[dev]"
pytest -q
ruff check .
python -m build
```

## Common pitfalls

| Pitfall | Why it hurts | Fix |
| --- | --- | --- |
| Flat layout without src | Tests import wrong code | `src/` layout |
| No requires-python | Installs on unsupported runtimes | Declare floor |
| Publishing with secrets in package data | Credential leak | Audit package files |
| Only testing editable installs | Hidden packaging bugs | Test installed wheel |

## Best practices

- Add a console script via `[project.scripts]` for CLIs.
- Use tox/nox or CI matrix for multiple Python versions when supporting a library.
- Prefer trusted publishing / API tokens over long-lived passwords for PyPI.
- Document supported platforms and optional extras clearly.

## Limitations

- Native extensions (Rust/C) need maturin/cibuildwheel beyond pure Python.
- Monorepo tooling (pants, bazel) may supersede simple pyproject flows.
- Namespace packages and plugin discovery have extra packaging rules.

## Related skills

- `@fastapi` / `@flask` - app frameworks that still need packaging discipline
- `@rust-cli` - alternative for shipping native CLIs
- `@docker` - app distribution when wheels are not the unit of deploy

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.