Your AI-powered coding buddy that helps you crush LeetCode problems!
CodeBro is an interactive CLI tool that takes any coding problem and breaks it down into:
- 📊 Problem Analysis
- 🎯 Solution Strategy
- 🧠 Algorithm Design
- 💻 Java Implementation
- ✅ Comprehensive Test Cases
- 🔄 Interactive CLI - Solve multiple problems in one session
- 🤖 Powered by Claude AI (Sonnet 4) - Expert-level explanations
- 📈 Multiple Approaches - See brute force → optimized solutions
- ⚡ Complexity Analysis - Understand time/space trade-offs
- 💻 Working Code - Get production-ready Java implementations with comments
- ✅ Test Cases - JUnit tests with edge cases included
- 🏗️ Built with Official SDK - Uses Anthropic's official Java SDK
- Java 21 or higher
- Maven 3.6+
- Anthropic API key (get one at https://console.anthropic.com)
- Clone the repository
git clone <your-repo-url>
cd codebro-
Configure API Key
Create
src/main/resources/config.properties:
anthropic.api.key=your-api-key-here.gitignore.
- Build the project
mvn clean installRun CodeBro:
mvn exec:java -Dexec.mainClass="org.codebro.Main"Or run Main.java directly from your IDE.
- Paste your problem - Copy any LeetCode or coding problem
- Type 'END' on a new line when done
- Get your tutorial - CodeBro provides a comprehensive breakdown
- Solve another or type 'quit' to exit
=================================
Welcome to CodeBro! 🤝
Your AI Coding Buddy
=================================
Paste your coding problem below.
Type 'END' on a new line when done, or 'quit' to exit.
Two Sum Problem:
Given an array of integers nums and an integer target,
return indices of the two numbers such that they add up to target.
Example:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
END
🤔 CodeBro is thinking...
[Complete tutorial with analysis, strategy, algorithm, code, and tests appears here]
==================================================
Solve another problem? (y/n):
src/
├── main/
│ ├── java/org/codebro/
│ │ ├── Main.java # Interactive CLI entry point
│ │ ├── CodeBro.java # Main agent orchestrator
│ │ ├── APIClient.java # API interface
│ │ ├── AnthropicSDKClient.java # Anthropic SDK implementation
│ │ └── PromptBuilder.java # Builds structured prompts
│ └── resources/
│ └── config.properties # API key configuration (gitignored)
└── test/java/org/codebro/
├── CodeBroTest.java # Unit tests with mocks
└── PromptBuilderTest.java # Prompt builder tests
CodeBro uses a clean, testable architecture:
- APIClient Interface - Abstraction for AI providers
- AnthropicSDKClient - Implementation using official Anthropic SDK
- PromptBuilder - Crafts structured prompts for optimal responses
- CodeBro - Orchestrates the problem-solving workflow
This design makes it easy to:
- Swap AI providers (just implement
APIClient) - Test with mocks (dependency injection)
- Customize prompts without changing core logic
Run all tests:
mvn testRun specific test:
mvn test -Dtest=CodeBroTestThe test suite uses Mockito to mock the API client, ensuring fast, reliable tests without API calls.
Modify AnthropicSDKClient.java to change:
- Model version (default:
claude-sonnet-4-20250514) - Max tokens (default: 4096)
Edit PromptBuilder.java to customize:
- Tutorial structure and sections
- Level of detail
- Output format and style
- Anthropic Java SDK (2.10.0) - Official Claude API client
- Gson (2.11.0) - JSON parsing (used by SDK)
- JUnit 5 (5.10.0) - Testing framework
- Mockito (5.2.0) - Mocking for unit tests
- Be specific: Include constraints, examples, and expected behavior
- Format clearly: Use line breaks and sections for complex problems
- Include examples: Show input/output examples from the problem
- Ask follow-ups: After getting a solution, you can solve another related problem
Make sure you created src/main/resources/config.properties with your API key.
Check that your config.properties file has the correct property name: anthropic.api.key
- Verify your API key is valid at https://console.anthropic.com
- Check you have sufficient credits in your account
- Ensure you're using Java 21+
- Save tutorials to files (Markdown, HTML)
- Problem history and favorites
- Different difficulty levels (beginner/interview/advanced)
- Conversation mode for follow-up questions
- Support for multiple programming languages
- Export to Anki flashcards
- Integration with LeetCode API
- Batch processing from files
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests
- Suggest improvements to prompts or architecture
MIT License - feel free to use this for learning and building!
- Built with Anthropic's Claude API
- Uses the official Anthropic Java SDK
- Inspired by the LeetCode learning community
Happy Coding! 💪
Built by developers, for developers who want to level up their problem-solving skills.