/byteforge-claude-skills:python-lib-setupfrom byteforge-claude-skills
Set up Python project for PyPI publishing or private GitHub distribution with pyproject.toml, src layout, and optional build scripts. Use when creating a new Python package, setting up for PyPI distribution, initializing a Python library project, or setting up a private library distributed via GitHub.
Ships in byteforge-claude-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill helps you set up a Python project for PyPI publishing following modern best practices with pyproject.toml, src layout, and standardized build/publish scripts.
Use this skill when:
pyproject.toml - Modern Python project configurationsrc/{package_name}/ - Source layout with package structure.gitignore - Comprehensive Python gitignorerequirements.txt - Development dependencies (includes build/twine for PyPI only)build-publish.sh - Automated build and publish script (PyPI only)LICENSE - License file (Proprietary, MIT, or O'Saasy)README.md - Basic project documentationtests/ - Test directory with a starter smoke test (pytest is scoped to it via pyproject.toml)IMPORTANT: Before creating files, ask the user these questions:
"What is your project name?" (e.g., "pg-podcast-toolkit", "mypackage")
{project-name} (with hyphens, e.g., pg-podcast-toolkit){package_name} (with underscores, e.g., pg_podcast_toolkit)src/{package_name}/"What is the project description?" (brief one-line description for PyPI)
"What is your name?" (for author field)
"What is your email?" (for author field — only ask this if the answer to question 6 is GitHub private. PyPI metadata and public GitHub repos are publicly browsable, so embedding the author email there exposes it to scrapers. For those, omit the email entirely; capture name only.)
"What is your GitHub username?" (for project URLs)
"How will this package be distributed?" (one of three; this drives both the tooling AND whether the author email is embedded)
authors and README (PyPI metadata is public).git+https:// URL. No PyPI artifacts. Email omitted from authors and README (repo is publicly browsable).git+https://${CR_PAT}@... URL. No PyPI artifacts. Email included (only readers with repo access see it)."What license do you want to use?" (options: Proprietary, MIT, O'Saasy)
"What Python version should be the minimum requirement?" (default: 3.13)
"What are your initial dependencies?" (optional - comma-separated list, can be empty)
pyproject.toml (see "Check dependency Python requirements" below)."What keywords describe your project?" (optional - for PyPI searchability)
The minimum from question 8 must be at least as high as what every initial dependency requires, or the library won't install. Also check that the Python that will create the venv meets the minimum (python3 --version).
For each dependency, find its requires-python:
curl -fsS https://pypi.org/pypi/{dependency}/json | jq -r .info.requires_python. This shows the latest release, so if the dependency is pinned to an older version, check that version instead: https://pypi.org/pypi/{dependency}/{version}/json.requires-python in that repo's pyproject.toml.If a dependency needs a newer Python than the chosen minimum, tell the user which one and what it requires, then ask whether to raise the minimum before continuing. If you can't determine a dependency's requirement, say so rather than assuming it is compatible.
Create these directories if they don't exist:
{project_root}/
├── src/
│ └── {package_name}/
├── tests/
└── (other files at root)
Create pyproject.toml with the following structure, substituting project-specific values:
[project]
name = "{project-name}"
version = "0.0.1"
authors = [
{ name="{author_name}", email="{author_email}" }, # GitHub PRIVATE only — see note below
]
description = "{project_description}"
keywords = [{keywords_list}]
readme = "README.md"
requires-python = ">={python_version}"
license = {text = "{license_text}"}
classifiers = [
"Programming Language :: Python :: 3",
"{license_classifier}",
"Operating System :: OS Independent",
]
# CRITICAL — private git deps MUST use TOKEN-FREE URLs here. Never embed
# {env:CR_PAT} in this list: hatchling expands it at wheel build time and
# bakes the live PAT into the wheel's .dist-info/METADATA Requires-Dist,
# leaking a valid credential into every published image. Auth belongs at
# install time (see the Installation section below + uv-supply-chain-hardening).
dependencies = [
{dependencies_list}
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
# Required if ANY dependency is a direct URL reference (e.g., a private
# GitHub repo via `pkg @ git+https://...`). Without this, hatchling refuses
# to build the package: `ValueError: Dependency #N cannot be a direct
# reference unless field tool.hatch.metadata.allow-direct-references is
# set to true`. Harmless when no direct-ref deps are present, so it's
# enabled unconditionally in this template.
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["src/{package_name}"]
[tool.pytest.ini_options]
# REQUIRED. The venv lives at the project root (bin/, lib/, include/), so an
# unconstrained `pytest` collects the venv's own site-packages tests (e.g.
# mypy's vendored mypyc tests) and dies on third-party collection errors
# before running a single project test. Restrict collection to our tests.
testpaths = ["tests"]
[project.urls]
Homepage = "https://github.com/{github_username}/{project-name}"
Issues = "https://github.com/{github_username}/{project-name}/issues"
CRITICAL Substitutions:
{project-name} → project name with hyphens (e.g., pg-podcast-toolkit){package_name} → package name with underscores (e.g., pg_podcast_toolkit){author_name} → author's name{author_email} → author's email — only when distribution is GitHub private. For PyPI and GitHub public, drop the , email="..." half and write the entry as { name="{author_name}" } (PEP 621 allows the email field to be omitted; it must not be left blank or set to a placeholder, just omit the key).{project_description} → one-line description{keywords_list} → comma-separated quoted keywords (e.g., "podcasting", "rss", "parser") or empty{python_version} → minimum Python version (e.g., 3.13){license_name} → license name for the README (e.g., MIT, O'Saasy, Proprietary - All Rights Reserved){license_text} → license text for pyproject.toml, exactly as listed under "License Text Handling" below{license_classifier} → Full classifier string:
License :: OSI Approved :: MIT LicenseLicense :: Other/Proprietary LicenseLicense :: Other/Proprietary License{dependencies_list} → comma-separated quoted dependencies (e.g., 'requests', 'beautifulsoup4') or empty{github_username} → GitHub usernameLicense Classifiers Mapping:
Other/Proprietary LicenseMIT LicenseOther/Proprietary License (modified MIT with SaaS restrictions)License Text Handling:
{license_text} is Proprietary - All Rights Reserved{license_text} is MIT License{license_text} is O'Saasy License, and create LICENSE file from https://osaasy.dev/CRITICAL ordering — the virtual environment MUST be created before this
.gitignore is written. Since Python 3.13, python3 -m venv <path> writes a
.gitignore containing just * into the venv root. This skill's convention
puts the venv at the project root (python3 -m venv . — see Step 6's
build-publish.sh and the README's Development / Setup section), so if
.gitignore is written first and python3 -m venv . runs after, the
project's .gitignore gets clobbered with *. git init && git add . then
silently ignores every file in the package.
Correct order:
python3 -m venv . (create the venv at the project root; produces a
throwaway .gitignore with * inside).gitignore below — this overwrites the venv-generated one
with the comprehensive pattern set, which itself already ignores the venv
directory contents.Create .gitignore with comprehensive Python patterns:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
# No trailing slash: Linux venvs can make lib64 a symlink to lib.
lib64
# uv writes this transient lock into the venv root (= project root here).
/.lock
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
Pipfile.lock
# PEP 582
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
bin/
include/
pyvenv.cfg
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store
Create requirements.txt with development dependencies. A library's runtime dependencies live in pyproject.toml's dependencies list, so requirements.txt here holds only the dev/build toolchain — the same filename python-project-scaffold uses, installed with pip install --upgrade -r requirements.txt.
Use python3 -m venv . (not python) to create the venv: no venv is active yet, and bare python does not exist on stock macOS.
If distribution is PyPI:
build
twine
pytest
black
mypy
If distribution is GitHub:
pytest
black
mypy
These are the tools needed to develop (and for PyPI, build/publish) the package. Add other dev tools as needed (isort, pytest-cov, etc.).
If distribution is GitHub, skip this step entirely.
If distribution is PyPI, create build-publish.sh with venv activation and build/publish commands:
#!/bin/bash
# Build and publish package to PyPI
# Activates virtual environment before running
# Activate virtual environment
source bin/activate
# Clean previous builds
rm -rf dist/*
# Build package
python -m build
# Upload to PyPI
python -m twine upload dist/*
Note: This script follows the convention that the virtual environment is in bin/ at the project root.
Create the basic package structure:
src/{package_name}/__init__.py - Package initialization file:
"""
{project_description}
"""
__version__ = "0.0.1"
If this is a library package, you can add:
# Export main classes/functions here for easier imports
# from .module import ClassName, function_name
# __all__ = ['ClassName', 'function_name']
tests/test_package.py - Starter smoke test, so pytest has something to collect (an empty tests/ exits with code 5, "no tests ran"):
import {package_name}
def test_package_imports() -> None:
assert {package_name}.__version__
Create the appropriate LICENSE file based on the user's license choice:
MIT License
Copyright (c) {year} {author_name}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Download the license text from https://osaasy.dev/ and replace <Year> and <Copyright Holder> with appropriate values:
O'Saasy License
Copyright (c) {year} {author_name}
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to
the following conditions:
1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2. The licensee may not use the Software to directly compete with the original
Licensor by offering it to third parties as a hosted, managed, or
Software-as-a-Service (SaaS) product or cloud service.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Proprietary License
Copyright (c) {year} {author_name}. All rights reserved.
This software and associated documentation files (the "Software") are proprietary
and confidential. Unauthorized copying, modification, distribution, or use of
this Software, via any medium, is strictly prohibited.
The Software is provided for use only by authorized licensees under the terms
of a separate written agreement with the copyright holder.
Create README.md with basic project documentation. The Installation and Development sections vary by distribution type.
If distribution is PyPI:
# {project-name}
{project_description}
## Installation
```bash
pip install {project-name}
import {package_name}
# Add usage examples here
Note (Python 3.13+):
python3 -m venv .writes a.gitignorewith*into the venv root, which is the project root under this convention — so re-creating the venv here overwrites this project's.gitignore. On first setup that's fine (the repo's real.gitignorehasn't been created yet). If you re-create the venv later, restore the tracked file immediately:git checkout .gitignore.
# Create virtual environment
python3 -m venv .
# Activate virtual environment
source bin/activate # On Windows: Scripts\activate
# Install dependencies
pip install --upgrade -r requirements.txt
pip install -e .
# Run tests
pytest
# Make sure you have PyPI credentials configured
# Build and publish to PyPI
./build-publish.sh
{license_name}
{author_name}
> The Author line above is `{author_name}` only — PyPI READMEs render publicly on
> pypi.org, so the email is intentionally omitted. (Same rule as the `pyproject.toml`
> `authors` block in Step 3.)
**If distribution is GitHub:**
```markdown
# {project-name}
{project_description}
## Installation
### Public repo
```bash
pip install git+https://github.com/{github_username}/{project-name}.git
CR_PAT environment variable)pip install git+https://${CR_PAT}@github.com/{github_username}/{project-name}.git
dependencies = [
# TOKEN-FREE URL — never embed {env:CR_PAT} here. hatchling expands it at
# wheel build time and bakes the live PAT into .dist-info/METADATA
# Requires-Dist, leaking a credential into every published image.
# Auth is supplied at install time (see below).
"{project-name} @ git+https://github.com/{github_username}/{project-name}.git",
]
Auth for private repos declared this way is supplied at INSTALL time — either
by a ${CR_PAT} line in the consuming app's requirements.txt (safe there;
requirements files are never packaged), or by git url.insteadOf config:
export GIT_CONFIG_COUNT=1 \
GIT_CONFIG_KEY_0="url.https://${CR_PAT}@github.com/.insteadOf" \
GIT_CONFIG_VALUE_0="https://github.com/"
The uv-supply-chain-hardening skill wires this end-to-end for a Docker build.
Token inline is safe here — requirements files are never packaged into wheels:
{project-name} @ git+https://${CR_PAT}@github.com/{github_username}/{project-name}.git
import {package_name}
# Add usage examples here
Note (Python 3.13+):
python3 -m venv .writes a.gitignorewith*into the venv root, which is the project root under this convention — so re-creating the venv here overwrites this project's.gitignore. On first setup that's fine (the repo's real.gitignorehasn't been created yet). If you re-create the venv later, restore the tracked file immediately:git checkout .gitignore.
# Create virtual environment
python3 -m venv .
# Activate virtual environment
source bin/activate # On Windows: Scripts\activate
# Install dependencies
pip install --upgrade -r requirements.txt
pip install -e .
# Run tests
pytest
Private git deps: install-time auth. If
pyproject.tomldeclares any private git dep via a token-free URL (per the pattern above),pip install -e .will fail auth on a fresh clone with no credentials in scope. Export the gitinsteadOfconfig in the shell first so pip'sgit clonepicks up your PAT:export GIT_CONFIG_COUNT=1 \ GIT_CONFIG_KEY_0="url.https://${CR_PAT}@github.com/.insteadOf" \ GIT_CONFIG_VALUE_0="https://github.com/"Add this to
~/.zshrc/~/.bashrcalongsideexport CR_PAT=...so every shell has it. Persist it globally withgit config --globalif you prefer.
{license_name}
{author_name} ({author_email})
> **Author line rule for the GitHub template above:**
> - **GitHub private** → keep as shown: `{author_name} ({author_email})`.
> - **GitHub public** → drop the email parens; write `{author_name}` only. Public
> GitHub READMEs are scraped, and the email was never collected in this branch
> anyway (see Step 1, question 4).
## Step 10: Make Script Executable (PyPI only)
**If distribution is GitHub, skip this step.**
**If distribution is PyPI**, run:
```bash
chmod +x build-publish.sh
If not already a git repository:
git init
git status --short
Do not commit without asking. Show the user what git status --short lists and ask whether to make the initial commit. Only if they approve:
git add .
git commit -m "Initial project structure"
Inform the user of the next steps.
If distribution is PyPI:
Install development dependencies:
source bin/activate
pip install --upgrade -r requirements.txt
Install package in development mode:
pip install -e .
Write your code in src/{package_name}/
Update version in pyproject.toml before publishing
Configure PyPI credentials (one-time setup):
# Create ~/.pypirc with your PyPI token
Build and publish:
./build-publish.sh
If distribution is GitHub:
Install development dependencies:
source bin/activate
pip install --upgrade -r requirements.txt
Install package in development mode:
pip install -e .
Write your code in src/{package_name}/
Update version in pyproject.toml before each release
Referencing this library from other projects:
pyproject.toml — always TOKEN-FREE, public or private. {env:CR_PAT}
inside a pyproject.toml gets baked into the wheel's Requires-Dist metadata
at build time (hatchling expansion), leaking a live PAT into every image built
from that consuming package. Auth is supplied at install time:
dependencies = [
"{project-name} @ git+https://github.com/{github_username}/{project-name}.git",
]
requirements.txt — inline token is safe (requirements files are never
packaged):
{project-name} @ git+https://${CR_PAT}@github.com/{github_username}/{project-name}.git
pyproject.toml with a private git dep,
run the uv-supply-chain-hardening skill — it wires install-time auth via a
BuildKit secret + git insteadOf, so the token never enters any committed file.This pattern follows these principles:
src/ directory for better separationbin/ at project rootUser: "Set up a Python package for PyPI" Claude: "What is your project name?" User: "awesome-lib" Claude: [Asks remaining questions, user selects PyPI for distribution] Claude:
User: "Set up a private Python library" Claude: "What is your project name?" User: "arcana-models" Claude: [Asks remaining questions, user selects GitHub for distribution] Claude:
If you find a bug or stale instruction while using this skill:
byteforge-skills-maintainer-agent is available,
file a ticket with that agent. Use discover_agents to find its project ID.Include the skill name, plugin version if known, the instruction followed, expected and actual results, relevant errors/runtime versions, and any fix or workaround that worked. Omit credentials and private data.
Address the user's immediate problem first; report the skill defect afterward.
What SKILL.md sets; muted values are Claude Code's defaults
16 skills in this plugin
/aegis-nextjs-frontendThis skill should be used when the user asks to "create a new website", "spin up a frontend", "set up a Next.js site with aegis auth", "scaffold a new web app with authentication", "create a site with login and i18n", or needs a production-ready Next.js frontend integrated with ByteForge Aegis authentication. Provides complete project scaffolding with auth pages, internationalization, Docker deployment, and a design system./byteforge-loki-loggingConfigure Grafana Loki logging using byteforge-loki-logging library for Python/Flask applications. Use when setting up Loki logging, configuring centralized logging, or adding structured JSON logging to any Python project./npx claudepluginhub jmazzahacks/byteforge-claude-skills --plugin byteforge-skills