config-git

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Interactive Git Configuration

交互式Git配置

Set up Git user identity and create
.claude/git.local.md
with conventional commit scopes, types, and branch naming conventions.
Current Git Config Context: !
git config --list --show-origin

设置Git用户身份并创建
.claude/git.local.md
文件,包含约定式提交的范围、类型以及分支命名规范。
当前Git配置上下文: !
git config --list --show-origin

Phase 1: Verify User Identity

阶段1:验证用户身份

Goal: Ensure git user.name and user.email are configured
Actions:
  1. Review the "Current Git Config Context" above
  2. Check if
    user.name
    and
    user.email
    are set
  3. If EITHER is missing, use
    AskUserQuestion
    to request the missing information
  4. Set the values globally (or locally if user specifies) using
    git config

目标:确保已配置git user.name和user.email
操作
  1. 查看上方的「当前Git配置上下文」
  2. 检查是否已设置
    user.name
    user.email
  3. 若其中任意一项缺失,使用
    AskUserQuestion
    请求用户提供缺失的信息
  4. 使用
    git config
    全局设置(或按用户指定的本地设置)对应的值

Phase 2: Analyze Project Context

阶段2:分析项目上下文

Goal: Understand project structure and existing commit patterns
Actions:
  1. Run
    ls -F
    or
    find . -maxdepth 2 -not -path '*/.*'
    to detect project languages/frameworks
  2. Run
    git log --format="%s" -n 50
    (if git repo exists) to analyze existing commit message patterns and scopes

目标:了解项目结构和现有提交模式
操作
  1. 运行
    ls -F
    find . -maxdepth 2 -not -path '*/.*'
    检测项目使用的语言/框架
  2. (若Git仓库已存在)运行
    git log --format="%s" -n 50
    分析现有提交消息的模式和范围

Phase 3: Determine Scopes

阶段3:确定提交范围

Goal: Generate appropriate commit scopes based on project structure
CRITICAL - Scope Naming Rules:
  • ALL scopes MUST be short (single words or abbreviations only)
  • Single words: use as-is (e.g.,
    <word1>
    ,
    <word2>
    ,
    <word3>
    )
  • Multi-word names: MUST convert to first letters (e.g.,
    <multi-word-name>
    <mwn>
    ,
    <another-example>
    <ae>
    )
  • MUST NOT use full multi-word names like
    <multi-word-name>
    or
    <another-example>
    as scopes
Actions:
  1. Propose a list of commit scopes based on analysis
  2. Ensure all scopes follow the naming rules above
  3. Request user input ONLY if genuine ambiguity exists

目标:根据项目结构生成合适的提交范围
重要 - 范围命名规则
  • 所有范围必须简短(仅允许单个单词或缩写)
  • 单个单词:直接使用(例如:
    <word1>
    <word2>
    <word3>
  • 多单词名称:必须转换为首字母缩写(例如:
    <multi-word-name>
    <mwn>
    <another-example>
    <ae>
  • 禁止使用
    <multi-word-name>
    <another-example>
    这类完整的多单词名称作为范围
操作
  1. 根据分析结果提交一份提交范围列表
  2. 确保所有范围都符合上述命名规则
  3. 仅在存在真正的歧义时才请求用户输入

Phase 4: Generate Configuration File

阶段4:生成配置文件

Goal: Create
.claude/git.local.md
with complete structure from example template
CRITICAL - Template Requirements:
  • Use the ENTIRE example file structure as template
  • Preserve ALL sections from the example:
    • YAML frontmatter with
      scopes
      ,
      types
      ,
      branch_prefixes
      , AND
      gitignore
    • "# Project-Specific Git Settings" section
    • "## Usage" section with all bullet points
    • "## Additional Guidelines" section with all bullet points
Actions:
  1. Read the example configuration file:
    ${CLAUDE_PLUGIN_ROOT}/examples/git.local.md
  2. Replace the
    scopes
    list with determined short scopes
  3. Update
    gitignore
    technologies based on detected project languages/frameworks
  4. Keep
    types
    as standard conventional commit types (unless user requests changes)
  5. Keep
    branch_prefixes
    as shown in example (unless user requests changes)
  6. Create or overwrite
    .claude/git.local.md
    in the project root
  7. Read the file back to verify it matches the example's complete structure
Output:
.claude/git.local.md
file with project-specific configuration

目标:参考示例模板创建结构完整的
.claude/git.local.md
文件
重要 - 模板要求
  • 必须使用示例文件的完整结构作为模板
  • 保留示例中的所有章节:
    • 包含
      scopes
      types
      branch_prefixes
      gitignore
      的YAML前置元数据
    • 「# 项目专属Git设置」章节
    • 「## 使用方法」章节及所有要点
    • 「## 额外指南」章节及所有要点
操作
  1. 读取示例配置文件:
    ${CLAUDE_PLUGIN_ROOT}/examples/git.local.md
  2. scopes
    列表替换为已确定的简短范围
  3. 根据检测到的项目语言/框架更新
    gitignore
    对应的技术项
  4. 保留标准的约定式提交类型作为
    types
    (除非用户要求修改)
  5. 保留示例中显示的
    branch_prefixes
    (除非用户要求修改)
  6. 在项目根目录创建或覆盖
    .claude/git.local.md
    文件
  7. 重新读取文件以验证其结构与示例完全匹配
输出:包含项目专属配置的
.claude/git.local.md
文件

Phase 5: Confirmation

阶段5:确认配置完成

Goal: Inform user of successful configuration
Actions:
  1. Confirm configuration is complete
  2. Show the location of the created file
目标:通知用户配置已成功完成
操作
  1. 确认配置已完成
  2. 告知用户已创建文件的位置