gemini-hooks

Automate Gemini CLI workflows by applying lifecycle hooks to sessions, tools, and prompts.

21|Updated Jan 5, 2024
One-click install
npx skills add https://github.com/olafkfreund/nixos_config --skill gemini-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gemini-hooks
Source: https://github.com/olafkfreund/nixos_config/tree/main/.gemini/skills/gemini-hooks
Command: npx skills add https://github.com/olafkfreund/nixos_config --skill gemini-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

## What problem does it solve? Gemini CLI hooks provide a structured mechanism to customize and automate Gemini CLI behavior across sessions, tool calls, and prompts, reducing manual setup and repetitive tasks.

## Core Features & Use Cases

  • Lifecycle events: trigger scripts on SessionStart, SessionEnd, BeforeAgent, AfterAgent, BeforeModel, AfterModel, BeforeTool, AfterTool, and Notification.
  • Command hooks: execute scripts or commands in response to events.
  • Matcher-based filters: selectively apply hooks to specific tools or prompts.
  • Layered configuration: project-specific hooks can override global user hooks for consistency.
  • Use cases: initialize environments for projects, log activity, enforce policies, and intercept tool calls.

### Quick Start Enable hooks in your settings.json, add scripts under the hooks directory (e.g., .gemini/settings.json hooks) and verify with /hooks commands.

Frequently Asked Questions about gemini-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Gemini CLI with lifecycle hooks?

To automate Gemini CLI with lifecycle hooks, you configure a hooks array in settings.json to trigger executable scripts on events like SessionStart, BeforeTool, and AfterTool. This enables automated project setup, logging, and cleanup for CLI workflows.

What lifecycle events can I trigger scripts on in Gemini CLI?

Gemini CLI lifecycle hooks support triggering scripts on events including SessionStart, SessionEnd, BeforeAgent, AfterAgent, BeforeModel, AfterModel, BeforeTool, AfterTool, and Notification. This allows interception and customization of tool calls and model interactions.

How do I set up per-project hook configurations in Gemini CLI?

You can set up per-project hook configurations by defining a hooks array in your project's settings.json. Project-specific hooks can override global user hooks, ensuring consistent environment initialization and policy enforcement across that specific project workspace.

Can I selectively apply hooks to specific tools or prompts in Gemini CLI?

Yes, you can selectively apply hooks to specific tools or prompts using matcher-based filters. This allows you to intercept and execute custom scripts only when targeted tools are called or specific prompt conditions are met during your CLI session.

Do I need any dependencies to use Gemini CLI hooks?

No external dependencies are required to use Gemini CLI hooks. You simply need to enable hooks in your settings.json file and provide executable scripts under your designated hooks directory to implement the desired lifecycle event actions.