Skip to content
Back to skills

Modern Python

ASecurity

Configures Python projects with modern tooling (uv, ruff, ty). Use when creating projects, writing standalone scripts, or migrating from pip/Poetry/mypy/black.

  • 4 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added June 4, 2026
testingpythonrustshellbashtestinggitbackendsecurity

Works with

  • terminal

Security analysis

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

Pro scans all 12 files and shows the line behind each finding

Scanned June 4, 2026

npx -y skills add lidge-jun/cli-jaw-skills --skill modern-python --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Modern Python?

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

Security grade badge for Modern Python
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lidge-jun-modern-python/badge)](https://www.skillsdirectory.com/skills/lidge-jun-modern-python)

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: modern-python
description: Configures Python projects with modern tooling (uv, ruff, ty). Use when creating projects, writing standalone scripts, or migrating from pip/Poetry/mypy/black.
---

# Modern Python

Ref: [trailofbits/cookiecutter-python](https://github.com/trailofbits/cookiecutter-python)

## Tool Choices

| Use | Instead of | Why |
|-----|-----------|-----|
| `uv add` / `uv sync` | `uv pip install`, manual pyproject.toml edits | Manages lockfile and venv automatically |
| `uv run <cmd>` | `source .venv/bin/activate` | No manual venv management |
| `uv_build` backend | `hatchling` | Simpler, sufficient for most cases |
| uv | Poetry | Faster, better ecosystem integration |
| pyproject.toml / PEP 723 | requirements.txt | Modern standard |
| ty | mypy / pyright | Faster, from Astral team |
| `[dependency-groups]` (PEP 735) | `[project.optional-dependencies]` | Dedicated dev/test grouping |
| `[tool.ty.environment]` python-version | `[tool.ty]` python-version | Correct config nesting |
| prek ([setup](./references/prek.md)) | pre-commit | Faster, Rust-native |

## Decision Tree

```
What are you doing?
│
├─ Single-file script with dependencies?
│   └─ PEP 723 inline metadata (./references/pep723-scripts.md)
│
├─ New multi-file project (not distributed)?
│   └─ Minimal uv setup (Quick Start below)
│
├─ New reusable package/library?
│   └─ Full project setup (Full Setup below)
│
└─ Migrating existing project?
    └─ Migration Guide below
```

## Tool Overview

| Tool | Purpose | Replaces |
|------|---------|----------|
| **uv** | Package/dependency management | pip, virtualenv, pip-tools, pipx, pyenv |
| **ruff** | Linting and formatting | flake8, black, isort, pyupgrade |
| **ty** | Type checking | mypy, pyright |
| **pytest** | Testing with coverage | unittest |
| **prek** | Pre-commit hooks | pre-commit |

### Security Tools

| Tool | Purpose |
|------|---------|
| **shellcheck** | Shell script linting |
| **detect-secrets** | Secret detection |
| **actionlint** | Workflow syntax validation |
| **zizmor** | Workflow security audit |
| **pip-audit** | Dependency vulnerability scanning |

See [security-setup.md](./references/security-setup.md) for configuration.

## Quick Start: Minimal Project

```bash
uv init myproject && cd myproject
uv add requests rich
uv add --group dev pytest ruff ty

uv run python src/myproject/main.py
uv run pytest
uv run ruff check .
```

## Full Project Setup

For distributable packages, consider the Trail of Bits cookiecutter:

```bash
uvx cookiecutter gh:trailofbits/cookiecutter-python
```

Or manually:

```bash
uv init --package myproject && cd myproject
```

### pyproject.toml Configuration

See [pyproject.md](./references/pyproject.md) for complete reference.

```toml
[project]
name = "myproject"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = []

[dependency-groups]
dev = [{include-group = "lint"}, {include-group = "test"}, {include-group = "audit"}]
lint = ["ruff", "ty"]
test = ["pytest", "pytest-cov"]
audit = ["pip-audit"]

[tool.ruff]
line-length = 100
target-version = "py311"

[tool.ruff.lint]
select = ["ALL"]
ignore = ["D", "COM812", "ISC001"]

[tool.pytest]
addopts = ["--cov=myproject", "--cov-fail-under=80"]

[tool.ty.terminal]
error-on-warning = true

[tool.ty.environment]
python-version = "3.11"

[tool.ty.rules]
possibly-unresolved-reference = "error"
unused-ignore-comment = "warn"
```

### Install and Verify

```bash
uv sync --all-groups
```

### Makefile

```makefile
.PHONY: dev lint format test build

dev:
uv sync --all-groups

lint:
uv run ruff format --check && uv run ruff check && uv run ty check src/

format:
uv run ruff format .

test:
uv run pytest

build:
uv build
```

## Migration Guide

### From requirements.txt + pip

**Scripts:** Convert to PEP 723 inline metadata ([pep723-scripts.md](./references/pep723-scripts.md))

**Projects:**
```bash
uv init --bare
uv add requests rich  # add each dependency
uv sync
```

Then delete `requirements.txt`, `requirements-dev.txt`, old venvs. Add `uv.lock` to version control.

### From setup.py / setup.cfg

1. `uv init --bare` to create pyproject.toml
2. `uv add` each dependency from `install_requires`
3. `uv add --group dev` for dev dependencies
4. Copy metadata (name, version, description) to `[project]`
5. Delete `setup.py`, `setup.cfg`, `MANIFEST.in`

### From flake8 + black + isort → ruff

1. Remove old tools, delete `.flake8`, `[tool.black]`, `[tool.isort]` configs
2. `uv add --group dev ruff`
3. Configure ruff ([ruff-config.md](./references/ruff-config.md))
4. `uv run ruff check --fix . && uv run ruff format .`

### From mypy / pyright → ty

1. Remove old tools, delete `mypy.ini`, `pyrightconfig.json`
2. `uv add --group dev ty`
3. `uv run ty check src/`

## uv Command Reference

| Command | Description |
|---------|-------------|
| `uv init` / `uv init --package` | Create project / distributable package |
| `uv add <pkg>` | Add dependency |
| `uv add --group dev <pkg>` | Add to dependency group |
| `uv remove <pkg>` | Remove dependency |
| `uv sync` / `uv sync --all-groups` | Install dependencies |
| `uv run <cmd>` | Run command in venv |
| `uv run --with <pkg> <cmd>` | Run with temporary dependency (one-off usage) |
| `uv build` / `uv publish` | Build / publish package |

## References

- [pyproject.md](./references/pyproject.md) — pyproject.toml reference
- [uv-commands.md](./references/uv-commands.md) — uv command reference
- [ruff-config.md](./references/ruff-config.md) — Ruff configuration
- [testing.md](./references/testing.md) — pytest and coverage
- [pep723-scripts.md](./references/pep723-scripts.md) — PEP 723 inline metadata
- [prek.md](./references/prek.md) — Pre-commit hooks
- [security-setup.md](./references/security-setup.md) — Security tools
- [dependabot.md](./references/dependabot.md) — Automated updates
- [migration-checklist.md](./references/migration-checklist.md) — Migration cleanup

Files in this skill

  • SKILL.md5.9 KB
  • references/dependabot.md1.8 KB
  • references/migration-checklist.md3 KB
  • references/pep723-scripts.md5 KB
  • references/prek.md5.8 KB
  • references/pyproject.md5.6 KB
  • references/ruff-config.md5.3 KB
  • references/security-setup.md6.4 KB
  • references/testing.md5.1 KB
  • references/uv-commands.md4.5 KB
  • templates/dependabot.yml958 B
  • templates/pre-commit-config.yaml2.2 KB

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.