# AI Rules

Giving system instructions to the AI

Starting with [v0.7.0](/content/docs/releases/0.7.0), Dyad lets you define AI rules for your project using an `AI_RULES.md` file in your project’s root directory. These rules guide the AI when making changes to your app.

**Note:** If your project doesn’t already have an `AI_RULES.md` file (likely because it was created with an earlier version of Dyad), you can copy this [default AI_RULES.md](https://github.com/dyad-sh/dyad/blob/main/scaffold/AI_RULES.md) into your project directory.

## [What are AI rules?](/content/docs/guides/ai-rules#what-are-ai-rules/index.html)

AI rules are part of the system prompt the AI uses to understand how to work on your project. They’re essentially instructions that help the AI stay consistent with your app’s architecture and coding standards.

A good set of rules should explain your tech stack—for example, which frameworks or libraries to use and for what purposes.

You can check out Dyad’s default AI rules for inspiration:

- [React.js template AI_RULES.md](https://github.com/dyad-sh/dyad/blob/main/scaffold/AI_RULES.md)
- [Next.js template AI_RULES.md](https://github.com/dyad-sh/nextjs-template/blob/main/AI_RULES.md)

## [Examples](/content/docs/guides/ai-rules#examples/index.html)

### [Production-Safe Database Changes](/content/docs/guides/ai-rules#production-safe-database-changes/index.html)

Once you're getting your app ready for production, it’s a good idea to make sure the AI only makes _safe_, backwards-compatible changes to your database.

To do this, you can add a rule like this to `AI_RULES.md`:

> When making any changes to the database schema, structure, or functionality, ensure all modifications are backwards compatible. This means:
>
> - Existing applications and queries must continue to work without modification
> - New columns should have default values or be nullable
> - Don’t remove or rename existing tables, columns, or constraints
> - Don’t change data types in ways that break existing code
> 
> The goal is to avoid breaking any systems that rely on the current database structure while still allowing new features to be added.
