# commit-guardian

Runs a 10-point automated inspection on staged git files and stops the commit if tests fail, secrets appear, or rules break.

- subagent · `type=agent` · Claude Code · 208 installs
- Author: davila7
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/agents/git/commit-guardian.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/agents/commit-guardian

## What it does

Commit Guardian inspects staged files before any git record is created. It blocks direct commits to `main` or `master`, scans contents for exposed credentials such as AWS or GitHub keys, and triggers project builds across environments like Go, Rust, .NET, Node.js, and Python. It also checks tests and styles.

The routine inspects code atomicity, warns about leftover debug statements, and verifies commit descriptions against Conventional Commits formatting rules under 72 characters.

The subagent refuses to run `git push`, never executes `--no-verify`, and immediately halts whenever an issue is flagged for human intervention.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --agent git/commit-guardian
```

2. **Manually: put the files in place**
- File: `.claude/agents/commit-guardian.md` — For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

### Codex

**Manually: put the files in place**
- File: `.codex/agents/commit-guardian.toml` — Codex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/

### Cursor

**Manually: put the files in place**
- File: `.cursor/agents/commit-guardian.md` — Cursor also reads .claude/agents/

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/agents/git/commit-guardian.md

## When to use it
- catch hardcoded API tokens and secret strings before git commit
- prevent unreviewed commits directly to `main` or `master` branches
- enforce Conventional Commits message standards and 72-character limits
- trigger compilation checks across multi-language staged changes
- detect leftover debug artifacts and unneeded imports in staged code

## Example prompts
- Run commit-guardian against staged files before committing
- Execute the commit-guardian check protocol on current changes
- Verify staged files and generate a Conventional Commit message

## Similar
- [deployment-engineer](https://affpapa.org/en/nevibecode/agents/deployment-engineer.md) — subagent · 6079 installs
- [launchdarkly-flag-cleanup](https://affpapa.org/en/nevibecode/agents/launchdarkly-flag-cleanup.md) — subagent · 171 installs
- [pr-test-analyzer](https://affpapa.org/en/nevibecode/agents/pr-test-analyzer.md) — subagent · ★ 44770
- [Technical Debt Remediation Plan](https://affpapa.org/en/nevibecode/agents/technical-debt-remediation-plan.md) — subagent · ★ 40451
- [TDD Red Phase - Write Failing Tests First](https://affpapa.org/en/nevibecode/agents/tdd-red-phase-write-failing-tests-first.md) — subagent · ★ 40451

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 804 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
