← Back to Lessons
Claude Skills

Research with Citations

Two skills that get you sourced answers. One pulls live, cited research from Perplexity. The other runs your question past several AI sources and cross-checks them.
⏱ ~8 min

The problem. Claude is great at reasoning, but for anything current or contested, you want sources you can check. These two skills give you that.

Two tools, two jobs. perplexity-research gets you one fast, cited answer from live search. compare-research runs the same question through several sources and tells you where they agree and where they disagree. Use the first for a quick sourced answer, the second when the stakes are high enough that you want it triangulated.

Both install in one paste. Each skill is a single copy-paste prompt you drop into Claude Code; it writes the files, wires up the key, and verifies the install. The prompts are below.

1
perplexity-research: live, cited answers
2 min

This skill sends your question to the Perplexity API, which searches the live web and returns an answer with a numbered list of sources. Claude then summarizes it for you and passes the source links through so you can verify.

When to use it

You want a current, sourced answer to a specific question, and one good source pass is enough. Benchmarks, recent changes, "what is the state of X in 2026," a quick sanity check on a claim.

Trigger it by naming Perplexity in your request:

Use Perplexity to find the 2026 response-rate benchmarks for B2B cold email to senior marketing decision-makers. Include specific percentages and sources.
It picks a depth for you

Perplexity has several models, from a fast general one up to a slower deep-research one. The skill chooses a sensible default and can go heavier for strategic, multi-angle questions. You do not have to specify.

Needs an API key

This skill calls the Perplexity API, so it needs a Perplexity API key. Install the skill below, then the Create a Perplexity API key step shows exactly how to get one and where to put it. A typical query costs a few cents, with deep research running higher, so use the heavy mode only when it earns it.

2
Install perplexity-research
30 sec

Open Claude Code in any folder, paste the prompt below, hit enter. Claude creates the skill in your global skills folder (~/.claude/skills/perplexity-research/), writes both files, sets up the (empty) key file, and verifies the install.

One-paste install prompt — self-contained: SKILL.md + the query script inline.

