Langsung ke konten
Skillpedia
Pemrograman umum8.0k Β· #12685

modern-python

Fungsinya

Memandu cara menyiapkan proyek atau skrip Python dengan alat terkini untuk paket, linting, format, dan pemeriksaan tipe. Skill ini untuk developer yang memulai pekerjaan Python baru atau berpindah dari alat lama.

Kapan dipakai

  • βœ“Saat developer membuat proyek atau paket Python baru.
  • βœ“Saat developer ingin beralih dari pip, Poetry, mypy, atau black ke alat modern.
  • βœ“Saat developer menulis skrip Python mandiri yang membutuhkan paket luar.

Link skill

https://github.com/trailofbits/skills/blob/main/plugins/modern-python/skills/modern-python/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/trailofbits/skills/blob/main/plugins/modern-python/skills/modern-python/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œSiapkan proyek Python baru untuk saya dengan alat modern.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini menyiapkan file proyek dengan uv untuk paket, ruff untuk linting dan format, dan ty untuk pemeriksaan tipe. Skill ini juga menunjukkan kebiasaan lama yang sebaiknya dihindari.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Modern Python

Guide for modern Python tooling and best practices, based on trailofbits/cookiecutter-python.

When to Use This Skill

  • Creating a new Python project or package
  • Setting up pyproject.toml configuration
  • Configuring development tools (linting, formatting, testing)
  • Writing Python scripts with external dependencies
  • Migrating from legacy tools (when user requests it)

When NOT to Use This Skill

  • User wants to keep legacy tooling: Respect existing workflows if explicitly requested
  • Python < 3.11 required: These tools target modern Python
  • Non-Python projects: Mixed codebases where Python isn't primary

Anti-Patterns to Avoid

Avoid Use Instead
[tool.ty] python-version [tool.ty.environment] python-version
uv pip install uv add and uv sync
Editing pyproject.toml manually to add deps uv add <pkg> / uv remove <pkg>
hatchling build backend uv_build (simpler, sufficient for most cases)
Poetry uv (faster, simpler, better ecosystem integration)
requirements.txt PEP 723 for scripts, pyproject.toml for projects
mypy / pyright ty (faster, from Astral team)
[project.optional-dependencies] for dev tools [dependency-groups] (PEP 735)
Manual virtualenv activation (source .venv/bin/activate) uv run <cmd>
pre-commit prek (faster, no Python runtime needed)

Key principles:

  • Always use uv add and uv remove to manage dependencies
  • Never manually activate or manage virtual environmentsβ€”use uv run for all commands
  • Use [dependency-groups] for dev/test/docs dependencies, not [project.optional-dependencies]

Decision Tree

What are you doing?
β”‚
β”œβ”€ Single-file script with dependencies?
β”‚   └─ Use PEP 723 inline metadata (./references/pep723-scripts.md)
β”‚
β”œβ”€ New multi-file project (not distributed)?
β”‚   └─ Minimal uv setup (see Quick Start below)
β”‚
β”œβ”€ New reusable package/library?
β”‚   └─ Full project setup (see Full Setup below)
β”‚
└─ Migrating existing project?
    └─ See 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, pydocstyle
ty Type checking mypy, pyright (faster alternative)
pytest Testing with coverage unittest
prek Pre-commit hooks (setup) pre-commit (faster, Rust-native)

Security Tools

Tool Purpose When It Runs
shellcheck Shell script linting pre-commit
detect-secrets Secret detection pre-commit
actionlint Workflow syntax validation pre-commit, CI
zizmor Workflow security audit pre-commit, CI
pip-audit Dependency vulnerability scanning CI, manual
Dependabot Automated dependency updates scheduled

See security-setup.md for configuration and usage.

Quick Start: Minimal Project

For simple multi-file projects not intended for distribution:

# Create project with uv
uv init myproject
cd myproject

# Add dependencies
uv add requests rich

# Add dev dependencies
uv add --group dev pytest ruff ty

# Run code
uv run python src/myproject/main.py

# Run tools
uv run pytest
uv run ruff check .

Full Project Setup

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.

uvx cookiecutter gh:trailofbits/cookiecutter-python

1. Create Project Structure

uv init --package myproject
cd myproject

This creates:

myproject/
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ README.md
β”œβ”€β”€ src/
β”‚   └── myproject/
β”‚       └── __init__.py
└── .python-version

2. Configure pyproject.toml

See pyproject.md for complete configuration reference.

Key sections:

[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 =
Pertanyaan umum

Apakah proyek lama saya akan dipindahkan ke alat baru?

Hanya jika Anda memintanya. Skill ini menyatakan untuk menghormati alur kerja yang ada jika Anda ingin tetap memakai alat lama.

Apakah skill ini mendukung versi Python yang lama?

Skill ini menargetkan Python modern, jadi tidak ditujukan untuk versi yang lebih lama dari 3.11.

Bagaimana dengan skrip?

Untuk skrip mandiri, skill ini memakai catatan dependensi inline PEP 723 sebagai pengganti file requirements.

Detail

Deskripsi asli dari pembuat

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

repo: trailofbits/skills

Popularitas

Bintang GitHub
8.0k
Peringkat
#12685
Lisensi
CC-BY-SA-4.0
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa