release-please-protection

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Release-Please Protection

Release-Please 保护机制

Automatically detects and prevents manual edits to release-please managed files across all projects.
自动检测并阻止对所有项目中由release-please管理的文件进行手动编辑。

Overview

概述

This skill provides proactive detection and warnings for files managed by Google's release-please automation tool. It helps prevent merge conflicts and workflow disruptions by identifying problematic edit attempts before they occur.
本技能针对Google的release-please自动化工具管理的文件提供主动检测和警告功能。它通过在问题编辑发生前识别风险,帮助避免合并冲突和工作流中断。

When This Skill Activates

技能触发场景

The skill automatically activates in these scenarios:
  1. Direct edit requests to protected files
  2. User mentions of version bumps, releases, or changelog updates
  3. Broad refactoring that might touch version-controlled files
  4. Documentation updates that could include CHANGELOG.md
  5. "Fix all issues" or similar sweeping requests
在以下场景中,技能会自动激活:
  1. 直接编辑请求:针对受保护文件的编辑操作
  2. 用户提及:涉及版本升级、发布或变更日志更新的请求
  3. 大范围重构:可能触及版本控制文件的重构操作
  4. 文档更新:可能包含CHANGELOG.md的文档修改
  5. **"修复所有问题"**或类似的批量操作请求

Protected Files

受保护文件

Hard Protection (Permission System)

严格保护(权限系统)

These files are completely blocked from editing by Claude Code's permission system:
  • **/CHANGELOG.md
    - All changelog files in any location
Operations blocked: Edit, Write, MultiEdit Operations allowed: Read (for analysis and context)
以下文件被Claude Code的权限系统完全禁止编辑
  • **/CHANGELOG.md
    - 所有位置的变更日志文件
被阻止的操作:编辑、写入、多文件编辑 允许的操作:读取(用于分析和获取上下文)

Soft Protection (Skill Detection)

柔性保护(技能检测)

These files trigger warnings and suggestions before edits:
以下文件在编辑前会触发警告和建议

Package Manager Manifests (Version Fields)

包管理器清单(版本字段)

  • package.json
    "version": "x.y.z"
    (npm/Node.js)
  • pyproject.toml
    version = "x.y.z"
    (Python/uv)
  • Cargo.toml
    version = "x.y.z"
    (Rust/cargo)
  • .claude-plugin/plugin.json
    "version": "x.y.z"
    (Claude Code plugins)
  • pom.xml
    <version>x.y.z</version>
    (Maven/Java)
  • build.gradle
    version = 'x.y.z'
    (Gradle)
  • pubspec.yaml
    version: x.y.z
    (Dart/Flutter)
Why soft protection? Claude Code's permission system operates at the file level, not field level. Blocking entire manifest files would prevent legitimate dependency updates via automated tools (npm, cargo, uv, etc.).
  • package.json
    "version": "x.y.z"
    (npm/Node.js)
  • pyproject.toml
    version = "x.y.z"
    (Python/uv)
  • Cargo.toml
    version = "x.y.z"
    (Rust/cargo)
  • .claude-plugin/plugin.json
    "version": "x.y.z"
    (Claude Code插件)
  • pom.xml
    <version>x.y.z</version>
    (Maven/Java)
  • build.gradle
    version = 'x.y.z'
    (Gradle)
  • pubspec.yaml
    version: x.y.z
    (Dart/Flutter)
为何采用柔性保护? Claude Code的权限系统基于文件级别而非字段级别运行。如果完全阻止整个清单文件,会影响通过自动化工具(npm、cargo、uv等)进行的合法依赖更新。

Detection Logic

检测逻辑

Before attempting any edit, the skill checks:
在尝试任何编辑操作前,技能会进行以下检查:

1. File Path Analysis

1. 文件路径分析

if file_path ends with "CHANGELOG.md":
    → Inform user of hard permission block
    → Explain release-please workflow
    → Suggest conventional commit approach
if file_path ends with "CHANGELOG.md":
    → 告知用户权限阻止情况
    → 解释release-please工作流
    → 建议使用规范提交方式

2. Content Pattern Matching

2. 内容模式匹配

if file is package manifest AND edit touches version field:
    → Warn about release-please management
    → Explain why manual edits cause conflicts
    → Offer to edit OTHER fields (but not version)
    → Provide conventional commit template
