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.

Analyze the conversation transcript for rule-worthy learnings:
- User corrections, redirections, or information Claude didn't know
- Investigation results and debugging knowledge
- Architecture and relationships not obvious from code
- Commands, workflows, and processes

Access and read files in the repo or in the .claude folder as needed.

Create new rules only when the learnings meet the guidelines in the context file.

IMPORTANT: If you create ANY rule files, write a short summary to `{{NOTIFICATION_FILE}}`. The summary should list each rule change, e.g.:
```
The background rule-reflection agent created the following rules:
- Created `.claude/rules/tooling/new-pattern.md` — documents X pattern
```
Only write the notification file when rules are created.

The project root is {{PROJECT_DIR}}

CRITICAL: All rule files MUST be written to {{PROJECT_DIR}}/.claude/rules/ (the project 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.