How to Update from Template¶
This guide shows you how to pull in the latest template improvements to an existing project generated from python-package-copier.
Prerequisites¶
- A project previously generated with
uvx copier copy gh:stateful-y/python-package-copier - The project must contain a
.copier-answers.ymlfile (generated automatically) - copier installed (
uvx copierworks)
Check Your Current Template Version¶
The _commit field shows the template commit your project was generated from.
Update to Latest Template¶
Run from your project's root directory:
Copier will:
- Pull the latest template from
gh:stateful-y/python-package-copier - Show you a diff of changes
- Prompt for any new configuration questions added since your last update
- Apply updates while preserving your modifications
Update to a Specific Version¶
Pin to a specific template version:
Or update to a specific commit:
Handle Conflicts¶
If you've modified files that the template also changed, Copier will flag conflicts.
Inline Conflict Markers (Default)¶
This adds Git-style conflict markers in the affected files:
Resolve them manually, then commit.
Reject Files¶
This creates .rej files alongside conflicting files. Review each .rej file, apply the changes you want, and delete the .rej files.
What Gets Updated¶
Template updates can include:
- CI workflow improvements - new testing strategies, updated actions versions
- Tool configuration - ruff rules, coverage settings, pre-commit hooks
- Documentation scaffolding - new doc pages, improved templates
- Build system - dependency group changes, hatchling config
What Is Preserved¶
Copier respects your local changes. Files you've customized are merged, not overwritten. Specifically:
- Your source code in
src/is never touched by template updates - Your test files in
tests/are preserved - Custom content you added to documentation is preserved
- Dependencies you added to
pyproject.tomlare preserved
AI-Assisted Updates¶
If you use GitHub Copilot or a similar AI coding assistant, you can ask it to handle the update for you. The template ships with an update-from-template skill that automates the full workflow:
- Pre-flight checks (clean working tree, current template version)
- Detecting which files you've customized vs. kept as-is
- Running
copier updateon a dedicated branch - Resolving conflicts using a 3-tier file classification (template-managed, merge-required, local-owned)
- Verifying tests and linting pass after the update
To trigger it, ask your AI assistant: "update from template" or "sync template changes" from within your generated project.
Troubleshooting¶
Problem: copier update fails with "not a copier project"
: Ensure .copier-answers.yml exists in the project root. If it was accidentally deleted, you cannot update - you would need to regenerate the project.
Problem: Too many conflicts after a long gap
: Update incrementally by specifying intermediate versions with --vcs-ref.
Problem: New template variables have no answers
: Copier will prompt you for any new variables interactively. To set defaults non-interactively, use --defaults.
See Also¶
- Template Variables - understand what each variable controls
- Project Structure - what files the template generates