if file is package manifest AND edit touches version field:
    → 警告用户该字段由release-please管理
    → 解释手动编辑会导致冲突的原因
    → 提供编辑其他字段的选项(但不包括版本字段)
    → 提供规范提交模板

3. Intent Recognition

3. 意图识别

if user request contains keywords: "version", "release", "bump", "changelog":
    → Proactively explain release-please workflow
    → Check if files in scope are protected
    → Suggest proper approach before attempting edits
if user request contains keywords: "version", "release", "bump", "changelog":
    → 主动解释release-please工作流
    → 检查范围内是否存在受保护文件
    → 在尝试编辑前建议正确的操作方式

Response Templates

响应模板

When CHANGELOG.md Edit Attempted

当尝试编辑CHANGELOG.md时

⚠️ CHANGELOG.md Protection Active

I cannot edit CHANGELOG.md files - they're protected by Claude Code's permission
system because they're managed by release-please automation.

**Why this matters:**
Manual edits to CHANGELOG.md cause merge conflicts with automated release PRs,
breaking your release workflow.

**Proper workflow:**
1. Make your changes with conventional commit messages:
   - feat: adds new features (minor version bump)
   - fix: bug fixes (patch version bump)
   - chore: maintenance tasks (no version bump)
   - BREAKING CHANGE: breaking changes (major version bump)

2. Release-please automatically:
   - Detects conventional commits
   - Generates CHANGELOG entries
   - Creates a release PR with version bumps
   - Tags releases when PR is merged

**Example commit:**
feat(auth): add OAuth2 support
Implements OAuth2 authentication flow with PKCE. Includes refresh token rotation and session management.

**Need to override?**
For emergency fixes, temporarily edit ~/.claude/settings.json:
1. Comment out the CHANGELOG.md deny rules
2. Make your edits
3. Re-enable protection
⚠️ CHANGELOG.md 保护已激活

我无法编辑CHANGELOG.md文件 - 这些文件由Claude Code的权限系统保护,因为它们由release-please自动化工具管理。

**重要性说明:**
手动编辑CHANGELOG.md会与自动化发布PR产生合并冲突,破坏您的发布工作流。

**正确工作流:**
1. 使用规范提交消息进行更改:
   - feat: 添加新功能(小版本升级)
   - fix: 修复bug(补丁版本升级)
   - chore: 维护任务(不触发版本升级)
   - BREAKING CHANGE: 破坏性变更(大版本升级)

2. release-please会自动:
   - 检测规范提交
   - 生成CHANGELOG条目
   - 创建包含版本升级的发布PR
   - 当PR合并时标记发布版本

**提交示例:**
feat(auth): add OAuth2 support
Implements OAuth2 authentication flow with PKCE. Includes refresh token rotation and session management.

**需要临时覆盖?**
如需紧急修复,可临时编辑~/.claude/settings.json:
1. 注释掉CHANGELOG.md的拒绝规则
2. 进行编辑操作
3. 重新启用保护

When Version Field Edit Detected

当检测到版本字段编辑时

⚠️ Version Field Protection Warning

I notice you're asking me to modify the version field in [file_name]. This field
is typically managed by release-please automation.

**Current version:** [current_version]
**Requested change:** [requested_change]

**Why manual edits are problematic:**
- Creates merge conflicts with release-please PRs
- Can cause version numbering inconsistencies
- Bypasses conventional commit history tracking

**I can help in two ways:**

1. **Automated approach (recommended):**
   I'll help you craft a conventional commit message that will trigger the
   appropriate version bump when release-please creates its next release PR.

   For [requested_change], you should use:
   - `feat:` for minor version bump
   - `fix:` for patch version bump
   - `feat!:` or `BREAKING CHANGE:` for major version bump

2. **Manual override (emergency only):**
   If you absolutely need to manually set the version (e.g., aligning with
   external requirements), I can edit other fields in [file_name] but will
   skip the version field. You'll need to edit that manually or temporarily
   disable the skill protection.

Which approach would you prefer?
⚠️ 版本字段保护警告

我注意到您请求修改[file_name]中的版本字段。该字段通常由release-please自动化工具管理。

