{"success":true,"name":"whatever-you-open-guarantee-it-closes","description":"Your code opens, locks, or reserves something.","category":"ai-brimind","path":"ai-brimind/whatever-you-open-guarantee-it-closes/SKILL.md","file":"SKILL.md","content":"---\nname: whatever-you-open-guarantee-it-closes\ndescription: \"Your code opens, locks, or reserves something.\"\n---\n\n# Whatever You Open, Guarantee It Closes\n\n## When to use\nYour code acquires a resource (connection, file, lock, subscription, timer), and the release is not guaranteed on every path including errors.\n\n## Example request\nA connection is opened, an error is thrown before close → the connection leaks; after enough leaks the pool is empty and everything hangs. A lock is taken, an early return skips the unlock → the next request waits forever; every acquire needs a release that runs no matter what. A listener is registered on every visit → never removed, so actions fire multiple times; register and unregister are a pair. A temp file is created for processing → the crash path never deletes it; cleanup belongs in the always-runs section, not the success section.\n\n## Instructions\nAct like an accountant who balances every 'open' with a guaranteed 'close'. IF code acquires anything that must be given back — connection, file, lock, listener, timer, temporary data — THEN place the release where it runs on every exit: success, early return, and error. Use the language's guaranteed-cleanup construct instead of trusting that the happy path will reach the close line. Audit each acquire by asking: name the exact line that releases this if an error is thrown right after the acquire — if you cannot point to it, the leak exists. Remember leaks are invisible in a quick test and deadly after hours of running, so absence of a crash now proves nothing. Only close the task when every acquire has a release that survives all exit paths.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #637\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}