# Chat

Unlike a generic AI assistant, C0 chat answers questions with reference to your actual code. It reads your files, follows call chains, and gives you answers grounded in what's really there not what typically exists in a project like yours.

***

### Opening chat

Select **Chat** from the mode selector in the C0 panel.

***

### Asking questions

Type any question in plain language and press Enter. C0 reads the relevant parts of your codebase and responds with a specific, grounded answer.

**Understanding an area of code you've never touched:**

```
How does the notification system work?
What triggers a notification and how does it get delivered?
```

**Tracing data through a system:**

```
Where does a user's profile picture get stored after upload? 
Trace it from the API endpoint to the final storage location.
```

**Understanding behavior before making a change:**

```
If I change the return type of getUserById from User to User | null,
what else in the codebase will I need to update?
```

**Finding where something is implemented:**

```
Where is the retry logic for failed API calls? Is it centralized or scattered across services?
```

***

### Using @mentions to set scope

By default, C0 searches across your entire indexed codebase to answer a question. If you want to focus on a specific file, function, or directory, use @mentions.

```
@src/services/billing.ts How does proration work when a user upgrades mid-cycle?
```

```
@PaymentService.charge Walk me through exactly what happens when a charge fails.
```

```
@src/api/routes/ Which endpoints are missing authentication middleware?
```

@mentions can reference:

* File paths — `@src/utils/logger.ts`
* Directories — `@src/services/`
* Function or class names — `@UserRepository.findById`

You can combine multiple @mentions to give C0 a richer scope:

```
@AuthService @TokenValidator How do these two work together to validate a request?
```

***

### Referencing selected code

Select any code in your editor before asking a question and C0 will use your selection as the primary context.

This is useful when you want to ask something about a specific block without typing out a file path:

1. Select the code
2. Open the C0 chat panel
3. Ask your question C0 will automatically attach the selection

```
(with a complex function selected)
"What does this do? Are there any edge cases I should know about?"
```

***

### Following up

Chat is conversational. C0 remembers what was said earlier in the session, so you can ask follow-up questions without repeating context.

```
You: How does session expiry work?
C0:  (explains the session expiry flow, referencing SessionManager and the Redis TTL logic)

You: What happens if the Redis connection is down when a session expires?
C0:  (continues from the previous answer, now tracing the error path)

You: Is that error handled the same way everywhere, or are there inconsistencies?
C0:  (searches the codebase for all session error handlers and compares them)
```

***

### What chat is good for

Chat works best for **understanding** exploring, learning, and reasoning about code before making changes.

| Good for chat                        | Better with another workflow              |
| ------------------------------------ | ----------------------------------------- |
| "How does X work?"                   | Fixing a specific bug → Debug mode        |
| "Where is Y implemented?"            | Improving a slow function → Optimize mode |
| "What calls Z?"                      | Writing tests → Test generation           |
| "What will break if I change W?"     | Reviewing a PR → Code review              |
| "Explain this code to me"            | Documenting a module → DeepWiki           |
| "How does this system fit together?" | Visualizing a system → CodeMaps           |

***

### Tips

**Be specific about what you want to understand.** `How does auth work?` gets a general answer. "How does token refresh work when a user's access token expires mid-session?" gets a precise one.

**Ask about behavior, not just structure.** C0 can explain not just what code does, but what happens in specific scenarios timeouts, edge cases, error paths, concurrent access.

**Use chat to plan before you change.** Before refactoring or adding a feature, ask C0 to map out what's involved. This surfaces dependencies and risks before you touch anything.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codemate.ai/c0/chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