Install a global Claude Code skill called "perplexity-research". Do all of the following: 1. Create directory: ~/.claude/skills/perplexity-research/scripts/ 2. Write the file ~/.claude/skills/perplexity-research/SKILL.md with EXACTLY this content (between the SKILL_START and SKILL_END markers, do not include the markers themselves): ===SKILL_START=== --- name: perplexity-research description: Research any topic using the Perplexity API (Sonar models) with citations. TRIGGER whenever the user says "use Perplexity", "ask Perplexity", "check Perplexity", "Perplexity research", or otherwise mentions Perplexity for research on a given topic. Returns a cited, sourced answer from Perplexity's live-search Sonar models. --- # Perplexity Research Run live-search research through the Perplexity API. Returns a cited answer with sources. ## When to use ALWAYS invoke this skill when the user: - Says "use Perplexity to..." / "ask Perplexity..." / "check Perplexity for..." - Mentions Perplexity in the context of researching a topic - Requests "Perplexity research" or similar - Asks for a Perplexity sanity-check on a claim ## How to invoke Run the query script. The API key lives in `~/.claude/skills/perplexity-research/.env` (gitignored). Invoke via bash: ```bash bash ~/.claude/skills/perplexity-research/scripts/query.sh "your research question" ``` Optional second argument picks the model: - `sonar` — fastest, cheapest, general questions - `sonar-pro` — default, stronger synthesis, better citations - `sonar-reasoning` — chain-of-thought style, good for analytical questions - `sonar-deep-research` — slowest, most thorough, use for strategic/multi-angle research Example: ```bash bash ~/.claude/skills/perplexity-research/scripts/query.sh "2026 B2B SaaS cold outreach benchmarks" sonar-pro ``` ## How to phrase the query Perplexity works best with specific, self-contained questions. Don't pass the user's exact wording if it's vague. Reframe as a concrete research question: - Bad: "research cold outreach" - Good: "What are the 2026 response-rate benchmarks for B2B cold email to senior marketing decision-makers? Include specific percentages and industry sources." When the topic has a recency angle, include the year. The current working year is 2026. ## How to return results After running the script: 1. Read the output (contains the synthesized answer and a numbered citations list) 2. Summarize for the user in your own words, preserving key facts and numbers 3. Pass through the citation URLs so the user can verify 4. Flag anything that seems contradictory with other sources you have ## Output format for the user Present as: - 2-4 sentence summary of the key finding - Bullet list of specific facts/numbers worth keeping - Sources as markdown hyperlinks Do not mention you ran a shell script; just present the research. ## Troubleshooting - "API error: invalid_api_key" → the `.env` file is missing or corrupted. Tell the user to re-provide the key. - Empty `content` field → retry once with a more specific query, then fall back to WebSearch. - Rate limit errors → wait 30 seconds and retry, or switch to WebSearch. ## Cost note Sonar models cost $1-5 per million tokens. A typical research query runs a few cents. Deep-research runs higher; use judiciously. ===SKILL_END=== 3. Write the file ~/.claude/skills/perplexity-research/scripts/query.sh with EXACTLY this content (between the SCRIPT_START and SCRIPT_END markers, do not include the markers themselves): ===SCRIPT_START=== #!/bin/bash # Perplexity API query script # Usage: ./query.sh "your research question" [model] # Models: sonar, sonar-pro (default), sonar-reasoning, sonar-deep-research set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ENV_FILE="$SCRIPT_DIR/../.env" if [[ ! -f "$ENV_FILE" ]]; then echo "Error: .env file not found at $ENV_FILE" >&2 exit 1 fi # shellcheck disable=SC1090 source "$ENV_FILE" if [[ -z "${PERPLEXITY_API_KEY:-}" ]]; then echo "Error: PERPLEXITY_API_KEY not set in .env" >&2 exit 1 fi QUERY="${1:-}" MODEL="${2:-sonar-pro}" if [[ -z "$QUERY" ]]; then echo "Usage: $0 \"your research question\" [model]" >&2 echo "Models: sonar, sonar-pro (default), sonar-reasoning, sonar-deep-research" >&2 exit 1 fi RESPONSE=$(curl -sS https://api.perplexity.ai/chat/completions \ -H "Authorization: Bearer $PERPLEXITY_API_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -n --arg model "$MODEL" --arg query "$QUERY" '{ model: $model, messages: [ {role: "system", content: "Provide accurate, well-cited research. Include specific facts, numbers, and examples. Cite sources inline."}, {role: "user", content: $query} ] }')") # Check for API errors if echo "$RESPONSE" | jq -e '.error' >/dev/null 2>&1; then echo "API error:" >&2 echo "$RESPONSE" | jq '.error' >&2 exit 1 fi # Extract content and citations CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content') CITATIONS=$(echo "$RESPONSE" | jq -r '.citations // .search_results // [] | if type == "array" then .[] | if type == "string" then . else (.url // .title // tostring) end else . end' 2>/dev/null || echo "") echo "=== PERPLEXITY RESPONSE (model: $MODEL) ===" echo "" echo "$CONTENT" echo "" if [[ -n "$CITATIONS" ]]; then echo "=== CITATIONS ===" echo "$CITATIONS" | nl -w2 -s'. ' fi ===SCRIPT_END=== 4. Make the script executable: chmod +x ~/.claude/skills/perplexity-research/scripts/query.sh 5. Create the file ~/.claude/skills/perplexity-research/.env with this exact line (I will paste my real key into it in the next step): PERPLEXITY_API_KEY="" 6. Create the file ~/.claude/skills/perplexity-research/.gitignore with this single line so the key is never committed: .env 7. Make sure `jq` is installed (the script needs it to parse JSON). Run `which jq`; if it is missing, install it — on Mac `brew install jq`, on Debian/Ubuntu `sudo apt-get install -y jq`. 8. Verify the install: ls -la ~/.claude/skills/perplexity-research/ bash -n ~/.claude/skills/perplexity-research/scripts/query.sh && echo "script syntax OK" When done, tell me the skill is installed, and remind me to paste my Perplexity API key into ~/.claude/skills/perplexity-research/.env before using it. The trigger phrase is anything like "use Perplexity to research ...".
Paste once

