Guide · git skills

Git Skills for Claude Code: Safe Commits, PRs and Stacked Branches

The most-installed git skill for Claude Code is git-guardrails-claude-code from mattpocock/skills (523,036 installs). It adds a hook that blocks force push, hard reset and other destructive git commands. Pair it with caveman-commit (422,617 installs) for clean Conventional Commits messages.

By Skillselion, an Ellelion LLC publication · Updated November 2, 2026 · 5 min read · Stats verified against the live catalog

Git skills give Claude Code rules for the one tool where a single wrong command can erase work. The top result for "git" in the catalog is git-guardrails-claude-code from mattpocock/skills, with 523,036 installs (skills.sh registry), and it blocks destructive commands with a hook instead of a prompt.

Key takeaways

  • mattpocock's git-guardrails-claude-code (523,036 installs) registers a PreToolUse hook that stops git push, reset --hard, clean -f and branch -D before Claude Code can run them.
  • caveman-commit from juliusbrussee/caveman (422,617 installs) writes terse Conventional Commits subjects under 50 characters and leaves out the AI attribution line. The caveman skill guide covers the rest of that pack.
  • obra's using-git-worktrees (223,088 installs) puts each task in an isolated worktree, so parallel agent sessions never share one checkout.
  • addyosmani's git-workflow-and-versioning (63,600 installs, 113,748 GitHub stars) treats commits as save points and prefers feature flags over long-lived branches.
  • For stacked PRs, Graphite's own graphite skill (9,977 installs) covers the gt CLI, and GitLab teams get glab from gitlab-org/ai (1,208 installs). The best dev tools skills page ranks the wider set.

Why does Claude Code need a git skill?

Claude Code runs git through its Bash tool, so without a skill it can run any git command your shell allows, including ones that rewrite or delete history. A line in CLAUDE.md that says "never force push" is only an instruction, and a long session can lose it. A hook is code that runs on every tool call, and that is the approach of git-guardrails-claude-code, the top git result at 523,036 installs (skills.sh registry). Anthropic's hooks documentation explains how a PreToolUse hook can block a tool call before it runs.

What is the best git skill for Claude Code?

git-guardrails-claude-code from mattpocock/skills is the best first install, with 523,036 installs and 316,801 GitHub stars (skills.sh registry, GitHub). Install it with:

npx skills add https://github.com/mattpocock/skills --skill git-guardrails-claude-code

Matt Pocock, author of the git-guardrails-claude-code skill
Matt Pocock, author of the git-guardrails-claude-code skill

The skill copies a bundled block-dangerous-git.sh script into .claude/hooks/ for one project or ~/.claude/hooks/ for every project, then registers it under hooks.PreToolUse with a Bash matcher. It asks you which scope you want, merges into an existing PreToolUse array instead of overwriting it, and tests itself by piping a fake git push through the script and expecting exit code 2. When a command is blocked, Claude is told it lacks authority to run it, so you push yourself.

Two practice skills sit on top of the guard. addyosmani's git-workflow-and-versioning (63,600 installs) opens with "Git is your safety net" and calls every day a dev branch lives a cost in merge risk. wshobson's git-advanced-workflows (19,663 installs) covers interactive rebase, cherry-pick, bisect and reflog recovery for the cases where history already went wrong.

How do you get clean commit messages from Claude Code?

Install one commit skill so the agent writes the same format every time. caveman-commit (422,617 installs, 118,027 GitHub stars on juliusbrussee/caveman) keeps subjects under 50 characters and explains why the change exists, not only what changed. The git-commit skill from github/awesome-copilot (47,830 installs) writes Conventional Commits messages and stages files from a plain-language request. patricio0312rev's conventional-commits (476 installs) picks the type and scope from the staged diff and adds breaking-change footers. All three follow the Conventional Commits 1.0.0 specification.

Once messages are consistent, wshobson's changelog-automation (13,949 installs) turns them into Keep a Changelog release notes and adds commitlint checks in CI.

