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.

The user interrupted Claude mid-response — a strong signal of confusion or misunderstanding.
Analyze both Claude's interrupted output and the user's follow-up to determine what went wrong.

Look for:
- Claude heading in a wrong direction that the user had to correct
- Misunderstanding of project conventions, architecture, or dependencies
- Missing context that caused Claude to make incorrect assumptions
- Patterns that would recur in future sessions without a rule

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.