commit · git:20260408.61db2e8 · 2026-04-08 · sha256 00892bbe0cc79863

commit git:20260408.61db2e8A

Immutable. This exact content never changes and is served at /api/v1/blob/00892bbe0cc79863.

---
description: Commit rules — branch safety, explicit staging, 3-option commit messages, push approval
globs: 
alwaysApply: true
---

# Commit Rules

Stage, commit, and push **only the files you modified in this chat session** to the **current working branch**. Do not include files changed by other tasks or tools.

---

## Branch Safety (BLOCKING GATE)

1. **Check the current branch** — run `git branch --show-current`.
2. **If on `master` or `main`** — **STOP immediately**. Do not stage, commit, or push. Tell the user and wait.
3. **If on `dev`** — you may commit, but **do NOT push automatically**. After committing, ask: "Committed. Ready to push to dev?" Wait for explicit approval.
4. **Stay on the branch you started on.** Never switch branches just to commit.
5. Never push or commit directly to `master` or `main` unless explicitly instructed.

---

## Verification Gate (BLOCKING)

Before committing, confirm that **ALL** required verification steps from the task plan have passed. If any verification is blocked or incomplete, do **NOT** commit. Report the blocker. See `task.mdc` → Blocker Protocol.

---

## Steps

1. **Check `git status --short`** — Review all modified and untracked files. Identify which ones you touched.

2. **Stage only your files** — Use `git add` with explicit file paths. Never use `git add -A` or `git add .` because they can capture unrelated changes.

3. **Write a high-quality commit message** using **multiple `-m` flags**. Never use one long quoted multi-line string.

   ### Commit Subject Rules

   ```
   <type>(<optional-scope>): <action-oriented summary>
   ```

   **Allowed Types:** `feat`, `fix`, `refactor`, `docs`, `style`, `data`, `config`, `chore`, `merge`

   ### Commit Subject Standards

   - Keep subjects under ~80 characters.
   - Use lowercase for type and scope.
   - Start with a clear verb (add, fix, move, remove, migrate, refine, etc.).
   - Be specific, not generic.
   - For multi-change sessions: summarize themes, put details in body.

   ### Commit Body Rules

   Use additional `-m` flags for body. **Keep to 2–3 `-m` flags total.**

   The body should:
   - Summarize key changes in one short paragraph (3–5 sentences max)
   - Mention most important modules or areas
   - Explain *why* if not obvious
   - Never enumerate every single change
   - End with `Files: <key files touched>`

   ### Quick Subject Rewrite Guide

   - `Updated gateway` → `feat(gateway): add card payment method support`
   - `fix webhook` → `fix(webhooks): resolve duplicate event processing`
   - `update docs` → `docs: refresh webhook integration documentation`
   - `fix refund issue` → `fix(refunds): handle partial refund edge case`

4. **Push to the current working branch** — If on `dev`, ask before pushing. On other branches, push immediately. If push fails, `git pull --rebase` first.

---

## Rules

- **Never stage files you did not change.**
- **Never use `git add .` or `git add -A`.** Always stage explicit paths.
- **Never use a vague commit subject.**
- **Do not include Copilot co-author trailers unless explicitly requested.**
- **Never force push.**
- **One commit per session batch.** Do not batch unrelated tasks.
- **ALWAYS ask for explicit user approval before committing.**
- **ALWAYS present 3 commit message options.** Number them 1–3, concise to descriptive. Let the user pick.
- **ALWAYS ask before pushing.**

---

## Batch Commit (commit-all)

When multiple accumulated changes need committing at once:

1. Run `git status --short` and `git diff --stat`.
2. Group changes into **commit batches** by feature/module area.
3. For each batch, present **3 numbered commit message options** and wait for user pick.
4. Stage and commit each batch with explicit file paths.
5. After all batches committed, ask: "Ready to push to <branch>?"

---

## Merge Dev to Master

When dev changes are ready for master:

1. Ensure all dev changes are pushed: `git status` + `git log origin/dev..dev`.
2. Switch to master: `git checkout master && git pull origin master`.
3. Merge: `git merge dev --no-ff -m "merge(dev→master): <summary>"`.
4. If conflicts: STOP and report. Do not auto-resolve.
5. Push: `git push origin master`.
6. Switch back: `git checkout dev`.

**Rules:** Only merge pushed changes. Never force push to master. Always push immediately after merge.