Sanderson's First Law
Brandon Sanderson's First Law of Magic: an author's ability to use magic to solve a problem is directly proportional to how well the reader understands that magic before the problem arises. An unexplained magic system used to solve plot problems is a deus ex machina with a fantasy label. The law is about earned solutions. If you want your protagonist to win with magic, the reader must have seen the magic's capabilities, understood its costs and limits, and been in a position to theorize the solution before the protagonist uses it. Solutions can be surprising. Capabilities cannot be revealed for the first time at the moment they are needed.