Skip to content

Epic: Claude-Powered GitHub Issue Processor - Stage 10: Optimizing Context for Claude (MCP & RAG Exploration) #14

Closed

Description

@integry

General Goal of the Epic

To create an automated system that monitors GitHub issues, uses Anthropic's Claude Code to generate solutions, and automates the Git workflow including PR creation.

Current Stage (Issue 10 of N) - Future Enhancement

This issue focuses on exploring and outlining strategies for optimizing the context provided to Claude Code, aiming to improve its performance, accuracy, and cost-effectiveness. This involves investigating Model Context Protocol (MCP) and Retrieval Augmented Generation (RAG) techniques. (Refers to Proposal Section 6.1)

  • What's being done in this issue:
    1. Research and document the potential of using MCP servers with Claude Code for dynamic and structured context (e.g., vector DBs, API docs).
    2. Outline a strategy for implementing a RAG pre-processing step to provide Claude with more focused context (relevant file snippets based on issue description) instead of the entire worktree.
    3. Reinforce the continuous refinement of CLAUDE.md files.
  • What's been done (up to $PREVIOUS_ISSUE_9_ID_PLACEHOLDER): Core workflow from issue detection to PR creation, including initial CLAUDE.md and slash command scaffolding. System robustness and QA frameworks have also been initiated.
  • What's remaining (for the epic): Implementation of this and other advanced enhancements, full operationalization, monitoring, etc.

Task Details

1. Research and Document Model Context Protocol (MCP) Potential (Sec 6.1, Ref 24)

  • Objective: Understand how MCP servers can be leveraged with the Claude Code CLI.
  • Tasks:
    • Review Anthropic's documentation on MCP and its usage with Claude Code (claude mcp add, --mcp-config).
    • Identify potential use cases for MCP in this project:
      • Access to a vector database of past similar issues and their resolutions.
      • Providing project-specific API documentation dynamically.
      • Access to real-time build status or CI information.
    • Document the steps required to set up a basic MCP server (e.g., a simple Node.js HTTP server providing specific contextual data based on requests from Claude).
    • Outline how the worker would configure Claude Code (running in Docker) to use this MCP server.
  • Deliverable: A markdown document summarizing findings, potential architecture for an MCP server, and integration steps.

2. Outline a Retrieval Augmented Generation (RAG) Strategy (Sec 6.1, Ref 60)

  • Objective: Reduce token consumption and improve Claude's focus by providing only the most relevant code snippets.
  • Tasks:
    • Design a pre-processing step to be run by the worker before invoking Claude:
      • Option 1 (Static Analysis): Use linters or tree-sitter to identify files/functions related to keywords in the issue description.
      • Option 2 (Git History Analysis): Analyze Git history for files frequently changed when similar issues (e.g., based on keywords or labels) were addressed.
      • Option 3 (Vector Search - RAG):
        • Plan for creating embeddings for the codebase (e.g., per file, per function, per class). This might be a separate batch process.
        • At runtime, embed the current GitHub issue description.
        • Perform a similarity search against the codebase vector index to retrieve the top N relevant code snippets.
    • Document the chosen RAG approach (e.g., starting with a simpler keyword-based file identification, then moving to vector search).
    • Specify how these relevant files/snippets would be packaged and presented to Claude (e.g., concatenated into a context string, or listed for Claude to read from the workspace).
  • Deliverable: A section in the context optimization document outlining the RAG strategy, including tools (e.g., embedding models, vector DB choices like FAISS, ChromaDB, or cloud-based options), and workflow.

3. Continuous Refinement of `CLAUDE.md` (Sec 6.1, Ref 16)

  • Re-emphasize that `CLAUDE.md` files (established in Issue 9) are a living document.
  • Define a process for updating `CLAUDE.md` files based on:
    • Lessons learned from successful/failed AI processing attempts.
    • New architectural patterns introduced in the target repositories.
    • Common pitfalls observed in AI-generated code.
  • This ensures domain knowledge is continuously injected into Claude's static context.

Acceptance Criteria

  • A research document detailing MCP integration possibilities and a basic MCP server design is produced.
  • A RAG strategy document is produced, outlining at least one approach for focused context retrieval.
  • The process for maintaining and updating `CLAUDE.md` files is formally documented.
  • (Optional) A proof-of-concept script for a simple RAG step (e.g., keyword-based file identification) is developed.

Activity

  1. integry commented on May 24, 2025

    @integry
    OwnerAuthor

    Implementation Considerations & Pointers

    1. Model Context Protocol (MCP):

    • Claude Code CLI documentation (Ref 24) should be the primary source.
    • An MCP server is essentially an HTTP server that Claude Code can query for additional context during its execution.
    • Example MCP Server (Conceptual Node.js/Express):
      // Basic MCP server concept
      // import express from 'express';
      // const app = express();
      // app.use(express.json());
      //
      // app.post('/mcp_endpoint', (req, res) => {
      //     const query = req.body.query; // Query from Claude
      //     let contextData = {};
      //     // Logic to fetch/generate context based on query
      //     // e.g., if (query.type === 'api_docs' && query.library === 'myLib') { ... }
      //     // e.g., if (query.type === 'vector_search' && query.text) { /* call vector DB */ }
      //     res.json({ context: contextData });
      // });
      //
      // // app.listen(3000, () => console.log('MCP Server listening on port 3000'));
    • Worker would need to pass --mcp-config to claude or use claude mcp add within the Docker container setup.

    2. Retrieval Augmented Generation (RAG):

    • Simple Keyword Matching (Initial RAG):
      • Extract keywords from the GitHub issue title and body.
      • Use grep or similar tools within the worktree to find files containing these keywords.
      • Concatenate the content of these files (or relevant surrounding lines) into a context string for Claude.
    • Vector Embeddings:
      • Embedding Generation (Offline/Periodic):
        • Tools: Sentence Transformers (e.g., all-MiniLM-L6-v2), OpenAI Embeddings API, Cohere Embeddings.
        • Chunk code into meaningful segments (functions, classes, or larger file chunks).
        • Store embeddings and corresponding text in a vector database (FAISS, Chroma, Pinecone, Weaviate).
      • Runtime Retrieval:
        • Embed the GitHub issue description.
        • Query the vector DB for top-k similar code chunks.
        • Provide these chunks as context to Claude.
      • Example libraries for Node.js: langchainjs, direct vector DB client libraries.

    3. CLAUDE.md Refinement Process:

    • Integrate into the "Definition of Done" for tasks that required significant AI debugging or prompt tuning.
    • Schedule periodic reviews (e.g., monthly) of CLAUDE.md for staleness or missing critical project patterns.

    This issue is exploratory. The goal is to define strategies and potentially small PoCs, not full implementation of complex RAG/MCP systems immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions