Skip to content

Latest commit

 

History

History
91 lines (67 loc) · 3.2 KB

File metadata and controls

91 lines (67 loc) · 3.2 KB
description AI-powered codebase optimisation with language-specific best practices and interactive approval.

Code Optimisation

Code-Graph-RAG provides AI-powered codebase optimisation with best practices guidance and an interactive approval workflow.

Basic Usage

cgr optimize python --repo-path /path/to/your/repo

With Reference Documentation

Guide the optimisation process using your own coding standards:

cgr optimize python \
  --repo-path /path/to/your/repo \
  --reference-document /path/to/best_practices.md
cgr optimize java \
  --reference-document ./ARCHITECTURE.md
cgr optimize rust \
  --reference-document ./docs/performance_guide.md

The agent incorporates guidance from your reference documents when suggesting optimisations, ensuring they align with your project's standards and architectural decisions.

Using Specific Models

cgr optimize javascript \
  --repo-path /path/to/frontend \
  --orchestrator google:gemini-2.0-flash-thinking-exp-01-21
cgr optimize javascript --repo-path /path/to/frontend \
  --batch-size 5000

Supported Languages

All supported languages: python, javascript, typescript, rust, go, java, scala, c, cpp

How It Works

  1. Analysis Phase: The agent analyses your codebase structure using the knowledge graph
  2. Pattern Recognition: Identifies common anti-patterns, performance issues, and improvement opportunities
  3. Best Practices Application: Applies language-specific best practices and patterns
  4. Interactive Approval: Presents each optimisation suggestion for your approval before implementation
  5. Guided Implementation: Implements approved changes with detailed explanations

Example Session

Starting python optimization session...
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ The agent will analyze your python codebase and propose specific          ┃
┃ optimizations. You'll be asked to approve each suggestion before          ┃
┃ implementation. Type 'exit' or 'quit' to end the session.                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Analyzing codebase structure...
Found 23 Python modules with potential optimizations

Optimization Suggestion #1:
   File: src/data_processor.py
   Issue: Using list comprehension in a loop can be optimized
   Suggestion: Replace with generator expression for memory efficiency

   [y/n] Do you approve this optimization?

CLI Options

Option Description
--orchestrator Specify provider:model for main operations
--cypher Specify provider:model for graph queries
--repo-path Path to repository (defaults to current directory)
--batch-size Override Memgraph flush batch size
--reference-document Path to reference documentation