How do you run parallel Claude Code sessions without branch conflicts?

Give each session its own git worktree. using-git-worktrees from obra/superpowers (223,088 installs, 313,657 GitHub stars) first checks whether the session is already isolated, then prefers the platform's native worktree tool, and only falls back to a manual git worktree add when nothing else exists. Its rule is short: never fight the harness. That order matters in Claude Code, which can already start a session inside a worktree, so a second layer of isolation would only add confusion. The git worktree reference lists the underlying commands.

How do you open pull requests and stacked PRs from Claude Code?

For GitHub, cline's create-pull-request (810 installs) checks gh --version, reads the diff and recent commit style, pushes with -u and opens the PR through gh pr create with a HEREDOC body. awesome-copilot's create-github-pull-request-from-specification (8,945 installs) reads your pull_request_template.md, checks for an existing PR first and drafts the body from the spec and the diff.

For stacked PRs, the graphite skill from withgraphite (9,977 installs) is a quick reference for gt create, modify, up, down, submit and restack. It argues for small, hermetic PRs that each pass CI, restacks onto main before every submit, and uses gt track to recover untracked branches in worktrees.

On GitLab, the official glab skill from gitlab-org/ai (1,208 installs) covers merge request creation, pipeline monitoring and GLQL queries, and henricook's claude-glab-skill (1,070 installs) adds issues and self-hosted GitLab hostnames. When the agent needs the GitHub API rather than the CLI, see the best GitHub MCP servers.

A complete starter stack

  • git-guardrails-claude-code (523,036 installs): a hook-enforced block on push and history-destroying commands.
  • caveman-commit (422,617 installs) or git-commit (47,830 installs): one consistent commit format.
  • using-git-worktrees (223,088 installs): one isolated checkout per task.
  • create-pull-request, graphite or glab: PRs that match your host and your template.
  • changelog-automation (13,949 installs): release notes generated from commit history.

Common pitfalls

  • Trusting a prompt rule to stop force pushes. git-guardrails-claude-code exists because a hook runs on every Bash call, while an instruction can drop out of a long context.
  • Installing two commit skills with different styles. caveman-commit caps subjects at 50 characters, so pairing it with a verbose commit skill gives you a history that mixes both formats.
  • Running two agents in one checkout. Without worktrees they share one staging area, and one session's git add picks up the other's half-finished files.

Start with the guardrail hook, then add one commit skill and one PR skill for your host. The dev tools category lists the rest of the git and CLI skills.

FAQ

Common questions

What is the best git skill for Claude Code?

git-guardrails-claude-code from mattpocock/skills, with 523,036 installs, is the top git result in the catalog. It installs a PreToolUse hook that blocks destructive git commands. See git-guardrails-claude-code.

How do I stop Claude Code from force pushing?

Install git-guardrails-claude-code (523,036 installs). Its hook blocks git push in all variants, reset --hard, clean -f and branch -D, and Claude is told it lacks authority to run them. See git-guardrails-claude-code.

Is there a Claude Code skill for Conventional Commits?

Yes. caveman-commit (422,617 installs) writes Conventional Commits subjects under 50 characters, and git-commit from github/awesome-copilot (47,830 installs) also stages files. See git-commit.

Can Claude Code work with Graphite stacked PRs?

Yes. The graphite skill from withgraphite (9,977 installs) teaches the gt CLI: create, navigate, restack and submit stacks of small PRs. See graphite.

Is there a GitLab skill for Claude Code?

Yes. gitlab-org/ai publishes an official glab skill (1,208 installs) for merge requests, pipelines and GLQL, and henricook/claude-glab-skill (1,070 installs) adds issues and self-hosted instances. See the dev tools category.

Ranked by Skillselion - an independent directory of AI-coding tools, not affiliated with Anthropic, OpenAI or Cursor. Tool rankings reflect real adoption (installs, then GitHub stars) from the skills.sh registry and GitHub, last updated November 2, 2026.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.