Hooks: Context Injectors
The Development Kit includes two powerful hooks designed to automatically inject the correct context into AI interactions, ensuring consistency and saving you from repetitive manual work.
1. Sub-Agent Context Injector
Script: subagent-context-injector.sh
Purpose: To ensure that every sub-agent spawned via the Task
tool has the same foundational understanding of your project.
Trigger: PreToolUse
for the Task
tool.
How It Works
Whenever you or a command spawns a sub-agent, this hook intercepts the request. It automatically prepends references to three core documentation files to the sub-agent's prompt:
@/CLAUDE.md
(Master context, coding standards)@/docs/ai-context/project-structure.md
(Tech stack and file tree)@/docs/ai-context/docs-overview.md
(Documentation map)
Benefits
- Consistency: All sub-agents start with the same baseline knowledge.
- Efficiency: Eliminates the need to manually add context to every
Task
prompt. - Maintainability: You only need to update the core documentation files, and the changes are automatically propagated to all future sub-agents.
2. Gemini Context Injector
Script: gemini-context-injector.sh
Purpose: To provide the Gemini Assistant MCP with deep, project-specific context at the beginning of every new consultation.
Trigger: PreToolUse
for the mcp__gemini__consult_gemini
tool.
How It Works
This hook detects when a new Gemini consultation session is being started (i.e., the request has no session_id
). For these new sessions, it automatically adds two key files to the attached_files
list:
docs/ai-context/project-structure.md
: Gives Gemini a complete overview of your project's technology and layout.MCP-ASSISTANT-RULES.md
: Provides Gemini with your project's specific coding standards and principles.
The hook is smart enough not to add these files if they are already present or if it's an existing session, preventing redundancy.
Benefits
- Higher Quality Advice: Gemini's architectural suggestions are tailored to your specific tech stack and standards from the very first prompt.
- Automation: You don't have to remember to attach these crucial files every time you start a new consultation.