{"slug": "i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests", "title": "I Built RepoPilot: An AI-Powered Tool to Understand Codebases and Generate Tests", "summary": "A developer built RepoPilot, an AI-powered developer tool that indexes GitHub, GitLab, and Bitbucket repositories to enable codebase-aware chat and automated test generation. The tool combines AST parsing (via TypeScript's compiler ecosystem, Python AST, and a comment-aware Java scan) with dependency graphs to build targeted context for LLM requests, avoiding the inefficiency of passing entire repositories into a prompt. RepoPilot supports context-aware unit and integration test generation as well as scenario-based tests described in natural language.", "body_md": "*How a side project evolved into a developer tool combining AST parsing, dependency graphs, repository-aware AI, and automated test generation.*\n\nAs developers, we've all been there.\n\nYou open an unfamiliar repository. There are hundreds of files, deeply nested dependencies, unfamiliar abstractions, and barely any documentation.\n\nBefore you can fix a bug or introduce a feature, you need to answer a few questions:\n\nAI coding assistants have made parts of this easier. But I wanted to experiment with something more structured.\n\n**What if an AI assistant could first understand a repository's architecture and dependencies, then use that context to answer questions and generate tests?**\n\nThat's how **RepoPilot** started.\n\nRepoPilot is an AI-powered developer tool designed to help engineers explore unfamiliar codebases, understand their structure, and generate context-aware tests.\n\n🔗 **Try RepoPilot:** [https://repopilotapp.com](https://repopilotapp.com)\n\nInstead of manually copying files into an AI chatbot, you can connect a repository and let RepoPilot build the context required for codebase-aware interactions.\n\nHere's what the current version offers:\n\n**1. Repository integration**\n\nConnect GitHub, GitLab, or Bitbucket repositories, including private repositories through supported OAuth integrations.\n\n**2. Codebase indexing and dependency analysis**\n\nRepoPilot analyzes the repository's source code, extracts structural information, and builds relationships between files and code entities.\n\n**3. AI-powered codebase chat**\n\nAsk questions about your repository and receive answers informed by the indexed codebase.\n\n**4. Context-aware unit and integration test generation**\n\nSelect source files and generate tests based on their implementation and related dependencies.\n\n**5. Scenario-based test generation**\n\nDescribe a business scenario in natural language and let RepoPilot generate relevant test cases using repository context.\n\nThe goal isn't to replace an engineer's judgment. It's to reduce the repetitive work required to understand a codebase and establish a useful testing foundation.\n\nOne of the biggest challenges with AI-assisted development is context.\n\nLarge repositories cannot simply be passed into an LLM prompt in their entirety.\n\nEven when a repository fits within a model's context window, providing every file is often inefficient.\n\nIt increases token consumption, introduces irrelevant information, and makes it harder to focus on the specific implementation being discussed.\n\nI wanted RepoPilot to retrieve relevant code based on its actual structural relationships.\n\nThat led me toward a combination of **AST parsing, dependency graphs, and targeted context building**.\n\nRepoPilot's indexing pipeline uses TypeScript's compiler ecosystem to analyze JavaScript and TypeScript source files, Python AST for Python source files & Comment-aware source scan for Java.\n\nRather than treating code as plain text, the parser extracts structural information such as:\n\nThis provides a structured representation of the repository.\n\nFor example, consider:\n\n``` js\nimport { PaymentService } from \"./payment.service\";\n\nexport async function checkout(order: Order) {\n  const paymentService = new PaymentService();\n  return paymentService.process(order);\n}\n```\n\nA text-based search might identify the imported class name.\n\nAn AST-based approach gives us a more reliable way to identify the import relationship and the structure of the function containing it.\n\nThat information becomes valuable when deciding which related files should be included in an AI request.\n\nAfter parsing, RepoPilot constructs a knowledge graph representing relationships within the codebase.\n\nConceptually:\n\n```\ncheckout.ts\n    |\n    | imports\n    v\npayment.service.ts\n    |\n    | imports\n    v\npayment.gateway.ts\n```\n\nNow, if someone requests tests for `checkout.ts`, we don't necessarily need to provide the entire repository.\n\nWe can start with the selected file and traverse relevant dependencies.\n\nThis allows the context-building layer to collect the implementation details most likely to matter.\n\nThe graph also creates a foundation for future capabilities such as impact analysis and architectural exploration.\n\nThis was one of the more interesting architectural decisions.\n\nI separated the code-analysis pipeline from the AI-generation pipeline.\n\nAt a high level, the flow looks like this:\n\n```\nGit Repository\n      |\n      v\nRepository Parser\n      |\n      v\nDependency Graph\n      |\n      v\nContext Builder\n      |\n      v\nPrompt Builder\n      |\n      v\nLLM Provider\n      |\n      v\nGenerated Tests / AI Responses\n```\n\nThe context builder is responsible for identifying and collecting relevant code.\n\nThe prompt builder then transforms that information into task-specific instructions.\n\nFor example, generating unit tests requires a different prompt structure from answering an architectural question.\n\nKeeping these responsibilities separate makes the system easier to extend, debug, and maintain.\n\nIt also allows the AI provider to evolve independently of the repository-analysis pipeline.\n\nOne of RepoPilot's primary use cases is test generation.\n\nConsider a function that validates an order, checks inventory, and processes payment.\n\nA useful test suite should consider more than the happy path.\n\nIt might include:\n\nBy supplying the relevant implementation and dependency context, RepoPilot aims to produce more meaningful test suggestions than a generic prompt containing only a function name.\n\nThe generated tests still require developer review and execution. AI-generated tests are not automatically proof of correctness.\n\nBut they can significantly reduce the effort required to create an initial testing baseline.\n\nI also wanted developers to describe tests in the language of business requirements.\n\nFor example:\n\nGenerate tests for a checkout flow where payment succeeds but inventory reservation fails.\n\nRepoPilot uses the scenario and available repository context to generate relevant test code.\n\nThis is particularly useful when developers know the behavior they want to validate but haven't yet identified every implementation detail.\n\nIt also helps connect business-level requirements with actual source-code behavior.\n\nHere's a simplified view of the technologies behind RepoPilot:\n\n| Layer | Technology | \n|---|---|\n| Frontend | Vue 3, TypeScript | \n| Backend | Python, FastAPI | \n| Code analysis | TypeScript Compiler API / ts-morph | \n| Repository intelligence | Dependency graph and context builder | \n| AI integration | Provider abstraction for LLM services | \n| Authentication | Auth0 | \n| Source integrations | GitHub, GitLab, Bitbucket | \n| Background processing | Asynchronous jobs and workers | \n\nOne of my main goals was to keep the architecture modular.\n\nI didn't want the repository parser, context builder, and LLM integration to become one large service that would be difficult to maintain.\n\nA few lessons stood out during development.\n\n**1. Better context matters as much as better prompts.**\n\nPrompt engineering is useful, but identifying the correct source files and relationships is equally important.\n\n**2. Deterministic code analysis and generative AI complement each other.**\n\nAST parsing provides structural information. LLMs help interpret that information and generate useful outputs.\n\nNeither approach needs to replace the other.\n\n**3. AI-generated tests require validation.**\n\nGenerated code can contain incorrect assumptions, incomplete mocks, or invalid assertions.\n\nHuman review and execution remain essential.\n\n**4. Security becomes more complicated with private repositories.**\n\nRepository credentials must be handled carefully, with scoped access, secure storage, and protection against accidental exposure in logs or prompts.\n\n**5. Building a product is different from building a prototype.**\n\nAuthentication, quotas, failure handling, deployment, observability, and user onboarding quickly become just as important as the AI functionality.\n\nRepoPilot is still evolving.\n\nSome areas I'm interested in exploring further include:\n\nI'm deliberately keeping production preview execution out of the initial public release while I validate the security, infrastructure, and operational requirements.\n\nFor now, the focus is on repository intelligence and AI-assisted testing.", "url": "https://wpnews.pro/news/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests", "canonical_source": "https://dev.to/sampi007able/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests-286g", "published_at": "2026-10-18 21:40:28+00:00", "updated_at": "2026-10-18 21:48:49.168768+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents", "large-language-models", "artificial-intelligence"], "entities": ["RepoPilot", "GitHub", "GitLab", "Bitbucket", "TypeScript"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests", "markdown": "https://wpnews.pro/news/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests.md", "text": "https://wpnews.pro/news/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests.txt", "jsonld": "https://wpnews.pro/news/i-built-repopilot-an-ai-powered-tool-to-understand-codebases-and-generate-tests.jsonld"}}