commit-guardian — Claude Code subagent: what it does, how to install
Runs a 10-point automated inspection on staged git files and stops the commit if tests fail, secrets appear, or rules break.
npx claude-code-templates@latest --agent git/commit-guardianWhat commit-guardian 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.
What it helps with
- catch hardcoded API tokens and secret strings before git commit
- prevent unreviewed commits directly to
mainormasterbranches - 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 for the agent
- 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
How to install commit-guardian
1claude-code-templates
npx claude-code-templates@latest --agent git/commit-guardian2Manually: put the files in place
.claude/agents/commit-guardian.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/commit-guardian.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/commit-guardian.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about commit-guardian
How to install commit-guardian in Claude Code?
Run npx claude-code-templates@latest --agent git/commit-guardian. The subagent configuration will be placed in .claude/agents/commit-guardian.md.
What does commit-guardian do?
It applies a sequential 10-step verification routine covering branch naming, secret detection, builds, tests, linting, and message formatting.
Will commit-guardian push changes to a remote repository?
No. The agent protocol strictly forbids executing git push, leaving all remote synchronisation entirely to the developer.