πŸ€– Fix it Claude

A powerful interactive command-line application that analyzes code snippets and files using Grok-4-fast via OpenRouter to provide comprehensive feedback on code efficiency, readability, and best practices. Completely free to use!

Co-authored by Claude Sonnet 4.5 πŸ€–

✨ Features

  • 🎯 Interactive CLI Interface: Beautiful menu-driven interface with easy navigation
  • πŸ“ Interactive Mode: Paste code directly into the terminal for instant analysis
  • πŸ“ File Mode: Drop files into a folder and select them for review
  • πŸ€– Smart Code Analysis: Uses Grok-4-fast for intelligent code review (free!)
  • πŸ” Language Detection: Automatically detects programming language
  • 🎨 Beautiful Interface: Rich, colorful terminal output with syntax highlighting
  • πŸ“Š Comprehensive Feedback: Covers efficiency, readability, best practices, and bug detection
  • πŸ”’ Security Analysis: Detects vulnerabilities, security issues, and provides risk assessments
  • πŸ’‘ Corrected Code Generation: Creates improved versions of your code with detailed explanations
  • πŸ’Ύ Automatic File Management: Saves enhanced code to organized folders
  • πŸ“ Detailed Comments: Explains what was changed, why, and the pros/cons of each approach
  • πŸ”„ Return to Menu: Seamless navigation between different review modes
  • 🌐 Cross-Platform: Works on Windows, macOS, and Linux

πŸš€ Quick Start

1. Installation

# Clone or download the project
git clone <repository-url>
cd clauder-Hackathon

# Install dependencies
pip install -r requirements.txt

2. Setup API Key

Get your OpenRouter API key from openrouter.ai/keys and create a .env file:

Create .env file:

# Run the helper script
python scripts/create_env.py

# Or manually create .env file with:
OPENROUTER_API_KEY=your-api-key-here

Note: The Grok-4-fast model is completely free to use!

3. Quick Setup

# Run the setup script to create directories and check dependencies
python scripts/setup.py

# Create your .env file with API key
python scripts/create_env.py

4. Usage

🎯 Interactive CLI App (Recommended)

python main.py

Or use the launcher:

  • Windows: Double-click run_cli.bat
  • Linux/Mac: ./run_cli.sh

πŸ“‹ CLI App Menu Options:

  1. Interactive Mode - Paste code directly into terminal
  2. File Mode - Select files from files_to_review/ folder
  3. Browse Reviewed Files - View previously reviewed files
  4. Exit - Close the application

πŸ“– How to Use the Interactive CLI App

🎯 Getting Started

  1. Launch the App:

    python main.py
    
  2. Choose Your Mode:

    • Option 1: Interactive Mode (paste code directly)
    • Option 2: File Mode (select from folder)
    • Option 3: Browse Reviewed Files (view previous reviews)
    • Option 4: Exit

πŸ“ Interactive Mode

  • Paste your code directly into the terminal
  • Press Enter twice when done (cross-platform compatible)
  • Code is automatically analyzed and improved

πŸ“ File Mode

  1. Drop files into the files_to_review/ folder
  2. Select the file you want to review from the numbered list
  3. The app will analyze and save improved code to reviewed_files/

πŸ“‚ Browse Reviewed Files

  • View all previously reviewed files
  • See the analysis results and corrected code
  • Navigate through your review history

πŸ“ Project Structure