Paste this single message into Claude Code. After it finishes, add your API key (next step), then restart Claude Code so the skill loads.

3
Create a Perplexity API key
3 min

perplexity-research authenticates to Perplexity with an API key. Here is how to get one.

Open the Perplexity API console →

  1. Sign in, or create a Perplexity account.
  2. Add a payment method and load credits. This is the step people miss: the Perplexity API runs on prepaid credits, and a new free account starts with zero. Add a card (adding it does not charge you), then click Add Credits and load a small amount, $5 is plenty to start. Until the account has credits, the key will not work.
  3. Open the API Keys tab and generate a new key. Copy it.
  4. Add the key to the skill. The install step created an empty key file at ~/.claude/skills/perplexity-research/.env. Open it and paste your key between the quotes, or set it in one command:
echo 'PERPLEXITY_API_KEY="paste-your-key-here"' > ~/.claude/skills/perplexity-research/.env

That file is gitignored, so your key never gets committed. The skill reads it automatically on every run, so there is nothing to export and no terminal restart needed.

Already a Perplexity Pro subscriber?

Pro subscribers get $5 in API credits each month, so you may already have a balance to spend. You still create the key the same way, in the API Keys tab.

4
compare-research: triangulate across sources
2 min

This skill takes one research question and runs it through several independent sources, then synthesizes the results. Instead of trusting a single answer, you see where the sources line up and where they split.

When to use it

The decision matters and you do not want to bet it on one source. Contested topics, strategic calls, anything where being wrong is expensive. This is the "get a second and third opinion" tool.

Trigger it with phrases like compare research, triangulate, cross-check, or get multiple AI opinions:

Compare research on whether a free Skool community or a paid one converts better to a paid offer in 2026. Triangulate it and flag any contradictions.

What you get back is structured: a synthesized answer up top, the points all sources agree on (treat those as high-confidence), the contradictions spelled out source by source, anything unique that only one source raised, and the list of sources.

It can go deeper on demand

By default compare-research does a single triangulation pass. If you ask it to "go deeper" or "drill into" something, it recursively investigates the contested or thinly-supported claims instead of leaving them hanging. That deep mode costs more and takes longer, so reach for it only on the calls that justify it.

5
Install compare-research
30 sec

This skill is pure orchestration — no script of its own. It calls perplexity-research for its first source, so install that one first. Paste the prompt below into Claude Code.

One-paste install prompt — writes the skill's SKILL.md and an (optional) Gemini key file.

