GPT-5 Reasoner
Two-phase prompt optimization tool for GPT-5: optimize metadata with Claude, then execute with GPT-5.
Features
- Two-phase architecture: Optimizer (configurable model) analyzes file metadata, executor (GPT-5) processes full content
- Directory support: Automatically discover and include files from directories with filtering
- Dual interfaces: CLI and MCP (Model Context Protocol) support via universal-tool framework
- Smart file handling: Binary detection, UTF-8 validation, path normalization
- Configurable traversal: Control recursion, hidden files, extensions, and file limits
- Type safety: Strongly-typed Rust with comprehensive test coverage (40 tests)
Installation
Or build from source:
Usage
CLI
Basic usage with files:
Using directories:
MCP Server
Run as MCP server:
Environment Variables
OPENROUTER_API_KEY(required): API key for OpenRouterOPTIMIZER_MODEL(optional): Override default optimizer model- Default:
anthropic/claude-sonnet-4.5 - Precedence: parameter > env var > default
- Default:
RUST_LOG(optional): Control logging level (e.g.,gpt5_reasoner=debug)
Directory Support
DirectoryMeta Structure
Fields
directory_path(required): Path to directory (relative or absolute)description(required): Description inherited by all files from this directoryextensions(optional): File extensions to include (case-insensitive, accepts "rs" or ".rs")nullor[]: Include all files
recursive(optional, default:false): Traverse subdirectoriesinclude_hidden(optional, default:false): Include hidden files and directories- When
false, prunes entire hidden directories from traversal
- When
max_files(optional, default:1000): Maximum files per directory (safety cap)
Behavior Notes
- Binary files: Automatically skipped with debug logs
- Extension matching: Case-insensitive, handles both "rs" and ".rs" formats
- Hidden directories: When
include_hidden=false, hidden directories are pruned entirely (not just files) - Path normalization: All paths converted to absolute without resolving symlinks
- Symlinks: Not followed (
follow_links=false) - Deduplication: Files appearing in both
filesanddirectoriesare automatically deduplicated - Token limit: Final guard enforces 250k token limit on complete prompt
- Multi-dot extensions:
foo.rs.bkmatches "bk", not "rs" - Platform: Unix/Linux dotfile-based (Windows hidden attribute not checked)
Examples
Recursive Rust files only
All files including hidden
Multiple directories
Model Configuration
Optimizer Model
The optimizer analyzes file metadata to determine which files to include and how to structure the final prompt.
Default: anthropic/claude-sonnet-4.5
Override via:
- Function parameter (MCP/library usage)
OPTIMIZER_MODELenvironment variable- Falls back to default
Executor Model
The executor processes the full file content with the optimized prompt.
Fixed: openai/gpt-5 (high reasoning effort)
This model is not configurable and always uses reasoning_effort: high.
Reasoning Effort
- Models containing "gpt-5" or "gpt-oss" get
reasoning_effortset - Anthropic models do not support this parameter (correctly omitted)
Architecture
User Prompt + File Metadata
↓
Optimizer (Claude)
↓
Optimized Prompt Template
↓
File Content Injection
↓
Executor (GPT-5 high reasoning)
↓
Final Output
Two-Phase Benefits
- Cost efficiency: Optimizer sees only metadata (filenames, descriptions), not full content
- Token optimization: Executor prompt is pre-filtered to relevant files only
- Flexibility: Easy to swap optimizer models without changing executor
Development
# Run checks
# Run tests
# Build
# All in one
Breaking Changes from 0.1.0
- Default optimizer model changed from
openai/gpt-5toanthropic/claude-sonnet-4.5 gpt5_reasoner_implsignature now includesdirectoriesparameteroptimize_and_executeMCP function now accepts optionaldirectoriesparameter
License
MIT - See LICENSE