Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
Replace gemini-coach CLI with direct Gemini API calls (#42)
Jeremy Dawesec0276101f7a
diff --git a/plugins/dev-tools/skills/gemini-peer-review/SKILL.md b/plugins/dev-tools/skills/gemini-peer-review/SKILL.mdindex 48c4adca..9eb93184 100644--- a/plugins/dev-tools/skills/gemini-peer-review/SKILL.md+++ b/plugins/dev-tools/skills/gemini-peer-review/SKILL.md@@ -1,6 +1,6 @@---name: gemini-peer-review-description: "Get a second opinion from Gemini on code, architecture, debugging, or security. Uses gemini-coach CLI with AI-to-AI prompting for clear, actionable analysis. Trigger with 'ask gemini', 'gemini review', 'second opinion', 'peer review', or 'consult gemini'."+description: "Get a second opinion from Gemini on code, architecture, debugging, or security. Uses direct Gemini API calls — no CLI dependencies. Trigger with 'ask gemini', 'gemini review', 'second opinion', 'peer review', or 'consult gemini'."compatibility: claude-code-only---@@ -8,61 +8,83 @@ compatibility: claude-code-onlyConsult Gemini as a coding peer for a second opinion on code quality, architecture decisions, debugging, or security reviews.-## Prerequisites+## Setup-- `gemini-coach` CLI installed (wraps Gemini CLI with AI-to-AI prompting)-- Gemini CLI authenticated (`gemini` to test)+**API Key**: Retrieve from Vault before first use:-## Modes+```+mcp__vault__secret_get name="Google Gemini"+```-### Code Review+Export as `GEMINI_API_KEY` for the script.++## Workflow++1. **Determine mode** from user request (review, architect, debug, security, quick)+2. **Read target files** into context+3. **Build prompt** using the AI-to-AI template from [references/prompt-templates.md](references/prompt-templates.md)+4. **Write prompt to file** at `.claude/artifacts/gemini-prompt.txt` (avoids shell escaping issues)+5. **Call the API** via the review script:```bash-gemini-coach review src/auth.ts src/api.ts+mkdir -p .claude/artifacts+# Write prompt to file first (step 4), then:+GEMINI_API_KEY="$KEY" python3 plugins/dev-tools/skills/gemini-peer-review/scripts/gemini-review.py \+ --model gemini-2.5-flash \+ --prompt-file .claude/artifacts/gemini-prompt.txt```+6. **Synthesize** — present Gemini's findings, add your own perspective (agree/disagree), let the user decide what to implement++## Modes++### Code Review+Review specific files for bugs, logic errors, security vulnerabilities, performance issues, and best practice violations.+Read the target files, build a prompt using the Code Review template, call with `gemini-2.5-flash`.+### Architecture Advice-```bash-gemini-coach architect "Should I use D1 or KV for session storage?" .-```+Get feedback on design decisions with trade-off analysis. Include project context (CLAUDE.md, relevant source files).-Get feedback on design decisions with trade-off analysis. Passing `.` includes project context.+Read project context, build a prompt using the Architecture template, call with `gemini-2.5-pro`.### Debugging Help-```bash-gemini-coach debug src/problematic-file.ts-```-Analyse errors when stuck after 2+ failed fix attempts. Gemini sees the code fresh without your debugging context bias.-### Security Scan+Read the problematic files, build a prompt using the Debug template (include error message and previous attempts), call with `gemini-2.5-flash`.-```bash-gemini-coach security-scan ./src/api/-```+### Security ScanScan code for security vulnerabilities (injection, auth bypass, data exposure).+Read the target directory's source files, build a prompt using the Security template, call with `gemini-2.5-pro`.+### Quick Question+Fast question without file context. Build prompt inline and call with `gemini-2.5-flash`.+```bash-gemini-coach quick "Best way to handle WebSockets in Workers?"+GEMINI_API_KEY="$KEY" python3 plugins/dev-tools/skills/gemini-peer-review/scripts/gemini-review.py \+ --model gemini-2.5-flash \+ --prompt "[Claude Code consulting Gemini] Quick question: What's the best way to handle WebSockets in Workers?"```-Fast question without file context.+## Model Selection++| Mode | Model | Why |+|------|-------|-----|+| review, debug, quick | `gemini-2.5-flash` | Fast, good for straightforward analysis |+| architect, security-scan | `gemini-2.5-pro` | Better reasoning for complex trade-offs |-### Project Review+Override by changing the `--model` argument. Check current model IDs if errors occur — they change frequently:```bash-gemini-coach project-review "Analyse architecture and suggest improvements" /path/to/project+curl -s "https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY" | python3 -c "import sys,json; [print(m['name']) for m in json.load(sys.stdin)['models'] if 'gemini' in m['name']]"```-Full project analysis using Gemini's 1M token context.-## When to Use**Good use cases**:@@ -70,33 +92,25 @@ Full project analysis using Gemini's 1M token context.- When stuck debugging after multiple attempts- Architecture decisions with multiple valid options- Security-sensitive code review-- "What am I missing?" moments**Avoid using for**:- Simple syntax checks (Claude handles these faster)- Every single edit (too slow, unnecessary)- Questions with obvious answers-## Model Selection--`gemini-coach` automatically selects the right model:--| Mode | Model | Typical Time |-|------|-------|-------------|-| review, debug, quick | gemini-2.5-flash | 5-15s |-| architect, security-scan | gemini-2.5-pro | 15-30s |--Override: `GEMINI_MODEL=gemini-2.5-pro gemini-coach review ...`+## Prompt Construction-## Synthesizing Results+**Critical**: Always use the AI-to-AI prompting format. Write the full prompt to a file — never pass code inline via bash arguments (shell escaping will break it).-After receiving Gemini's analysis:-1. Present Gemini's findings to the user-2. Add your own perspective — agree/disagree with specific points-3. Let the user decide which recommendations to implement+When building the prompt:+1. Start with the AI-to-AI header from [references/prompt-templates.md](references/prompt-templates.md)+2. Append the mode-specific template+3. Append the file contents with clear `--- filename ---` separators+4. Write to `.claude/artifacts/gemini-prompt.txt`+5. Call the script with `--prompt-file`## Reference Files| When | Read ||------|------|-| AI-to-AI prompt templates, model details | [references/prompt-templates.md](references/prompt-templates.md) |+| Building prompts for any mode | [references/prompt-templates.md](references/prompt-templates.md) |diff --git a/plugins/dev-tools/skills/gemini-peer-review/scripts/gemini-review.py b/plugins/dev-tools/skills/gemini-peer-review/scripts/gemini-review.pynew file mode 100644index 00000000..4b2e7ac5--- /dev/null+++ b/plugins/dev-tools/skills/gemini-peer-review/scripts/gemini-review.py@@ -0,0 +1,81 @@+#!/usr/bin/env python3+"""Call Gemini API for peer review. No CLI dependencies — just urllib.++Usage:+ python3 gemini-review.py --model gemini-2.5-flash --prompt-file /tmp/prompt.txt+ python3 gemini-review.py --model gemini-2.5-pro --prompt "Review this code..."++Reads GEMINI_API_KEY from environment. Exit 1 on error with message to stderr.+"""++import argparse+import json+import os+import sys+import urllib.request+import urllib.error+++def call_gemini(model: str, prompt: str, api_key: str) -> str:+ url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={api_key}"++ payload = json.dumps({+ "contents": [{"parts": [{"text": prompt}]}],+ "generationConfig": {+ "temperature": 0.3,+ "maxOutputTokens": 8192,+ },+ }).encode()++ req = urllib.request.Request(+ url,+ data=payload,+ headers={"Content-Type": "application/json"},+ method="POST",+ )++ try:+ with urllib.request.urlopen(req, timeout=120) as resp:+ data = json.loads(resp.read().decode())+ except urllib.error.HTTPError as e:+ body = e.read().decode() if e.fp else ""+ print(f"Gemini API error {e.code}: {body}", file=sys.stderr)+ sys.exit(1)+ except urllib.error.URLError as e:+ print(f"Network error: {e.reason}", file=sys.stderr)+ sys.exit(1)++ try:+ return data["candidates"][0]["content"]["parts"][0]["text"]+ except (KeyError, IndexError):+ print(f"Unexpected response structure: {json.dumps(data, indent=2)}", file=sys.stderr)+ sys.exit(1)+++def main():+ parser = argparse.ArgumentParser(description="Call Gemini API for peer review")+ parser.add_argument("--model", default="gemini-2.5-flash", help="Gemini model ID")+ parser.add_argument("--prompt", help="Prompt text (inline)")+ parser.add_argument("--prompt-file", help="Path to file containing the prompt")+ args = parser.parse_args()++ api_key = os.environ.get("GEMINI_API_KEY")+ if not api_key:+ print("GEMINI_API_KEY not set. Get it from Vault: mcp__vault__secret_get name='Google Gemini'", file=sys.stderr)+ sys.exit(1)++ if args.prompt_file:+ with open(args.prompt_file) as f:+ prompt = f.read()+ elif args.prompt:+ prompt = args.prompt+ else:+ print("Provide --prompt or --prompt-file", file=sys.stderr)+ sys.exit(1)++ result = call_gemini(args.model, prompt, api_key)+ print(result)+++if __name__ == "__main__":+ main()