{"id":47625279,"url":"https://github.com/kawarimidoll/guard-and-guide","last_synced_at":"2026-05-28T05:02:13.352Z","repository":{"id":344409285,"uuid":"1179906179","full_name":"kawarimidoll/guard-and-guide","owner":"kawarimidoll","description":"🛡️ Guard coding agents from dangerous operations, and 🧭 Guide them to safer alternatives.","archived":false,"fork":false,"pushed_at":"2026-04-21T23:02:45.000Z","size":135,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-22T01:11:30.711Z","etag":null,"topics":["ai-agent","claude-code","cli","gemini-cli","hooks","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kawarimidoll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"kawarimidoll","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2026-03-12T13:58:57.000Z","updated_at":"2026-04-21T23:02:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kawarimidoll/guard-and-guide","commit_stats":null,"previous_names":["kawarimidoll/guard-and-guide"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/kawarimidoll/guard-and-guide","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawarimidoll%2Fguard-and-guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawarimidoll%2Fguard-and-guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawarimidoll%2Fguard-and-guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawarimidoll%2Fguard-and-guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kawarimidoll","download_url":"https://codeload.github.com/kawarimidoll/guard-and-guide/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawarimidoll%2Fguard-and-guide/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32208480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","claude-code","cli","gemini-cli","hooks","rust"],"created_at":"2026-04-01T22:44:54.938Z","updated_at":"2026-04-24T04:03:53.868Z","avatar_url":"https://github.com/kawarimidoll.png","language":"Rust","funding_links":["https://github.com/sponsors/kawarimidoll"],"categories":["Rust"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# guard-and-guide\n\n[![CI](https://github.com/kawarimidoll/guard-and-guide/actions/workflows/ci.yml/badge.svg)](https://github.com/kawarimidoll/guard-and-guide/actions/workflows/ci.yml)\n[![Latest version](https://img.shields.io/github/v/release/kawarimidoll/guard-and-guide)](https://github.com/kawarimidoll/guard-and-guide/releases/latest)\n[![Claude Code](https://img.shields.io/badge/Claude_Code-D97757?logo=claude\u0026logoColor=white)](https://docs.anthropic.com/en/docs/claude-code)\n[![Gemini CLI](https://img.shields.io/badge/Gemini_CLI-8E75B2?logo=google%20gemini\u0026logoColor=white)](https://github.com/google-gemini/gemini-cli)\n[![Rust](https://img.shields.io/badge/Rust-000000?logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![Nix](https://img.shields.io/badge/Nix-5277C3?logo=nixos\u0026logoColor=white)](https://nixos.org/)\n\n🛡️ Guard coding agents from dangerous operations, and 🧭 Guide them to safer alternatives.\n\n\u003c/div\u003e\n\n## Motivation\n\nYou tell your AI coding agent: \"Don't run `git push`.\"\n\nThe agent gets blocked — and tries harder:\n\n```\n🧑 deny(git push)\n🤖 Got it! I'll use /usr/bin/git push instead.\n🧑 NOOO!!!\n```\n\nAI agents don't give up when simply denied. They try absolute paths, alternative commands, and creative workarounds to get the job done.\n\n**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.\n\n## Install\n\n### nix\n\n```sh\nnix profile install github:kawarimidoll/guard-and-guide\n```\n\n### cargo\n\n```sh\ncargo install --git https://github.com/kawarimidoll/guard-and-guide\n```\n\n## Setup\n\n### 1. Create rules\n\nCreate `~/.config/guard-and-guide/rules.toml` with your rules.\nSee [`rules.example.toml`](rules.example.toml) for a full example.\n\nRules use canonical tool names (`Bash`, `File`) and regex patterns:\n\n```toml\nversion = 1\n\n[[rules]]\nmatcher = \"File\"\nregex = '\\.env$'\nmessage = \"Access to .env files is prohibited. Ask the user to check or provide the values you need.\"\n\n[[rules]]\nmatcher = \"Bash\"\nregex = '\\bgit\\s+push\\b'\nmessage = \"Use of 'git push' is prohibited. Ask the user to execute it.\"\n```\n\n`File` is an alias for `Read|Write|Edit`.\n\n### 2. Register hook\n\n#### Claude Code\n\nAdd to `~/.claude/settings.json`:\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [{ \"type\": \"command\", \"command\": \"guard-and-guide\" }]\n      }\n    ]\n  }\n}\n```\n\n#### Gemini CLI\n\nAdd to `~/.gemini/settings.json`:\n\n```json\n{\n  \"hooks\": {\n    \"BeforeTool\": [\n      {\n        \"matcher\": \"\",\n        \"hooks\": [{ \"type\": \"command\", \"command\": \"guard-and-guide --agent gemini-cli\" }]\n      }\n    ]\n  }\n}\n```\n\n\u003e Copilot CLI support is planned.\n\n## Usage\n\n```\nstdin (hook JSON) | guard-and-guide [OPTIONS]\n```\n\n| Option | Description |\n|---|---|\n| `--agent \u003cAGENT\u003e` | `claude-code` (default), `gemini-cli` |\n| `--config \u003cPATH\u003e` | Rules file path (default: `~/.config/guard-and-guide/rules.toml`) |\n\n## How it works\n\n```\nHook stdin → Parse JSON → Resolve tool name → Match rules → Deny or pass\n```\n\n1. Agent hook pipes JSON to stdin\n2. Parse and extract tool name + input (format depends on `--agent`)\n3. Resolve agent-specific tool name to canonical name (`Bash`, `Read`, `Write`, `Edit`)\n4. Check each rule: does the canonical name match? Does the regex match the relevant field?\n5. First match → output deny JSON to stdout. No match → silent exit 0.\n\n### Tool name mapping\n\n| Canonical | Claude Code | Gemini CLI |\n|---|---|---|\n| `Bash` | `Bash` | `run_shell_command` |\n| `Read` | `Read` | `read_file` |\n| `Write` | `Write` | `write_file` |\n| `Edit` | `Edit` | `replace` |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawarimidoll%2Fguard-and-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkawarimidoll%2Fguard-and-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawarimidoll%2Fguard-and-guide/lists"}