clauder-Hackathon/
β”œβ”€β”€ πŸ“ src/                          # Source code
β”‚   β”œβ”€β”€ cli_app.py                   # 🎯 Main Interactive CLI Application
β”œβ”€β”€ πŸ“ scripts/                      # Utility scripts
β”‚   β”œβ”€β”€ create_env.py               # πŸ”‘ Environment setup helper
β”‚   β”œβ”€β”€ setup.py                    # βš™οΈ Project setup script
β”‚   └── env_template.txt            # πŸ“ Environment template
β”œβ”€β”€ πŸ“ examples/                     # Example files and demos
β”‚   β”œβ”€β”€ sample_code.py              # 🐍 Sample Python code
β”‚   β”œβ”€β”€ simple_demo.py              # 🎭 Demo output example
β”‚   └── test_demo.py                # πŸ§ͺ Test demonstration
β”œβ”€β”€ πŸ“ tests/                        # Test files
β”‚   └── test_api.py                 # πŸ”Œ API connection test
β”œβ”€β”€ πŸ“ files_to_review/              # πŸ“ Drop files here for review
β”‚   β”œβ”€β”€ sample_code.py              # 🐍 Sample Python code
β”‚   β”œβ”€β”€ example_js.js               # 🟨 Sample JavaScript code
β”‚   β”œβ”€β”€ test_comments.py            # πŸ’¬ Comment handling demo
β”‚   β”œβ”€β”€ vulnerable_code.py          # πŸ”’ Python security vulnerabilities
β”‚   └── vulnerable_js.js            # πŸ”’ JavaScript security vulnerabilities
β”œβ”€β”€ πŸ“ reviewed_files/               # πŸ’Ύ Corrected code saved here
β”‚   β”œβ”€β”€ example_js_improved.js      # βœ… Improved JavaScript code
β”‚   β”œβ”€β”€ pasted_code_improved.python # βœ… Improved pasted code
β”‚   β”œβ”€β”€ test_comments_improved.py   # βœ… Improved comment handling demo
β”‚   └── vulnerable_js_improved.js   # βœ… Secured JavaScript code
β”œβ”€β”€ πŸ“„ main.py                       # πŸš€ Main entry point
β”œβ”€β”€ πŸ“„ code_review_bot.py            # πŸ—‚οΈ Legacy core logic (kept for reference)
β”œβ”€β”€ πŸ“„ requirements.txt              # πŸ“¦ Dependencies
β”œβ”€β”€ πŸ“„ README.md                     # πŸ“– Documentation
β”œβ”€β”€ πŸ“„ PROJECT_STRUCTURE.md          # πŸ“ Project structure guide
β”œβ”€β”€ πŸ“„ SECURITY_ANALYSIS.md          # πŸ”’ Security analysis guide
β”œβ”€β”€ πŸ“„ VIDEO_SCRIPT.html             # 🎬 Video recording script
β”œβ”€β”€ πŸ”‘ .env                          # πŸ” API configuration (not tracked)
β”œβ”€β”€ πŸš€ run_cli.bat                   # Windows launcher
└── πŸš€ run_cli.sh                    # Linux/Mac launcher

πŸ”„ Workflow

Interactive Mode Workflow:

  1. Launch python main.py
  2. Choose "1" for Interactive Mode
  3. Paste your code into the terminal
  4. Press Enter twice when finished
  5. View analysis and corrected code
  6. Press Enter to return to main menu

File Mode Workflow:

  1. Drop files into files_to_review/ folder
  2. Launch python main.py
  3. Choose "2" for File Mode
  4. Select file from numbered list
  5. View analysis and corrected code
  6. Find improved code in reviewed_files/ folder
  7. Press Enter to return to main menu

Browse Reviewed Files Workflow:

  1. Launch python main.py
  2. Choose "3" for Browse Reviewed Files
  3. Select a previously reviewed file from the list
  4. View the original analysis and corrected code
  5. Press Enter to return to browse menu or main menu

πŸ”’ Security Analysis

The bot now includes comprehensive security analysis capabilities! Try analyzing the example vulnerability files:

  • vulnerable_code.py - Python security vulnerabilities
  • vulnerable_js.js - JavaScript security vulnerabilities
  • test_comments.py - Demonstrates comment handling (ignores AI instructions)

Security Features:

  • Detects SQL injection, XSS, CSRF, and other critical vulnerabilities
  • Provides risk assessments (CRITICAL, HIGH, MEDIUM, LOW, INFO)
  • Generates secure code fixes with detailed explanations
  • Covers authentication, authorization, and data protection issues
  • Smart Comment Handling: Ignores AI instruction comments, analyzes all code regardless

πŸ“– Read the full guide: SECURITY_ANALYSIS.md

🎯 What It Analyzes

