ai-universe-second-opinion-workflow
Complete workflow for using AI Universe MCP /secondo command
What this skill does
# AI Universe Second Opinion Workflow
**Quick start:** Use `/secondo` or the HTTPie helper script to gather multi-model analysis (Cerebras, Gemini, Perplexity, GPT-4o + synthesis).
---
## Activation cues
- Requests to run or debug the AI Universe "second opinion" workflow.
- Follow-ups after failed `/secondo` runs or HTTPie 401/5xx errors.
- Planning sessions that need step-by-step instructions for MCP calls.
- Questions about cost, rate limits, or interpreting multi-model output.
## Prerequisites & authentication
1. **Verify auth-cli.mjs installation**:
```bash
test -f ~/.claude/scripts/auth-cli.mjs && echo "✅ Installed" || echo "❌ Not found - run /localexportcommands"
```
2. **Check authentication status**:
```bash
node ~/.claude/scripts/auth-cli.mjs status
```
3. **If not authenticated or token expired**, run login (opens browser for OAuth):
```bash
# Run this outside Claude Code in a regular terminal
node ~/.claude/scripts/auth-cli.mjs login
```
4. Ensure `http` (HTTPie), `jq`, `python3`, and `node` (>=20.0.0) are installed in the environment.
> ℹ️ **Seamless Auto-Refresh**: The `/secondo` command uses the exact same auth-cli.mjs from AI Universe repo. If your token is valid, it does nothing. If expired, it auto-refreshes using your refresh token (silent, no browser popup). Only prompts for login if refresh token expires (30+ days).
> ℹ️ **Token Location**: All tokens stored in `~/.ai-universe/auth-token.json` (same as AI Universe repo)
> - ID token: 1-hour expiration
> - Refresh token: enables 30+ day sessions
> ℹ️ For a dedicated authentication walkthrough see [ai-universe-auth.md](ai-universe-auth.md). Dependency notes live in [secondo-dependencies.md](secondo-dependencies.md).
## Primary commands
| Scenario | Command |
| --- | --- |
| Quick question (when SlashCommand is working) | `/secondo "Should I use Redis or in-memory caching?"` |
| Build MCP request with PR context | `python3 skills/second_opinion_workflow/scripts/build_second_opinion_request.py /tmp/mcp_request.json "QUESTION" 3 origin/main` |
| Call MCP via HTTPie | `http POST https://ai-universe-backend-dev-114133832173.us-central1.run.app/mcp "Authorization:Bearer $TOKEN" < /tmp/mcp_request.json --timeout=180 --print=b` |
| Parse embedded JSON response | `jq -r '.result.content[0].text' /tmp/mcp_response.json > /tmp/mcp_parsed.json` |
| Summarize models/costs | `python3 skills/second_opinion_workflow/scripts/parse_second_opinion.py /tmp/mcp_parsed.json` |
| End-to-end helper | `skills/second_opinion_workflow/scripts/request_second_opinion.sh "QUESTION" [MAX_OPINIONS]` |
## Recommended workflow (HTTPie)
1. **Generate the request payload** (captures diff + per-file patches automatically):
```bash
python3 skills/second_opinion_workflow/scripts/build_second_opinion_request.py \
/tmp/mcp_request.json \
"YOUR QUESTION HERE" \
3 \
origin/main
```
Adjust `SECOND_OPINION_MAX_FILES`, `SECOND_OPINION_MAX_DIFF_CHARS`, or `SECOND_OPINION_MAX_PATCH_CHARS` if you need more/less context.
2. **(Optional) Inspect/tweak** `/tmp/mcp_request.json` to refine the natural-language question while keeping the attached git context intact.
3. **Get authentication token** (auto-refresh from AI Universe repo):
```bash
# Get token (auto-refreshes if expired, does nothing if valid)
TOKEN=$(node ~/.claude/scripts/auth-cli.mjs token)
```
4. **Send request** (allowing up to 180s for cold starts):
```bash
http POST https://ai-universe-backend-dev-114133832173.us-central1.run.app/mcp \
"Accept:application/json, text/event-stream" \
"Authorization:Bearer $TOKEN" \
< /tmp/mcp_request.json \
--timeout=180 \
--print=b > /tmp/mcp_response.json
```
5. **Parse embedded JSON** and display summary (or use the helper script):
```bash
jq -r '.result.content[0].text' /tmp/mcp_response.json > /tmp/mcp_parsed.json
python3 <<'PYEOF'
import json
with open('/tmp/mcp_parsed.json', 'r') as f:
data = json.load(f)
print(f"✅ Received responses from {data['summary']['totalModels']} models")
print(f"💰 Total cost: ${data['summary']['totalCost']:.4f}")
print(f"📊 Total tokens: {data['summary']['totalTokens']:,}")
print("\nPrimary response:\n")
print(data['primary']['response'])
PYEOF
```
Or run:
```bash
python3 skills/second_opinion_workflow/scripts/parse_second_opinion.py /tmp/mcp_parsed.json
```
6. **Review synthesis** to confirm consensus and recommended actions.
> 📌 Need more HTTPie patterns? Use [ai-universe-httpie.md](ai-universe-httpie.md) as a companion reference.
## SlashCommand fallback (Option A)
Use `/secondo "QUESTION"` for quick prompts **only when the command file is healthy**. If it fails or hangs, switch to the HTTPie workflow.
## Automation helper script
Run the bundled script from repo root for a streamlined flow:
```bash
skills/second_opinion_workflow/scripts/request_second_opinion.sh "How should I harden our auth endpoints?" 4
```
The script:
1. Validates token presence and checks that `MAX_OPINIONS` is a positive integer.
2. Invokes `build_second_opinion_request.py` to embed branch/base metadata, diffstat, recent commits, and per-file patches into the payload.
3. Calls the MCP endpoint with HTTPie and a 180s timeout.
4. Parses the embedded JSON and prints model count, token usage, cost, and the primary + synthesis responses.
5. Writes raw artifacts to `/tmp`; set `KEEP_TEMP_FILES=1` when running the script to keep them after completion.
For advanced prompting templates and interactive options, see the existing `~/.claude/scripts/secondo-cli.sh` utility.
## Troubleshooting
- **502 Bad Gateway / cold start** → Retry after 30–60 seconds. Send a lightweight `"What is 2+2?"` request first to warm the backend.
- **401 Unauthorized / invalid token** → Token expired (30-day TTL). Re-run `node scripts/auth-cli.mjs login` outside Claude Code.
- **"command -c invalid" errors** → Avoid nested command substitutions. Use heredocs + two-step token capture as shown above.
- **Parsing failures** → Always extract `.result.content[0].text` before loading JSON. Use the helper Python snippet or script for safe parsing.
## Cost & rate limits
- Authenticated users: 100 requests/hour, with multi-model synthesis limited to 1/hr.
- Typical cost ranges: $0.01–$0.20 depending on prompt complexity.
- Model cost breakdown (approx.): Cerebras $0.003, Gemini 2.5 Flash $0.001, Perplexity $0.002, GPT-4o $0.10, synthesis $0.005.
## Reporting expectations
- Confirm authentication status and whether `/secondo` or HTTPie path was used.
- Provide model count, total tokens, and total cost from the parsed summary.
- Include primary + synthesis takeaways or recommended next actions.
- Note any errors encountered and remediation steps (e.g., re-authentication, retries).
## Related references
- `skills/second_opinion_workflow/scripts/` for helper tooling.
- [ai-universe-auth.md](ai-universe-auth.md) for login instructions.
- [secondo-dependencies.md](secondo-dependencies.md) for HTTPie/JQ requirements.
- [ai-universe-httpie.md](ai-universe-httpie.md) for advanced HTTPie patterns.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.