When using cached data/artifacts, treat the cache as ephemeral and potentially stale/corrupt. Apply three rules:
1) Make cache scope explicit (and CI-safe)
2) Validate before trusting
3) Fall back deterministically
Example pattern (epic context cache)
# Pseudocode/steps
if cache_file_exists(epic_N_context) then
content = read(cache_file)
if content is empty OR not content.startswith("# Epic <N> Context") then
delete/ignore cache
compiled = compile_epic_context(N) # deterministic recompute
assert compiled exists and non-empty
load(compiled)
else
load(cache_file)
else
compiled = compile_epic_context(N)
assert compiled exists and non-empty
load(compiled)
fi
Also ensure you only apply these rules where the system actually caches. If something is reloaded fresh every run (e.g., prompt/step files read at execution time), don’t treat it as cached state and don’t add cache-migration guidance to it.