How do my agents use the Rules before they change my site?

Agents receive the rules at every step where it matters, and must follow them: the answer to open_project brings them near the start, one line per rule with its code, planning_preflight gives them before its verdict, and every write through SyncNow carries them in the check before the write.

An agent that tells open_project which environment it works on, with environment set to STAGING or PRODUCTION, is given in those three places the rules of that section; otherwise it is given those of both, each marked with its section, and is told to follow the ones of the environment it changes. It can read them whole at any time with get_environment and search_environment, which keep their old names.

Rules apply whatever files are touched: they are not filtered by path or by the agent's objective, and a context that carries only what changed since the agent's last session still carries all of them. The first write of a session is held once so that the agent reads them, unless planning_preflight already gave them at the same revision, and held again after a rule changes. SyncNow does not judge whether a change respects a rule: it does not match the text of a rule against the agent's plan, and nothing is refused because of a rule, so the agent itself must read and follow them.

Agents cannot add, change or remove a rule: project_program refuses it with ERR_RULES_PEOPLE_ONLY and nothing is written. An agent that thinks a rule is wrong, out of date or missing asks the people of the project in Conversations, naming the rule by its code, and follows it until someone changes it, so write rules that can be followed without guessing. See How do I stop agents from editing generated or third-party files?.


Can I write my database password or API keys in a rule?
What does the Activity tab show?
Getting Started
Projects and the Workspace
Agents and Work Sessions
Planning
Rules
Activity, History and Insights
Managers and Teamwork
Connections, Credentials and Security
Source, Safe Editing and Recovery
Updates, Reports and Troubleshooting