> For the complete documentation index, see [llms.txt](https://docs.codemate.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codemate.ai/cora/modes/code.md).

# Code

Writes, modifies, and refactors code. The primary execution mode.

Code mode makes changes to files. Before writing anything, it reads the existing codebase so that additions and modifications are consistent with what's already there matching the project's folder structure, naming conventions, import patterns, and code style.

<figure><img src="https://2395938751-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZ8BnJrGJwy0hT6DEkmb4%2Fuploads%2FCn2TlhJ7ir5r02M2YWyw%2FCode-mode-CORA%20(1).gif?alt=media&amp;token=a6392eb7-4476-4f23-b1b0-421cd3a39c32" alt=""><figcaption></figcaption></figure>

***

### Adding new features

When adding a feature to an existing project, Code mode reads the current architecture before writing anything. New files follow the conventions already in use. New endpoints follow the pattern of existing endpoints. New components follow the pattern of existing components.

```
Add a webhook system so organizations can register HTTPS endpoints
to receive alerts when a specific event type exceeds a threshold.
Retry failed deliveries up to 3 times with exponential backoff.
```

Cora will add the `WebhookEndpoint` model to the schema, create the registration API and management UI, extend the aggregation pipeline to check thresholds, build a delivery service with retry logic, and update the admin panel in a style consistent with the surrounding code.

***

### Refactoring

Code mode can refactor across multiple files simultaneously, maintaining consistency across the change.

```
The rate limiter logic is duplicated in three middleware files.
Extract it into a shared utility and update all three to import from there.
```

```
The dashboard API calls are scattered across components. Move them
into a centralized api.ts client with typed return values.
```

***

### Staying in scope

Code mode works best with clear, scoped prompts. The smaller the scope, the more precise the implementation and the easier the diff is to review. For large features, break them into steps model changes first, then service logic, then API layer, then frontend and run Code mode once per step.

> For changes that touch authentication, API key handling, tenant isolation, or database access patterns, follow up with a Review pass after Code completes.
