Ask the Oracle
Inspired by Andrej Karpathy's approach of consulting GPT-5 Pro as an "Oracle" for complex code questions that require 20+ minutes of deep reasoning.
When to Use This Skill
Use this skill when the user:
- Asks for architectural analysis or design review
- Needs debugging help for complex, non-obvious issues
- Requests comprehensive code review across multiple files
- Wants expert analysis beyond my immediate capabilities
- Says things like "deep dive", "expert analysis", "comprehensive review", "consult the Oracle"
- Is willing to wait 10-20 minutes for high-quality results
- Has a question that requires reasoning across large amounts of code
When NOT to Use This Skill
Skip this skill when:
- The question is simple and I can answer it directly
- The user needs an immediate response
- The task is about editing or generating code (not analysis)
- The question is conversational or doesn't require codebase context
Instructions
Phase 1: Understand the Question
Capture the user's question
- What specifically do they want to know?
- What problem are they trying to solve?
Determine scope
- Which files/directories are relevant?
- Is this about architecture, bugs, performance, security, or best practices?
Phase 2: Select Files
Use Glob to identify relevant files
- Search for patterns matching the question scope
- Examples:
**/*.{js,ts} for JavaScript/TypeScript projects
src/**/*.py for Python source code
**/*.{go,mod} for Go projects
Ask user to confirm or refine file selection using AskUserQuestion
- Present the file count and pattern
- Allow them to add/remove patterns
- Example: "I found 45 JavaScript files in src/. Should I include tests/ as well?"
Show estimated token count
- Use Bash to run:
cd <project-root> && node .claude/skills/ask-the-oracle/scripts/oracle.js <patterns> -- "test" 2>&1 | grep "tokens"
- This will show the token estimate from Repomix
Phase 3: Formulate the Question
Ask clarifying questions using AskUserQuestion if needed:
- "What specific aspect are you investigating?" (architecture/bugs/performance/etc.)
- "What is the expected behavior or outcome?"
- "Have you tried any debugging steps already?"
Format the question clearly
- Start with context: "This is a [type] project with [key characteristics]"
- State the specific question
- Add any constraints or focus areas
- Example:
This is a Node.js Express API with TypeScript. The codebase handles user authentication
and data processing. I'm experiencing memory leaks that occur after several hours of
operation, particularly related to request handlers. Please analyze the code and:
1. Identify potential memory leak sources
2. Explain why the async refactor may have triggered this
3. Suggest specific fixes with code examples
Phase 4: Estimate Cost and Confirm
Calculate estimated cost
- Repomix will show token count when packing
- GPT-5 Pro pricing: $15/M input, $120/M output
- Typical costs: $2-10 depending on codebase size
Check against limits (from .oraclerc)
- If cost > $5, inform user and ask for confirmation
- If cost > configured limit, don't proceed without explicit approval
Confirm with user using AskUserQuestion:
- Show estimated cost
- Confirm they want to proceed
- Remind them it may take 20 minutes
Phase 5: Submit to Oracle
Run the oracle script using Bash:
cd <project-root> && node .claude/skills/ask-the-oracle/scripts/oracle.js <patterns> -- "<question>"
Example:
cd /Users/robgruhl/Projects/my-app && \
node .claude/skills/ask-the-oracle/scripts/oracle.js \
"src/**/*.ts" "lib/**/*.ts" -- \
"Analyze this codebase for memory leaks. Focus on async handlers and event listeners."
The script will:
- Pack code with Repomix
- Show cost estimate
- Submit to GPT-5 Pro (background mode)
- Poll every 3 seconds for completion
- Display progress updates
- Save response to history
Monitor the output
- The script will show status updates
- Wait for completion (don't timeout Claude Code!)
- Typical time: 10-20 minutes
Phase 6: Present Results
The oracle script will display:
- Provider and model used
- Time elapsed
- Cost breakdown (input/reasoning/output tokens)
- Full response from GPT-5 Pro
Read the history file using Read tool:
- Location:
.claude/oracle-history/oracle-<timestamp>.json
- Contains full response and metadata
Present to user:
- Summarize key findings
- Highlight actionable recommendations
- Show cost and time metrics
- Ask if they have follow-up questions
Error Handling
If .oraclerc not found:
- Inform user they need to set up configuration
- Point them to .oraclerc.example
- Explain they need an OpenAI API key
If API key invalid:
- Check if OPENAI_API_KEY environment variable is set
- Suggest checking their API key configuration
- Remind them they need GPT-5 Pro access
If cost limit exceeded:
- Show the estimated cost
- Ask if they want to proceed anyway
- Suggest ways to reduce cost (fewer files, compression)
If timeout:
- The script has a 25-minute timeout
- If it times out, the request might still be processing
- Response ID is saved, can be retrieved later
If request fails:
- Show the error message from OpenAI
- Suggest checking API status
- Offer to retry
Important Notes
- Cost: Typically $2-10 per request depending on codebase size
- Time: Expect 10-20 minutes for responses (GPT-5 Pro uses extended reasoning)
- API Access: Requires OpenAI API key with GPT-5 Pro access
- Privacy: Code is sent to OpenAI (retained for 30 days per their policy)
- History: All consultations are saved to
.claude/oracle-history/
- Limits: Configurable cost limits in .oraclerc prevent accidental overspending
Example Usage
Example 1: Memory Leak Analysis
User: "I have a memory leak in my Node.js service. Can you do a deep analysis?"
Claude Code:
- Uses Glob to find:
**/*.js, src/**/*.ts
- Asks: "I found 42 files. Should I include tests?"
- Asks: "What symptoms are you seeing?" → "Gradual memory growth, crashes at 2GB"
- Asks: "When did this start?" → "After async refactor"
- Shows estimate: ~$3.20 (45K tokens input)
- Confirms: "Proceed?"
- Runs oracle script
- Waits 18 minutes
- Presents detailed analysis with fixes
Example 2: Architecture Review
User: "Review the architecture of my API"
Claude Code:
- Uses Glob:
src/api/**/*.ts, src/models/**/*.ts
- Estimates: 80K tokens (~$5.40)
- Asks confirmation (exceeds $5 threshold)
- User confirms
- Runs oracle script
- Waits 22 minutes
- Presents architecture analysis with recommendations
Configuration
Users must have .oraclerc in project root:
{
"defaultProvider": "openai",
"providers": {
"openai": {
"apiKey": "$OPENAI_API_KEY",
"model": "gpt-5-pro",
"enabled": true
}
},
"limits": {
"maxCostPerRequest": 10.00,
"warnCostThreshold": 5.00
}
}
Tips for Best Results
- Be specific in questions - the Oracle works best with clear, focused questions
- Select relevant files only - more code = higher cost and longer processing
- Provide context - explain what you've tried and what you're looking for
- Use for complex issues - save simple questions for me directly
- Follow up - you can ask clarifying questions after getting the response
Remember: This skill makes external API calls that cost money and take time. Always confirm with the user before submitting, and set clear expectations about the 20-minute wait time.
1---2name: ask-the-oracle3description: Submit complex code questions to OpenAI GPT-5 Pro for deep analysis when you have 20 minutes. Use when the user asks for architectural analysis, comprehensive code review, debugging complex issues, or requests expert analysis of their codebase that requires extended reasoning. Automatically handles file selection, code packing with Repomix, cost estimation, long-running API requests, and result presentation.4---56# Ask the Oracle78Inspired by Andrej Karpathy's approach of consulting GPT-5 Pro as an "Oracle" for complex code questions that require 20+ minutes of deep reasoning.910## When to Use This Skill1112Use this skill when the user:13- Asks for **architectural analysis or design review**14- Needs **debugging help for complex, non-obvious issues**15- Requests **comprehensive code review** across multiple files16- Wants **expert analysis** beyond my immediate capabilities17- Says things like "deep dive", "expert analysis", "comprehensive review", "consult the Oracle"18- Is willing to wait 10-20 minutes for high-quality results19- Has a question that requires reasoning across large amounts of code2021## When NOT to Use This Skill2223Skip this skill when:24- The question is simple and I can answer it directly25- The user needs an immediate response26- The task is about editing or generating code (not analysis)27- The question is conversational or doesn't require codebase context2829## Instructions3031### Phase 1: Understand the Question32331. **Capture the user's question**34 - What specifically do they want to know?35 - What problem are they trying to solve?36372. **Determine scope**38 - Which files/directories are relevant?39 - Is this about architecture, bugs, performance, security, or best practices?4041### Phase 2: Select Files42431. **Use Glob to identify relevant files**44 - Search for patterns matching the question scope45 - Examples:46 - `**/*.{js,ts}` for JavaScript/TypeScript projects47 - `src/**/*.py` for Python source code48 - `**/*.{go,mod}` for Go projects49502. **Ask user to confirm or refine file selection** using AskUserQuestion51 - Present the file count and pattern52 - Allow them to add/remove patterns53 - Example: "I found 45 JavaScript files in src/. Should I include tests/ as well?"54553. **Show estimated token count**56 - Use Bash to run: `cd <project-root> && node .claude/skills/ask-the-oracle/scripts/oracle.js <patterns> -- "test" 2>&1 | grep "tokens"`57 - This will show the token estimate from Repomix5859### Phase 3: Formulate the Question60611. **Ask clarifying questions** using AskUserQuestion if needed:62 - "What specific aspect are you investigating?" (architecture/bugs/performance/etc.)63 - "What is the expected behavior or outcome?"64 - "Have you tried any debugging steps already?"65662. **Format the question clearly**67 - Start with context: "This is a [type] project with [key characteristics]"68 - State the specific question69 - Add any constraints or focus areas70 - Example:71 ```72 This is a Node.js Express API with TypeScript. The codebase handles user authentication73 and data processing. I'm experiencing memory leaks that occur after several hours of74 operation, particularly related to request handlers. Please analyze the code and:75 1. Identify potential memory leak sources76 2. Explain why the async refactor may have triggered this77 3. Suggest specific fixes with code examples78 ```7980### Phase 4: Estimate Cost and Confirm81821. **Calculate estimated cost**83 - Repomix will show token count when packing84 - GPT-5 Pro pricing: $15/M input, $120/M output85 - Typical costs: $2-10 depending on codebase size86872. **Check against limits** (from .oraclerc)88 - If cost > $5, inform user and ask for confirmation89 - If cost > configured limit, don't proceed without explicit approval90913. **Confirm with user** using AskUserQuestion:92 - Show estimated cost93 - Confirm they want to proceed94 - Remind them it may take 20 minutes9596### Phase 5: Submit to Oracle97981. **Run the oracle script** using Bash:99 ```bash100 cd <project-root> && node .claude/skills/ask-the-oracle/scripts/oracle.js <patterns> -- "<question>"101 ```102103 Example:104 ```bash105 cd /Users/robgruhl/Projects/my-app && \106 node .claude/skills/ask-the-oracle/scripts/oracle.js \107 "src/**/*.ts" "lib/**/*.ts" -- \108 "Analyze this codebase for memory leaks. Focus on async handlers and event listeners."109 ```1101112. **The script will**:112 - Pack code with Repomix113 - Show cost estimate114 - Submit to GPT-5 Pro (background mode)115 - Poll every 3 seconds for completion116 - Display progress updates117 - Save response to history1181193. **Monitor the output**120 - The script will show status updates121 - Wait for completion (don't timeout Claude Code!)122 - Typical time: 10-20 minutes123124### Phase 6: Present Results1251261. **The oracle script will display**:127 - Provider and model used128 - Time elapsed129 - Cost breakdown (input/reasoning/output tokens)130 - Full response from GPT-5 Pro1311322. **Read the history file** using Read tool:133 - Location: `.claude/oracle-history/oracle-<timestamp>.json`134 - Contains full response and metadata1351363. **Present to user**:137 - Summarize key findings138 - Highlight actionable recommendations139 - Show cost and time metrics140 - Ask if they have follow-up questions141142### Error Handling143144**If .oraclerc not found:**145- Inform user they need to set up configuration146- Point them to .oraclerc.example147- Explain they need an OpenAI API key148149**If API key invalid:**150- Check if OPENAI_API_KEY environment variable is set151- Suggest checking their API key configuration152- Remind them they need GPT-5 Pro access153154**If cost limit exceeded:**155- Show the estimated cost156- Ask if they want to proceed anyway157- Suggest ways to reduce cost (fewer files, compression)158159**If timeout:**160- The script has a 25-minute timeout161- If it times out, the request might still be processing162- Response ID is saved, can be retrieved later163164**If request fails:**165- Show the error message from OpenAI166- Suggest checking API status167- Offer to retry168169## Important Notes170171- **Cost**: Typically $2-10 per request depending on codebase size172- **Time**: Expect 10-20 minutes for responses (GPT-5 Pro uses extended reasoning)173- **API Access**: Requires OpenAI API key with GPT-5 Pro access174- **Privacy**: Code is sent to OpenAI (retained for 30 days per their policy)175- **History**: All consultations are saved to `.claude/oracle-history/`176- **Limits**: Configurable cost limits in .oraclerc prevent accidental overspending177178## Example Usage179180### Example 1: Memory Leak Analysis181182**User**: "I have a memory leak in my Node.js service. Can you do a deep analysis?"183184**Claude Code**:1851. Uses Glob to find: `**/*.js`, `src/**/*.ts`1862. Asks: "I found 42 files. Should I include tests?"1873. Asks: "What symptoms are you seeing?" → "Gradual memory growth, crashes at 2GB"1884. Asks: "When did this start?" → "After async refactor"1895. Shows estimate: ~$3.20 (45K tokens input)1906. Confirms: "Proceed?"1917. Runs oracle script1928. Waits 18 minutes1939. Presents detailed analysis with fixes194195### Example 2: Architecture Review196197**User**: "Review the architecture of my API"198199**Claude Code**:2001. Uses Glob: `src/api/**/*.ts`, `src/models/**/*.ts`2012. Estimates: 80K tokens (~$5.40)2023. Asks confirmation (exceeds $5 threshold)2034. User confirms2045. Runs oracle script2056. Waits 22 minutes2067. Presents architecture analysis with recommendations207208## Configuration209210Users must have `.oraclerc` in project root:211212```json213{214 "defaultProvider": "openai",215 "providers": {216 "openai": {217 "apiKey": "$OPENAI_API_KEY",218 "model": "gpt-5-pro",219 "enabled": true220 }221 },222 "limits": {223 "maxCostPerRequest": 10.00,224 "warnCostThreshold": 5.00225 }226}227```228229## Tips for Best Results2302311. **Be specific** in questions - the Oracle works best with clear, focused questions2322. **Select relevant files only** - more code = higher cost and longer processing2333. **Provide context** - explain what you've tried and what you're looking for2344. **Use for complex issues** - save simple questions for me directly2355. **Follow up** - you can ask clarifying questions after getting the response236237---238239**Remember**: This skill makes external API calls that cost money and take time. Always confirm with the user before submitting, and set clear expectations about the 20-minute wait time.