Configs2026年7月28日·1 分钟阅读

Copier — Render Project Templates with Answers and Updates

Copier is a Python-based project scaffolding tool that renders templates from Git repositories, supports answer-driven customization, and can update previously generated projects when the template evolves.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Copier Overview
直接安装命令
npx -y tokrepo@latest install bd98bba9-8a83-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Copier is a command-line tool and Python library for generating projects from template repositories. It asks the user a series of questions, renders Jinja templates with the answers, and can later update generated projects when the upstream template changes — preserving local modifications.

What Copier Does

  • Generates project scaffolds from Git-hosted or local template directories
  • Prompts users with configurable questions and validates answers with types and constraints
  • Renders files and directory names using Jinja2 templating with the collected answers
  • Updates previously generated projects by replaying template changes on top of local edits
  • Supports conditional file inclusion, multi-choice prompts, and computed values

Architecture Overview

Copier clones the template repository, reads a copier.yml configuration file that defines questions and settings, collects answers interactively or from a file, and renders all Jinja2 templates in the source tree into the destination directory. A .copier-answers.yml file is saved in the generated project, enabling future copier update runs to diff the old template version against the new one and apply changes while respecting local modifications via a three-way merge.

Self-Hosting & Configuration

  • Install via pipx: pipx install copier (recommended) or pip: pip install copier
  • Define template questions and defaults in a copier.yml at the template root
  • Use Jinja2 syntax in filenames and file contents with {{ variable }} placeholders
  • Tag template versions with Git tags so consumers can update between specific releases
  • Run copier update in a generated project to pull in upstream template improvements

Key Features

  • Template update workflow that three-way-merges upstream changes with local project edits
  • Rich question types including text, integer, float, boolean, choice, and multi-choice
  • Conditional file rendering and directory creation based on answer values
  • Subdirectory support for templates that live inside a larger monorepo
  • Extensible via pre- and post-generation tasks defined in the template configuration

Comparison with Similar Tools

  • Cookiecutter — The original Python project templater; Copier adds template updates, richer question types, and Git-tag versioning
  • Yeoman — Node.js generator ecosystem; Copier is Python-native with built-in update support
  • degit — Copies Git repos without history; Copier adds templating, questions, and updates
  • Hygen — File generator for JavaScript projects; Copier is language-agnostic with answer-driven scaffolding
  • Plop — Micro-generator for adding files to existing projects; Copier generates full project scaffolds with lifecycle updates

FAQ

Q: How does Copier handle template updates? A: Copier stores your answers in .copier-answers.yml. Running copier update diffs the old and new template versions, then applies the changes to your project with a three-way merge.

Q: Can I use Copier with non-Python projects? A: Yes. Copier is language-agnostic. Templates can generate projects in any language or framework.

Q: Does Copier support private Git repositories? A: Yes. Copier uses Git for cloning, so any repository accessible via SSH keys or credential helpers works.

Q: How do I skip certain questions programmatically? A: Define when conditions in copier.yml that reference previous answers. Questions with a false when are skipped and use their default values.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产