creating-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese⚠️ CRITICAL CONSTRAINTS
⚠️ 重要约束
No Claude Code Footer Policy
无Claude Code页脚政策
YOU MUST NEVER add Claude Code attribution to git commits.
- ❌ NO "🤖 Generated with [Claude Code]" in commit messages
- ❌ NO "Co-Authored-By: Claude noreply@anthropic.com" in commit messages
- ❌ NO Claude Code attribution, footer, or branding of any kind
Git commits are permanent project history and must remain clean and professional.
绝对禁止在Git提交中添加Claude Code署名。
- ❌ 提交信息中禁止出现“🤖 Generated with [Claude Code]”
- ❌ 提交信息中禁止出现“Co-Authored-By: Claude noreply@anthropic.com”
- ❌ 禁止任何形式的Claude Code署名、页脚或品牌标识
Git提交是项目的永久历史记录,必须保持简洁专业。
Git Commit Workflow
Git提交工作流
Execute intelligent git commit workflows with automatic repository detection, smart pre-commit checks, and conventional commit message generation.
执行智能Git提交工作流,包含自动仓库检测、智能预提交检查和规范提交信息生成。
Usage
使用场景
This skill is invoked when:
- User runs command
/commit - User requests to commit changes
- User asks to create a git commit
当以下情况触发此技能:
- 用户运行命令
/commit - 用户请求提交更改
- 用户要求创建Git提交
How It Works
工作原理
This skill handles the complete commit workflow:
- Repository Detection - Automatically detects root repository and submodules
- Change Analysis - Identifies modified files and determines scope
- Pre-commit Checks - Runs appropriate checks based on file types
- Commit Message Generation - Creates conventional commit messages with emojis
- Submodule Handling - Prompts to update submodule references in root repository
此技能处理完整的提交工作流:
- 仓库检测 - 自动检测根仓库和子模块
- 变更分析 - 识别已修改文件并确定范围
- 预提交检查 - 根据文件类型运行相应检查
- 提交信息生成 - 创建带有表情符号的规范提交信息
- 子模块处理 - 提示更新根仓库中的子模块引用
Supported Arguments
支持的参数
Parse arguments from user input:
- No arguments: Interactive mode (auto-detect changes)
- : Direct commit to specific repository (root, submodule-name)
<scope> - : Skip all pre-commit checks
--no-verify - : Run full builds (backend + frontend)
--full-verify - : Combine scope with flags
<scope> --no-verify
从用户输入中解析参数:
- 无参数:交互模式(自动检测变更)
- :直接提交到特定仓库(root、子模块名称)
<scope> - :跳过所有预提交检查
--no-verify - :运行完整构建(后端+前端)
--full-verify - :结合范围与标志
<scope> --no-verify
Commit Workflow Steps
提交工作流步骤
Step 1: Parse Arguments
步骤1:解析参数
Extract scope and flags from user input:
bash
undefined从用户输入中提取范围和标志:
bash
undefinedParse arguments
Parse arguments
SCOPE=""
FLAG=""
SCOPE=""
FLAG=""
Example parsing logic (adapt to user input):
Example parsing logic (adapt to user input):
"root --no-verify" → SCOPE="root", FLAG="--no-verify"
"root --no-verify" → SCOPE="root", FLAG="--no-verify"
"plan" → SCOPE="plan", FLAG=""
"plan" → SCOPE="plan", FLAG=""
"--full-verify" → SCOPE="", FLAG="--full-verify"
"--full-verify" → SCOPE="", FLAG="--full-verify"
undefinedundefinedStep 2: Detect Repositories with Changes
步骤2:检测存在变更的仓库
Find monorepo root and detect all repositories with uncommitted changes:
bash
undefined找到单体仓库根目录并检测所有存在未提交变更的仓库:
bash
undefinedFind monorepo root (works from submodules too)
Find monorepo root (works from submodules too)
if SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null) && [ -n "$SUPERPROJECT" ]; then
# We're in a submodule
MONOREPO_ROOT="$SUPERPROJECT"
else
# We're in root or standalone repo
MONOREPO_ROOT=$(git rev-parse --show-toplevel)
fi
if SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null) && [ -n "$SUPERPROJECT" ]; then
# We're in a submodule
MONOREPO_ROOT="$SUPERPROJECT"
else
# We're in root or standalone repo
MONOREPO_ROOT=$(git rev-parse --show-toplevel)
fi
Detect repositories with changes
Detect repositories with changes
REPOS_WITH_CHANGES=()
REPOS_WITH_CHANGES=()
Check root repository
Check root repository
if git -C "$MONOREPO_ROOT" status --porcelain | grep -q .; then
REPOS_WITH_CHANGES+=("root")
fi
if git -C "$MONOREPO_ROOT" status --porcelain | grep -q .; then
REPOS_WITH_CHANGES+=("root")
fi
Check for submodules and their changes
Check for submodules and their changes
git -C "$MONOREPO_ROOT" submodule foreach --quiet 'echo $name' | while read -r submodule; do
SUBMODULE_PATH="$MONOREPO_ROOT/$submodule"
if git -C "$SUBMODULE_PATH" status --porcelain | grep -q .; then
REPOS_WITH_CHANGES+=("$submodule")
fi
done
undefinedgit -C "$MONOREPO_ROOT" submodule foreach --quiet 'echo $name' | while read -r submodule; do
SUBMODULE_PATH="$MONOREPO_ROOT/$submodule"
if git -C "$SUBMODULE_PATH" status --porcelain | grep -q .; then
REPOS_WITH_CHANGES+=("$submodule")
fi
done
undefinedStep 3: Select Target Repository
步骤3:选择目标仓库
If no scope specified, select repository interactively or automatically:
bash
undefined如果未指定范围,交互式或自动选择仓库:
bash
undefinedIf only one repository has changes, auto-select it
If only one repository has changes, auto-select it
if [ ${#REPOS_WITH_CHANGES[@]} -eq 1 ]; then
SCOPE="${REPOS_WITH_CHANGES[0]}"
echo "ℹ️ Auto-selected: $SCOPE (only repository with changes)"
elif [ ${#REPOS_WITH_CHANGES[@]} -gt 1 ]; then
# Multiple repositories - ask user to select
echo "Found changes in:"
for i in "${!REPOS_WITH_CHANGES[@]}"; do
REPO="${REPOS_WITH_CHANGES[$i]}"
REPO_PATH=$([ "$REPO" = "root" ] && echo "$MONOREPO_ROOT" || echo "$MONOREPO_ROOT/$REPO")
CHANGE_COUNT=$(git -C "$REPO_PATH" status --porcelain | wc -l | tr -d ' ')
echo "$((i+1)). $REPO ($CHANGE_COUNT files modified)"
done
# Use AskUserQuestion tool to let user select repository
# Set SCOPE to selected repository namefi
undefinedif [ ${#REPOS_WITH_CHANGES[@]} -eq 1 ]; then
SCOPE="${REPOS_WITH_CHANGES[0]}"
echo "ℹ️ 自动选择:$SCOPE(唯一存在变更的仓库)"
elif [ ${#REPOS_WITH_CHANGES[@]} -gt 1 ]; then
# Multiple repositories - ask user to select
echo "发现变更的仓库:"
for i in "${!REPOS_WITH_CHANGES[@]}"; do
REPO="${REPOS_WITH_CHANGES[$i]}"
REPO_PATH=$([ "$REPO" = "root" ] && echo "$MONOREPO_ROOT" || echo "$MONOREPO_ROOT/$REPO")
CHANGE_COUNT=$(git -C "$REPO_PATH" status --porcelain | wc -l | tr -d ' ')
echo "$((i+1)). $REPO($CHANGE_COUNT个文件已修改)"
done
# 使用AskUserQuestion工具让用户选择仓库
# 将SCOPE设置为选中的仓库名称fi
undefinedStep 4: Resolve Repository Path
步骤4:解析仓库路径
Convert scope to absolute path:
bash
undefined将范围转换为绝对路径:
bash
undefinedResolve scope to repository path
Resolve scope to repository path
if [ "$SCOPE" = "root" ]; then
REPO_PATH="$MONOREPO_ROOT"
else
# Submodule or custom scope
REPO_PATH="$MONOREPO_ROOT/$SCOPE"
fi
if [ "$SCOPE" = "root" ]; then
REPO_PATH="$MONOREPO_ROOT"
else
# Submodule or custom scope
REPO_PATH="$MONOREPO_ROOT/$SCOPE"
fi
Validate repository exists
Validate repository exists
if [ ! -d "$REPO_PATH/.git" ]; then
echo "❌ Error: Not a valid git repository: $REPO_PATH" >&2
exit 1
fi
undefinedif [ ! -d "$REPO_PATH/.git" ]; then
echo "❌ 错误:不是有效的Git仓库:$REPO_PATH" >&2
exit 1
fi
undefinedStep 5: Check Branch Protection
步骤5:检查分支保护
Validate not on protected branch (main branch for root only):
bash
undefined验证当前不在受保护分支(仅根仓库的主分支):
bash
undefinedGet current branch
Get current branch
CURRENT_BRANCH=$(git -C "$REPO_PATH" rev-parse --abbrev-ref HEAD)
CURRENT_BRANCH=$(git -C "$REPO_PATH" rev-parse --abbrev-ref HEAD)
Check branch protection (only enforce for root repository)
Check branch protection (only enforce for root repository)
if [ "$CURRENT_BRANCH" = "main" ] && [ "$SCOPE" = "root" ]; then
echo "❌ Cannot commit to protected branch: main" >&2
echo "" >&2
echo "The main branch requires pull requests." >&2
echo "Please create a feature branch first:" >&2
echo "" >&2
echo " git checkout -b feature/your-feature-name" >&2
echo "" >&2
exit 1
fi
undefinedif [ "$CURRENT_BRANCH" = "main" ] && [ "$SCOPE" = "root" ]; then
echo "❌ 无法提交到受保护分支:main" >&2
echo "" >&2
echo "主分支需要通过拉取请求提交。" >&2
echo "请先创建功能分支:" >&2
echo "" >&2
echo " git checkout -b feature/your-feature-name" >&2
echo "" >&2
exit 1
fi
undefinedStep 6: Stage Files
步骤6:暂存文件
Stage all unstaged changes or use already-staged files:
bash
undefined暂存所有未暂存的变更或使用已暂存的文件:
bash
undefinedCheck if there are already staged files
Check if there are already staged files
STAGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
if [ -z "$STAGED_FILES" ]; then
# No staged files - stage all changes
echo "Staging all changes..."
git -C "$REPO_PATH" add -A
# Verify staging worked
STAGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
if [ -z "$STAGED_FILES" ]; then
echo "❌ No changes to commit" >&2
exit 1
fielse
echo "ℹ️ Using already staged files"
fi
STAGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
if [ -z "$STAGED_FILES" ]; then
# No staged files - stage all changes
echo "暂存所有变更..."
git -C "$REPO_PATH" add -A
# Verify staging worked
STAGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
if [ -z "$STAGED_FILES" ]; then
echo "❌ 无变更可提交" >&2
exit 1
fielse
echo "ℹ️ 使用已暂存的文件"
fi
Show what will be committed
Show what will be committed
git -C "$REPO_PATH" status --short
undefinedgit -C "$REPO_PATH" status --short
undefinedStep 7: Run Pre-commit Checks
步骤7:运行预提交检查
Execute pre-commit checks based on changed file types and flags:
bash
undefined根据变更文件类型和标志执行预提交检查:
bash
undefinedSkip checks if --no-verify flag is set
Skip checks if --no-verify flag is set
if [ "$FLAG" = "--no-verify" ]; then
echo "⚠️ Skipping pre-commit checks (--no-verify flag)"
elif [ "$SCOPE" = "plan" ] || [[ "$SCOPE" == "doc" ]]; then
echo "ℹ️ Skipping checks for documentation repository"
elif [ "$FLAG" = "--full-verify" ]; then
# Full build verification
echo "Running full build verification..."
if [ -d "$MONOREPO_ROOT/backend" ]; then
echo "Building backend..."
(cd "$MONOREPO_ROOT/backend" && ./gradlew build test) || {
echo "❌ Backend build failed" >&2
exit 1
}
fi
if [ -d "$MONOREPO_ROOT/frontend" ]; then
echo "Building frontend..."
(cd "$MONOREPO_ROOT/frontend" && npm run build) || {
echo "❌ Frontend build failed" >&2
exit 1
}
fi
echo "✅ Full build verification passed"else
# Smart detection - run checks based on file types
CHANGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
# Detect Kotlin files
if echo "$CHANGED_FILES" | grep -q '\.kt$'; then
echo "Running backend checks (Kotlin files detected)..."
if [ -f "$MONOREPO_ROOT/backend/gradlew" ]; then
(cd "$MONOREPO_ROOT/backend" && ./gradlew detekt) || {
echo "❌ Kotlin checks failed" >&2
exit 1
}
fi
fi
# Detect TypeScript/JavaScript files
if echo "$CHANGED_FILES" | grep -qE '\.(ts|tsx|js|jsx)$'; then
echo "Running frontend checks (TypeScript files detected)..."
if [ -f "$MONOREPO_ROOT/frontend/package.json" ]; then
(cd "$MONOREPO_ROOT/frontend" && npx tsc --noEmit) || {
echo "❌ TypeScript checks failed" >&2
exit 1
}
fi
fi
# Detect Python files
if echo "$CHANGED_FILES" | grep -q '\.py$'; then
echo "Running Python checks..."
# Add Python linting if configured (e.g., pylint, flake8)
fi
# Detect Rust files
if echo "$CHANGED_FILES" | grep -q '\.rs$'; then
echo "Running Rust checks..."
if [ -f "$REPO_PATH/Cargo.toml" ]; then
(cd "$REPO_PATH" && cargo check) || {
echo "❌ Rust checks failed" >&2
exit 1
}
fi
fi
echo "✅ Pre-commit checks passed"fi
undefinedif [ "$FLAG" = "--no-verify" ]; then
echo "⚠️ 跳过预提交检查(--no-verify标志)"
elif [ "$SCOPE" = "plan" ] || [[ "$SCOPE" == "doc" ]]; then
echo "ℹ️ 跳过文档仓库的检查"
elif [ "$FLAG" = "--full-verify" ]; then
# Full build verification
echo "运行完整构建验证..."
if [ -d "$MONOREPO_ROOT/backend" ]; then
echo "构建后端..."
(cd "$MONOREPO_ROOT/backend" && ./gradlew build test) || {
echo "❌ 后端构建失败" >&2
exit 1
}
fi
if [ -d "$MONOREPO_ROOT/frontend" ]; then
echo "构建前端..."
(cd "$MONOREPO_ROOT/frontend" && npm run build) || {
echo "❌ 前端构建失败" >&2
exit 1
}
fi
echo "✅ 完整构建验证通过"else
# Smart detection - run checks based on file types
CHANGED_FILES=$(git -C "$REPO_PATH" diff --cached --name-only)
# Detect Kotlin files
if echo "$CHANGED_FILES" | grep -q '\.kt$'; then
echo "运行后端检查(检测到Kotlin文件)..."
if [ -f "$MONOREPO_ROOT/backend/gradlew" ]; then
(cd "$MONOREPO_ROOT/backend" && ./gradlew detekt) || {
echo "❌ Kotlin检查失败" >&2
exit 1
}
fi
fi
# Detect TypeScript/JavaScript files
if echo "$CHANGED_FILES" | grep -qE '\.(ts|tsx|js|jsx)$'; then
echo "运行前端检查(检测到TypeScript文件)..."
if [ -f "$MONOREPO_ROOT/frontend/package.json" ]; then
(cd "$MONOREPO_ROOT/frontend" && npx tsc --noEmit) || {
echo "❌ TypeScript检查失败" >&2
exit 1
}
fi
fi
# Detect Python files
if echo "$CHANGED_FILES" | grep -q '\.py$'; then
echo "运行Python检查..."
# Add Python linting if configured (e.g., pylint, flake8)
fi
# Detect Rust files
if echo "$CHANGED_FILES" | grep -q '\.rs$'; then
echo "运行Rust检查..."
if [ -f "$REPO_PATH/Cargo.toml" ]; then
(cd "$REPO_PATH" && cargo check) || {
echo "❌ Rust检查失败" >&2
exit 1
}
fi
fi
echo "✅ 预提交检查通过"fi
undefinedStep 8: Generate Commit Message
步骤8:生成提交信息
Analyze changes and create conventional commit message:
bash
undefined分析变更并创建规范提交信息:
bash
undefinedDetect commit type from changed files
Detect commit type from changed files
DIFF_STAT=$(git -C "$REPO_PATH" diff --cached --stat)
DIFF_STAT=$(git -C "$REPO_PATH" diff --cached --stat)
Simple heuristic based on file patterns
Simple heuristic based on file patterns
if echo "$DIFF_STAT" | grep -q "test|spec"; then
COMMIT_TYPE="test"
EMOJI="✅"
elif echo "$DIFF_STAT" | grep -q ".md|README|docs/"; then
COMMIT_TYPE="docs"
EMOJI="📝"
elif echo "$DIFF_STAT" | grep -qE "build.gradle|package.json|pom.xml|Cargo.toml"; then
COMMIT_TYPE="build"
EMOJI="🏗️"
elif echo "$DIFF_STAT" | grep -qE ".github|.gitlab|Jenkinsfile|.circleci"; then
COMMIT_TYPE="ci"
EMOJI="👷"
elif echo "$DIFF_STAT" | grep -q "refactor"; then
COMMIT_TYPE="refactor"
EMOJI="♻️"
elif echo "$DIFF_STAT" | grep -q "fix|bug"; then
COMMIT_TYPE="fix"
EMOJI="🐛"
else
# Default to feat for most changes
COMMIT_TYPE="feat"
EMOJI="✨"
fi
if echo "$DIFF_STAT" | grep -q "test|spec"; then
COMMIT_TYPE="test"
EMOJI="✅"
elif echo "$DIFF_STAT" | grep -q ".md|README|docs/"; then
COMMIT_TYPE="docs"
EMOJI="📝"
elif echo "$DIFF_STAT" | grep -qE "build.gradle|package.json|pom.xml|Cargo.toml"; then
COMMIT_TYPE="build"
EMOJI="🏗️"
elif echo "$DIFF_STAT" | grep -qE ".github|.gitlab|Jenkinsfile|.circleci"; then
COMMIT_TYPE="ci"
EMOJI="👷"
elif echo "$DIFF_STAT" | grep -q "refactor"; then
COMMIT_TYPE="refactor"
EMOJI="♻️"
elif echo "$DIFF_STAT" | grep -q "fix|bug"; then
COMMIT_TYPE="fix"
EMOJI="🐛"
else
# Default to feat for most changes
COMMIT_TYPE="feat"
EMOJI="✨"
fi
Analyze the actual changes to generate a meaningful description
Analyze the actual changes to generate a meaningful description
CHANGED_FILES_LIST=$(git -C "$REPO_PATH" diff --cached --name-only)
ADDITIONS=$(git -C "$REPO_PATH" diff --cached --numstat | awk '{sum+=$1} END {print sum}')
DELETIONS=$(git -C "$REPO_PATH" diff --cached --numstat | awk '{sum+=$2} END {print sum}')
CHANGED_FILES_LIST=$(git -C "$REPO_PATH" diff --cached --name-only)
ADDITIONS=$(git -C "$REPO_PATH" diff --cached --numstat | awk '{sum+=$1} END {print sum}')
DELETIONS=$(git -C "$REPO_PATH" diff --cached --numstat | awk '{sum+=$2} END {print sum}')
Generate commit message based on changes
Generate commit message based on changes
You should analyze the diff and create a concise, meaningful message
You should analyze the diff and create a concise, meaningful message
For now, this is a template - Claude should intelligently describe the changes
For now, this is a template - Claude should intelligently describe the changes
COMMIT_SUBJECT="$COMMIT_TYPE: [brief description of changes]"
COMMIT_BODY="[optional detailed explanation]
Changes:
$CHANGED_FILES_LIST
$ADDITIONS additions, $DELETIONS deletions"
COMMIT_SUBJECT="$COMMIT_TYPE: [变更简要描述]"
COMMIT_BODY="[可选详细说明]
变更文件:
$CHANGED_FILES_LIST
新增$ADDITIONS行,删除$DELETIONS行"
Present commit message to user for approval
Present commit message to user for approval
echo ""
echo "Suggested commit message:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "$EMOJI $COMMIT_SUBJECT"
echo ""
echo "$COMMIT_BODY"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo ""
echo "建议的提交信息:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "$EMOJI $COMMIT_SUBJECT"
echo ""
echo "$COMMIT_BODY"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
Use AskUserQuestion tool to confirm or let user edit the message
使用AskUserQuestion工具确认或让用户编辑信息
undefinedundefinedStep 9: Create Commit
步骤9:创建提交
Execute git commit with the approved message:
bash
undefined使用已确认的信息执行Git提交:
bash
undefinedIMPORTANT: No Claude Code footer in commit messages
IMPORTANT: No Claude Code footer in commit messages
Create commit with clean message only
Create commit with clean message only
git -C "$REPO_PATH" commit -m "$COMMIT_SUBJECT" -m "$COMMIT_BODY" || {
echo "❌ Commit failed" >&2
exit 1
}
git -C "$REPO_PATH" commit -m "$COMMIT_SUBJECT" -m "$COMMIT_BODY" || {
echo "❌ 提交失败" >&2
exit 1
}
Get commit hash
Get commit hash
COMMIT_HASH=$(git -C "$REPO_PATH" rev-parse --short HEAD)
echo "✅ Commit created: $COMMIT_HASH"
echo ""
git -C "$REPO_PATH" log -1 --oneline
undefinedCOMMIT_HASH=$(git -C "$REPO_PATH" rev-parse --short HEAD)
echo "✅ 提交已创建:$COMMIT_HASH"
echo ""
git -C "$REPO_PATH" log -1 --oneline
undefinedStep 10: Handle Submodule References (if applicable)
步骤10:处理子模块引用(如适用)
If committed to a submodule, prompt to update root repository:
bash
undefined如果提交到子模块,提示更新根仓库:
bash
undefinedIf we committed to a submodule, check if root needs update
If we committed to a submodule, check if root needs update
if [ "$SCOPE" != "root" ]; then
# Check if submodule reference changed in root
SUBMODULE_REF_CHANGED=$(git -C "$MONOREPO_ROOT" status --porcelain | grep "^ M $SCOPE$")
if [ -n "$SUBMODULE_REF_CHANGED" ]; then
echo ""
echo "ℹ️ Submodule reference changed in root repository"
echo ""
# Use AskUserQuestion to ask if they want to commit the submodule reference
# If yes:
# git -C "$MONOREPO_ROOT" add "$SCOPE"
# git -C "$MONOREPO_ROOT" commit -m "build: update $SCOPE submodule reference"
fifi
undefinedif [ "$SCOPE" != "root" ]; then
# Check if submodule reference changed in root
SUBMODULE_REF_CHANGED=$(git -C "$MONOREPO_ROOT" status --porcelain | grep "^ M $SCOPE$")
if [ -n "$SUBMODULE_REF_CHANGED" ]; then
echo ""
echo "ℹ️ 根仓库中的子模块引用已变更"
echo ""
# 使用AskUserQuestion询问是否要提交子模块引用
# 如果是:
# git -C "$MONOREPO_ROOT" add "$SCOPE"
# git -C "$MONOREPO_ROOT" commit -m "build: update $SCOPE submodule reference"
fifi
undefinedCommit Type Detection
提交类型检测
The skill automatically detects commit types based on file patterns:
| Pattern | Type | Emoji |
|---|---|---|
| test/spec files | | ✅ |
| .md/README/docs/ | | 📝 |
| build files (package.json, Cargo.toml, etc.) | | 🏗️ |
| CI/CD files (.github, Jenkinsfile) | | 👷 |
| Files with "refactor" | | ♻️ |
| Files with "fix" or "bug" | | 🐛 |
| Default | | ✨ |
技能根据文件模式自动检测提交类型:
| 模式 | 类型 | 表情符号 |
|---|---|---|
| test/spec文件 | | ✅ |
| .md/README/docs/ | | 📝 |
| 构建文件(package.json, Cargo.toml等) | | 🏗️ |
| CI/CD文件(.github, Jenkinsfile) | | 👷 |
| 包含"refactor"的文件 | | ♻️ |
| 包含"fix"或"bug"的文件 | | 🐛 |
| 默认 | | ✨ |
Pre-commit Check Matrix
预提交检查矩阵
| File Type | Check Command | When |
|---|---|---|
| | Unless --no-verify |
| | Unless --no-verify |
| Configurable linting | Unless --no-verify |
| | Unless --no-verify |
Documentation ( | Skip checks | Always |
| Full verify flag | | When --full-verify |
| 文件类型 | 检查命令 | 执行条件 |
|---|---|---|
| | 除非使用--no-verify |
| | 除非使用--no-verify |
| 可配置的代码检查 | 除非使用--no-verify |
| | 除非使用--no-verify |
文档( | 跳过检查 | 始终 |
| 完整验证标志 | | 使用--full-verify时 |
Important Notes
重要说明
- Multi-repo/Submodule Support: Automatically detects and handles monorepo structures
- Branch Protection: Prevents commits to main branch in root repository
- Smart Checks: Only runs checks relevant to changed file types
- No External Dependencies: All logic uses git commands and Bash tool
- Clean Commit History: No Claude Code attribution in commit messages
- 多仓库/子模块支持:自动检测并处理单体仓库结构
- 分支保护:禁止提交到根仓库的main分支
- 智能检查:仅运行与变更文件类型相关的检查
- 无外部依赖:所有逻辑使用Git命令和Bash工具
- 干净的提交历史:提交信息中无Claude Code署名
Supporting Documentation
相关文档
For detailed information, see:
- WORKFLOW.md - Step-by-step commit process including repository detection, pre-commit checks, and submodule handling
- EXAMPLES.md - Real-world commit scenarios covering features, bug fixes, submodules, and verification modes
- TROUBLESHOOTING.md - Common issues and solutions for pre-commit failures and submodule conflicts
如需详细信息,请参阅:
- WORKFLOW.md - 包含仓库检测、预提交检查和子模块处理的分步提交流程
- EXAMPLES.md - 涵盖功能、 bug修复、子模块和验证模式的真实提交场景
- TROUBLESHOOTING.md - 预提交失败和子模块冲突的常见问题及解决方案