AgentSkillsCN

gemini-assistant

针对复杂任务,协调Claude与Gemini两大模型协作。Gemini擅长处理大型代码库(100KB以上),能在多文件间快速发现规律,并高效完成验证性查询。当上下文信息超出Claude的处理上限,或需进行全代码库分析、实施效果验证时,可选择调用Gemini。通过‘gemini -p’ CLI命令,配合@语法实现文件引入。务必对Gemini的输出结果进行严格审视;若Gemini无法使用,则自动回退至Claude。

SKILL.md
--- frontmatter
name: gemini-assistant
description: Coordinate between Claude and Gemini for complex tasks. Gemini excels at ingesting large codebases (100KB+), finding patterns across many files, and verification queries. Use when context would overflow Claude, for codebase-wide analysis, or implementation verification. Invoke via 'gemini -p' CLI with @ syntax for file inclusion. Always critically review Gemini's output. Falls back to Claude if Gemini is unavailable.

Skill: Gemini Assistant

Purpose

Delegate large-context analysis tasks to Gemini CLI when Claude's context window is insufficient or when you need rapid pattern-matching across entire codebases.

When to Use This Skill

Use Gemini when:

  • Analyzing entire codebases or large directories (100KB+ of files)
  • Comparing multiple large files simultaneously
  • Need to understand project-wide patterns or architecture
  • Verifying if specific features, patterns, or security measures exist
  • Checking for coding patterns across the entire codebase
  • Current context would overflow with the required files

When NOT to Use

  • Small, focused tasks that fit in current context
  • Tasks requiring execution, code changes, or file modifications
  • When you need precise, step-by-step reasoning
  • For tasks where accuracy is more important than breadth

Fallback Protocol

If Gemini is unavailable (rate limits, errors, not installed), fall back to Claude:

  1. Check for Gemini errors:

    • "API rate limit exceeded" → Wait or fall back
    • "command not found: gemini" → Gemini CLI not installed
    • Connection errors → Network issue, fall back
    • Empty or garbled response → Retry once, then fall back
  2. Claude fallback strategy:

    • Break the task into smaller chunks that fit Claude's context
    • Use targeted file reads instead of directory-wide analysis
    • Prioritize most critical files first
    • Use grep/glob to narrow scope before reading
  3. Inform the user:

    • Explain Gemini is unavailable
    • Describe the adapted approach
    • Note any limitations of the fallback

See workflows/fallback-to-claude.md for detailed fallback procedures.

Routing Logic

Analyze user intent and route to appropriate workflow:

Codebase Analysisworkflows/analyze-codebase.md

  • "Summarize the architecture"
  • "What does this codebase do?"
  • "Give me an overview of the project"
  • "Analyze the project structure"

Implementation Verificationworkflows/verify-implementation.md

  • "Has [feature] been implemented?"
  • "Is [pattern] used in the codebase?"
  • "Check if [security measure] exists"
  • "Verify [functionality] is present"

Pattern Searchworkflows/search-patterns.md

  • "Find all [pattern] in the code"
  • "Search for [usage] across files"
  • "Locate [specific code pattern]"
  • "List all [type of code]"

File Comparisonworkflows/compare-files.md

  • "Compare [file1] and [file2]"
  • "What's the difference between these implementations?"
  • "Analyze dependencies between files"

Dependency Auditworkflows/audit-dependencies.md

  • "Find unused dependencies"
  • "Which packages aren't being used?"
  • "Audit the package.json"

Duplication Detectionworkflows/detect-duplication.md

  • "Find duplicated code"
  • "What code is copy-pasted?"
  • "Find repeated patterns to refactor"

Documentation Draftsworkflows/draft-documentation.md

  • "Generate API documentation"
  • "Write an architecture doc"
  • "Create onboarding guide"

Migration Analysisworkflows/migration-analysis.md

  • "What breaks if we upgrade [library]?"
  • "Impact of migrating to [framework]?"
  • "Analyze migration from X to Y"

CLI Syntax Reference

Basic invocation:

bash
gemini -p "Your prompt here"

File/directory inclusion with @ syntax (paths relative to CWD):

bash
# Single file
gemini -p "@src/main.py Explain this file"

# Multiple files
gemini -p "@package.json @src/index.js Analyze dependencies"

# Entire directory
gemini -p "@src/ Summarize the architecture"

# Multiple directories
gemini -p "@src/ @tests/ Analyze test coverage"

# Current directory
gemini -p "@./ Give me an overview"

# All files flag
gemini --all_files -p "Analyze project structure"

Context Files

  • context/gemini-capabilities.md - What Gemini excels at and limitations
  • context/cli-reference.md - Complete CLI syntax and options

Issue Tracking

Log problems encountered with Gemini in ISSUES.md to improve this skill over time. Include:

  • The command that failed
  • What went wrong (accuracy, timeout, rate limit, etc.)
  • How it was resolved
  • Suggestions for improvement

Critical Notes

  1. Always review Gemini's output - It's good at breadth, Claude is better at precision
  2. Paths are relative - The @ syntax uses paths relative to where gemini command runs
  3. Read-only tool - Gemini CLI is for analysis, not execution or modification
  4. Claude orchestrates - Results come back to Claude for final processing and action
  5. Fallback ready - If Gemini fails, Claude can handle the task with adapted strategy