/jleechan-skills:extended-library:second_opinionfrom jleechan-skills
Gets multi-model AI feedback on code, design decisions, or bug analysis by routing through the AI Universe MCP server for unified authentication and orchestration across Gemini, Perplexity, and OpenAI.
Ships in jleechan-skills. Installing the plugin adds it to Claude Code.
Get comprehensive multi-model AI feedback on your code, design decisions, or bug analysis.
🚀 Uses command-line approach to bypass 25K token limits and send full PR context!
This command MUST route ALL requests through the AI Universe MCP server.
Set an environment variable so the endpoint can switch between dev/stage/prod without editing docs:
export AI_UNIVERSE_MCP_ENDPOINT="${AI_UNIVERSE_MCP_ENDPOINT:-https://ai-universe-backend-dev-114133832173.us-central1.run.app/mcp}"
Use the dev URL only as the default. Override
AI_UNIVERSE_MCP_ENDPOINTfor staging/production deployments.
❌ NEVER call Gemini MCP tools directly (e.g., mcp__gemini__*, mcp__google__*)
❌ NEVER call Perplexity MCP tools directly (e.g., mcp__perplexity__*)
❌ NEVER call OpenAI MCP tools directly (e.g., mcp__openai__*)
❌ NEVER use WebSearch as a substitute for second opinion
❌ NEVER skip the AI Universe authentication flow
❌ NEVER construct direct API calls to Gemini/Perplexity/OpenAI endpoints
The AI Universe server provides:
If you call model MCPs directly, you bypass all these benefits and get inferior results.
# Get second opinion on current PR branch
/secondo
# Specify feedback type
/secondo design
/secondo code-review
/secondo bugs
# With specific question
/secondo "Should I use Redis or in-memory caching for rate limiting?"
This command uses a direct approach with auth-cli.mjs for secure token management:
Authentication (Auto-Refresh):
~/.claude/scripts/auth-cli.mjs token for secure token retrievalGather Full PR Context (automated via build_second_opinion_request.py):
SECOND_OPINION_BASE_REF, falls back to origin/main → main → master)git status --short, git diff --stat, and recent commits for orientationBuild Comprehensive Request:
Direct MCP Server Call:
AI_UNIVERSE_MCP_ENDPOINT (dev URL is the default)Multi-Model Analysis:
Results Display:
tmp/secondo_analysis_[timestamp].mdWhen executing /second_opinion or /secondo:
Testing note (documentation-only update): This change clarifies routing and auth requirements for the existing workflow. No application code was modified, so no automated test suite was rerun for this documentation revision.
PRIMARY APPROACH: Use MCP CLI (Recommended)
Try the installed MCP server first using Claude Code's built-in MCP CLI:
# Check if second-opinion-tool MCP server is available
if mcp-cli tools second-opinion-tool 2>&1 | grep -q "agent.second_opinion"; then
echo "✅ Using MCP CLI approach"
USE_MCP_CLI=true
else
echo "⚠️ MCP server not available, falling back to manual CLI"
USE_MCP_CLI=false
fi
FALLBACK APPROACH: Manual CLI with HTTPie
If MCP CLI is not available or fails, use the manual HTTP approach with authentication.
Action Steps:
/e to gather context from ALL memory sources:
/e /memory_search "$ARGUMENTS"
Note: Only required for FALLBACK approach. MCP CLI handles auth automatically.
# Verify auth-cli.mjs is installed
if [ ! -f "$HOME/.claude/scripts/auth-cli.mjs" ]; then
echo "❌ auth-cli.mjs not found. Install it to $HOME/.claude/scripts/auth-cli.mjs"
exit 1
fi
# CRITICAL: Use AI Universe Firebase credentials with VITE_ prefix (required by auth-cli.mjs)
export VITE_AI_UNIVERSE_FIREBASE_PROJECT_ID="${VITE_AI_UNIVERSE_FIREBASE_PROJECT_ID:-ai-universe-b3551}"
export VITE_AI_UNIVERSE_FIREBASE_AUTH_DOMAIN="${VITE_AI_UNIVERSE_FIREBASE_AUTH_DOMAIN:-ai-universe-b3551.firebaseapp.com}"
# API key - hardcoded default for AI Universe shared service (safe to expose per Firebase security model)
export VITE_AI_UNIVERSE_FIREBASE_API_KEY="${VITE_AI_UNIVERSE_FIREBASE_API_KEY:-[REDACTED_GCP_KEY]}"
# Get token (auto-refreshes if expired using refresh token)
# This is silent - only prompts for login if refresh token is invalid/missing
TOKEN=$(node ~/.claude/scripts/auth-cli.mjs token)
# If this fails, user needs to authenticate with AI Universe credentials
if [ $? -ne 0 ]; then
echo "❌ Authentication failed. Please run:"
echo " VITE_AI_UNIVERSE_FIREBASE_PROJECT_ID=ai-universe-b3551 \\"
echo " VITE_AI_UNIVERSE_FIREBASE_AUTH_DOMAIN=ai-universe-b3551.firebaseapp.com \\"
echo " VITE_AI_UNIVERSE_FIREBASE_API_KEY=[REDACTED_GCP_KEY] \\"
echo " node ~/.claude/scripts/auth-cli.mjs login"
exit 1
fi
Key Behavior:
ai-universe-b3551 Firebase project (NOT worldarchitecture-ai)~/.ai-universe/auth-token.json (exact same as AI Universe repo)The AI Universe workflow helper skills/second_opinion_workflow/scripts/request_second_opinion.sh (documented by the ai-universe plugin's ai-universe-second-opinion-workflow skill) calls
build_second_opinion_request.py to harvest the full PR delta. The helper:
SECOND_OPINION_BASE_REF, then origin/main → main → master, finally HEAD^).git status --short, git diff --stat, recent commits, and the full diff.SECOND_OPINION_MAX_FILES (default 20) with truncation markers when limits are hit.gitContextNotices so the MCP tool sees exactly what was trimmed.Manual usage if you want to inspect the payload directly:
python3 skills/second_opinion_workflow/scripts/build_second_opinion_request.py \
/tmp/secondo_request.json \
"What should I double-check before merging?" \
3 \
origin/main
Tune the capture limits with environment variables:
export SECOND_OPINION_BASE_REF=origin/main # override comparison base
export SECOND_OPINION_MAX_FILES=25 # number of per-file patches to attach
export SECOND_OPINION_MAX_DIFF_CHARS=32000 # full diff char budget
export SECOND_OPINION_MAX_PATCH_CHARS=8000 # per-file diff char budget
The generated payload now includes the git context automatically:
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "agent.second_opinion",
"arguments": {
"question": "Should I land this patch set as-is?",
"maxOpinions": 3,
"gitContext": {
"branch": "feature/refactor",
"base": "origin/main",
"diffstat": "…",
"recentCommits": "…",
"changedFiles": [
{"status": "M", "path": "$PROJECT_ROOT/api/routes.py"},
{"status": "A", "path": "$PROJECT_ROOT/services/cache.py"}
],
"patches": {
"$PROJECT_ROOT/api/routes.py": "@@ -42,6 +42,15 @@ …",
"$PROJECT_ROOT/services/cache.py": "@@ -0,0 +1,200 @@ …"
},
"limits": {
"maxFiles": 20,
"diffCharLimit": 24000,
"patchCharLimit": 6000
}
},
"gitContextNotices": [
"git diff origin/main...HEAD truncated by 1520 characters (limit 24000)."
]
}
},
"id": 1
}
💡 You can still tailor the natural-language question, but you no longer need to paste diff snippets manually—the helper attaches them for you.
Option A: MCP CLI Approach (Primary)
# First, check the MCP CLI tool schema
mcp-cli info second-opinion-tool/agent.second_opinion
# Prepare the request payload (simplified for MCP CLI)
QUESTION="${1:-Should I land this patch set as-is?}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
# Call via MCP CLI
mcp-cli call second-opinion-tool/agent.second_opinion - <<EOF
{
"question": "$QUESTION",
"maxOpinions": 3,
"gitContext": $(cat /tmp/secondo_git_context.json)
}
EOF > /tmp/secondo_analysis_${TIMESTAMP}.json
# Check if successful
if [ $? -eq 0 ] && [ -s /tmp/secondo_analysis_${TIMESTAMP}.json ]; then
echo "✅ Analysis complete via MCP CLI"
echo "📄 Results: /tmp/secondo_analysis_${TIMESTAMP}.json"
else
echo "⚠️ MCP CLI failed, falling back to manual approach"
USE_MCP_CLI=false
fi
Option B: Manual HTTPie Approach (Fallback)
# Call MCP server with HTTPie (matches request_second_opinion.sh)
MCP_ENDPOINT="${AI_UNIVERSE_MCP_ENDPOINT:-https://ai-universe-backend-dev-114133832173.us-central1.run.app/mcp}"
http POST "$MCP_ENDPOINT" \
"Accept:application/json, text/event-stream" \
"Authorization:Bearer $TOKEN" \
< /tmp/secondo_request.json \
--timeout=180 \
--print=b > /tmp/secondo_response.json
# Check if successful
if [ $? -eq 0 ] && [ -s /tmp/secondo_response.json ]; then
echo "✅ Analysis complete"
else
echo "❌ Request failed"
exit 1
fi
Extract from /tmp/secondo_response.json:
result.content[0].text)tmp/secondo_analysis_[timestamp].mdExample parsing:
# Extract the main response text
jq -r '.result.content[0].text' /tmp/secondo_response.json > /tmp/secondo_parsed.txt
# Extract metrics if available
TOKENS=$(jq -r '.result.content[0].text' /tmp/secondo_response.json | grep -o 'Total Tokens: [0-9,]*' | head -1)
COST=$(jq -r '.result.content[0].text' /tmp/secondo_response.json | grep -o 'Total Cost: \$[0-9.]*' | head -1)
Maximum token budget: 24,900 tokens (stay under 25K limit)
Allocation strategy:
Tips to maximize context:
Authentication: Required via Firebase OAuth (exact same as AI Universe repo)
node ~/.claude/scripts/auth-cli.mjs login (browser-based OAuth, run outside Claude Code)node ~/.claude/scripts/auth-cli.mjs status (view current auth status)~/.ai-universe/auth-token.json (ID token + refresh token)/secondo automatically refreshes expired ID tokens (no browser popup needed)Token Lifecycle:
When You'll Need to Re-authenticate:
Rate Limits: Applied per authenticated user based on Firebase account
Practical limits:
Display results in markdown with:
Save to: tmp/secondo_analysis_[timestamp].md
✅ Request completes successfully (curl exit code 0)
✅ Response file is non-empty
✅ Response contains valid JSON with result.content
✅ Analysis report saved to tmp directory
✅ User sees verdict and key findings
Common issues:
--max-time 180User: /secondo
1. Gather PR context:
✓ Branch: fix_mcp
✓ Changed files: 18 files (+2448/-799)
✓ Git diff saved to /tmp/secondo_diff_full.txt
✓ Commits: 5 commits analyzed
2. Build analysis request:
✓ Question: 487 words
✓ Code context: 14,250 tokens
✓ Total estimated: 23,890 tokens (95.6% of limit)
3. Execute request:
✓ curl -X POST [MCP endpoint]
✓ Response: 73KB received in 47 seconds
✓ Status: HTTP 200 OK
4. Parse results:
✓ Models: 3 (Gemini, Perplexity, OpenAI)
✓ Total tokens: 24,964
✓ Total cost: $0.10193
✓ Sources: 52 authoritative references
5. Display verdict:
🎯 UNANIMOUS VERDICT: CORRECT (with caveats)
✅ Fix is safe for production
⚠️ Array initialization discipline required
📊 Report saved: tmp/secondo_analysis_20251031_1847.md
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: commands: Invalid input, agents.0: Invalid string: must start with "./", agents.0: Invalid string: must end with ".md", skills.0: Invalid string: must start with "./"
.claude-plugin/plugin.json: commands: Invalid input, agents.0: Invalid string: must start with "./", agents.0: Invalid string: must end with ".md", skills.0: Invalid string: must start with "./"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
176 commands in this plugin
/abalAlias for /ablation./ablationAblation — measure a disputed root cause by replaying the real payload through the real path, one variable per arm, control first/adviceIndependent full-scope second opinion bound to an exact SHA or document bundle. Follow the canonical advice skill for lifecycle-dependent quorum, capability tiers, reviewer-class caps, deadlines and receipts; /research is nonvoting.