# claude-gh-guard

> Stop Claude Code from committing to your work repo with your personal GitHub account. Free and open source (MIT).

claude-gh-guard is a free AI agent skill on Agensi by Seunghoon Jung, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Seunghoon Jung](https://www.agensi.io/creators/seunghoon-jung)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.1
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/claude-gh-guard
- Tags: claude-code, github, git, gh, security, hooks, statusline

## About this skill

**Free and open source (MIT).** Install with one command:

```
npx claude-gh-guard init
```

⭐ **If it saves you from a wrong-account commit, a star on GitHub would mean a lot:**
https://github.com/seuthootDev/claude-gh-guard

**What it does**
- Status line shows which GitHub account is active for the current repo, plus your Claude account
- Blocks `git commit`, `git push` and `gh pr create` when the identity is definitely wrong
- Only a definite mismatch blocks. Ambiguous, unknown or error states let the command through
- Zero runtime dependencies, Node >= 18, one command to uninstall

**Compatibility:** Claude Code only. It relies on Claude Code hooks and the status line, so it does not work in Cursor, Copilot or other agents.

Bugs and ideas: https://github.com/seuthootDev/claude-gh-guard/issues

## Requires

- Git
- Node.js 18+
- GitHub CLI
- Claude Code

On Windows, works through Git Bash (installed with Git for Windows); no WSL needed.

## Known limitations

Only supports github.com. No support for GitHub Enterprise. Commands in subshells or with 'env' prefixes are ignored. Custom SSH commands may limit push identity detection.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the claude-gh-guard skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How exactly does this skill prevent the wrong account from being used?

The skill acts as a pre-execution gate for Claude Code, automatically checking your local Git config and GitHub CLI auth against your repository's requirements before allowing a commit or push to proceed.

### What software do I need to have installed to use claude gh guard?

This skill is specifically built for Claude Code and requires the GitHub CLI (`gh`), Git, and Node.js 18+ to be installed on your local machine.

### Can I set different rules for my work repositories versus my personal open-source projects?

Yes, you can use the account mapping feature to bind specific GitHub organizations or repositories to distinct profiles, ensuring your personal and work identities never cross-pollinate.

### What happens if the skill detects an identity mismatch during a push?

If a mismatch is detected, the skill intercepts the command and blocks execution, providing a diagnostic report so you can switch accounts before any data is sent to the remote repository.

### Does this work with GitHub Enterprise or custom SSH command aliases?

While it provides robust protection for standard git and GitHub CLI commands, it currently only supports github.com and may not track identities inside custom subshells or non-standard SSH configurations.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
