← 返回
未分类 中文

Structuring Git Workflow

Use when working in a git repository and about to start new work, complete a module, commit, push, merge, or rebase. Use before any destructive git operation...
在 Git 仓库中准备开始新工作、完成模块、提交、推送、合并或变基时使用。请在任何破坏性 Git 操作之前执行。
yiiknow
未分类 clawhub v0.1.1 1 版本 99537 Key: 无需
★ 0
Stars
📥 215
下载
💾 0
安装
1
版本
#latest

概述

Structuring Git Workflow

Overview

Imposes branch discipline, commit structure, and safety checks at every git decision point. The skill acts as a gate: it does not execute commands, it asks the right questions before you do.

Violating the letter of these rules is violating the spirit of these rules.

When to Use

Starting new work?
  ├─ Yes → Create branch (Rule 1)
  └─ No → Continue

Module/feature complete?
  ├─ Yes → Remind about commit (Rule 2)
  └─ No → Continue

About to commit/push/merge/rebase?
  ├─ Yes → Run safety checklist (Rule 4)
  └─ No → Continue

Core Rules

Rule 1: Never Commit to Main/Master

All work happens on branches. When starting any task (feature, fix, refactor), create a branch first:

Task typeBranch patternExample
-----------------------------------
Featurefeature/feature/user-login
Bug fixfix/fix/login-timeout
Refactorrefactor/refactor/auth-middleware

If you catch yourself about to commit on main/master, stop and create a branch. If work already started on main, stash it, create a branch, then unstash.

Rule 2: Remind About Commit at Module Boundaries

When a discrete unit of work is complete (a function, a component, a feature slice), proactively ask: "This module is complete. Commit it?"

Do not wait for the user to remember. The default answer is yes — most modules should be committed. If the user says no, respect it and move on.

Rule 3: Structured Commit Messages

Commit messages follow a consistent format. The default format is:

<type>: <description>

Types: feat, fix, refactor, style, docs, test, chore

  • First line under 72 characters
  • Use imperative mood ("add" not "added")
  • If the project CLAUDE.md or CONTRIBUTING.md specifies a different convention, follow that instead

Rule 4: Safety Checklist Before Destructive Operations

Before reset --hard, rebase, force push, or branch -D:

  1. Is this a shared branch? → Do not rewrite history
  2. Do I have uncommitted changes? → Stash or commit first
  3. Am I on the right branch? → git branch to verify
  4. Is remote up to date? → git fetch first

State each check result explicitly before proceeding.

Rule 5: Push Is a Separate Decision

Commit and push are distinct steps. Commit accumulates locally. After commits are verified (tests pass, no regressions), ask: "Ready to push?"

Never push automatically after commit. Never force-push to shared branches. Use --force-with-lease on feature branches only.

Quick Reference

TriggerAction
-----------------
Starting new workCreate feature/ or fix/ branch from main
Module completeRemind user about commit
About to commitUse structured message format
About to pushVerify first, ask user
Force push needed--force-with-lease on feature branches only
Destructive operationRun 4-point safety checklist
Work accidentally on mainStash → create branch → unstash

Common Mistakes

MistakeFix
--------------
Committing directly to mainAlways create a branch first
Commit message "fix stuff"Describe the specific change
Pushing immediately after commitAccumulate, verify, then push
Force push without checkingRun safety checklist first
Skipping branch for "small fix"Small fixes go on fix/ branches too
Amend pushed commitsOnly amend local, unpushed commits

Edge Cases

ScenarioHandling
--------------------
User insists on committing to mainPush back once: "This should go on a branch. Sure you want it on main?" If they confirm, comply.
Project initialization (first commit)The initial commit (README, scaffold) is the only exception to Rule 1
Collaborating on an existing branchNo need to create a new branch — commit to the existing feature/fix branch
Local repo, no remoteRules 1-3 still apply. Rules 4-5 (push safety) are dormant until a remote is added
User's CLAUDE.md specifies different conventionFollow the project convention. This skill is the default, not an override

Red Flags — STOP

  • "This is too small for a branch" → Even one-line fixes go on a branch
  • "I'll branch after I start" → Branch first, then work
  • "Nobody else works on this repo" → Discipline is habit, not circumstance-dependent
  • "The user seems in a hurry" → Urgency is when mistakes happen. Follow the rules
  • "The user told me to skip the branch" → Push back once, then comply if they insist
  • "It's just a config tweak" → Config changes can break things. Use a branch

All of these mean: Create the branch. Write the structured message. Run the checklist.

版本历史

共 1 个版本

  • v0.1.1 当前
    2026-05-26 18:14 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,223 📥 267,309
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,936
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,371 📥 319,655