| 1 | --- |
| 2 | name: principle-encode-lessons-in-structure |
| 3 | description: "Apply when you catch yourself writing the same instruction a second time, or notice a recurring correction. Encode the rule as a lint, metadata flag, runtime check, or script instead of more text." |
| 4 | disable-model-invocation: true |
| 5 | --- |
| 6 | |
| 7 | # Encode Lessons in Structure |
| 8 | |
| 9 | Encode recurring fixes in mechanisms (tools, code, metadata, automation) instead of textual instructions. Every error, human correction, and unexpected outcome is a learning signal. Capture it, route it, and close the loop. |
| 10 | |
| 11 | **Why:** Textual instructions are easy to miss. They require the reader to notice, remember, and comply. Structural mechanisms (lint rules, metadata flags, runtime checks, automation scripts) enforce the rule without cooperation. |
| 12 | |
| 13 | **Pattern:** |
| 14 | When you catch yourself writing the same instruction a second time: |
| 15 | 1. Ask: can this be a lint rule, a metadata flag, a runtime check, or a script? |
| 16 | 2. If yes, encode it. Delete the instruction |
| 17 | 3. If no (requires judgment), make the instruction more prominent and add an example of the failure mode |
| 18 | |
| 19 | **Pick the strongest mechanism.** When more than one mechanism would work, choose the strongest the situation allows (an unrepresentable state that cannot compile, then a lint or banned API that fails CI, then a canonical helper, then a runtime check), because agents copy whatever the surrounding code already does and a weaker guard becomes the next template. |
| 20 | |
| 21 | **Corollary:** If the fix is structural, only use the structural fix. The instruction is the symptom. |
| 22 | |
| 23 | **Feedback loop:** |
| 24 | - **Capture every correction.** When the human intervenes or tests fail, decide if it's a one-off or a pattern. |
| 25 | - **Route to the right layer.** One-off -> brain note. Recurring fix -> skill or lint rule. Systemic issue -> principle. |
| 26 | - **Close the loop.** Don't just record. Apply now or create a concrete todo. |
| 27 | |
| 28 | **Anti-patterns:** |
| 29 | - Acknowledging without recording ("I'll keep that in mind" does not persist) |
| 30 | - Recording without routing (a brain note about a lint rule that should exist is wasted unless the lint rule gets implemented) |
| 31 | - Fixing without generalizing (fixing one instance while leaving the recurring pattern intact) |