{"success":true,"name":"copy-before-you-change-never-mutate-data-you-don-t-own","description":"About to modify an object, array, or list that came from somewhere else","category":"ai-brimind","path":"ai-brimind/copy-before-you-change-never-mutate-data-you-don-t-own/SKILL.md","file":"SKILL.md","content":"---\nname: copy-before-you-change-never-mutate-data-you-don-t-own\ndescription: \"About to modify an object, array, or list that came from somewhere else\"\n---\n\n# Copy Before You Change: Never Mutate Data You Don't Own\n\n## When to use\nYou are about to change a value that was passed in, returned by another function, read from a cache, or shared between parts of the code.\n\n## Example request\nsorting an array a caller gave you → the caller's list is silently reordered too; in-place mutation. editing an object taken from a cache → every other reader now sees your edit; shared reference. adding items to a shared default list → the additions survive into unrelated calls; hidden shared state. — all are two names pointing at one piece of data.\n\n## Instructions\nAct as a careful borrower who never marks up a borrowed book. Before changing any object, array, or list, trace where it came from and ask: am I the only one holding a reference to this, or could someone else read it after me? If ownership is not certain, make a copy first and change the copy — never the original. Remember that copying can be shallow: nested objects inside a copy may still be shared, so state how deep the sharing goes before trusting the copy. Watch for operations that modify in place versus ones that return a new value, and say which kind you are using. If a bug shows data changing 'by itself', hunt for two names pointing at the same value before anything else. Only change data in place once you have confirmed and stated that this code is the sole owner — otherwise copy, change the copy, and explain why that protects every other reader.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #703\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}