Loading...
Loading...
Compare original and translation side by side
.env*credentials**secret**.pem*.key.npmrc.pypirc.env*credentials**secret**.pem*.key.npmrc.pypirc<type>[scope]: <description><type>[scope]: <description>--auto-stage--skip-validation--dry-run--push--auto-stage--skip-validation--dry-run--pushgit commit --amendgit commit --amendgit status --porcelain
git rev-parse --abbrev-ref HEAD.git/MERGE_HEAD.git/rebase-merge/references/banned-patterns.mdundefinedgit status --porcelain
git rev-parse --abbrev-ref HEAD.git/MERGE_HEAD.git/rebase-merge/references/banned-patterns.mdundefined
If sensitive files detected: display them, suggest `.gitignore` additions, and HARD STOP until resolved.
**Step 3: Load CLAUDE.md rules**
Read repository CLAUDE.md to extract:
- Banned commit message patterns
- Conventional commit requirements
- Custom commit rules
If no CLAUDE.md exists, use defaults: ban "Generated with Claude Code" and "Co-Authored-By: Claude".
**Step 4: Check branch state**
If on `main` or `master`: warn user and require explicit confirmation before proceeding.
**Gate**: All checks pass. No sensitive files, no merge/rebase state, CLAUDE.md loaded.
若检测到敏感文件:展示这些文件,建议添加到`.gitignore`,并直接终止流程直至问题解决。
**步骤3:加载CLAUDE.md规则**
读取仓库的CLAUDE.md文件,提取:
- 禁用的提交消息模式
- 规范化提交要求
- 自定义提交规则
若不存在CLAUDE.md文件,则使用默认规则:禁止「Generated with Claude Code」和「Co-Authored-By: Claude」。
**步骤4:检查分支状态**
若当前分支为`main`或`master`:向用户发出警告并要求明确确认后再继续。
**门控要求**:所有检查通过。无敏感文件、无合并/变基操作进行中、已加载CLAUDE.md规则。git status --porcelainMAD??references/staging-rules.md| Category | Patterns | Commit Prefix |
|---|---|---|
| Documentation | | |
| Source code | | |
| Configuration | | |
| Tests | | |
| CI/Build | | |
git add <files>git status --porcelainMAD??references/staging-rules.md| 分类 | 匹配模式 | 提交前缀 |
|---|---|---|
| 文档 | | |
| 源代码 | | |
| 配置文件 | | |
| 测试文件 | | |
| CI/构建文件 | | |
git add <files>undefinedundefined
Check:
- Conventional commit format: `<type>[scope]: <description>` (see `references/conventional-commits.md`)
- No banned patterns (see `references/banned-patterns.md`)
- Subject line: lowercase after type, no trailing period, max 72 chars, imperative mood
- Body: separated by blank line, wrapped at 72 chars
If validation fails with CRITICAL (banned pattern): block commit, show suggested revision.
If validation fails with WARNING (line length): show warning, allow user to proceed or revise.
**Step 3: Execute commit**
Use heredoc format to preserve multi-line messages:
```bash
git commit -m "$(cat <<'EOF'
<type>: <subject>
<body>
EOF
)"
检查内容:
- 规范化提交格式:`<type>[scope]: <description>`(参考`references/conventional-commits.md`)
- 无禁用模式(参考`references/banned-patterns.md`)
- 主题行:类型后为小写、无结尾句号、最长72字符、使用祈使语气
- 正文:与主题行空一行分隔、每行最多72字符
若验证出现严重错误(包含禁用模式):阻止提交,展示建议的修改方案。
若验证出现警告(行长度问题):展示警告,允许用户选择继续或修改。
**步骤3:执行提交操作**
使用heredoc格式保留多行消息:
```bash
git commit -m "$(cat <<'EOF'
<type>: <subject>
<body>
EOF
)"git log -1 --format="%H %s"git status --porcelaingit log -1 --format="%B"git log -1 --format="%H %s"git status --porcelaingit log -1 --format="%B"feat: add user authenticationfeat: add user authenticationskill: git-commit-flow --message "fix: apply PR review feedback"skill: git-commit-flow --message "fix: apply PR review feedback"skill: git-commit-flow --dry-runskill: git-commit-flow --dry-run.env*credentials**.key.gitignoreecho ".env" >> .gitignoregit reset HEAD .envgit rm --cached .env.env*credentials**.key.gitignoreecho ".env" >> .gitignoregit reset HEAD .envgit rm --cached .envreferences/banned-patterns.mdreferences/banned-patterns.mdgit add -ugit add -ugit merge --abortgit rebase --abortgit merge --abortgit rebase --abortgit add . && git commit -m "update files"git add . && git commit -m "update files"git add .git bisectgit add .git bisectmainmain.env.gitignoregit stashgit stash popgit diffgit stashgit stash popgit diff| 合理化借口 | 问题所在 | 要求操作 |
|---|---|---|
| "快速提交,不需要验证" | 快速提交可能泄露凭证 | 运行全部4个阶段 |
| "只是文档,跳过敏感文件扫描" | 文档提交可能包含 | 验证每一次提交 |
| "我之后再修改消息" | 之后永远不会做;提交历史是永久的 | 现在就验证消息 |
| "这个小改动直接提交到主分支没问题" | 小改动也可能引发大问题 | 创建功能分支 |
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "Quick commit, no need to validate" | Quick commits leak credentials | Run all 4 phases |
| "It's just docs, skip sensitive scan" | Docs commits can include | Validate every commit |
| "I'll fix the message later" | Later never comes; history is permanent | Validate message now |
| "Main branch is fine for this small change" | Small changes cause big problems | Create feature branch |
${CLAUDE_SKILL_DIR}/references/conventional-commits.md${CLAUDE_SKILL_DIR}/references/banned-patterns.md${CLAUDE_SKILL_DIR}/references/staging-rules.md${CLAUDE_SKILL_DIR}/references/commit-workflow-examples.md${CLAUDE_SKILL_DIR}/references/conventional-commits.md${CLAUDE_SKILL_DIR}/references/banned-patterns.md${CLAUDE_SKILL_DIR}/references/staging-rules.md${CLAUDE_SKILL_DIR}/references/commit-workflow-examples.md