{"slug":"modern-python-2","title":"modern-python","summary":"Configures Python projects with modern tooling (uv, ruff, ty). Use when creating projects, writing standalone scripts, or migrating from pip/Poetry/mypy/black.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-04T21:22:08.480921Z","repo":{"url":"https://github.com/mchawa/eidos","stars":18,"forks":3,"license":"MIT","updatedAt":"2026-12-04T21:04:14Z"},"bodyHtml":"<hr>\n<h2>name: modern-python\ndescription: Configures Python projects with modern tooling (uv, ruff, ty). Use when creating projects, writing standalone scripts, or migrating from pip/Poetry/mypy/black.</h2>\n<h1>Modern Python</h1>\n<p>Guide for modern Python tooling and best practices, based on <a href=\"https://github.com/trailofbits/cookiecutter-python\">trailofbits/cookiecutter-python</a>.</p>\n<h2>When to Use This Skill</h2>\n<ul>\n<li>Creating a new Python project or package</li>\n<li>Setting up <code>pyproject.toml</code> configuration</li>\n<li>Configuring development tools (linting, formatting, testing)</li>\n<li>Writing Python scripts with external dependencies</li>\n<li>Migrating from legacy tools (when user requests it)</li>\n</ul>\n<h2>When NOT to Use This Skill</h2>\n<ul>\n<li><strong>User wants to keep legacy tooling</strong>: Respect existing workflows if explicitly requested</li>\n<li><strong>Python &lt; 3.11 required</strong>: These tools target modern Python</li>\n<li><strong>Non-Python projects</strong>: Mixed codebases where Python isn't primary</li>\n</ul>\n<h2>Anti-Patterns to Avoid</h2>\n<table>\n<thead>\n<tr>\n<th>Avoid</th>\n<th>Use Instead</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>[tool.ty]</code> python-version</td>\n<td><code>[tool.ty.environment]</code> python-version</td>\n</tr>\n<tr>\n<td><code>uv pip install</code></td>\n<td><code>uv add</code> and <code>uv sync</code></td>\n</tr>\n<tr>\n<td>Editing pyproject.toml manually to add deps</td>\n<td><code>uv add &lt;pkg&gt;</code> / <code>uv remove &lt;pkg&gt;</code></td>\n</tr>\n<tr>\n<td><code>hatchling</code> build backend</td>\n<td><code>uv_build</code> (simpler, sufficient for most cases)</td>\n</tr>\n<tr>\n<td>Poetry</td>\n<td>uv (faster, simpler, better ecosystem integration)</td>\n</tr>\n<tr>\n<td>requirements.txt</td>\n<td>PEP 723 for scripts, pyproject.toml for projects</td>\n</tr>\n<tr>\n<td>mypy / pyright</td>\n<td>ty (faster, from Astral team)</td>\n</tr>\n<tr>\n<td><code>[project.optional-dependencies]</code> for dev tools</td>\n<td><code>[dependency-groups]</code> (PEP 735)</td>\n</tr>\n<tr>\n<td>Manual virtualenv activation (<code>source .venv/bin/activate</code>)</td>\n<td><code>uv run &lt;cmd&gt;</code></td>\n</tr>\n<tr>\n<td>pre-commit</td>\n<td>prek (faster, no Python runtime needed)</td>\n</tr>\n</tbody>\n</table>\n<p><strong>Key principles:</strong></p>\n<ul>\n<li>Always use <code>uv add</code> and <code>uv remove</code> to manage dependencies</li>\n<li>Never manually activate or manage virtual environments—use <code>uv run</code> for all commands</li>\n<li>Use <code>[dependency-groups]</code> for dev/test/docs dependencies, not <code>[project.optional-dependencies]</code></li>\n</ul>\n<h2>Decision Tree</h2>\n<pre><code>What are you doing?\n│\n├─ Single-file script with dependencies?\n│   └─ Use PEP 723 inline metadata (./references/pep723-scripts.md)\n│\n├─ New multi-file project (not distributed)?\n│   └─ Minimal uv setup (see Quick Start below)\n│\n├─ New reusable package/library?\n│   └─ Full project setup (see Full Setup below)\n│\n└─ Migrating existing project?\n    └─ See Migration Guide below\n</code></pre>\n<h2>Tool Overview</h2>\n<table>\n<thead>\n<tr>\n<th>Tool</th>\n<th>Purpose</th>\n<th>Replaces</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>uv</strong></td>\n<td>Package/dependency management</td>\n<td>pip, virtualenv, pip-tools, pipx, pyenv</td>\n</tr>\n<tr>\n<td><strong>ruff</strong></td>\n<td>Linting AND formatting</td>\n<td>flake8, black, isort, pyupgrade, pydocstyle</td>\n</tr>\n<tr>\n<td><strong>ty</strong></td>\n<td>Type checking</td>\n<td>mypy, pyright (faster alternative)</td>\n</tr>\n<tr>\n<td><strong>pytest</strong></td>\n<td>Testing with coverage</td>\n<td>unittest</td>\n</tr>\n<tr>\n<td><strong>prek</strong></td>\n<td>Pre-commit hooks (<a href=\"./references/prek.md\">setup</a>)</td>\n<td>pre-commit (faster, Rust-native)</td>\n</tr>\n</tbody>\n</table>\n<h3>Security Tools</h3>\n<table>\n<thead>\n<tr>\n<th>Tool</th>\n<th>Purpose</th>\n<th>When It Runs</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>shellcheck</strong></td>\n<td>Shell script linting</td>\n<td>pre-commit</td>\n</tr>\n<tr>\n<td><strong>detect-secrets</strong></td>\n<td>Secret detection</td>\n<td>pre-commit</td>\n</tr>\n<tr>\n<td><strong>actionlint</strong></td>\n<td>Workflow syntax validation</td>\n<td>pre-commit, CI</td>\n</tr>\n<tr>\n<td><strong>zizmor</strong></td>\n<td>Workflow security audit</td>\n<td>pre-commit, CI</td>\n</tr>\n<tr>\n<td><strong>pip-audit</strong></td>\n<td>Dependency vulnerability scanning</td>\n<td>CI, manual</td>\n</tr>\n<tr>\n<td><strong>Dependabot</strong></td>\n<td>Automated dependency updates</td>\n<td>scheduled</td>\n</tr>\n</tbody>\n</table>\n<p>See <a href=\"./references/security-setup.md\">security-setup.md</a> for configuration and usage.</p>\n<h2>Quick Start: Minimal Project</h2>\n<p>For simple multi-file projects not intended for distribution:</p>\n<pre><code># Create project with uv\nuv init myproject\ncd myproject\n\n# Add dependencies\nuv add requests rich\n\n# Add dev dependencies\nuv add --group dev pytest ruff ty\n\n# Run code\nuv run python src/myproject/main.py\n\n# Run tools\nuv run pytest\nuv run ruff check .\n</code></pre>\n<h2>Full Project Setup</h2>\n<p>If starting from scratch, ask the user if they prefer to use the Trail of Bits cookiecutter template to bootstrap a complete project with already preconfigured tooling.</p>\n<pre><code>uvx cookiecutter gh:trailofbits/cookiecutter-python\n</code></pre>\n<h3>1. Create Project Structure</h3>\n<pre><code>uv init --package myproject\ncd myproject\n</code></pre>\n<p>This creates:</p>\n<pre><code>myproject/\n├── pyproject.toml\n├── README.md\n├── src/\n│   └── myproject/\n│       └── __init__.py\n└── .python-version\n</code></pre>\n<h3>2. Configure pyproject.toml</h3>\n<p>See <a href=\"./references/pyproject.md\">pyproject.md</a> for complete configuration reference.</p>\n<p>Key sections:</p>\n<pre><code>[project]\nname = \"myproject\"\nversion = \"0.1.0\"\nrequires-python = \"&gt;=3.11\"\ndependencies = []\n\n[dependency-groups]\ndev = [{include-group = \"lint\"}, {include-group = \"test\"}, {include-group = \"audit\"}]\nlint = [\"ruff\", \"ty\"]\ntest = [\"pytest\", \"pytest-cov\"]\naudit = [\"pip-audit\"]\n\n[tool.ruff]\nline-length = 100\ntarget-version = \"py311\"\n\n[tool.ruff.lint]\nselect = [\"ALL\"]\nignore = [\"D\", \"COM812\", \"ISC001\"]\n\n[tool.pytest]\naddopts = [\"--cov=myproject\", \"--cov-fail-under=80\"]\n\n[tool.ty.terminal]\nerror-on-warning = true\n\n[tool.ty.environment]\npython-version = \"3.11\"\n\n[tool.ty.rules]\n# Strict from day 1 for new projects\npossibly-unresolved-reference = \"error\"\nunused-ignore-comment = \"warn\"\n</code></pre>\n<h3>3. Install Dependencies</h3>\n<pre><code># Install all dependency groups\nuv sync --all-groups\n\n# Or install specific groups\nuv sync --group dev\n</code></pre>\n<h3>4. Add Makefile</h3>\n<pre><code>.PHONY: dev lint format test build\n\ndev:\n\tuv sync --all-groups\n\nlint:\n\tuv run ruff format --check &amp;&amp; uv run ruff check &amp;&amp; uv run ty check src/\n\nformat:\n\tuv run ruff format .\n\ntest:\n\tuv run pytest\n\nbuild:\n\tuv build\n</code></pre>\n<h2>Migration Guide</h2>\n<p>When a user requests migration from legacy tooling:</p>\n<h3>From requirements.txt + pip</h3>\n<p>First, determine the nature of the code:</p>\n<p><strong>For standalone scripts</strong>: Convert to PEP 723 inline metadata (see <a href=\"./references/pep723-scripts.md\">pep723-scripts.md</a>)</p>\n<p><strong>For projects</strong>:</p>\n<pre><code># Initialize uv in existing project\nuv init --bare\n\n# Add dependencies using uv (not by editing pyproject.toml)\nuv add requests rich  # add each package\n\n# Or import from requirements.txt (review each package before adding)\n# Note: Complex version specifiers may need manual handling\ngrep -v '^#' requirements.txt | grep -v '^-' | grep -v '^\\s*$' | while read -r pkg; do\n    uv add \"$pkg\" || echo \"Failed to add: $pkg\"\ndone\n\nuv sync\n</code></pre>\n<p>Then:</p>\n<ol>\n<li>Delete <code>requirements.txt</code>, <code>requirements-dev.txt</code></li>\n<li>Delete virtual environment (<code>venv/</code>, <code>.venv/</code>)</li>\n<li>Add <code>uv.lock</code> to version control</li>\n</ol>\n<h3>From setup.py / setup.cfg</h3>\n<ol>\n<li>Run <code>uv init --bare</code> to create pyproject.toml</li>\n<li>Use <code>uv add</code> to add each dependency from <code>install_requires</code></li>\n<li>Use <code>uv add --group dev</code> for dev dependencies</li>\n<li>Copy non-dependency metadata (name, version, description, etc.) to <code>[project]</code></li>\n<li>Delete <code>setup.py</code>, <code>setup.cfg</code>, <code>MANIFEST.in</code></li>\n</ol>\n<h3>From flake8 + black + isort</h3>\n<ol>\n<li>Remove flake8, black, isort via <code>uv remove</code></li>\n<li>Delete <code>.flake8</code>, <code>pyproject.toml [tool.black]</code>, <code>[tool.isort]</code> configs</li>\n<li>Add ruff: <code>uv add --group dev ruff</code></li>\n<li>Add ruff configuration (see <a href=\"./references/ruff-config.md\">ruff-config.md</a>)</li>\n<li>Run <code>uv run ruff check --fix .</code> to apply fixes</li>\n<li>Run <code>uv run ruff format .</code> to format</li>\n</ol>\n<h3>From mypy / pyright</h3>\n<ol>\n<li>Remove mypy/pyright via <code>uv remove</code></li>\n<li>Delete <code>mypy.ini</code>, <code>pyrightconfig.json</code>, or <code>[tool.mypy]</code>/<code>[tool.pyright]</code> sections</li>\n<li>Add ty: <code>uv add --group dev ty</code></li>\n<li>Run <code>uv run ty check src/</code></li>\n</ol>\n<h2>Quick Reference: uv Commands</h2>\n<table>\n<thead>\n<tr>\n<th>Command</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>uv init</code></td>\n<td>Create new project</td>\n</tr>\n<tr>\n<td><code>uv init --package</code></td>\n<td>Create distributable package</td>\n</tr>\n<tr>\n<td><code>uv add &lt;pkg&gt;</code></td>\n<td>Add dependency</td>\n</tr>\n<tr>\n<td><code>uv add --group dev &lt;pkg&gt;</code></td>\n<td>Add to dependency group</td>\n</tr>\n<tr>\n<td><code>uv remove &lt;pkg&gt;</code></td>\n<td>Remove dependency</td>\n</tr>\n<tr>\n<td><code>uv sync</code></td>\n<td>Install dependencies</td>\n</tr>\n<tr>\n<td><code>uv sync --all-groups</code></td>\n<td>Install all dependency groups</td>\n</tr>\n<tr>\n<td><code>uv run &lt;cmd&gt;</code></td>\n<td>Run command in venv</td>\n</tr>\n<tr>\n<td><code>uv run --with &lt;pkg&gt; &lt;cmd&gt;</code></td>\n<td>Run with temporary dependency</td>\n</tr>\n<tr>\n<td><code>uv build</code></td>\n<td>Build package</td>\n</tr>\n<tr>\n<td><code>uv publish</code></td>\n<td>Publish to PyPI</td>\n</tr>\n</tbody>\n</table>\n<h3>Ad-hoc Dependencies with <code>--with</code></h3>\n<p>Use <code>uv run --with</code> for one-off commands that need packages not in your project:</p>\n<pre><code># Run Python with a temporary package\nuv run --with requests python -c \"import requests; print(requests.get('https://httpbin.org/ip').json())\"\n\n# Run a module with temporary deps\nuv run --with rich python -m rich.progress\n\n# Multiple packages\nuv run --with requests --with rich python script.py\n\n# Combine with project deps (adds to existing venv)\nuv run --with httpx pytest  # project deps + httpx\n</code></pre>\n<p><strong>When to use <code>--with</code> vs <code>uv add</code>:</strong></p>\n<ul>\n<li><code>uv add</code>: Package is a project dependency (goes in pyproject.toml/uv.lock)</li>\n<li><code>--with</code>: One-off usage, testing, or scripts outside a project context</li>\n</ul>\n<p>See <a href=\"./references/uv-commands.md\">uv-commands.md</a> for complete reference.</p>\n<h2>Quick Reference: Dependency Groups</h2>\n<pre><code>[dependency-groups]\ndev = [\"ruff\", \"ty\"]\ntest = [\"pytest\", \"pytest-cov\", \"hypothesis\"]\ndocs = [\"sphinx\", \"myst-parser\"]\n</code></pre>\n<p>Install with: <code>uv sync --group dev --group test</code></p>\n<h2>Best Practices Checklist</h2>\n<ul>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Use <code>src/</code> layout for packages</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Set <code>requires-python = \"&gt;=3.11\"</code></li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Configure ruff with <code>select = [\"ALL\"]</code> and explicit ignores</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Use ty for type checking</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Enforce test coverage minimum (80%+)</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Use dependency groups instead of extras for dev tools</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Add <code>uv.lock</code> to version control</li>\n<li><input disabled=\"disabled\" type=\"checkbox\"> Use PEP 723 for standalone scripts</li>\n</ul>\n<h2>Read Next</h2>\n<ul>\n<li><a href=\"./references/migration-checklist.md\">migration-checklist.md</a> - Step-by-step migration cleanup</li>\n<li><a href=\"./references/pyproject.md\">pyproject.md</a> - Complete pyproject.toml reference</li>\n<li><a href=\"./references/uv-commands.md\">uv-commands.md</a> - uv command reference</li>\n<li><a href=\"./references/ruff-config.md\">ruff-config.md</a> - Ruff linting/formatting configuration</li>\n<li><a href=\"./references/testing.md\">testing.md</a> - pytest and coverage setup</li>\n<li><a href=\"./references/pep723-scripts.md\">pep723-scripts.md</a> - PEP 723 inline script metadata</li>\n<li><a href=\"./references/prek.md\">prek.md</a> - Fast pre-commit hooks with prek</li>\n<li><a href=\"./references/security-setup.md\">security-setup.md</a> - Security hooks and dependency scanning</li>\n<li><a href=\"./references/dependabot.md\">dependabot.md</a> - Automated dependency updates</li>\n</ul>\n","files":[{"path":"agents/openai.yaml","sizeBytes":226,"isText":true},{"path":"assets/trail-of-bits-mark.svg","sizeBytes":3084,"isText":false},{"path":"references/dependabot.md","sizeBytes":1800,"isText":true},{"path":"references/migration-checklist.md","sizeBytes":3071,"isText":true},{"path":"references/pep723-scripts.md","sizeBytes":5134,"isText":true},{"path":"references/prek.md","sizeBytes":5951,"isText":true},{"path":"references/pyproject.md","sizeBytes":5694,"isText":true},{"path":"references/ruff-config.md","sizeBytes":5476,"isText":true},{"path":"references/security-setup.md","sizeBytes":6504,"isText":true},{"path":"references/testing.md","sizeBytes":5214,"isText":true},{"path":"references/uv-commands.md","sizeBytes":4653,"isText":true},{"path":"SKILL.md","sizeBytes":10015,"isText":true},{"path":"templates/dependabot.yml","sizeBytes":958,"isText":true},{"path":"templates/pre-commit-config.yaml","sizeBytes":2259,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-04T21:22:29.130069Z","sha256":"16C52743C7AE19FA532FD8717218D6D771B655412EB0279280CC1E798208CAC2","sizeBytes":25778},"review":null,"source":{"repositoryUrl":"https://github.com/mchawa/eidos","path":".agents/skills/modern-python","license":"MIT","commit":"2465e2d8750547810c402114d1c4e86cbd7ac495","subtreeSha":"0A0A72EBA5E289E0F4092175B1E0DB168E28B9010ED4B0F3EA38FF97E4BF6CC3","lastSyncedAt":"2026-12-04T21:22:07.437367Z"},"reviewedAt":"2026-12-04T21:22:36.208378Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/mchawa/eidos/tree/main/.agents/skills/modern-python"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install mchawa-eidos@llmmart"},{"target":"git","command":"git clone https://github.com/mchawa/eidos.git"}]}