Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问clear审计通过

pythonPython 开发

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

659

周安装

28

GitHub Stars

40

下载量

231
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:python(Python 开发)
来源仓库:https://github.com/knoopx/pi
仓库路径:skills/python
安装命令:
npx skills add https://github.com/knoopx/pi --skill python
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/knoopx/pi --skill python

简介

用于辅助 Python 项目开发、测试和依赖管理全流程。

  • 适合阅读代码、定位问题、整理命令或分析数据处理逻辑。
  • 可生成脚本、运行测试或调用外部 API,但需明确输入输出范围。
  • 涉及文件操作或数据库访问时,应先确认运行目录和环境隔离。
  • python 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Python

Modern Python development with type hints, testing, and code quality tools.

Contents

Project Setup

Structure

my-project/
├── pyproject.toml
├── src/my_project/
│   ├── __init__.py
│   ├── main.py
│   └── py.typed          # PEP 561 marker
├── tests/
│   ├── conftest.py
│   └── test_main.py
└── README.md

pyproject.toml

[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = ["requests>=2.31.0"]

[project.optional-dependencies]
ml = ["scikit-learn>=1.0.0"]

[dependency-groups]
dev = ["pytest>=7.0.0", "ruff>=0.1.0", "mypy>=1.0.0"]

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

[tool.ruff.lint]
select = ["E", "F", "W", "I"]

[tool.mypy]
python_version = "3.9"
strict = true

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v"

Code Quality

Formatting (ruff)

uv run ruff format .              # Format all
uv run ruff format --check .      # Check only

Linting (ruff)

uv run ruff check .               # Check issues
uv run ruff check . --fix         # Auto-fix

Type Checking (mypy)

uv run mypy src/                  # Check types
uv run mypy --strict src/         # Strict mode

Testing

Running Tests

uv run pytest                     # Run all
uv run pytest -v                  # Verbose
uv run pytest tests/test_main.py  # Specific file
uv run pytest -k "test_add"       # Pattern match
uv run pytest -x                  # Stop on first failure
uv run pytest --cov=src tests/    # With coverage

# Watch mode (use tmux for background, requires pytest-watch)
tmux new -d -s pytest 'uv run ptw'

Test Structure

import pytest
from my_project.utils import add, divide

class TestArithmetic:
    def test_add(self) -> None:
        assert add(2, 3) == 5

    def test_divide_by_zero(self) -> None:
        with pytest.raises(ValueError, match="Cannot divide by zero"):
            divide(10, 0)

    @pytest.mark.parametrize("a,b,expected", [
        (1, 1, 2),
        (10, 20, 30),
    ])
    def test_add_parametrized(self, a: int, b: int, expected: int) -> None:
        assert add(a, b) == expected

Fixtures

import pytest

@pytest.fixture
def db():
    db = Database(":memory:")
    db.init()
    yield db
    db.close()

def test_user_insert(db):
    db.insert("users", {"name": "Test"})
    assert db.count("users") == 1

Dataclasses

Prefer dataclasses over regular classes for data containers. Auto-generates __init__, __repr__, __eq__.

from dataclasses import dataclass, field

@dataclass
class User:
    id: int
    name: str
    email: str

@dataclass(frozen=True)  # Immutable, hashable
class Point:
    x: float
    y: float

@dataclass
class Config:
    name: str
    debug: bool = False                           # Simple default
    tags: list[str] = field(default_factory=list) # Mutable default
    area: float = field(init=False)               # Computed field

    def __post_init__(self) -> None:
        self.area = len(self.tags)

Decorator Options

OptionEffect
frozen=TrueImmutable, hashable (use for value objects)
slots=TrueMemory-efficient (Python 3.10+)
order=TrueEnable <, >, <=, >= comparisons

When to Use

✅ Dataclasses❌ Regular Classes
DTOs, configs, recordsComplex behavior/methods
API request/response modelsCustom __init__ logic
Immutable value objectsMutable state with invariants

Type Hints

Functions

from typing import Optional, List, Dict

def greet(name: str, formal: bool = False) -> str:
    return f"Good day, {name}!" if formal else f"Hello, {name}!"

def process(data: List[Dict[str, int]]) -> Optional[int]:
    return sum(d.get("value", 0) for d in data) or None

Classes

from dataclasses import dataclass
from typing import Generic, TypeVar

@dataclass
class User:
    id: int
    name: str
    email: str

T = TypeVar('T')

class Container(Generic[T]):
    def __init__(self, value: T) -> None:
        self.value = value

    def get(self) -> T:
        return self.value

Error Handling

from pathlib import Path
from typing import Optional

def read_file(path: Path) -> Optional[str]:
    try:
        return path.read_text()
    except FileNotFoundError:
        return None
    except PermissionError as e:
        raise PermissionError(f"Cannot read {path}") from e

Best Practices

  1. Type hints: All function parameters and return values
  2. Docstrings: Document public APIs
  3. Test coverage: Comprehensive tests for business logic
  4. Fixtures: Organize test setup, not setup methods
  5. Parametrize: Use @pytest.mark.parametrize for multiple cases
  6. Strict mypy: Enable --strict in pyproject.toml
  7. Logging: Use logging module, not print()

Development Loop

# 1. Format
uv run ruff format .

# 2. Lint
uv run ruff check . --fix

# 3. Type check
uv run mypy src/

# 4. Test
uv run pytest -v

Related Skills

  • uv: Manage Python dependencies and environments

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.97%
按下载量换算65

OpenCode

23.16%
按下载量换算53

Codex

19.53%
按下载量换算45

Antigravity

11.61%
按下载量换算27

Gemini CLI

8.3%
按下载量换算19

windsurf

3.59%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills