AgentSkillsCN

python-starter

在初始化Python项目时,自动配置格式化工具与linter设置。默认安装ruff,并通过pyproject.toml进行配置。自动检测或询问用户关于venv/poetry/uv等虚拟环境,并作为开发依赖项一并安装。还可选择性配置pre-commit与ty。当用户使用VSCode时,会智能推荐相应的VSCode工作区设置。适用于Python项目的启动场景(如“启动Python项目”“创建FastAPI项目”“创建数据分析Python项目”等)。

SKILL.md
--- frontmatter
name: python-starter
description: Automatically configures formatter and linter settings when initializing Python projects. Installs ruff by default and uses pyproject.toml for configuration. Detects or asks the user about venv/poetry/uv environments and installs as dev dependencies. Optionally configures pre-commit and ty. Suggests VSCode workspace settings when using VSCode. Use this skill when starting Python projects ("Start a Python project", "Create a FastAPI project", "Create a data analysis Python project", etc.).

Python Starter

Automatically configures formatter and linter when initializing Python projects.

Workflow

  1. Environment Detection and Selection

    • Use UV if uv.lock file exists or uv command is available
    • Use Poetry if [tool.poetry] section exists in pyproject.toml
    • If no environment is configured, recommend uv
    • Otherwise use venv
    • Ask the user if uncertain
  2. Install ruff

    • Install ruff as dev dependency based on selected environment
    • Use commands (avoid writing code directly)
    • Reference: environment-setup.md
  3. Configure pyproject.toml

  4. Install pytest

    • Install pytest as dev dependency based on selected environment
    • Use commands (avoid writing code directly)
  5. Type Checking Setup (Optional)

    • Ask the user if they want ty setup
    • Install ty as dev dependency if needed
    • Add ty configuration to pyproject.toml
    • Reference: pyproject-toml-examples.md
  6. Pre-commit Setup (Optional)

  7. VSCode Settings Suggestion

  8. Create .gitignore

    • Create .gitignore if it doesn't exist
    • Include common Python ignores for virtual environments, cache files, build artifacts, IDE files, and OS files
    • Template: assets/.gitignore.template

Principles

  • Command-first: Use commands whenever possible instead of writing code directly
  • Use pyproject.toml: Store all configuration in pyproject.toml
  • Dev dependencies: Install ruff, pytest, ty, and pre-commit as dev dependencies
  • User confirmation: Confirm with user for environment selection, ty, and pre-commit before proceeding

References