commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Smart Commit

智能提交

Simple, validated commit creation. Run checks locally, no agents needed for standard commits.
简单、经过验证的提交创建方式。本地运行检查,标准提交无需使用Agent。

Quick Start

快速开始

bash
/commit
bash
/commit

Workflow

工作流

Phase 1: Pre-Commit Safety Check

阶段1:提交前安全检查

bash
undefined
bash
undefined

CRITICAL: Verify we're not on dev/main

CRITICAL: Verify we're not on dev/main

BRANCH=$(git branch --show-current) if [[ "$BRANCH" == "dev" || "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then echo "STOP! Cannot commit directly to $BRANCH" echo "Create a feature branch: git checkout -b issue/<number>-<description>" exit 1 fi
undefined
BRANCH=$(git branch --show-current) if [[ "$BRANCH" == "dev" || "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then echo "STOP! Cannot commit directly to $BRANCH" echo "Create a feature branch: git checkout -b issue/<number>-<description>" exit 1 fi
undefined

Phase 2: Run Validation Locally

阶段2:本地运行验证

Run every check that CI runs:
bash
undefined
运行CI会执行的所有检查:
bash
undefined

Backend (Python)

Backend (Python)

poetry run ruff format --check app/ poetry run ruff check app/ poetry run mypy app/
poetry run ruff format --check app/ poetry run ruff check app/ poetry run mypy app/

Frontend (Node.js)

Frontend (Node.js)

npm run format:check npm run lint npm run typecheck

Fix any failures before proceeding.
npm run format:check npm run lint npm run typecheck

在继续之前修复所有检查失败的问题。

Phase 3: Review Changes

阶段3:查看更改

bash
git status
git diff --staged   # What will be committed
git diff            # Unstaged changes
bash
git status
git diff --staged   # What will be committed
git diff            # Unstaged changes

Phase 4: Stage and Commit

阶段4:暂存并提交

bash
undefined
bash
undefined

Stage files

Stage files

git add <files>
git add <files>

Or all: git add .

Or all: git add .

Commit with conventional format

Commit with conventional format

git commit -m "<type>(#<issue>): <brief description>
  • [Change 1]
  • [Change 2]
Co-Authored-By: Claude noreply@anthropic.com"
git commit -m "<type>(#<issue>): <brief description>
  • [Change 1]
  • [Change 2]
Co-Authored-By: Claude noreply@anthropic.com"

Verify

Verify

git log -1 --stat
undefined
git log -1 --stat
undefined

Commit Types

提交类型

TypeUse For
feat
New feature
fix
Bug fix
refactor
Code improvement
docs
Documentation
test
Tests only
chore
Build/deps/CI
类型适用场景
feat
新功能
fix
Bug修复
refactor
代码优化
docs
文档更新
test
仅测试代码
chore
构建/依赖/CI相关

Rules

规则

  1. Run validation locally - Don't spawn agents to run lint/test
  2. NO file creation - Don't create MD files or documentation
  3. One logical change per commit - Keep commits focused
  4. Reference issues - Use
    #123
    format in commit message
  5. Subject line < 72 chars - Keep it concise
  1. 本地运行验证 - 不要启动Agent来运行lint或测试
  2. 禁止创建文件 - 不要创建MD文件或文档
  3. 每次提交一个逻辑更改 - 保持提交聚焦
  4. 关联问题 - 在提交信息中使用
    #123
    格式
  5. 主题行少于72个字符 - 保持简洁

Quick Commit

快速提交

For trivial changes (typos, single-line fixes):
bash
git add . && git commit -m "fix(#123): Fix typo in error message

Co-Authored-By: Claude <noreply@anthropic.com>"
针对微小更改(拼写错误、单行修复):
bash
git add . && git commit -m "fix(#123): Fix typo in error message

Co-Authored-By: Claude <noreply@anthropic.com>"

Related Skills

相关技能

  • create-pr: Create pull requests from commits
  • review-pr: Review changes before committing
  • fix-issue: Fix issues and commit the fixes
  • issue-progress-tracking: Auto-updates GitHub issues with commit progress
  • create-pr: 从提交创建拉取请求
  • review-pr: 提交前审查更改
  • fix-issue: 修复问题并提交更改
  • issue-progress-tracking: 自动更新GitHub问题的提交进度

Rules

规则详情

Each category has individual rule files in
rules/
loaded on-demand:
CategoryRuleImpactKey Pattern
Atomic Commits
rules/atomic-commit.md
CRITICALOne logical change per commit, atomicity test
Commit Splitting
rules/commit-splitting.md
HIGH
git add -p
, interactive staging, separation strategies
Conventional Format
rules/conventional-format.md
HIGHtype(scope): description, breaking changes
Total: 3 rules across 3 categories
每个分类的独立规则文件位于
rules/
目录,按需加载:
分类规则影响级别核心模式
原子提交
rules/atomic-commit.md
关键每次提交一个逻辑更改,原子性测试
提交拆分
rules/commit-splitting.md
git add -p
,交互式暂存,拆分策略
规范格式
rules/conventional-format.md
type(scope): description, 破坏性更改
总计:3个分类下的3条规则

References

参考资料

  • Conventional Commits
  • Recovery
  • Conventional Commits
  • 恢复指南