Smart Commit Skill
This skill manages the flow of committing changes, ensuring they are on the correct branch, rebased with main, and committed or pushed.
Agent Instructions
Follow this logic map precisely. Interact with the user in Spanish, but generate branch names and commit messages in English.
Phase 1: Status & Branch Check
- •Run
git status -sb. - •IF Output is empty (Clean Working Tree):
- •Go to Phase 4 (Sync & Push) directly.
- •IF on
main(ormaster):- •State: "Tienes cambios directamente en la rama main."
- •Propose: Analyze changes (
git diff --stat) and propose a new branch name (Conventional Commits). - •Ask: "¿Deseas mover estos cambios a una nueva rama llamada
[PROPOSED_NAME]?" - •IF YES: Execute
git checkout -b [PROPOSED_NAME]. (Changes carry over). - •IF NO: Warn "No recomendado" but proceed.
Phase 2: Staging & Commit
- •Check for Untracked Files (
??).- •If exist, Ask: "¿Incluir archivos no rastreados?"
- •Yes:
git add .| No:git add -u.
- •If currently clean but
git addhasn't run, rungit add .. - •Generate Commit Message (English, Conventional).
- •Ask: "Propongo el mensaje:
[MESSAGE]. ¿Proceder?" - •IF YES: Execute
git commit -m "[MESSAGE]". - •IF NO: Ask for message and commit.
Phase 3: Sync (Rebase)
- •Ask: "¿Deseas actualizar (rebase) tu rama con
origin/mainpara traer los últimos cambios?" - •IF YES:
- •Execute:
git fetch origin main. - •Execute:
git rebase origin/main. - •CRITICAL: If conflicts occur, STOP and inform the user.
- •Execute:
Phase 4: Push
- •Check remote status (
git ls-remote,git log). - •Condition A: Branch doesn't exist on remote.
- •Ask: "¿Publicar rama (
git push -u ...)?" -> Execute.
- •Ask: "¿Publicar rama (
- •Condition B: Local is ahead (
git log origin..HEAD).- •Ask: "¿Subir commits (
git push)?" -> Execute.
- •Ask: "¿Subir commits (
- •Condition C: Clean.
- •Inform: "Todo actualizado."