Original Reddit post

The other day, Claude changed the parameters on some of the most-used functions in my project. Naturally, changing the parameters means other processes that call this function break as their arguments now mismatch the function’s parameters. Unfortunately, Claude does not allow you to prevent this with absolute certainty, but there are three things you can do to mitigate this. Here’s a prompt that I gave Claude and its recommendation on what to do. All programmers should be aware of this particular risk and how to mitigate it. ❯ Is there a way to ensure that you never change any parameters and return value shapes of existing functions without my express permission? ⏺ Three possibilities, none of them perfect: 1. Feedback memory (soft enforcement). I save the rule to memory and it loads every session. I’d consistently check function signatures before editing, and stop to ask before changing parameter names/order/defaults or return shape. Honest caveat: this is steering, not a guarantee — I can still slip, and you’d correct me. 2. PreToolUse hook on Write|Edit (hard enforcement). A shell hook intercepts every edit; if the diff touches an exported-function signature line, the hook blocks the call and surfaces a message asking for approval. Real enforcement, but the detection logic is fiddly — “did this diff change a signature?” needs static analysis (grep ^exports.<name>\s*=\s*(async\s*)?( lines and compare old vs new, or run a tree-sitter check). Easy to write a naive version, hard to write one that doesn’t false-positive on whitespace/comment-only edits. 3. No native guard for “preserve return shape” — return shape isn’t expressible as a permission rule, and only a hook (with type-aware analysis or a JSON-schema sidecar) could enforce it. My recommendation is the feedback memory as the immediate move, with the option to add a hook later if I keep slipping. The memory costs nothing,applies the rule everywhere I edit, and you can sharpen it as concrete violations come up. —- Additional guidance: It might be useful to ask Claude to identify and list core functions that many parts of the project rely upon. Have Claude then generate an array that gives an array in the following shape: [{file_name, function, parameters, return_shapes}]. Then you can write a hook that checks to see if any of these has changed to implement hard enforcement in an intelligent way. Hope this helps! submitted by /u/mcmac_max

Originally posted by u/mcmac_max on r/ClaudeCode