# Safe Git Commit & PR

> Your agent proposes commits and PR descriptions in your repo's style, and waits for your OK before committing. Compatibility note: Requires git. GitHub CLI (gh) is optional and only used for draft PRs. Tested with Claude Code. Permissions notes: Shell access for git commands only. Network access only if you ask for a draft PR via gh. The skill instructs the agent never to push, merge or approve. Known limitations: These are instructions to the agent, not technical blocks. For hard enforcement, also deny git push and similar commands in your agent's permission settings.

Safe Git Commit & PR is a free AI agent skill on Agensi by Elmer Mejias, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Elmer Mejias](https://www.agensi.io/creators/elmer-mejias)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Uses: 2
- Version: 1.0
- Last updated: 2026-10-17
- Security: scan passed (2026-10-17); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/safe-git-commit-pr
- Tags: git, code-review, documentation, workflow-automation, github

## About this skill

Manual git workflows often lead to inconsistent commit history, leaked secrets, or vague pull request descriptions that slow down code reviews. This skill enforces a disciplined, safe process for local version control and PR drafting, ensuring your agent never performs destructive actions without your oversight.

### What it does
- **Enforces safety**: Blocks destructive commands like `git push`, hard resets, or history rewrites to protect your remote repository.
- **Style matching**: Analyzes `git log` to match the repository's existing commit message language, tone, and formatting conventions.
- **Secret detection**: Scans staged changes for `.env` files, private keys, or credentials and halts the process if any are found.
- **Structured PR drafting**: Generates formatted PR descriptions based on local diffs, following your `.github/pull_request_template.md` or a standard technical schema.
- **Ticket integration**: Automatically extracts ticket keys from branch names or user input to link commits and PRs to your project management tool.

### How it works
1. **Inspection**: The agent runs `git status` and `git diff` to understand staged and unstaged changes.
2. **Proposal**: It proposes a commit message or a list of files to stage and waits for your explicit approval.
3. **Execution**: Once confirmed, it runs `git commit` locally but stays on your machine, never pushing to origin.
4. **Drafting**: It compares your branch against the target to write a detailed PR description including summary, changes, and testing steps.

### Frameworks & tools
This tool works with any repository using `git`. It can optionally interface with the `gh` (GitHub) CLI to create draft pull requests if requested.

### Why this beats prompting it yourself
Generic prompts often result in "Updated files" messages or hallucinated PR descriptions that ignore your project's specific template. This skill forces a multi-step check of actual logs and diffs while hard-coding safety guards that prevent the AI from ever force-pushing or leaking secrets.

### Use cases
- Drafting standardized, professional commit messages for complex refactors.
- Generating comprehensive PR descriptions for large feature branches that require migration notes.
- Preventing accidental commits of build artifacts, logs, or sensitive environment variables.
- Ensuring new developers follow repo-specific commit conventions without manual policing.

### Known limitations
Does not support pushing code to remote branches or merging PRs. Requires the user to have git installed and initialized in the working directory.

## Requires

- Git

## 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 Safe Git Commit & PR 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 does this skill prevent accidental secret leaks and destructive git commands?

The skill acts as a safety layer by blocking commands like `git push` and `git reset`, and it includes an automated scanner that prevents the agent from committing sensitive credentials or private keys.

### Can this skill adapt to my team's unique commit message style?

Yes, the skill is designed to analyze your repository's `git log` to identify and replicate your specific tone, language, and formatting conventions automatically.

### What are the technical requirements for running this skill locally?

It works with any environment where `git` is installed; for PR drafting, it can also utilize the GitHub CLI (`gh`) to create drafts directly from your local diffs.

### Do I have the chance to review the commit messages before they are applied?

While it generates high-quality messages and PR drafts based on actual code diffs, it will always pause for your explicit approval before executing a local commit.

### How does the skill handle custom Pull Request templates?

The skill follows your project's `.github/pull_request_template.md` if it exists, otherwise it defaults to a professional, structured schema that includes summaries and testing steps.

---

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.
