Copier + Jinja template-repository design skill: reference architecture, implementation workflow, validation checklist, and a full worked example template (questionnaire, extensions, resolvers, wrapper-first .scripts). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
3.8 KiB
3.8 KiB
Validation Checklist (Template Engine Repository)
Use this checklist before considering Copier/Jinja template work complete.
A. Copier configuration
.copier/copier.yamlexists and is valid YAML._template_suffixis set to.jinja._answers_fileis explicitly configured._excludeblocks repo-internal operational files (.copier,.scripts, env/lock files as needed).- Questionnaire is loaded via
!include .copier/questionnaire/*.yml.
B. Input schema and answers
copier-answers.example.yamlreflects real expected shape.- Required keys used in templates are documented in the example answers.
{{ _copier_conf.answers_file }}.jinjarenders_copier_answers|to_nice_yaml.
C. Wrapper runtime surface
- Root
Taskfile.ymlincludes copier module Taskfile. .scripts/copier/Taskfile.ymlhas an operator-friendlybootstrap-onetask.- API wrapper (
api/bootstrap-one.sh) creates and enters a siblingtmp-<template-folder>copy before sourcing libs and rendering. - API wrapper returns to the live template repo after the temp-copy render completes.
- ENV variable prefix is explicitly confirmed/proposed and consistently applied across wrapper libs.
- Lib layer parses CLI args for:
- Lib layer parses CLI args for both forms:
--arg valueand--arg=value.--copier-target-dir--copier-force-copy--copier-params-file
D. Answers merge behavior
copier-answers-new.ymlis created if missing.- Existing target answers are imported when present.
- Params file is merged into working answers file.
- Render uses
--data-filepointing to merged answers file. - Local bootstrap render runs from the sanitized temp copy, not directly from the live Git-backed template folder.
- Temp copy removes
.git,.devbox, and.venvbeforecopier copyto avoid Copier/Git interference. - If Copier config lives under
.copier/copier.yaml, temp-copy bootstrap copies it to rootcopier.yamlbefore rendering. - No Git tags are created merely to suppress Copier local render warnings.
E. Templating behavior
- Conditional folder names render correctly (e.g.
{{ 'dev' if ... }}). - All optional resources are path-wrapped with Jinja conditions (folder and/or file names), not only guarded in file bodies.
- Conditional Jinja blocks in files match folder-level conditions.
- Safe/normalized names are provided by context-hook or resolver variables (e.g.
flat.project_safe), not repeated inline filter chains. - Template paths and file bodies do not duplicate complex expressions like
lower | replace(...) | trimfor identifiers used in more than one place. - Any generated temporary filenames (e.g.
.tmp-gitlab-ci.yml) are renamed correctly post-render.
F. Extensions (if used)
- All custom extensions are registered in
_jinja_extensions. - Resolver helpers are deterministic and side-effect free.
- Context hook logic is idempotent on repeated runs.
- Context hook exposes stable safe variables for reusable identifiers before templates consume them.
[INDEX]expansion creates concrete instance directories and removes placeholder template dir.
G. End-to-end runs
- Fresh render into empty target directory succeeds.
- Re-render into existing target with prior answers succeeds.
--copier-force-copy truepath works.- Default/non-force path works.
H. Documentation quality
- README explains local setup and one canonical bootstrap command.
- Skill/instructions mention architecture and anti-patterns.
- Examples use realistic paths and argument names.
Exit criteria
You are done when all checklist sections pass and rendering is reproducible in both fresh and update scenarios.