convez.ai
AgenteSegurançaAvançado
kawarimidoll

Guard and Guide

kawarimidoll/guard-and-guide

Bloqueie operações perigosas e guie agentes para alternativas seguras

Ver no GitHub
BomPluginScore · de 0 a 100

Agent que bloqueia operações perigosas em ferramentas de IA coding, como git push ou acesso a .env, e guia os agentes para alternativas seguras. Implementa regras customizáveis para controlar o que agentes Claude Code e Gemini CLI podem executar.

Instalação

$npx convez-ai kawarimidoll/guard-and-guide

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
9
Forks
2
Acompanhando
0
Saúde
42%
Último commit
há 1 dia
Versão
26.11.18
Issues abertas
3
Contribuidores
2

Casos de uso

  • Controlar quais operações git um agent pode realizar
  • Proteger arquivos sensíveis (.env, credenciais)
  • Enforçar políticas de segurança em execução de agents

Veredito

Ferramenta técnica essencial para quem usa agents coding em ambientes de produção ou sensíveis. Bloqueia não só a ação, mas orienta o agent para alternativas, aumentando significativamente a segurança da integração.

README

A tradução para o português deste README ainda está na fila.

guard-and-guide

CI Latest version Claude Code Gemini CLI Rust Nix

🛡️ Guard coding agents from dangerous operations, and 🧭 Guide them to safer alternatives.

Motivation

You tell your AI coding agent: "Don't run git push."

The agent gets blocked — and tries harder:

🧑 deny(git push)
🤖 Got it! I'll use /usr/bin/git push instead.
🧑 NOOO!!!

AI agents don't give up when simply denied. They try absolute paths, alternative commands, and creative workarounds to get the job done.

guard-and-guide solves this by not only blocking dangerous operations, but also telling the agent why it was blocked and what to do instead. When given clear guidance, agents are much more likely to comply.

Install

nix

nix profile install github:kawarimidoll/guard-and-guide

cargo

cargo install --git https://github.com/kawarimidoll/guard-and-guide

Setup

1. Create rules

Create ~/.config/guard-and-guide/rules.toml with your rules. See rules.example.toml for a full example.

Rules use canonical tool names (Bash, File) and regex patterns:

version = 1

[[rules]]
matcher = "File"
regex = '\.env$'
message = "Access to .env files is prohibited. Ask the user to check or provide the values you need."

[[rules]]
matcher = "Bash"
regex = '\bgit\s+push\b'
message = "Use of 'git push' is prohibited. Ask the user to execute it."

File is an alias for Read|Write|Edit.

2. Register hook

Claude Code

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "guard-and-guide" }]
      }
    ]
  }
}

Gemini CLI

Add to ~/.gemini/settings.json:

{
  "hooks": {
    "BeforeTool": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "guard-and-guide --agent gemini-cli" }]
      }
    ]
  }
}

Copilot CLI support is planned.

Usage

stdin (hook JSON) | guard-and-guide [OPTIONS]
OptionDescription
--agent <AGENT>claude-code (default), gemini-cli
--config <PATH>Rules file path (default: ~/.config/guard-and-guide/rules.toml)

How it works

Hook stdin → Parse JSON → Resolve tool name → Match rules → Deny or pass
  1. Agent hook pipes JSON to stdin
  2. Parse and extract tool name + input (format depends on --agent)
  3. Resolve agent-specific tool name to canonical name (Bash, Read, Write, Edit)
  4. Check each rule: does the canonical name match? Does the regex match the relevant field?
  5. First match → output deny JSON to stdout. No match → silent exit 0.

Tool name mapping

CanonicalClaude CodeGemini CLI
BashBashrun_shell_command
ReadReadread_file
WriteWritewrite_file
EditEditreplace

License

MIT

Ver o original no GitHub

Bom para

Relacionados