mcpbeat Sign in

Git Safe Workflow Agent Skill

Safely inspect, stage, commit, and (only if asked) push changes made by an AI agent. Use for commit/push requests, end-of-task checkpoints, merge conflict resolution, worktree safety checks, or deciding whether to use git commit --amend.

2k tokens
context cost
the whole folder, loaded on every use
2
files
instructions only
0
copies elsewhere
how many repositories repackaged it
131
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/instructa/agent-skills --skill git-safe-workflow

What comes with it

1 086 bytes besides the instruction
README.md

The instruction itself

18 sections, as written by the author

Git Safe Workflow

Core rules (always)

  • Collect repo context first (non-destructive):
  • git rev-parse --show-toplevel
  • git status --porcelain=v1 -b
  • git log -1 --oneline
  • Collect worktree context when relevant (also non-destructive):
  • git branch --show-current
  • git worktree list --porcelain

Run worktree context when:

  • branch name is unexpected
  • you are in a nested folder and not sure which checkout you are in
  • Git refuses checkout because branch is already checked out elsewhere
  • status shows detached HEAD or unusual metadata
  • Never run destructive or high-risk commands unless explicitly requested:
  • Do NOT use:
  • git reset --hard
  • git clean -fd
  • git push --force or --force-with-lease
  • git worktree prune
  • git worktree remove
  • git rebase (interactive or not) unless explicitly requested
  • If the user requests one:
  • restate the exact command you plan to run
  • explain why it is risky
  • then proceed
  • Avoid interactive prompts and editors unless the user says it is OK:
  • Prefer non-interactive commands
  • Avoid:
  • git add -p
  • editor-based rebase
  • commit message editor prompts
  • Prefer:
  • git commit -m "..." -m "..."

Worktree safety rules

  • Confirm you are in the intended worktree and branch before staging or committing:
  • git branch --show-current
  • git worktree list --porcelain
  • Detached HEAD safety:
  • If 'git branch --show-current' prints nothing, you are likely in detached HEAD.
  • Default behavior: do not commit immediately.
  • Explain the situation and ask whether to create a branch first, for example:
  • git switch -c <new-branch-name>
  • Only commit in detached HEAD if the user explicitly wants that and understands the risk.
  • Branch checked out in another worktree:
  • If Git refuses because the branch is already checked out elsewhere, do not use force by default.
  • Safe options:
  • switch that other worktree to a different branch, or
  • create a new branch for this worktree (recommended)
  • Worktree lifecycle operations:
  • Do not run these unless explicitly requested:
  • git worktree add
  • git worktree remove
  • git worktree move
  • git worktree lock or unlock
  • git worktree prune

Make a checkpoint commit (default)

1) Summarize the change

  • git diff --stat
  • git diff --staged --stat (if anything is staged)

2) Inspect details when needed

  • git diff
  • git diff --staged

Guidance:

  • Always inspect full diff if changes are large, touch security-sensitive code, or involve config or CI.

3) Stage changes safely

Prefer explicit paths when practical:

  • git add path/to/file1 path/to/file2

Otherwise stage tracked modifications and deletions:

  • git add -u

Avoid staging everything blindly unless user explicitly wants it:

  • avoid: git add .

4) Commit message

Use Conventional Commits when reasonable:

  • type(scope): summary

Include:

  • what behavior changed
  • tests run, or explicitly note: tests not run

5) Commit (non-interactive)

  • git commit -m "type(scope): summary" -m "Details... Tests: <what ran or not run>"

6) Verify

  • git status
  • git show --stat --oneline HEAD

Amend policy (git commit --amend)

Default rule

  • Do not use 'git commit --amend' unless it clearly improves the most recent commit AND the commit has not been pushed.

Safe uses

Use amend when:

  • You just made the last commit locally and immediately noticed:
  • you forgot a file
  • you need a tiny fix
  • the commit message is wrong

Common safe commands:

  • Add changes then amend without changing message:
  • git commit --amend --no-edit
  • Replace message non-interactively:
  • git commit --amend -m "type(scope): summary" -m "Details... Tests: ..."

Avoid

Do not amend when:

  • the commit is already pushed to a shared remote branch
  • amending would require a force push to reconcile the remote

In that case:

  • prefer a new follow-up commit
  • only rewrite history if the user explicitly requests it and accepts the risk

Merge conflicts

  • Collect context:
  • git status --porcelain=v1 -b
  • Identify conflicted files:
  • git diff --name-only --diff-filter=U
  • Resolve conflicts carefully (no automation that discards intent).
  • After resolving:
  • git add <resolved files>
  • Continue the operation:
  • If merge:
  • git commit -m "merge: resolve conflicts" -m "Details... Tests: ..."
  • If rebase was explicitly requested and is in progress:
  • git rebase --continue
  • Verify:
  • git status
  • git show --stat --oneline HEAD (if a commit was created)

Push policy

  • Only push if the user explicitly asks.
  • Preferred push:
  • git push -u origin HEAD

Main or master branch rule

  • If currently on main or master, do not push directly by default.
  • Create a branch first (ask user for branch name if not provided), then push that branch.

Force push rule

  • Never force push unless explicitly requested.
  • If requested:
  • restate the exact force push command
  • explain risk (rewriting shared history)
  • then proceed

Other skills for the same job

different authors, same section of the catalogue
MCP Builder
by anthropics
vendor ×13

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

30k tokens scripts
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
MCP Builder
by JayZeeDesign
×7

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

37k tokens scripts
Vercel React Native Skills
by vercel-labs
vendor ×6

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

39k tokens
Vercel React Best Practices
by ratacat
×5

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

34k tokens
Next Best Practices
by vercel-labs
vendor ×4

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

20k tokens
Using Git Worktrees
by ZhanlinCui
×4

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

1k tokens

How to use it

Copy the folder

Take instructa/git-safe-workflow from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.