pypreset

编码与调试

by kaierikniermann

基于 YAML presets 快速搭建 Python 项目,也可为现有项目补充 CI、tests 等工程化配置。

什么是 pypreset

基于 YAML presets 快速搭建 Python 项目,也可为现有项目补充 CI、tests 等工程化配置。

README

<p align="center"> <img src="https://raw.githubusercontent.com/KaiErikNiermann/pypreset/main/resources/banner.png" alt="PyPreset" height="160"> </p> <p align="center"> A meta-tool for scaffolding Python projects with configurable YAML presets.<br> Supports Poetry, uv, and setuptools, generates CI workflows, testing scaffolds, type checking configs, and more. </p>

mcp-name: io.github.KaiErikNiermann/pypreset

Features

  • Preset-based project creation from YAML configs with single inheritance
  • Augment existing projects with CI workflows, tests, Docker, documentation, and more
  • Three package managers: Poetry, uv (PEP 621 + hatchling), and setuptools (PEP 621 + setuptools.build_meta)
  • Two layout styles: src/ layout and flat layout
  • Type checking: mypy, pyright, ty, or none
  • Code quality: ruff linting/formatting, radon complexity checks, pre-commit hooks
  • Docker & devcontainer: generate multi-stage Dockerfiles, .dockerignore, and VS Code devcontainer configs (Docker or Podman)
  • Coverage integration: Codecov support with configurable thresholds and ignore patterns
  • Documentation scaffolding: MkDocs (Material theme) or Sphinx (RTD theme) with optional GitHub Pages deployment
  • Multi-environment testing: tox configuration with tox-uv backend
  • pyenv / .python-version: generate .python-version for pyenv and uv, with python-version-file in CI workflows
  • Version management: bump-my-version integration, GitHub release automation via gh CLI
  • Workflow verification: local GitHub Actions testing with act (auto-detect, auto-install, dry-run and full-run modes)
  • PyPI metadata management: read, set, and check publish-readiness of pyproject.toml metadata
  • User defaults: persistent config at ~/.config/pypreset/config.yaml
  • MCP server: expose all functionality to AI coding assistants via the Model Context Protocol

Installation

bash
pip install pypreset

# With MCP server support
pip install pypreset[mcp]

Quick Start

bash
# Create a CLI tool project with Poetry
pypreset create my-cli --preset cli-tool

# Create a data science project with uv
pypreset create my-analysis --preset data-science --package-manager uv

# Create an empty package with src layout (default)
pypreset create my-package --preset empty-package

# Create a Discord bot
pypreset create my-bot --preset discord-bot

# Create a project with Docker support
pypreset create my-service --preset cli-tool --docker --devcontainer

# Create with .python-version for pyenv/uv
pypreset create my-lib --pyenv --python-version 3.13

# Create with Podman, Codecov, docs, and tox
pypreset create my-project --preset empty-package \
    --container-runtime podman --docker \
    --coverage-tool codecov --coverage-threshold 80 \
    --docs mkdocs --docs-gh-pages \
    --tox

Commands

create -- Scaffold a new project

bash
pypreset create <name> [OPTIONS]
OptionDescription
--preset, -pPreset to use (default: empty-package)
--output, -oOutput directory (default: .)
--config, -cCustom preset YAML file
--package-managerpoetry or uv
--layoutsrc or flat
--type-checkermypy, pyright, ty, or none
--typingnone, basic, or strict
--python-versione.g., 3.12
--testing / --no-testingEnable/disable testing scaffold
--formatting / --no-formattingEnable/disable formatting config
--radon / --no-radonEnable radon complexity checking
--pre-commit / --no-pre-commitGenerate pre-commit hooks config
--bump-my-version / --no-bump-my-versionInclude bump-my-version config
--extra-package, -eAdditional packages (repeatable)
--extra-dev-package, -dAdditional dev packages (repeatable)
--docker / --no-dockerGenerate Dockerfile and .dockerignore
--devcontainer / --no-devcontainerGenerate .devcontainer/ configuration
--container-runtimedocker or podman
--coverage-toolcodecov or none
--coverage-thresholdMinimum coverage % (e.g., 80)
--docssphinx, mkdocs, or none
--docs-gh-pages / --no-docs-gh-pagesGenerate GitHub Pages deploy workflow
--tox / --no-toxGenerate tox.ini with tox-uv backend
--pyenv / --no-pyenvGenerate .python-version and use python-version-file in CI
--git / --no-gitInitialize git repository
--install / --no-installRun dependency install after creation
--dry-runPreview what would be created without generating anything

