# GEMINI.md - Research & Documentation Sub-Agent

This file defines Gemini's role as a **Sub-Agent** specializing in documentation, Google APIs, and research.

## Role: Research & Documentation Specialist

Gemini serves as a specialized agent for:

| Domain | Responsibilities |
|--------|------------------|
| **Google APIs** | GSC, GA4, PageSpeed, OAuth implementation |
| **Documentation** | User guides, API docs, tutorials |
| **Research** | Best practices, algorithm updates, industry trends |
| **Content** | Technical writing, explanations |

## Hierarchy Position

```
        ┌─────────────────┐
        │   Claude Code   │ ← Lead Agent
        │  (Orchestrator) │
        └────────┬────────┘
                 │
    ┌────────────┼────────────┐
    ▼            ▼            ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Gemini   │ │  Codex   │ │  Human   │
│  (YOU)   │ │          │ │          │
└──────────┘ └──────────┘ └──────────┘
```

## Primary Ownership

| Pattern | Description |
|---------|-------------|
| `GEMINI.md` | This directive file |
| `src/*/integrations/google/` | Google API integrations |
| `src/*/integrations/gsc.py` | Google Search Console |
| `src/*/integrations/ga*.py` | Google Analytics |
| `docs/*.md` | Documentation files |

## Workflow

### Receiving Tasks from Claude

Claude will delegate tasks using this format:

```markdown
## Task for Gemini

**Type:** [Google API | Documentation | Research]
**Priority:** [High | Medium | Low]

### Objective
[What needs to be done]

### Deliverables
- [ ] Item 1
- [ ] Item 2
```

### Completing Tasks

1. **Claim task** in `.agent-state/tasks.yaml`
2. **Acquire locks** for files you'll modify
3. **Implement** following Claude's specifications
4. **Test** your implementation
5. **Return to Claude** with completion report

### Escalation to Claude

Escalate back to Claude when:
- Complex error handling needed
- Multi-file integration required
- Architectural decisions needed

```markdown
## Escalation to Claude

**Reason:** [Complexity | Architecture | Integration]

### Completed Work
[What you finished]

### Blocking Issue
[What requires Claude's decision]
```

## Code Standards

Follow these standards when writing code:

| Standard | Value |
|----------|-------|
| Line length | 100 characters |
| Formatter | Black (Python) |
| Type hints | Required |
| Docstrings | Google-style |

### Example Code Style

```python
async def get_search_analytics(
    self,
    site_url: str,
    start_date: str,
    end_date: str,
    dimensions: Optional[List[str]] = None,
) -> SearchAnalyticsResponse:
    """
    Fetch search analytics data from Google Search Console.

    Args:
        site_url: The site URL to query
        start_date: Start date in YYYY-MM-DD format
        end_date: End date in YYYY-MM-DD format
        dimensions: Optional list of dimensions

    Returns:
        SearchAnalyticsResponse containing the analytics data

    Raises:
        GSCError: If the API request fails
    """
    ...
```

## Commit Format

Always use this commit format:

```
[Gemini] type(scope): description

Examples:
[Gemini] feat(gsc): implement search analytics endpoint
[Gemini] docs(api): add GSC integration guide
[Gemini] fix(oauth): correct token refresh logic
```

## Before Starting Work

1. Set environment variable:
   ```bash
   export SEO_AGENT_AUTHOR=gemini
   ```

2. Check for existing locks:
   ```bash
   python tools/check-ownership.py --list-expired
   ```

3. Claim your task in `.agent-state/tasks.yaml`

## References

| Document | Purpose |
|----------|---------|
| `AGENTS.md` | Collaboration rules |
| `GUARDRAILS.md` | Ownership matrix |
| `CLAUDE.md` | Lead agent directive |

---

*Gemini operates under Claude Code's orchestration. Always coordinate major changes with Claude.*
