Git workflow

From akillness/jeo-skills · View interactive version

Git workflow is an AI agent skill from the GitHub repository akillness/jeo-skills. Route local Git work into the safest next move: branch hygiene, selective staging, commit cleanup, merge-vs-rebase choice, conflict resolution, lease-safe pushes, and recovery from resets or bad history edits. Use when the user needs help preparing a branch, cleaning up commits, syncing with an upda

How to use this skill

Skill file

Git Workflow

Use this skill as the repo's routing-first local Git collaboration and recovery anchor.

The job is not to teach all of Git. The job is to:

Read these references when the case gets sharp-edged or the user needs more than the brief:

If the main need is:

When to use this skill

When not to use this skill

Instructions

Step 1: Normalize the local Git intake

Classify the request before suggesting commands.

git_intake:
  current_goal: branch-setup | commit-shaping | sync-with-base | conflict-resolution | push-safety | undo-recovery | history-inspection | unknown
  branch_state: clean | has-unstaged-changes | staged-only | ahead-of-origin | behind-origin | diverged | detached-head | unknown
  collaboration_risk: solo-branch | shared-branch | unknown
  remote_context: no-remote | origin-only | fork-plus-upstream | unknown
  trigger_event:
    - need-clean-commits
    - rebased-branch
    - merge-conflict
    - wrong-branch-commit
    - accidental-reset
    - rejected-push
    - lost-commit
    - prepare-for-review
    - sync-main
    - unclear
  preferred_history: keep-linear | preserve-merge-context | unknown
  confidence: high | medium | low

If the packet is incomplete, choose the safest reasonable next move and state the assumptions.

Step 2: Choose one primary workflow mode

Pick exactly one mode:

  1. branch-and-stage hygiene — branch creation/switching, staging, stash-or-clean decisions
  2. commit-shaping — amend, fixup, reword, interactive rebase, cleaner review units
  3. sync-with-base — fetch + merge/rebase choice when the branch must catch up
  4. conflict-resolution — merge/rebase already produced conflicts; the next safe loop matters most
  5. push-safety — upstream setup, rejected pushes, diverged branches, rewrite-safe pushes
  6. undo-and-recovery — reset/rebase/amend/checkout/branch deletion went sideways; rescue first

Step 3: Use the safety ladder

Always prefer these checks before irreversible actions:

Core rules:

Step 4: Apply the decision ladder

Use these callouts explicitly:

Merge vs rebase
Revert vs reset
Normal push vs `--force-with-lease`

Step 5: Build the Git Workflow Brief

Return this exact structure:

# Git Workflow Brief

## Recommended mode
- Mode: branch-and-stage hygiene | commit-shaping | sync-with-base | conflict-resolution | push-safety | undo-and-recovery
- Why this mode fits: ...

## Current state
- Branch: ...
- Worktree / index state: ...
- Remote context: ...
- Collaboration risk: solo-branch | shared-branch | unknown
- Confidence: high | medium | low

## Safest next move
1. ...
2. ...
3. ...

## Commands

...


## Why this is the safe path
- ...
- ...

## Watch-outs
- ...
- ...

## Recovery fallback
- If this goes wrong, use ...

## Adjacent handoff
- Use `code-review` when ...
- Use `debugging` when ...
- Use `task-planning` when ...

Step 6: Use concise mode packets

Use the detailed command packets in references/mode-selection-and-command-packets.md when you need the expanded workflow.

Step 7: Keep boundaries sharp

Before finalizing:

Output format

Always return a compact Git Workflow Brief, not a giant command dump.

Required qualities:

Examples

Example 1: rebased branch needs safe push

Input

I rebased my feature branch onto main and now I need to push it without overwriting teammates.

Output sketch

Example 2: clean up local commits before review

Input

Help me turn these messy local commits into something clean before review.

Output sketch

Example 3: wrong-branch reset panic

Input

I think I hard-reset the wrong branch. Can Git recover this?

Output sketch

Example 4: request is really PR review

Input

Review this PR and tell me if the architecture is okay.

Output sketch

Best practices

  1. Inspect before surgery. Status, branch, and recent log beat guesswork.
  2. Prefer reviewable commits over giant snapshots. Commit shape affects review quality.
  3. Treat history rewrites as collaboration decisions, not personal preferences. Shared branches change the answer.
  4. Use --force-with-lease, not raw --force. Rewrite safely or do not rewrite.
  5. Reach for reflog early in recovery. Lost commits are often only misplaced pointers.
  6. Choose the smallest safe fix. Not every problem needs branch surgery.
  7. Route out when the problem changes. Review, debugging, planning, and hosted PR work stay separate.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.