|
| 1 | +# Finding Answers - Decision Tree |
| 2 | + |
| 3 | +## Quick Decision Tree |
| 4 | + |
| 5 | +``` |
| 6 | +What am I looking for? |
| 7 | +
|
| 8 | +├─ Documentation for a tool/library? |
| 9 | +│ ├─ This Nx workspace? → Nx MCP |
| 10 | +│ ├─ Graphite gt CLI? → Graphite MCP |
| 11 | +│ └─ Other library/framework? → Context7 MCP |
| 12 | +│ |
| 13 | +├─ Content from a specific URL? → URL Crawler* |
| 14 | +│ |
| 15 | +└─ Generic search/question? → Perplexity Search |
| 16 | +
|
| 17 | +*Check if library docs first - use Context7 instead |
| 18 | +``` |
| 19 | + |
| 20 | +## When to Use Tools vs Answer Directly |
| 21 | + |
| 22 | +**Default: Answer from your training knowledge WITHOUT tools.** |
| 23 | + |
| 24 | +**ONLY use search/research tools when user explicitly signals intent:** |
| 25 | +- "search for..." |
| 26 | +- "find..." |
| 27 | +- "look up..." |
| 28 | +- "research..." |
| 29 | +- "what's the latest..." |
| 30 | +- "current best practices..." |
| 31 | +- User provides a URL to crawl/fetch |
| 32 | + |
| 33 | +**CRITICAL: DO NOT use WebFetch to fetch documentation you know about:** |
| 34 | +- "ask for info about X" → Answer directly or use appropriate MCP (NOT WebFetch) |
| 35 | +- "tell me about X" → Answer directly (NOT WebFetch) |
| 36 | +- WebFetch is ONLY for when user explicitly provides a URL to fetch |
| 37 | +- For Claude Code docs → Answer from knowledge or use URL if user provides it |
| 38 | + |
| 39 | +**ALWAYS use MCP tools for specific systems (even without explicit "search" signal):** |
| 40 | +- Questions about THIS workspace → Nx MCP (always) |
| 41 | +- Questions about gt CLI → Graphite MCP (always) |
| 42 | +- Questions about library APIs → Context7 MCP (always) |
| 43 | + |
| 44 | +## Tool Selection Hierarchy |
| 45 | + |
| 46 | +**ALWAYS follow this order. Never skip steps.** |
| 47 | + |
| 48 | +| Priority | Scenario | Tool | Notes | |
| 49 | +|----------|----------|------|-------| |
| 50 | +| 1 | THIS workspace | Nx MCP (`nx_docs`, `nx_workspace`, `nx_project_details`) | Don't read nx.json directly | |
| 51 | +| 2 | `gt` CLI commands | Graphite MCP (`learn_gt`) | ANY "gt" mention = use this | |
| 52 | +| 3 | Library/framework docs | Context7 MCP (`resolve-library-id` → `get-library-docs`) | Token limits: 3k-10k, use `topic` param | |
| 53 | +| 4 | Complex reasoning | Sequential Thinking MCP | Multi-step analysis only | |
| 54 | +| 5 | Generic search | Perplexity Search | `max_results: 3`, `max_tokens_per_page: 512` | |
| 55 | +| 6 | Conversational answer | Perplexity Ask | When Search returns nothing | |
| 56 | +| 7 | Specific URL content | URL Crawler (`crawl4ai-sse__md`) | Try Context7 first for library docs | |
| 57 | +| 8 | Deep multi-source research | Researcher agent (`/research <topic>`) | 30-50k tokens, use sparingly | |
| 58 | +| 9 | Last resort - search | WebSearch | ONLY after Perplexity Search/Ask exhausted | |
| 59 | +| 10 | Last resort - fetch | WebFetch | ONLY after URL Crawler exhausted | |
| 60 | + |
| 61 | +**PROHIBITED:** `mcp__perplexity__perplexity_research` - Use researcher agent instead |
| 62 | + |
| 63 | +**CRITICAL: WebSearch and WebFetch are last resort tools:** |
| 64 | +- WebSearch: Use ONLY when Perplexity Search AND Perplexity Ask both failed |
| 65 | +- WebFetch: Use ONLY when URL Crawler failed OR user explicitly provides URL to fetch |
| 66 | + |
| 67 | +## Critical Anti-Patterns (Top 4) |
| 68 | + |
| 69 | +Learn these mistakes to avoid them: |
| 70 | + |
| 71 | +❌ **Library docs → WebSearch or WebFetch** |
| 72 | +- WRONG: Use WebSearch/WebFetch for React, Temporal, etc. |
| 73 | +- RIGHT: Use Context7 MCP first |
| 74 | +- Why: Context7 provides structured, up-to-date library docs |
| 75 | + |
| 76 | +❌ **"gt commands" → Perplexity Search** |
| 77 | +- WRONG: Search for "gt stack", "gt sync", etc. |
| 78 | +- RIGHT: Use Graphite MCP for ANY "gt" mention |
| 79 | +- Why: Graphite MCP has complete CLI documentation |
| 80 | + |
| 81 | +❌ **Deep research → perplexity_research tool** |
| 82 | +- WRONG: Use `mcp__perplexity__perplexity_research` |
| 83 | +- RIGHT: Use researcher agent (`/research <topic>`) |
| 84 | +- Why: perplexity_research is PROHIBITED |
| 85 | + |
| 86 | +❌ **"ask about X" → WebFetch** |
| 87 | +- WRONG: Fetch docs when user says "ask about" or "tell me about" |
| 88 | +- RIGHT: Answer from training knowledge (not a URL fetch request) |
| 89 | +- Why: WebFetch is ONLY for explicit URLs provided by user |
| 90 | + |
| 91 | +**Note:** More detailed examples available in `.claude/tool_examples.md` (user can reference when needed) |
| 92 | + |
| 93 | +## Key Decision Rules |
| 94 | + |
| 95 | +1. **Tool/library docs?** → Nx MCP / Graphite MCP / Context7 MCP |
| 96 | +2. **Known URL?** → Try Context7 first (if library), else URL Crawler → WebFetch (last resort) |
| 97 | +3. **Generic search?** → Perplexity Search → Perplexity Ask → WebSearch (last resort) |
| 98 | +4. **Deep research?** → `/research <topic>` (researcher agent) |
| 99 | +5. **User says "crawl [url]"?** → URL Crawler → WebFetch (if failed) |
| 100 | +6. **User says "search [query]"?** → Perplexity Search → Perplexity Ask → WebSearch (if failed) |
| 101 | +7. **User provides explicit URL?** → URL Crawler → WebFetch (fallback) |
| 102 | + |
| 103 | +## Context7 MCP Quick Reference |
| 104 | + |
| 105 | +**Token limits (always specify):** |
| 106 | +- Focused: `tokens: 3000` |
| 107 | +- Default: `tokens: 5000` |
| 108 | +- Broad: `tokens: 8000` |
| 109 | +- Maximum: `tokens: 10000` |
| 110 | + |
| 111 | +**Always provide `topic` parameter** (e.g., "hooks", "routing", "authentication") |
| 112 | + |
| 113 | +**Examples:** |
| 114 | +- React hooks → `/facebook/react`, topic: "hooks", tokens: 5000 |
| 115 | +- Temporal workflows → `/temporalio/temporal`, topic: "workflows", tokens: 5000 |
| 116 | +- Supabase functions → `/supabase/supabase`, topic: "edge functions", tokens: 5000 |
| 117 | + |
| 118 | +## Perplexity Search Quick Reference |
| 119 | + |
| 120 | +**Always limit results:** |
| 121 | +```typescript |
| 122 | +mcp__perplexity__perplexity_search({ |
| 123 | + query: "your search query", |
| 124 | + max_results: 3, // Default is 10 - too many! |
| 125 | + max_tokens_per_page: 512 // Reduce per-result content |
| 126 | +}) |
| 127 | +``` |
| 128 | + |
| 129 | +## Researcher Agent Quick Reference |
| 130 | + |
| 131 | +**When to use:** |
| 132 | +- Comprehensive multi-source research needed |
| 133 | +- Comparing approaches/technologies |
| 134 | +- Trade-off analysis with citations |
| 135 | + |
| 136 | +**Token cost:** 30-50k tokens per research |
| 137 | +**Use sparingly:** Only for complex questions requiring synthesis |
| 138 | + |
| 139 | +**Examples:** |
| 140 | +```bash |
| 141 | +/research postgres advisory locks vs row locking trade-offs |
| 142 | +/research database migration strategies comparison |
| 143 | +``` |
| 144 | + |
| 145 | +## Project-Specific Documentation URLs |
| 146 | + |
| 147 | +**Use Context7 first, fallback to URL Crawler only if Context7 fails** |
| 148 | + |
| 149 | +### Starlight (website framework) |
| 150 | +- Getting Started: https://starlight.astro.build/getting-started/ |
| 151 | + |
| 152 | +### Vitest (testing framework) |
| 153 | +- Guide: https://vitest.dev/guide/ |
| 154 | + |
| 155 | +### pgTAP (PostgreSQL testing framework) |
| 156 | +- Documentation: https://pgtap.org/documentation.html |
| 157 | + |
| 158 | +### PGMQ (Postgres Message Queue) |
| 159 | +- Overview: https://pgmq.github.io/pgmq/ |
| 160 | +- Functions: https://pgmq.github.io/pgmq/api/sql/functions/ |
| 161 | +- Types: https://pgmq.github.io/pgmq/api/sql/types/ |
| 162 | + |
| 163 | +### Claude Code |
| 164 | +- Overview: https://docs.claude.com/en/docs/claude-code/overview |
0 commit comments