**当前版本:** [current_version]
**请求的变更:** [requested_change]

**手动编辑的问题:**
- 与release-please的PR产生合并冲突
- 可能导致版本编号不一致
- 绕过规范提交历史跟踪

**我可以提供两种帮助方式:**

1. **自动化方式(推荐):**
   我会帮您编写规范提交消息,当release-please创建下一个发布PR时,会自动触发相应的版本升级。

   针对[requested_change],您应使用:
   - `feat:` 用于小版本升级
   - `fix:` 用于补丁版本升级
   - `feat!:` 或 `BREAKING CHANGE:` 用于大版本升级

2. **手动覆盖(仅限紧急情况):**
   如果您确实需要手动设置版本(例如,与外部要求对齐),我可以编辑[file_name]中的其他字段,但会跳过版本字段。您需要手动编辑该字段或临时禁用技能保护。

您倾向于哪种方式?

When Broad Refactoring Requested

当收到大范围重构请求时

📋 Release-Please Files Detected

I've identified several release-please managed files in the scope of this
refactoring:

**Protected files found:**
- plugins/dotfiles-core/CHANGELOG.md (hard block)
- plugins/dotfiles-toolkit/.claude-plugin/plugin.json (version field)
- [other files...]

**My approach:**
✅ I'll refactor all other files as requested
⚠️ I'll skip protected files and explain why
📝 I'll provide a summary of skipped changes

**If you need version/changelog updates:**
I'll generate appropriate conventional commit messages that will trigger
release-please to make those changes automatically.

Should I proceed with this approach?
📋 检测到release-please管理文件

我在本次重构范围内识别到多个由release-please管理的文件:

**发现的受保护文件:**
- plugins/dotfiles-core/CHANGELOG.md(严格阻止)
- plugins/dotfiles-toolkit/.claude-plugin/plugin.json(版本字段)
- [其他文件...]

**我的处理方式:**
✅ 按照请求重构所有其他文件
⚠️ 跳过受保护文件并解释原因
📝 提供跳过的变更摘要

**如果您需要版本/变更日志更新:**
我会生成合适的规范提交消息,触发release-please自动进行这些变更。

是否按照此方式继续?

Conventional Commit Guide

规范提交指南

The skill provides instant conventional commit templates based on the type of change:
技能会根据变更类型即时提供规范提交模板:

Feature Addition

功能新增

feat(scope): brief description

Detailed explanation of what was added and why.
Can be multiple paragraphs.

Refs: #issue-number
feat(scope): brief description

Detailed explanation of what was added and why.
Can be multiple paragraphs.

Refs: #issue-number

Bug Fix

Bug修复

fix(scope): brief description

Explanation of the bug and how it was fixed.

Fixes: #issue-number
fix(scope): brief description

Explanation of the bug and how it was fixed.

Fixes: #issue-number

Breaking Change

破坏性变更

feat(scope)!: brief description

BREAKING CHANGE: Explanation of what breaks and migration path.

Details about the new behavior.

Refs: #issue-number
feat(scope)!: brief description

BREAKING CHANGE: Explanation of what breaks and migration path.

Details about the new behavior.

Refs: #issue-number

Chore (No Version Bump)

日常维护(不触发版本升级)

chore(scope): brief description

Maintenance work that doesn't affect functionality.
Examples: dependency updates, refactoring, docs.
chore(scope): brief description

Maintenance work that doesn't affect functionality.
Examples: dependency updates, refactoring, docs.

Integration with Other Skills

与其他技能的集成

This skill works alongside:
  • Chezmoi Expert - Ensures dotfiles templates don't manually edit versions
  • Git Workflow - Enforces conventional commits before creating PRs
  • GitHub Actions - Aware of release-please workflow configurations
本技能可与以下技能协同工作:
  • Chezmoi Expert - 确保dotfiles模板不会手动修改版本
  • Git Workflow - 在创建PR前强制执行规范提交
  • GitHub Actions - 适配release-please工作流配置

Skill Configuration

技能配置

Located in
dot_claude/skills/release-please-protection/
(source) which becomes
~/.claude/skills/release-please-protection/
after chezmoi apply:
  • SKILL.md
    - This file (skill definition)
  • patterns.md
    - Protected file pattern reference
  • workflow.md
    - Detailed release-please workflow guide
