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

# Rules

> Define behavior rules for all agents

Rules help Firebender understand how to write high quality code. Define rules using `.mdc` files in the `.firebender/rules/` directory.

<Tip>Rules apply to **all** features of Firebender such as autocomplete, chat, and inline AI changes</Tip>

<Info>
  Firebender supports both project-specific rules and personal rules that apply across all projects.

  * **Project Rules**: `.firebender/rules/*.mdc` in your project root
  * **Personal Rules**: `~/.firebender/rules/*.mdc` for rules across all projects
</Info>

## Quick Start

Create a `.firebender/rules/` directory in your project root and add `.mdc` files:

## General Rules Example: Food delivery app

Create `.firebender/rules/project-context.mdc`:

```markdown .firebender/rules/project-context.mdc theme={null}
---
alwaysApply: true
---

# Project Context

This is a food delivery app (similar to DoorDash).

Guidelines:
- Never use runBlocking
- Don't hardcode dpi
- Use `@SerializedName` for data/retrofit classes because code gets obfuscated
- Follow Material Design 3 guidelines and components
- Use Kotlin coroutines and Flow for asynchronous operations
```

## Situational Rules Example: Test files

Rules can apply only to specific files using glob patterns:

```markdown .firebender/rules/test-rules.mdc theme={null}
---
description: Testing guidelines
globs: "*Kotest.kt, *Test.kt"
---

- Use Kotest framework/BDD for tests
- Mock external dependencies
- Prefer property-based testing where applicable
```

If you modify the file `ProfileViewModelKotest.kt`, AI will follow the test rules. If you modify `MainActivity.kt`, AI will not be provided the irrelevant rule.

<Tip>`globs` follows the same pattern syntax as `.gitignore`.</Tip>

## Architecture Documentation as Rules

For complex or extensive rules, you can reference existing documentation in your rules:

```markdown .firebender/rules/architecture.mdc theme={null}
---
description: Android architecture guidelines
globs: "*.kt"
alwaysApply: false
---

# Android Architecture Guidelines

## UI Layer
- Use Jetpack Compose for new UI components
- Follow Material Design 3 guidelines
- Implement unidirectional data flow with ViewModels

## Data Layer
- Use Room for local database storage
- Implement Repository pattern for data access
- Use Retrofit for network operations
```

This keeps rules organized and easier to maintain than embedding everything in a JSON file.

## Live Reload

Rules reload automatically when you save changes to `.mdc` files. If there are parsing errors in the frontmatter, Firebender will notify you.

For a complete reference of the rules syntax including advanced patterns and configuration options, see the [Rules Reference](/api-reference/rules).

## Ignore Files

Firebender reads your project's codebase to power its features like autocomplete and chat context. You can control which files Firebender can access automatically to protect sensitive information and improve performance.

### How it works

Firebender respects ignore patterns for:

* **Implicit context**: Files added automatically to chat context
* **Autocomplete**: Code suggestions from ignored files are completely blocked

Firebender ignores patterns when:

* **Explicit mentions**: You manually paste code from an ignored file into chat
* **Direct edits**: You run inline edit commands on ignored files
* **Terminal/MCP tools**: These tools cannot be restricted by ignore patterns

### Why ignore files?

**Security**: Keep API keys, credentials, and secrets out of AI context. While Firebender blocks ignored files from implicit context, complete protection isn't guaranteed due to LLM unpredictability.

**Performance**: In large codebases or monorepos, exclude irrelevant portions for more accurate file discovery and faster responses.

<Warning>
  Never store production API keys in your local development environment. Ignore patterns provide defense-in-depth but are not foolproof security.
</Warning>

<Tip>Type `/help I want you to ignore these files...` in chat to get AI assistance setting up ignore patterns for your project.</Tip>

For configuration details and syntax, see [Ignore Files Configuration](/api-reference/syntax#ignore).
