Claude Code agent toolkit: guard, score, and more.
A standalone CLI for Claude Code agent integration. Provides deterministic command guards, session scoring, and other agent utilities.
cargo install --git https://github.com/gitkb/agentOr build from source:
cargo build --releaseEvaluate a command for destructive patterns. Designed to run as a Claude Code PreToolUse hook.
# Test directly
echo '{"tool_input":{"command":"git push --force"}}' | agent guard
# Output: JSON with permissionDecision: "deny" and reason
echo '{"tool_input":{"command":"git status"}}' | agent guard
# Output: (silent = allowed)Claude Code hook configuration (.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"command": "agent guard",
"timeout": 5,
"type": "command"
}
],
"matcher": "Bash"
}
]
}
}Blocked patterns (configurable via .claude/agent-guard.toml):
| Pattern | What it blocks | Safe alternative |
|---|---|---|
git push --force |
Force push | --force-with-lease |
git reset --hard |
Hard reset | git stash or commit first; git reflog |
git clean -fd |
Clean force | git clean -nd (dry run) |
git checkout . |
Checkout all | Specific files |
git branch -D |
Force delete branch | git branch -d |
git stash drop/clear |
Drop stashes | git stash list first |
rm -rf . / * / .meta |
Dangerous rm | Specific paths |
Score Claude Code sessions for agent effectiveness.
# Score most recent session
agent score
# Score specific session
agent score --session abc123
# Score last 5 sessions
agent score --recent 5
# JSON output
agent score --jsonMetrics:
- Meta-command ratio (using
meta gitvs baregit) - Workspace discovery (running
meta contextearly) - Cross-repo awareness (status checks before commits)
- Guard effectiveness (blocked vs allowed destructive commands)
Create .claude/agent-guard.toml in your project to customize patterns:
schema_version = "1.0"
[[patterns]]
id = "custom.my_pattern"
priority = 100
enabled = true
matcher = { type = "regex", pattern = 'dangerous-command' }
message = "This command is blocked because..."Pattern options:
id: Unique identifier (namespaced recommended)priority: Higher = checked first (default: 100)enabled: Toggle pattern on/offmatcher: Currently onlyregextype supportedvalidator: Optional additional checks (not_contains,flags_present,args_match_any,all_of,any_of,not)message: Shown to Claude when command is blocked
The guard reads the project file, else ~/.claude/agent-guard.toml, else its built-in defaults. A file that exists but cannot be read or parsed denies every Bash command, with a reason naming the file, until it is fixed or removed.
# Run tests
cargo test
# Run integration tests (requires bats)
bats tests/
# Build
cargo buildMIT