源代码位于
dot_claude/skills/release-please-protection/
,应用chezmoi后会变为
~/.claude/skills/release-please-protection/
  • SKILL.md
    - 本文件(技能定义)
  • patterns.md
    - 受保护文件模式参考
  • workflow.md
    - 详细的release-please工作流指南

Limitations

局限性

What This Skill Cannot Prevent

本技能无法阻止的情况

  1. Explicit overrides - If you explicitly instruct me to edit despite warnings
  2. Out-of-context files - Files not in the current context window
  3. External tools - Commands like
    sed
    ,
    awk
    , or direct bash edits
  4. Git operations - Manual
    git commit
    with modified protected files
  1. 明确覆盖 - 如果您明确指示忽略警告进行编辑
  2. 上下文外文件 - 当前上下文窗口外的文件
  3. 外部工具 - 如
    sed
    awk
    或直接bash编辑命令
  4. Git操作 - 手动
    git commit
    包含修改后的受保护文件

What This Skill DOES Prevent

本技能可以阻止的情况

  1. Accidental edits - Catching mistakes before they happen
  2. Workflow violations - Explaining proper release-please patterns
  3. Merge conflicts - Preventing automated PR conflicts
  4. Version inconsistencies - Maintaining semantic versioning discipline
  1. 意外编辑 - 在错误发生前及时发现
  2. 工作流违规 - 解释正确的release-please使用模式
  3. 合并冲突 - 避免与自动化PR产生冲突
  4. 版本不一致 - 维护语义化版本规范

Emergency Overrides

紧急覆盖方式

If you absolutely must manually edit protected files:
如果您确实需要手动编辑受保护文件:

Temporary Permission Override

临时权限覆盖

bash
undefined
bash
undefined

1. Edit global settings

1. 编辑全局设置

vim ~/.claude/settings.json
vim ~/.claude/settings.json

2. Comment out deny rules

2. 注释掉拒绝规则

"deny": [ "Bash(git add .)", "Bash(git add -A)", "Bash(git add --all)", // "Edit(/CHANGELOG.md)", // "Write(/CHANGELOG.md)", // "MultiEdit(**/CHANGELOG.md)" ]
"deny": [ "Bash(git add .)", "Bash(git add -A)", "Bash(git add --all)", // "Edit(/CHANGELOG.md)", // "Write(/CHANGELOG.md)", // "MultiEdit(**/CHANGELOG.md)" ]

3. Make your edits

3. 进行编辑

4. Re-enable protection (uncomment the lines)

4. 重新启用保护(取消注释)

5. Verify with chezmoi

5. 使用chezmoi验证

chezmoi diff ~/.claude/settings.json chezmoi apply # If template is out of sync
undefined
chezmoi diff ~/.claude/settings.json chezmoi apply # 如果模板不同步
undefined

Skill Bypass (Not Recommended)

技能绕过(不推荐)

bash
undefined
bash
undefined

Temporarily disable skill

临时禁用技能

mv .claude/skills/release-please-protection .claude/skills/release-please-protection.disabled
mv .claude/skills/release-please-protection .claude/skills/release-please-protection.disabled

Make edits

进行编辑

Re-enable

重新启用

mv .claude/skills/release-please-protection.disabled .claude/skills/release-please-protection
undefined
mv .claude/skills/release-please-protection.disabled .claude/skills/release-please-protection
undefined

Success Metrics

成功指标

This skill is working properly when:
✅ All CHANGELOG.md edit attempts are blocked with helpful explanations ✅ Version field modifications trigger warnings and alternatives ✅ Conventional commit suggestions match the requested changes ✅ Users understand the release-please workflow after first warning ✅ No merge conflicts occur with automated release PRs ✅ Version numbers follow semantic versioning consistently
本技能正常工作的表现:
✅ 所有CHANGELOG.md编辑尝试均被阻止并提供有用解释 ✅ 版本字段修改触发警告和替代方案 ✅ 规范提交建议与请求的变更匹配 ✅ 用户在首次警告后理解release-please工作流 ✅ 与自动化发布PR无合并冲突 ✅ 版本号始终遵循语义化版本规范

Further Reading

扩展阅读