I wrote a rule to prevent live-state misses. Four hours later I broke it. #8
crowcreation
started this conversation in
CLAUDE.md Patterns
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
After the 20th time my AI session acted on stale data instead of querying the live source, I wrote a CLAUDE.md rule: "Query live state before any recommendation, draft, or schema proposal whose correctness depends on external system state."
The rule was specific. It listed examples: HubSpot contacts, mailbox state, registry YAML, portal config. It said "when two artefacts disagree, the live source wins."
I committed it. I felt good.
Four hours later, I asked the system to draft five LinkedIn text posts. Earlier that morning, I'd commissioned a research synthesis that explicitly showed carousel posts outperform text posts by 120-180% on reach. My actual posting rhythm was already one carousel per week. The strategy document the system loaded said "5 text posts per week." The system followed the strategy document.
Two artefacts disagreed. The synthesis was newer and more accurate. The rule I'd written that morning said the newer source wins. The system didn't apply the rule, because the examples it listed were all external systems (CRM, mailbox, config files). It didn't recognise "strategy doc vs fresh synthesis" as the same class of conflict.
I caught it on review: "Is this actually best practice on LinkedIn?" Traced it back to the artefact conflict. Updated the rule to explicitly cover internal KB documents, not just external systems.
Drift mode: Context fragmentation (the rule existed but didn't self-fire because its scope was too narrow)
What broke: Writing a rule is not the same as having a rule that fires reliably. The rule's examples anchored the system to external-system lookups. Same-document-type conflicts (strategy doc vs synthesis output) weren't in the example set, so they weren't pattern-matched against the rule. The rule was correct in principle but incomplete in scope.
What changed: Two things. First, the rule was extended: "When two KB artefacts on the same topic have different last-reviewed dates, the newer wins. Same-session research output supersedes any pre-session strategy doc on its topic." Second, a pre-dispatch check was added: before sending work to a subagent, scan for artefact conflicts (synthesis freshness vs strategy-doc freshness vs ledger actuals) and surface disagreements before drafting.
Pattern: CLAUDE.md rules degrade through scope narrowness, not through removal. A rule with three examples will pattern-match against those three examples and miss the broader category. When you write a rule, ask: "what is the class of situation this addresses?" and write the rule at the class level, not at the instance level. Then stress-test by imagining a case that is structurally identical but uses different nouns.
All reactions