Install a global Claude Code skill called "compare-research". This skill orchestrates Perplexity + Gemini + web search; it depends on the "perplexity-research" skill, so make sure that one is installed first. Do all of the following: 1. Create directory: ~/.claude/skills/compare-research/ 2. Write the file ~/.claude/skills/compare-research/SKILL.md with EXACTLY this content (between the SKILL_START and SKILL_END markers, do not include the markers themselves): ===SKILL_START=== --- name: compare-research description: TRIGGERS on "deep research", "deep compare research", "compare research", "triangulate", "cross-check", "drill into", "run all three", "verify across sources", "multiple AI opinions". MANDATORY — invoke this skill IMMEDIATELY when ANY trigger phrase appears ANYWHERE in the user message, even at the end. Do NOT use WebSearch or Agent instead. Route through this skill. --- # Compare Research (Perplexity + Gemini + Web) Run the same research question through three independent sources, then synthesize. Optionally drill recursively into subtopics that warrant deeper investigation. ## Modes - **Standard** (default): Single-pass triangulation. Triggered by "compare research", "triangulate", etc. - **Deep**: Recursive chain that drills into contested/under-supported claims. Triggered by "deep research", "deep compare research", "drill into", or "go deeper on". ## When to use Invoke when the user: - Says "compare research between Gemini and Perplexity" - Asks to "triangulate" or "cross-check" research across Gemini and Perplexity - Requests "all three" (Perplexity + Gemini + web) - Wants a high-confidence answer on something strategic or contested - Says any variant of "get multiple AI opinions on X" - Says "deep research" or "drill into X" (activates deep mode) If the user just says "use Perplexity", use the `perplexity-research` skill alone; don't trigger this one. ## The core process (Steps 1-4) Run steps 1-3 in parallel (single message, multiple tool calls) when possible. They are independent and parallelizing saves time. ### Step 1: Perplexity research Invoke via the `perplexity-research` skill or directly: ```bash bash ~/.claude/skills/perplexity-research/scripts/query.sh "research question here" sonar-pro ``` ### Step 2: Gemini research **Default model: `gemini-3-pro-preview`** for text research (NOT flash; flash is only for image/video tasks). **Try the CLI first (skip if you don't have the Gemini CLI installed):** ```bash gemini -p "research question here" -m gemini-3-pro-preview ``` **If the CLI is missing or fails (auth error, rate limit, timeout, hang):** fall back to the Google Generative Language REST API using `GEMINI_API_KEY` from `~/.claude/skills/compare-research/.env`: ```bash source ~/.claude/skills/compare-research/.env 2>/dev/null curl -s "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent?key=$GEMINI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"contents":[{"parts":[{"text":"your research question here. Cite specific sources with URLs where possible."}]}]}' \ | jq -r '.candidates[0].content.parts[0].text' ``` If `gemini-3-pro-preview` is not available via either path, fall back to `gemini-2.5-pro`. If no `GEMINI_API_KEY` is set and the CLI isn't installed, skip the Gemini source and triangulate with Perplexity + web search only (a 2-source compare). Tell the user Gemini was skipped for lack of a key. Gemini does NOT cite sources by default. Always append to the query: "Cite specific sources with URLs where possible." ### Step 3: Native web search Use the WebSearch tool directly. Run 1-3 targeted queries that cover different angles of the question. ### Step 4: Synthesize Compare the three responses. Specifically look for: - **Agreement (high-confidence):** facts all three sources confirm. These are load-bearing; lean on them. - **Contradictions:** claims one source makes that another disputes. Call them out explicitly ("Perplexity says X, Gemini says Y, web search suggests Z"). Don't paper over them. - **Unique contributions:** points only one source raises. Note which source, so the user can weigh credibility. - **Source quality:** if Perplexity and web search cite primary sources but Gemini asserts without citations, weight the cited sources higher. ## Step 5: Recursive drilling (deep mode only) This step ONLY runs when deep mode is active. Skip entirely for standard compare-research. ### 5a: Identify drill-worthy subtopics After synthesizing, scan the results for claims that meet ANY of these criteria: 1. **Contested**: Sources directly contradict each other on a specific factual claim (not just framing differences) 2. **Unsupported but load-bearing**: A claim that matters to the user's decision but only one source mentions it and provides no citation 3. **Surface-level**: All three sources mention a topic but none go beyond a single sentence, and the topic is central to the user's question 4. **Surprising**: A claim that contradicts conventional wisdom or the user's apparent assumptions Do NOT drill into: - Points where all three agree with citations (already high-confidence) - Tangential details that don't affect the user's core question - Subjective framing differences between sources ### 5b: Prioritize and cap - Rank drill-worthy subtopics by relevance to the user's original question - **Cap at 3 subtopics per level** to control cost and time - **Cap total depth at 3 levels** (original query = level 0, first drill = level 1, max = level 2) - If more than 3 subtopics qualify, pick the top 3 by relevance and note the others as "flagged but not drilled" ### 5c: Execute sub-runs For each drill-worthy subtopic: - Formulate a narrow, specific research question targeting just that claim - Run Steps 1-4 again on that narrow question (using parallel Agent subagents when drilling multiple subtopics at the same level) - Tag each sub-run with its depth level and parent topic ### 5d: Roll up findings After all sub-runs complete, integrate findings back into the parent synthesis: - Replace low-confidence claims with the deeper findings - Resolve contradictions where the drill provided clarity - Note where drilling deepened understanding vs. where it confirmed the original finding - Preserve the chain of reasoning so the user can trace how you got there ## Output format ### Standard mode output YOU MUST include ALL of these sections in standard mode. Do not skip any. ``` ## Synthesized answer [2-5 sentence distilled conclusion] ## Agreement across all three - [point with source: "all three" / "P + W" / etc.] - ... ## Contradictions - [claim A] vs. [claim B] (who said which) ## Unique from Gemini - [point only Gemini raised] ## Unique from Perplexity - [point only Perplexity raised] ## Potential deep-dive topics - [Contested or under-supported claim that would benefit from recursive drilling] (reason: contested / unsupported / surface-level / surprising) - ... If no claims warrant deeper investigation, write: "None identified — findings are well-corroborated." ## Drill chain preview - **L0**: [original query] - **L1**: [subtopic from deep-dive topics above] -> [what you'd expect to find] - **L1**: [another subtopic] -> [what you'd expect to find] This shows the user what a deep-mode investigation would look like. Keep it to 2-4 lines. ## Sources (from Perplexity + web) - [URL 1] - [URL 2] - ... ``` **MANDATORY in standard mode:** Always include BOTH the "Potential deep-dive topics" section AND the "Drill chain preview" section. The deep-dive topics identify WHAT would benefit from drilling. The drill chain preview shows the user the STRUCTURE of how that drilling would unfold -- a lightweight tree showing L0 (their query) and L1 branches (the subtopics you identified). This pair of sections signals to the user where deep mode would add value and what it would look like. Neither section is optional. ### Deep mode output YOU MUST include ALL of these sections in deep mode. Do not skip any. In particular, you MUST include "Unique from Gemini" and "Unique from Perplexity" sections even in deep mode -- source-specific unique contributions must always be attributed. ``` ## Synthesized answer [2-5 sentence distilled conclusion incorporating all drilling] ## High-confidence findings - [point confirmed at surface + depth, with sources] - ... ## Unique from Gemini - [point only Gemini raised that was not covered by other sources] ## Unique from Perplexity - [point only Perplexity raised that was not covered by other sources] ## Resolved through drilling - [Original contradiction or gap] -> [What drilling revealed] (depth level, sources) - ... ## Still contested - [Claims that remained unresolved even after drilling] (note depth reached) ## Flagged but not drilled - [Subtopics that qualified but were deprioritized] ## Drill chain - **L0**: [original query] - **L1**: [subtopic A] -> [finding] - **L2**: [sub-subtopic] -> [finding] - **L1**: [subtopic B] -> [finding] ## Sources (all levels) - [URL 1] (L0) - [URL 2] (L1, subtopic A) - ... ``` **MANDATORY in deep mode:** The "Unique from Gemini" and "Unique from Perplexity" sections must appear. Even when findings are reorganized around the drill chain, per-source unique contributions must be preserved as distinct sections so the user can assess source-specific value. The "Drill chain" and "Flagged but not drilled" sections are also mandatory and must never be omitted. Keep the final answer in the user's context. Don't dump all three raw outputs back unless they ask — you've already processed them. ## Cost and time expectations | Mode | Branches | Estimated cost | Estimated time | |------|----------|---------------|----------------| | Standard | 0 | $0.05-0.20 | 30-90 seconds | | Deep (1 level, 1-2 branches) | 1-2 | $0.15-0.60 | 2-3 minutes | | Deep (2 levels, 2-3 branches) | 3-6 | $0.50-1.50 | 4-7 minutes | | Deep (max: 3 levels, 3 branches) | up to 12 | $1.00-3.00 | 8-15 minutes | Don't use deep mode for trivial lookups. Standard mode is the right default. Deep mode is for strategic decisions, contested topics, or when the user explicitly asks to go deeper. ## Troubleshooting - Gemini CLI hangs or errors -> fall back immediately to the REST API path above using `GEMINI_API_KEY`. Do not ask the user to re-auth mid-task. - Perplexity returns empty -> check `.env` key; fall back to web search + Gemini for 2-source compare. - All three disagree completely -> that's a signal the topic is genuinely contested or the question is ambiguous. In standard mode, report this to the user. In deep mode, this is a prime candidate for drilling. - Deep mode taking too long -> reduce branch cap to 2 or depth cap to 1. Tell the user you're throttling to keep time reasonable. - Sub-run returns nothing new -> stop drilling that branch. Note "drilling confirmed surface-level finding" and move on. ===SKILL_END=== 3. Create the file ~/.claude/skills/compare-research/.env with this exact line (optional — only the Gemini source needs it; paste your Google AI Studio key between the quotes): GEMINI_API_KEY="" 4. Create the file ~/.claude/skills/compare-research/.gitignore with this single line so the key is never committed: .env 5. Verify the install: ls -la ~/.claude/skills/compare-research/ head -5 ~/.claude/skills/compare-research/SKILL.md When done, tell me the skill is installed. Remind me that it requires the "perplexity-research" skill for its first source, and that the Gemini source is optional — without a GEMINI_API_KEY it will triangulate with Perplexity + web search only. Trigger phrases: "compare research on ...", "triangulate ...", "cross-check ...", "deep research on ...".
The Gemini source is optional

