> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codealive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codebase Chat

> Have AI-powered conversations with deep understanding of your code

## Overview

Codebase Chat is an AI consultant that knows your entire codebase. Unlike semantic search which returns file locations and snippets, Codebase Chat provides synthesized, ready-to-use answers — architecture explanations, debugging analysis, implementation guidance, and code reviews grounded in your actual code.

This is powered by CodeAlive's GraphRAG approach: the AI has access to the full knowledge graph of your codebase, not just individual files.

## How It Works

**1. Ask a Question**

Ask any question about your codebase in natural language. The AI retrieves relevant context from the knowledge graph before generating a response.

**2. Get a Synthesized Answer**

The response combines information from across your codebase — referencing multiple files, tracing data flows, and explaining architectural patterns.

**3. Iterate**

Ask another self-contained question that includes the findings and constraints the next answer needs.

## Example Conversations

> [tab] Architecture
>
> ```
> You: "Explain how the authentication system works in this project"
>
> AI: The authentication system uses a JWT-based flow with three main components:
>     1. AuthController (src/controllers/auth.ts) handles login/signup endpoints
>     2. JwtService (src/services/jwt.ts) manages token generation and validation
>     3. AuthMiddleware (src/middleware/auth.ts) protects routes...
>     [continues with specific code references]
> ```

> [tab] Debugging
>
> ```
> You: "Why might payments be failing intermittently?"
>
> AI: Based on the payment processing code, there are several potential causes:
>     1. Race condition in PaymentProcessor.process() (src/services/payment.ts:142)
>        - The lock acquisition doesn't cover the full transaction...
>     2. Timeout configuration mismatch between the gateway client and...
>     [continues with specific code analysis]
> ```

> [tab] Implementation
>
> ```
> You: "How should I add rate limiting to the API?"
>
> AI: Based on your existing middleware pattern in src/middleware/:
>     1. Create a new RateLimitMiddleware following the pattern in AuthMiddleware
>     2. The existing Redis connection in src/config/redis.ts can be reused...
>     3. Your API routes in src/routes/index.ts use the middleware chain pattern...
>     [continues with implementation guidance matching your codebase patterns]
> ```

> [tab] Code Review
>
> ```
> You: "Review the error handling in the user service"
>
> AI: The UserService has inconsistent error handling:
>     1. createUser() (line 45) catches all errors but only logs generic messages
>     2. updateUser() (line 89) correctly throws typed errors
>     3. deleteUser() (line 112) has no error handling at all...
>     [continues with specific recommendations]
> ```

## Access Methods

> [tab] MCP Tool
>
> The `chat` tool is available through any CodeAlive-connected agent:
>
> | Parameter | Required | Description |
> | - | - | - |
> | `question` | Yes | Your question about the codebase |
> | `data_sources` | Yes | Repository or workspace names |
> | Your AI agent may call this tool for synthesized analysis after search. For the highest reliability and depth, prefer `semantic_search` and `grep_search` first. | | |

> [tab] REST API
>
> Chat directly via the CodeAlive API:
>
> ```bash theme={null}
> curl -X POST https://app.codealive.ai/api/tools/chat \
>   -H "Authorization: Bearer YOUR_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "question": "Explain the authentication flow",
>     "data_sources": ["my-backend"]
>   }'
> ```
>
> See the [API reference](https://docs.codealive.ai/api-reference/toolapi/stateless-chat.md) for the request and response schemas.

> [tab] Skill CLI
>
> If you have the [CodeAlive skill](https://docs.codealive.ai/integrations/skills.md) installed:
>
> ```bash theme={null}
> python scripts/chat.py "Explain the authentication flow" my-backend
> ```

## Stateless requests

Tool API chat does not retain conversation state. Include prior findings, artifact identifiers, assumptions, scope, and constraints in every `question`. This keeps each request reproducible across agents and integrations.

## Best Practices

> [card] Search First
>
> Use `semantic_search` and `grep_search` for locating code. Use `chat` when you need explanations or analysis — it's more expensive per call and can take up to 30 seconds.

> [card] Include context
>
> Make every question self-contained by including the relevant findings and constraints

> [card] Be Specific
>
> "Explain the payment retry logic" gets better results than "tell me about payments"

> [card] Scope by Repo
>
> Target specific repositories for more focused, accurate answers

## Related Resources

> [card] [Semantic Search](https://docs.codealive.ai/features/semantic-search.md)
>
> Fast code search for finding file locations and snippets

> [card] [Multi-Repository](https://docs.codealive.ai/features/multi-repo.md)
>
> Chat across multiple repositories and workspaces

> [card] [MCP Integration](https://docs.codealive.ai/integrations/mcp.md)
>
> Connect chat to your AI assistant

> [card] [API Reference](https://docs.codealive.ai/api-reference/toolapi/stateless-chat.md)
>
> Tool API chat endpoint documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.