---
title: Add project rules
description: Give the harness project instructions it reads at the start of every attempt.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reeval.ai/llms.txt
> Use this file to discover all available pages before exploring further.

The `rules` field holds project instructions for the harness. reeval writes them into the file the harness reads at the start of every attempt, such as the `AGENTS.md` file. For more information about the file each harness reads, see [Rules and skills](/reference/options#rules-and-skills).

You extend the `plain` environment in the `evals/environments.ts` file with a variant, `with-rules`. A comparison between the baseline and the variant shows whether the rules helped.

## Write rules

In the `evals/environments.ts` file, declare the baseline and set `rules` to the instructions as a string.

```ts title="evals/environments.ts"
import { defineEnvironment } from '{{ pkg }}'

export const plain = defineEnvironment('plain', {})

export const withRules = plain.extendEnvironment('with-rules', {
  rules: `# SDK
Call generateText from Vercel AI SDK for model calls.
Do not call a provider SDK directly.
`,
})
```

After reeval prepares the workspace, it writes the rules file to the workspace root and replaces a rules file the repository holds. The harness loads the rules file. The prompt does not name that file.

An environment that extends another and sets `rules` replaces the parent's rules.

## Load rules from a file

To read the rules from the `rules/sdk.md` file, set `rules` to `file('./rules/sdk.md')`. In the `evals/environments.ts` file, accept `file` from the helpers.

```ts title="evals/environments.ts"
export const withRules = plain.extendEnvironment('with-rules', ({ file }) => ({
  rules: file('./rules/sdk.md'),
}))
```

reeval resolves the path against the `evals/environments.ts` file. reeval reads the `rules/sdk.md` file when the attempt starts, so the next run uses edits to that file without a change to the environment.

To check that reeval wrote the rules, read the `AGENTS.md` file in the evaluation body ([Assertions](/evaluations/grading/assertions)).

```ts title="evals/rules.eval.ts"
expect(await c.readFile('AGENTS.md')).toContain('generateText')
```

For the values `rules` accepts, see [the `rules` field](/reference/environment-helpers#environmentspec). For runnable projects, see [`with-rules`](https://github.com/invertase/reeval/tree/main/examples/with-rules), and [`with-rules-ab`](https://github.com/invertase/reeval/tree/main/examples/with-rules-ab) for two rules files compared.
