cookiecutter

当需要将 Cookiecutter 模板中的新更改拉入已生成且正在维护的仓库而不从头重建项目时使用 Cruft。该流程会跟踪模板来源、预览差异、应用更新,并尽可能保留仓库中已保存的答案和本地自定义设置。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "cookiecutter":https://skillpi.com/zh/skills/deepskill-c1060a3af6f641a2553c4f8af1f055e7252e8081146984b9d791a467fa23170b。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/refresh-cookiecutter-based-repositories-from-upstream-template。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

当需要将 Cookiecutter 模板中的新更改拉入已生成且正在维护的仓库而不从头重建项目时使用 Cruft。该流程会跟踪模板来源、预览差异、应用更新,并尽可能保留仓库中已保存的答案和本地自定义设置。

0 下载

介绍来源: third_party · user_3c6cb52e · 0.1.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: cookiecutter
description: Use when adding, changing, testing, or debugging Cookiecutter templates, including cookiecutter.json variables, Jinja-rendered files, hooks, _copy_without_render, optional feature cleanup, and generated-project validation.
license: MIT
compatibility: Codex, Claude Code, and other Agent Skills-compatible clients.
metadata:
  version: "0.1.0"
  displayName: Cookiecutter
  category: Developer Tooling
  tags: cookiecutter,templates,jinja,scaffolding

Cookiecutter Template Work

Use this skill before changing a repository that has cookiecutter.json, hooks/, or a generated project directory such as {{ cookiecutter.project_slug }}/.

First Pass

  1. Read the repo instructions, README.md, cookiecutter.json, existing tests, and any hooks before editing.
  2. Identify the template root and the generated project root. Make changes in the template files, not in one rendered sample.
  3. Search for the relevant Cookiecutter variables and feature flags with rg before adding new ones.
  4. Check how the repo validates rendered projects. Prefer existing render tests and smoke-check commands over inventing a separate validation path.

Template Boundaries

  • cookiecutter.json is the user-facing interface. Every new prompt, default, derived value, private value, and choice should be deliberate and documented where the repo documents options.
  • The generated project directory may itself contain Jinja in file names and paths. Treat both file contents and paths as render surfaces.
  • Follow the repo's current variable style. If it already uses y/n strings, keep using that style for new feature flags. If it uses Cookiecutter boolean values, keep those as real JSON booleans.
  • Optional features must be valid in both enabled and disabled states. Remove or gate app files, imports, URL routes, settings, dependencies, docs, tests, workflows, and migrations together.
  • Do not add maintainer-specific names, local paths, secrets, or one-agent assumptions to generated output.

Jinja Rules

  • Keep rendered files valid in their target language: Python, JSON, TOML, YAML, shell, Markdown, HTML, JavaScript, or CSS.
  • Watch for dangling commas after conditional blocks in JSON, TOML, Python data structures, YAML lists, package manifests, and GitHub Actions.
  • Use whitespace control ({%- ... -%}) only when it improves rendered syntax or formatting. Validate the rendered result, not only the template source.
  • Use safe serialization for strings inserted into code or data files. Prefer the repo's existing JSON/Jinja filter pattern, such as |tojson, when it is already used.
  • If generated output must preserve literal Jinja, template syntax, or agent placeholders, either escape the braces, wrap the content in raw blocks, or add the path to _copy_without_render.
  • _copy_without_render prevents rendering file contents, but paths are still rendered. Include both directory and recursive glob entries when a whole tree must be copied verbatim.

Hooks

  • Put Cookiecutter hooks in hooks/ as pre_prompt, pre_gen_project, or post_gen_project scripts. Prefer Python for cross-platform templates unless the repo is intentionally platform-specific.
  • pre_gen_project and post_gen_project run from the generated project root and can use rendered Cookiecutter variables.
  • Make hooks deterministic, idempotent, and relative-path based. Avoid network calls, secrets, interactive prompts, and machine-local paths.
  • A non-zero hook exit stops generation and Cookiecutter cleans the generated directory. Fail early for invalid user input; be defensive for cleanup.
  • Use post-generation cleanup for whole optional files or directories. Use inline Jinja for small syntax-aware changes inside files that must remain.

Testing

  • Add or update tests that render the template with explicit context values. Cover each changed option both enabled and disabled when practical.
  • Include assertions for absence, not only presence: disabled optional features should not leave imports, dependencies, routes, docs, workflows, migrations, or placeholder text behind.
  • Exercise the real Cookiecutter CLI when changing generation behavior, hooks, template selection, or command-line assumptions.
  • For runtime behavior changes, generate a project in a temp directory and run that project's documented checks.
  • Inspect rendered files that are sensitive to syntax: JSON, TOML, YAML, Python modules, shell scripts, and package manifests.

Common Failure Patterns

  • Jinja renders syntactically valid template source into invalid generated code.
  • A disabled option removes files but leaves settings, imports, URLs, dependencies, docs, tests, migrations, or CI references.
  • Literal {{ ... }} placeholders intended for the generated project are consumed by Cookiecutter.
  • Hooks assume the template repo as the working directory instead of the generated project root.
  • Tests render one happy-path context but miss another supported option combination.
  • Generated files include local paths, personal names, secrets, or assumptions about a specific AI tool.

Definition of Done

  • Template changes are made at the template level.
  • Relevant enabled and disabled option combinations render successfully.
  • The generated output has no stale placeholders, syntax errors, orphan imports, or hard-coded maintainer-specific values.
  • The repo's template test suite passes.
  • Docs and changelog entries are updated when users or generated-project contributors need to know about the change.

References

当前收录版本

0.1.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值78/100

亮点

  • Cookiecutter模板开发是开发者常见需求,Skill提供了详细的模板修改、测试、Jinja规则等实用指导
  • 覆盖了模板边界、Jinja规则、hooks、测试等完整工作流程,具有广泛受众的实用能力
触发精准85/100

亮点

  • 触发词精准完整,description明确指出了使用场景包括添加、修改、测试、调试Cookiecutter模板等
  • 覆盖多种变体,边界清晰,能够有效区分Cookiecutter相关工作与其他开发任务
结构规范92/100

亮点

  • Phase/步骤清晰,有First Pass、Template Boundaries、Jinja Rules、Hooks、Testing等明确章节
  • 包含Common Failure Patterns和Definition of Done作为出口条件,frontmatter完整,结构规范
执行可靠88/100

亮点

  • 工具来源明确,参数正确,覆盖了主要异常情况如Jinja渲染错误、可选功能处理、hooks执行等
  • 提供了详细的最佳实践和常见失败模式,执行流程可靠
证据可验 (前四项均值)86/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • cookiecutter.readthedocs.io
  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。