augment -- Add components to an existing project

Analyzes pyproject.toml to auto-detect your tooling, then generates the selected components. Runs in interactive mode by default (prompts for values it can't detect); use --auto to skip prompts.

bash
pypreset augment [path] [OPTIONS]

Available components:

FlagComponentWhat it generates
--test-workflow / --no-test-workflowTest CIGitHub Actions workflow that runs pytest across a Python version matrix
--lint-workflow / --no-lint-workflowLint CIGitHub Actions workflow for ruff, type checking, and complexity analysis
--dependabot / --no-dependabotDependabot.github/dependabot.yml for automated dependency updates
--tests / --no-testsTests directorytests/ with template test files and conftest.py
--gitignore / --no-gitignoreGitignorePython-specific .gitignore
--pypi-publish / --no-pypi-publishPyPI publishGitHub Actions workflow for OIDC-based publishing to PyPI on release
--dockerfile / --no-dockerfileDockerMulti-stage Dockerfile and .dockerignore (Poetry, uv, or setuptools aware)
--devcontainer / --no-devcontainerDevcontainer.devcontainer/devcontainer.json with VS Code extensions
--codecov / --no-codecovCodecovcodecov.yml configuration
--docsDocumentationSphinx or MkDocs scaffolding (--docs sphinx or --docs mkdocs)
--tox / --no-toxtoxtox.ini with tox-uv backend for multi-environment testing
--readme / --no-readmeREADMEREADME.md generated from the shared template (badges, install, features)
--pyenv / --no-pyenvpyenv.python-version file for pyenv and uv version pinning
bash
# Interactive mode (prompts for missing values)
pypreset augment ./my-project

# Auto-detect everything, no prompts
pypreset augment --auto

# Generate only specific components
pypreset augment --test-workflow --lint-workflow --gitignore

# Add Docker and devcontainer
pypreset augment --dockerfile --devcontainer

# Add PyPI publish workflow
pypreset augment --pypi-publish

# Add documentation scaffolding
pypreset augment --docs mkdocs

# Generate a README from your project metadata
pypreset augment --readme

# Overwrite existing files
pypreset augment --force

workflow -- Local workflow verification

Verify GitHub Actions workflows locally using act. The proxy auto-detects whether act is installed, can install it on supported systems, and surfaces all act output directly.

bash
# Verify all workflows (dry-run, no containers)
pypreset workflow verify

# Verify a specific workflow file
pypreset workflow verify --workflow .github/workflows/ci.yaml

# Verify a specific job
pypreset workflow verify --job lint

# Full run (executes in containers, requires Docker)
pypreset workflow verify --full-run

# Auto-install act if missing
pypreset workflow verify --auto-install

# Pass extra flags to act
pypreset workflow verify --flag="--secret=GITHUB_TOKEN=xxx"

# Check if act is installed
pypreset workflow check-act

# Install act automatically
pypreset workflow install-act

Supported auto-install targets: Arch Linux (pacman), Ubuntu/Debian (apt), Fedora (dnf), macOS/Linux with Homebrew. Other systems get a link to the act installation page.

version -- Release management

bash
pypreset version release --bump patch     # 0.1.0 -> 0.1.1
pypreset version release --bump minor     # 0.1.0 -> 0.2.0
pypreset version release --bump major     # 0.1.0 -> 1.0.0
pypreset version release-version 2.0.0    # Explicit version
pypreset version rerun <ver>              # Re-tag and push an existing version
pypreset version rerelease <ver>          # Delete and recreate a GitHub release

Requires the gh CLI to be installed and authenticated.

metadata -- PyPI metadata management

bash
pypreset metadata show                                   # Display current metadata
pypreset metadata set --description "My cool package"    # Set description
pypreset metadata set --github-owner myuser              # Auto-generate URLs
pypreset metadata set --license MIT --keyword python     # Set license and keywords
pypreset metadata check                                  # Check publish-readiness

badges -- Generate badge markdown

Reads pyproject.toml to detect your project name, repository URL, and license, then prints badge markdown you can paste into your README.

bash
pypreset badges                  # Badges for current directory
pypreset badges ./my-project     # Badges for a specific project

Other commands

bash
pypreset list-presets              # List all available presets
pypreset show-preset <name>        # Show full preset details
pypreset validate [path]           # Validate project structure
pypreset analyze [path]            # Detect and display project tooling
pypreset config show               # Show current user defaults
pypreset config init               # Create default config file
pypreset config set <key> <value>  # Set a config value

Presets

Built-in presets: empty-package, cli-tool, data-science, discord-bot.

Presets are YAML files that define metadata, dependencies, directory structure, testing, formatting, and more. They support single inheritance via the base: field. Presets can override the README template by setting metadata.readme_template to a custom .j2 filename.

Custom presets

Place custom preset files in ~/.config/pypreset/presets/ or pass a file directly:

bash
pypreset create my-project --config ./my-preset.yaml

User presets take precedence over built-in presets with the same name.

User Configuration

Persistent defaults are stored at ~/.config/pypreset/config.yaml and applied as the lowest-priority layer (presets and CLI flags override them).

bash
pypreset config init                    # Create with defaults
pypreset config set layout flat         # Set default layout
pypreset config set type_checker ty     # Set default type checker
pypreset config show                    # View current config

MCP Server

pypreset is published to the MCP Registry as io.github.KaiErikNiermann/pypreset.

Install via the registry (recommended):

bash
# Claude Code
claude mcp add pypreset -- uvx --from "pypreset[mcp]" pypreset-mcp

# Or add manually to ~/.claude/settings.json
json
{
  "mcpServers": {
    "pypreset": {
      "command": "uvx",
      "args": ["--from", "pypreset[mcp]", "pypreset-mcp"]
    }
  }
}

Or install locally:

bash
pip install pypreset[mcp]
json
{
  "mcpServers": {
    "pypreset": {
      "command": "pypreset-mcp",
      "args": []
    }
  }
}

Available tools:

ToolDescription
create_projectCreate a new project from a preset with optional overrides
augment_projectAdd CI workflows, tests, Docker, docs, and more to an existing project
validate_projectCheck structural correctness of a project directory
verify_workflowVerify GitHub Actions workflows locally using act
list_presetsList all available presets with names and descriptions
show_presetShow the full YAML configuration of a specific preset
get_user_configRead current user-level defaults
set_user_configUpdate user-level defaults
set_project_metadataSet or update PyPI metadata in pyproject.toml
generate_badgesGenerate badge markdown links from project metadata

Resources: preset://list, config://user, template://list

Prompts: create-project, augment-project

Development

All tasks use the Justfile:

bash
just install     # Install dependencies
just test        # Run tests
just test-cov    # Tests with coverage
just lint        # Ruff check
just format      # Ruff format
just typecheck   # Pyright
just radon       # Cyclomatic complexity check
just check       # lint + typecheck + radon + test
just all         # format + lint-fix + typecheck + radon + test

See CONTRIBUTING.md for development setup and guidelines.

License

MIT

常见问题

pypreset 是什么?

基于 YAML presets 快速搭建 Python 项目,也可为现有项目补充 CI、tests 等工程化配置。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描166.1k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描166.1k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描166.1k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
89.2k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
60.2k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
49.6k

评论