The bot provides comprehensive feedback in these areas:

  1. Security Vulnerabilities: SQL injection, XSS, CSRF, buffer overflows, authentication bypasses, etc.
  2. Code Vulnerabilities: Race conditions, memory leaks, null pointer dereferences, integer overflows
  3. Input Validation Issues: Missing validation, improper sanitization, injection vulnerabilities
  4. Authentication & Authorization: Weak passwords, session management, privilege escalation
  5. Cryptographic Issues: Weak encryption, hardcoded secrets, improper random number generation
  6. Data Protection: PII exposure, data leakage, improper data handling
  7. Efficiency: Performance optimizations, algorithmic improvements, resource usage
  8. Readability: Code clarity, naming conventions, structure, comments
  9. Best Practices: Language-specific conventions, design patterns, secure coding practices
  10. Bug Detection: Potential issues, edge cases, error handling
  11. Security Risk Assessment: CRITICAL, HIGH, MEDIUM, LOW, or INFO risk levels
  12. Corrected Code: Complete improved version with detailed comments explaining:
    • What security vulnerabilities were fixed and why
    • What was changed and why
    • Cons of the previous approach (especially security-wise)
    • Pros of the new approach (especially security-wise)
    • Performance improvements
    • Security best practices applied

πŸ› οΈ Supported Languages

The bot automatically detects and supports most programming languages including:

  • Python
  • JavaScript/TypeScript
  • Java
  • C/C++
  • Go
  • Rust
  • PHP
  • Ruby
  • Swift
  • And many more!

πŸ“‹ Requirements

  • Python 3.7+
  • OpenRouter API key (free!)
  • Internet connection

πŸ”§ Dependencies

  • requests - HTTP requests for OpenRouter API
  • python-dotenv - Environment variable management
  • click - Command-line interface framework
  • rich - Beautiful terminal output
  • pygments - Syntax highlighting
  • colorama - Cross-platform colored terminal text

🎨 Features in Detail

Beautiful CLI Interface

  • Syntax-highlighted code display
  • Colorful panels and borders
  • Progress indicators
  • Rich text formatting

Smart Analysis

  • Uses the free Grok-4-fast model via OpenRouter
  • Context-aware suggestions
  • Language-specific best practices
  • Performance optimization tips

Flexible Input

  • Interactive code pasting
  • File analysis
  • Automatic language detection
  • Support for various file formats

🚨 Troubleshooting

API Key Issues

If you get an API key error:

  1. Make sure you have a valid OpenRouter API key
  2. Check that the .env file exists and contains your API key
  3. Get your free API key from: https://openrouter.ai/keys

Installation Issues

If you encounter dependency issues:

pip install --upgrade pip
pip install -r requirements.txt

Language Detection Issues

The tool automatically detects the programming language, but you can also specify it manually in the interactive mode.

πŸ“ Example Output

🎯 Interactive CLI App Interface

+---------------------------------------------+
| Fix it Claude                               |
| Analyze and improve your code with AI       |
| Using free Grok-4-fast model via OpenRouter |
+---------------------------------------------+

Main Menu

1. Interactive Mode - Paste code directly
2. File Mode - Select file from folder
3. Browse Reviewed Files - View previous reviews
4. Exit

Select an option [1/2/3/4] (1): 

πŸ“Š Analysis Results

β”Œβ”€ Code Review Analysis ─┐
β”‚ File: example.py       β”‚
β”‚ Language: python       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ Analysis Results ─┐
β”‚                    β”‚
β”‚ **Efficiency**:    β”‚
β”‚ - Consider using   β”‚
β”‚   memoization for  β”‚
β”‚   recursive calls  β”‚
β”‚                    β”‚
β”‚ **Readability**:   β”‚
β”‚ - Add type hints   β”‚
β”‚ - Improve variable β”‚
β”‚   naming           β”‚
β”‚                    β”‚
β”‚ **Best Practices**:β”‚
β”‚ - Add docstrings   β”‚
β”‚ - Handle edge casesβ”‚
β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ Corrected Code ─┐
β”‚                  β”‚
β”‚ # Improved code  β”‚
β”‚ # with detailed  β”‚
β”‚ # comments...    β”‚
β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βœ“ Corrected code saved to: reviewed_files/example_improved.py

Built With

Share this project:

Updates

Submission history