Mobile notifications and session persistence for Gemini CLI, part of the ShadowAI ecosystem.
Gemini Shadow enables real-time synchronization between Gemini CLI and ShadowAI Android app through ShadowBridge. Get notified on your phone when Gemini needs input, approve tool executions remotely, and maintain session history across devices.
- Session Tracking: Automatic session start/end notifications
- Permission Requests: Remote approval for tool executions (shell commands, file writes)
- Notifications: Forward Gemini notifications to your phone
- Context Caching: Maintains context for richer notifications
- Provider Identification: All messages tagged with
provider: "gemini"for routing
- Gemini CLI v1.0.0 or later
- ShadowBridge running on Windows PC
- ShadowAI Android app
- Dependencies:
bash(Git Bash on Windows, native on Linux/Mac)jqfor JSON parsingpython3for TCP communication
-
Copy the
gemini-shadowdirectory to your Gemini CLI plugins location:# Linux/Mac cp -r gemini-shadow ~/.gemini/plugins/ # Windows (Git Bash) cp -r gemini-shadow "$APPDATA/gemini/plugins/"
-
Make scripts executable:
chmod +x ~/.gemini/plugins/gemini-shadow/scripts/*.sh
-
Configure Gemini CLI to load the plugin:
gemini config set plugins.gemini-shadow.enabled true
If you already have claude-shadow configured, you can migrate:
# Use Gemini CLI's migration tool (if available)
gemini hooks migrate --from-claude
# Or manually copy and adapt configurationgemini hooks install ./gemini-shadow/Create ~/.gemini-shadow-config.json:
{
"bridgeHost": "127.0.0.1",
"bridgePort": 19286,
"enabled": true
}| Option | Default | Description |
|---|---|---|
bridgeHost |
127.0.0.1 |
ShadowBridge host IP |
bridgePort |
19286 |
ShadowBridge companion port |
enabled |
true |
Enable/disable plugin |
| Event | Script | Description |
|---|---|---|
SessionStart |
session-start.sh |
Triggered when Gemini CLI session begins |
SessionEnd |
session-end.sh |
Triggered when session ends |
BeforeAgent |
before-agent.sh |
Triggered before processing user prompt |
AfterAgent |
after-agent.sh |
Triggered after agent completes turn |
BeforeTool |
before-tool.sh |
Triggered before tool execution (permission requests) |
AfterTool |
after-tool.sh |
Triggered after tool execution |
Notification |
notification.sh |
Triggered for Gemini notifications |
All messages use the ShadowBridge length-prefixed JSON protocol:
[4-byte big-endian length][JSON payload]
Session Start:
{
"type": "session_start",
"id": "msg_1234567890_abcd1234",
"sessionId": "gemini_1234567890_efgh5678",
"timestamp": 1704067200000,
"provider": "gemini",
"payload": {
"hostname": "MY-PC",
"cwd": "/home/user/project",
"projectName": "project",
"provider": "gemini"
}
}Permission Request:
{
"type": "permission_request",
"id": "msg_1234567890_abcd1234",
"sessionId": "gemini_1234567890_efgh5678",
"timestamp": 1704067200000,
"provider": "gemini",
"payload": {
"requestId": "req_1234567890_ijkl9012",
"toolName": "run_shell_command",
"description": "Run: npm install",
"options": ["Approve", "Deny", "Always Allow"],
"promptType": "PERMISSION",
"provider": "gemini"
}
}# View recent log entries
tail -f ~/.gemini-shadow-debug.log# Check if ShadowBridge is listening
nc -zv 127.0.0.1 19286- Connection Refused: Ensure ShadowBridge is running and listening on port 19286
- Permission Denied: Run
chmod +xon all script files - jq not found: Install jq:
apt install jq(Linux) orbrew install jq(Mac) - Python not found: Ensure python3 is in PATH
┌─────────────────┐
│ Gemini CLI │◄──hooks (SessionStart, BeforeTool, etc.)
│ (gemini- │
│ shadow) │
└────────┬────────┘
│ JSON via TCP (port 19286)
▼
┌─────────────────┐
│ ShadowBridge │◄──WebSocket──► Android App
│ (Windows PC) │ (Room Database)
└─────────────────┘
| Claude Code Event | Gemini CLI Event |
|---|---|
| SessionStart | SessionStart |
| SessionEnd | SessionEnd |
| PermissionRequest | BeforeTool |
| UserPromptSubmit | BeforeAgent |
| Stop | AfterAgent |
| Notification | Notification |
| Claude Tool | Gemini Tool |
|---|---|
| Bash | run_shell_command |
| Edit | replace |
| Read | read_file |
| Write | write_file |
| Glob | glob |
| Grep | search_file_content |
MIT License - See LICENSE file for details.