compare-research triangulates Perplexity + Gemini + web search. Perplexity and web search work out of the box. The Gemini leg needs a free Google AI Studio key — create one here and paste it into ~/.claude/skills/compare-research/.env as GEMINI_API_KEY="...". No key? The skill quietly drops to a Perplexity + web two-source compare.

6
Which one do I use?
1 min

A simple rule:

Use perplexity-research when...

You want one good cited answer, fast. The question is fairly settled, you just need current numbers and sources. Lower cost, quicker.

Use compare-research when...

The answer matters enough to verify across sources, or you suspect sources might disagree. You want agreement, contradictions, and confidence levels laid out. Higher cost, more thorough.

In practice: start with perplexity-research for most questions. Escalate to compare-research when a single source is not enough to make the call.

7
If something goes wrong

"Invalid API key" from Perplexity

Your key is missing or wrong. Open ~/.claude/skills/perplexity-research/.env and confirm your real key is between the quotes (PERPLEXITY_API_KEY="pplx-..."). A placeholder or empty value is the usual cause.

".env file not found" or "PERPLEXITY_API_KEY not set"

The skill never got its key. Re-run the Create a Perplexity API key step to write ~/.claude/skills/perplexity-research/.env.

Empty or thin result

Your question may be too vague. Reframe it as a specific, self-contained question with concrete terms and the year, then retry. Specific questions get specific answers.

compare-research did not trigger

Use one of its trigger phrases directly: "compare research on...", "triangulate...", "cross-check...", or "get multiple AI opinions on..." Those route the request through the skill.

compare-research skipped Gemini

Expected if you never set a GEMINI_API_KEY — it triangulates with Perplexity + web search instead. To add the third source, drop a Google AI Studio key into ~/.claude/skills/compare-research/.env.

A skill is not found

Run ls ~/.claude/skills/ — you should see perplexity-research and compare-research. If one is missing, its install didn't complete. Restart Claude Code after installing so it picks up new skills.

Questions?

Made by AI Service Engine · what is a skill? · build your own skill