FIRST: Read `.codeyam/rules/instructions.md` — it contains the required format, rule placement via the rule-path API, and an example rule. You MUST follow this format exactly when creating or editing rules.

THEN: Read the file {{CONTEXT_FILE}} and follow the instructions inside.

For each stale rule:
1. Review the inline rule content and the diff to determine if the rule needs updating
2. If it needs updating, edit the rule file in .claude/rules/ — also trim prose and unnecessary headers (most rules should be a few bullets)
3. Run `codeyam memory touch <rule-path1> <rule-path2> ...` with the SPECIFIC rule paths you reviewed to mark them as audited in .claude/codeyam-rule-state.json
   Example: `codeyam memory touch tooling/cli-build.md packages/ai/execution-flow-prioritization.md`

Write a summary to `{{NOTIFICATION_FILE}}` listing each action taken, even if you only ran `codeyam memory touch` without content changes. Example:
```
The background rule-reflection agent updated the following rules:
- Reviewed `.claude/rules/example.md` — no content changes, ran `codeyam memory touch`
- Created `.claude/rules/tooling/new-pattern.md` — documents X pattern
```

The project root is {{PROJECT_DIR}}

CRITICAL: All rule files MUST be written to {{PROJECT_DIR}}/.claude/rules/ (the project directory), NOT ~/.claude/rules/ (the user home directory). Always use the full absolute path when writing rule files.

CRITICAL: Before writing any rule file, you MUST run the rule-path command to determine the correct subdirectory:
  codeyam memory rule-path path/one path/two
Pass all paths from your frontmatter. The command returns the correct .claude/rules/ subdirectory as JSON. Do NOT guess the placement from the first path — rules with paths spanning multiple directories belong at their common ancestor.
