An intelligent TypeScript-based coding assistant that leverages Claude AI's function calling capabilities to autonomously read files and provide smart code insights. This project demonstrates how to build sophisticated AI agents with tool integration.
This application showcases an AI agent loop where Claude AI can:
- Receive user prompts and code-related queries
- Autonomously decide when to invoke tools (like file reading)
- Execute those tools and process results
- Maintain conversation context across multiple tool calls
- Provide intelligent, context-aware responses
LLM Integration - Seamless integration with Claude AI via OpenRouter API
Function Calling - AI agents autonomously invoke tools when needed
Multi-turn Conversations - Agent loops that maintain context across multiple exchanges
File Operations - Safe file reading with dynamic path handling
Error Handling - Robust validation and error management
TypeScript - Type-safe implementation with full type checking
- Runtime: TypeScript (Node.js)
- LLM: Claude Haiku 4.5 via OpenRouter API
- API Client: OpenAI SDK (OpenAI-compatible)
- Environment: TypeScript + Bun
- User Input → Send prompt to Claude with available tools
- AI Decision → Claude decides if it needs to call a tool
- Tool Execution → If needed, execute the tool (e.g., ReadFile)
- Context Addition → Send results back to Claude
- Loop Continue → Claude processes results and either:
- Calls another tool, or
- Provides final response
- Output → Return final response to user
- Node.js / Bun (1.3+)
- OpenRouter API Key (
OPENROUTER_API_KEYenvironment variable)
npm install
# or with bun
bun install./your_program.sh -p "Your prompt here"./your_program.sh -p "What does the main.ts file do?"The AI will automatically read the file and provide an analysis.
This project demonstrates:
- Building AI agents with autonomous tool calling
- Implementing agentic loops for multi-step reasoning
- API integration with OpenAI-compatible endpoints
- Proper error handling and validation
- TypeScript best practices for AI applications
app/
├── main.ts # Core agent logic and API integration
## Key Concepts Implemented
- **Tool Definition** - Describing tools to the LLM
- **Function Calling** - AI autonomously invoking tools
- **Agent Loop** - Iterative reasoning with context
- **Message History** - Maintaining conversation state
- **Error Handling** - Graceful failure management
---
**Built with focus on clean code, proper typing, and AI/LLM best practices.**