Gather Context (/gather-context)
Unified information acquisition — gather URLs, search the web, or explore local code.
Language: Adapt all user-facing output to match the user's prompt language.
Quick Reference
/gather-context <url> URL auto-detect → download to OUTPUT_DIR /gather-context <url1> <url2> ... Multiple URLs /gather-context --search <query> Web search (Tavily) /gather-context --search --news <q> News search (Tavily) /gather-context --search --deep <q> Advanced depth search (Tavily) /gather-context --search code <query> Code/technical search (Exa) /gather-context --local <query> Local codebase exploration /gather-context Usage guide /gather-context help Usage guide
Workflow
- •Parse args → mode (URL |
--search|--local| help) - •No args or "help" → print usage message and stop
- •Execute the appropriate handler (see sections below)
- •Save results to
OUTPUT_DIR(URL and--localmodes) - •Suggest follow-up: after URL gathering, suggest
--searchfor supplementary research if helpful
URL Auto-Detect
Scan input for all URLs. Classify each by pattern table (most specific first):
| URL Pattern | Handler | Script / Tool |
|---|---|---|
docs.google.com/{document,presentation,spreadsheets}/d/* | Google Export | scripts/g-export.sh |
*.slack.com/archives/*/p* | Slack to MD | scripts/slack-api.mjs + scripts/slack-to-md.sh |
*.notion.site/*, www.notion.so/* | Notion to MD | scripts/notion-to-md.py |
github.com/* | GitHub | gh CLI |
| Any other URL | Generic | scripts/extract.sh → WebFetch fallback |
Google Export
{SKILL_DIR}/scripts/g-export.sh <url> [format] [output-dir]
Prerequisites: Public documents only (Share > Publish to web). Sheets default to TOON format — see references/TOON.md. Details: references/google-export.md
Slack Export
URL format: https://{workspace}.slack.com/archives/{channel_id}/p{timestamp}
Parse thread_ts: p{digits} → {first10}.{rest} (e.g., p1234567890123456 → 1234567890.123456)
node {SKILL_DIR}/scripts/slack-api.mjs <channel_id> <thread_ts> --attachments-dir OUTPUT_DIR/attachments | \
{SKILL_DIR}/scripts/slack-to-md.sh <channel_id> <thread_ts> <workspace> OUTPUT_DIR/<output_file>.md [title]
After conversion, rename to a meaningful name from the first message (lowercase, hyphens, max 50 chars).
Existing .md file: Extract Slack URL from > Source: line to re-fetch.
Prerequisites: Node.js 18+, Slack Bot (channels:history, channels:join, users:read, files:read), SLACK_BOT_TOKEN in ~/.claude/.env.
Details: references/slack-export.md
Notion Export
python3 {SKILL_DIR}/scripts/notion-to-md.py "$URL" "$OUTPUT_PATH"
Prerequisites: Page must be published to the web. Python 3.7+.
Limitations: Sub-pages → <!-- missing block -->, images URL-only (S3 expires), no database views.
Details: references/notion-export.md
GitHub
For github.com URLs, use the gh CLI to extract content as markdown.
Prerequisite check: Verify command -v gh first. If gh is not available, fall through to Generic handler.
| URL type | Command |
|---|---|
PR (/pull/N) | gh pr view <url> --json title,body,state,author,comments --template '...' |
Issue (/issues/N) | gh issue view <url> --json title,body,state,author,comments --template '...' |
Repository (owner/repo) | gh repo view <url> --json name,description,readme |
| Other GitHub URL | Fall through to Generic handler |
Save output to {OUTPUT_DIR}/{type}-{owner}-{repo}-{number}.md.
Template for PR/Issue (pass to --template):
# {{.title}}
State: {{.state}} | Author: {{.author.login}}
{{.body}}
{{range .comments}}---
**{{.author.login}}** ({{.createdAt}}):
{{.body}}
{{end}}
Generic URL
For URLs that don't match any known service:
- •
Try
extract.sh(Tavily extract) ifTAVILY_API_KEYis likely set:bash{SKILL_DIR}/scripts/extract.sh "<url>"If extraction succeeds, save to
{OUTPUT_DIR}/{sanitized-title}.md. - •
Fallback to WebFetch if no
TAVILY_API_KEYor extraction fails:- •Use WebFetch tool to download the page content.
- •Save the result as markdown to
{OUTPUT_DIR}/{sanitized-title}.md.
Sanitize title: lowercase, spaces to hyphens, remove special characters, max 50 chars.
--search Mode
Web and code search via external APIs.
Read references/query-intelligence.md before executing search — it contains the routing logic and parameter tables.
Subcommands
| Command | Backend | Script |
|---|---|---|
--search <query> | Tavily | scripts/search.sh |
--search --news <query> | Tavily (topic: news) | scripts/search.sh --topic news |
--search --deep <query> | Tavily (advanced) | scripts/search.sh --deep |
--search code <query> | Exa | scripts/code-search.sh |
Execution
- •Read query-intelligence.md for routing and parameter decisions
- •Route:
codeprefix or auto-detected code context →code-search.sh; otherwise →search.sh - •Apply query intelligence (temporal, topic, token allocation) per reference
- •Call script via Bash:
bash
{SKILL_DIR}/scripts/search.sh [--topic news|finance] [--time-range day|week|month|year] [--deep] "<query>" {SKILL_DIR}/scripts/code-search.sh [--tokens NUM] "<query>" - •Display results to user (scripts output formatted markdown)
Graceful degradation: If API key is missing, scripts print setup instructions to stderr. Display the error message to the user. See references/search-api-reference.md.
Data Privacy
Queries are sent to external search services. Do not include confidential code or sensitive information in search queries.
--local Mode
Explore the local codebase for a topic and save structured results.
Execution
- •Launch a sub-agent:
text
Task(subagent_type="general-purpose", prompt="Explore this codebase for: <query>. Use Glob, Grep, and Read to find relevant code, patterns, and architecture. Return a structured markdown summary with: ## Overview, ## Key Files, ## Code Patterns, ## Notable Details. Be thorough but concise.")
- •Save sub-agent output to
{OUTPUT_DIR}/local-{sanitized-query}.md - •Report file location to user
Sanitize query for filename: lowercase, spaces to hyphens, remove special characters, max 50 chars.
Configuration
| Variable | Default | Description |
|---|---|---|
CLAUDE_CORCA_GATHER_CONTEXT_OUTPUT_DIR | ./gathered | Unified default output directory |
CLAUDE_CORCA_G_EXPORT_OUTPUT_DIR | (falls back to unified) | Google-specific override |
CLAUDE_CORCA_SLACK_TO_MD_OUTPUT_DIR | (falls back to unified) | Slack-specific override |
CLAUDE_CORCA_NOTION_TO_MD_OUTPUT_DIR | (falls back to unified) | Notion-specific override |
TAVILY_API_KEY | — | Required for --search and generic URL extract |
EXA_API_KEY | — | Required for --search code |
Output dir priority: CLI argument > service-specific env var > CLAUDE_CORCA_GATHER_CONTEXT_OUTPUT_DIR > hardcoded default (./gathered)
When a service-specific env var is not set, pass the unified output dir as a CLI argument to the handler script.
Supplementary Research
After gathering URL content, if best practices, reference documentation, or supplementary context would help the user, use the search scripts directly via Bash (not the WebSearch tool):
{SKILL_DIR}/scripts/search.sh "<query>"
Examples:
- •Gathered a Google Doc describing a migration plan → search for best practices
- •Gathered a Slack thread about an unfamiliar library → search for official docs
- •Gathered a Notion page with a technical spec → search for implementation examples
Usage Message
Print when no args or "help":
Gather Context — Unified Information Acquisition Usage: /gather-context <url> Gather content from URL (auto-detect service) /gather-context --search <query> Web search (Tavily) /gather-context --search --news <q> News search /gather-context --search --deep <q> Deep search /gather-context --search code <query> Code/technical search (Exa) /gather-context --local <query> Explore local codebase Supported URL services: Google Docs/Slides/Sheets, Slack threads, Notion pages, GitHub PRs/issues, generic web Environment variables: TAVILY_API_KEY Web search and URL extraction (https://app.tavily.com) EXA_API_KEY Code search (https://dashboard.exa.ai)
References
- •references/google-export.md — Google Docs/Slides/Sheets export details
- •references/slack-export.md — Slack thread export details
- •references/notion-export.md — Notion page export details
- •references/TOON.md — TOON format for spreadsheets
- •references/search-api-reference.md — Tavily/Exa API parameters
- •references/query-intelligence.md — Search routing and query enrichment