Skip to content

Commit 10d7423

Browse files
authored
Merge pull request #5969 from bdougie/bdougie/rules-doc-improvements
docs: Rules doc improvements
2 parents ffdd5f2 + e87a3a5 commit 10d7423

File tree

5 files changed

+95
-26
lines changed

5 files changed

+95
-26
lines changed

docs/docs/agent/how-to-customize.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ keywords: [customize, chat]
55
sidebar_position: 5
66
---
77

8+
## Add Rules Blocks
9+
10+
Adding Rules can be done in your assistant locally or in the Hub.
11+
12+
[Explore Rules on the Hub](https://hub.continue.dev/explore/rules) and see the [Rules deep dive](../customize/deep-dives/rules.md) for more details and tips on creating rules.
13+
814
## Add MCP tools
915

1016
You can add MCP servers to your assistant to give Agent access to more tools. [Explore MCP Servers on the Hub](https://hub.continue.dev/explore/mcp) and see the [MCP guide](../customize/deep-dives/mcp.mdx) for more details.

docs/docs/blocks/rules.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ keywords: [rules, blocks, standards, practices, guardrails]
66
sidebar_position: 5
77
---
88

9+
Rules allow you to provide specific instructions that guide how the AI assistant behaves when working with your code. Instead of the AI making assumptions about your coding standards, architecture patterns, or project-specific requirements, you can explicitly define guidelines that ensure consistent, contextually appropriate responses.
10+
911
Think of these as the guardrails for your AI coding assistants:
1012

1113
- **Enforce company-specific coding standards** and security practices
1214
- **Implement quality checks** that match your engineering culture
1315
- **Create paved paths** for developers to follow organizational best practices
1416

15-
![Rules Blocks Overview](/img/rules-blocks-overview.png)
17+
By implementing rules, you transform the AI from a generic coding assistant into a knowledgeable team member that understands your project's unique requirements and constraints.
18+
19+
### How Rules Work
20+
21+
Your assistant detects rule blocks and applies the specified rules while in [Agent](../agent/how-to-use-it), [Chat](../chat/how-to-use-it), and [Edit](../edit/how-to-use-it) modes.
1622

1723
## Learn More
1824

docs/docs/customize/deep-dives/rules.md

Lines changed: 82 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,65 @@ keywords: [rules, .continuerules, system, prompt, message]
55

66
# Rules
77

8-
Rules are used to provide instructions to the model for [Chat](../../chat/how-to-use-it.md), [Edit](../../edit/how-to-use-it.md), and [Agent](../../agent/how-to-use-it.md) requests.
8+
Rules provide instructions to the model for [Chat](../../chat/how-to-use-it.md), [Edit](../../edit/how-to-use-it.md), and [Agent](../../agent/how-to-use-it.md) requests.
99

10-
Rules are not included in most other requests, such as [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx).
10+
:::info Rules are not included in [autocomplete](./autocomplete.mdx) or [apply](../model-roles/apply.mdx).
11+
:::
12+
13+
## How it works
1114

1215
You can view the current rules by clicking the pen icon above the main toolbar:
1316

1417
![rules input toolbar section](/img/notch-rules.png)
1518

1619
To form the system message, rules are joined with new lines, in the order they appear in the toolbar. This includes the base chat system message ([see below](#chat-system-message)).
1720

18-
## `rules` blocks
21+
## Quick Start
22+
23+
Below is a quick example of setting up a new rule file:
24+
25+
1. Create a folder called `.continue/rules` at the top level of your workspace
26+
2. Add a file called `pirates-rule.yaml` to this folder.
27+
3. Write the following contents to `pirates-rule.prompt` and save.
28+
29+
```yaml title=".continue/rules/pirates-rule.yaml"
30+
name: Pirate rule
31+
version: 0.0.1
32+
schema: v1
33+
rules:
34+
- Talk like a pirate.
35+
```
36+
37+
Now test your rules by asking a question about a file in chat.
38+
39+
![pirate rule test](/img/pirate-rule-test.png)
1940
20-
Rules can be added to an Assistant on the Continue Hub. Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally.
41+
## Creating `rules` blocks
42+
43+
Rules can be added locally using the "Add Rules" button while viewing the Local Assistant's rules.
44+
45+
![add local rules button](/img/add-local-rules.png)
2146

2247
:::info Automatically create local rule blocks
23-
When in Agent mode, you can simply prompt the agent to create a rule for you using the `builtin_create_rule_block` tool if enabled.
48+
When in Agent mode, you can prompt the agent to create a rule for you using the `builtin_create_rule_block` tool if enabled.
2449

2550
For example, you can say "Create a rule for this", and a rule will be created for you in `.continue/rules` based on your conversation.
2651
:::
2752

53+
Rules can also be added to an Assistant on the Continue Hub.
54+
55+
Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally.
56+
2857
### Syntax
2958

3059
Rules blocks can be simple text, written in YAML configuration files, or as Markdown (`.md`) files. They can have the following properties:
3160

3261
- `name` (**required**): A display name/title for the rule
3362
- `rule` (**required**): The text content of the rule
63+
- `schema` (**required**): The schema version of the YAML file (e.g., `v1`)
3464
- `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`).
3565

36-
```yaml title="config.yaml"
66+
```yaml title=".config.yaml"
3767
rules:
3868
- Always annotate Python functions with their parameter and return types
3969
@@ -52,33 +82,60 @@ rules:
5282
TONE: concise
5383
```
5484

55-
## Chat System Message
85+
### `.continue/rules` folder
5686

57-
Continue includes a simple default system message for [Chat](../../chat/how-to-use-it.md) and [Agent](../../agent/how-to-use-it.md) requests, to help the model provide reliable codeblock formats in its output.
87+
You can create project-specific rules by adding a `.continue/rules` folder to the root of your project and adding new rule files.
5888

59-
This can be viewed in the rules section of the toolbar (see above), or visit the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4)
89+
```yaml title=".continue/rules/new-rule.yaml"
90+
name: New rule
91+
version: 0.0.1
92+
schema: v1
93+
rules:
94+
- Always give concise responses
95+
```
6096

61-
Advanced users can override this system message for a specific model if needed by using `chatOptions.baseSystemMessage`. See the [`config.yaml` reference](../../reference.md#models).
97+
This is also done when selecting "Add Rule" in the Assistant settings. This will create a new folder in `.continue/rules` with a default file named `new-rule.yaml`.
6298

63-
## `.continuerules`
99+
### Examples
64100

65-
You can create project-specific rules by adding a `.continuerules` file to the root of your project. This file is raw text and its full contents will be used as rules.
101+
If you want concise answers:
66102

67-
### Simple Examples
103+
```yaml title=".continue/rules/concise-rule.yaml"
104+
rules:
105+
- name: Always give concise answers
106+
rule: |
107+
Please provide concise answers. Don't explain obvious concepts.
108+
You can assume that I am knowledgable about most programming topics.
109+
```
68110

69-
- If you want concise answers:
111+
If you want to ensure certain practices are followed, for example in React:
70112

71-
```title=.continuerules
72-
Please provide concise answers. Don't explain obvious concepts. You can assume that I am knowledgable about most programming topics.
113+
```yaml title=".continue/rules/functional-rule.yaml"
114+
rules:
115+
- name: Always use functional components
116+
rule: |
117+
Whenever you are writing React code, make sure to
118+
- use functional components instead of class components
119+
- use hooks for state management
120+
- define an interface for your component props
121+
- use Tailwind CSS for styling
122+
- modularize components into smaller, reusable pieces
73123
```
74124

75-
- If you want to ensure certain practices are followed, for example in React:
125+
### Chat System Message
76126

77-
```title=.continuerules
78-
Whenever you are writing React code, make sure to
79-
- use functional components instead of class components
80-
- use hooks for state management
81-
- define an interface for your component props
82-
- use Tailwind CSS for styling
83-
- modularize components into smaller, reusable pieces
84-
```
127+
Continue includes a simple default system message for [Chat](../../chat/how-to-use-it.md) and [Agent](../../agent/how-to-use-it.md) requests, to help the model provide reliable codeblock formats in its output.
128+
129+
This can be viewed in the rules section of the toolbar (see above), or visit the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4)
130+
131+
Advanced users can override this system message for a specific model if needed by using `chatOptions.baseSystemMessage`. See the [`config.yaml` reference](../../reference.md#models).
132+
133+
### `.continuerules`
134+
135+
:::warning
136+
137+
`.contninuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead.
138+
139+
:::
140+
141+
You can create project-specific rules by adding a `.continuerules` file to the root of your project. This file is raw text and its full contents will be used as rules.

docs/static/img/add-local-rules.png

53.6 KB
Loading

docs/static/img/pirate-rule-test.png

77.1 KB
Loading

0 commit comments

Comments
 (0)