mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-08-08 16:11:58 -07:00
e17f927a69
Co-authored-by: Jerop Kipruto <jerop@google.com>
1.4 KiB
1.4 KiB
Policy engine example extension
This extension demonstrates how to contribute security rules and safety checkers to the Gemini CLI Policy Engine.
Description
The extension uses a policies/ directory containing .toml files to define:
- A rule that requires user confirmation for
rm -rfcommands. - A rule that denies searching for sensitive files (like
.env) usinggrep. - A safety checker that validates file paths for all write operations.
Structure
gemini-extension.json: The manifest file.policies/: Contains the.tomlpolicy files.
How to use
-
Link this extension to your local Gemini CLI installation:
gemini extensions link packages/cli/src/commands/extensions/examples/policies -
Restart your Gemini CLI session.
-
Observe the policies:
- Try asking the model to delete a directory: The policy engine will prompt
you for confirmation due to the
rm -rfrule. - Try asking the model to search for secrets: The
greprule will deny the request and display the custom deny message. - Any file write operation will now be processed through the
allowed-pathsafety checker.
- Try asking the model to delete a directory: The policy engine will prompt
you for confirmation due to the
Security note
For security, Gemini CLI ignores any allow decisions or yolo mode
configurations contributed by extensions. This ensures that extensions can
strengthen security but cannot bypass user confirmation.