Tear off two sheets of aluminum foil long enough to line the sides and bottom of the pan with a little extra to hang over the lip. Fold each sheet so that they're the same width as the bottom of the pan.
Lay one sheet on the bottom of the pan and cross it in the opposite direction with the second sheet. Spray the pan with non-stick cooking spray and fill with the batter as normal.
Once your cake or brownies have baked and cooled, you can lift them from the pan by the foil flaps, peel it back, and cut into squares without any fuss.
This method works best when baking in square pans. If you bake in a rectangular pan, it helps to have a second pair of hands to support the bottom as you transfer it to the cutting board.
Related: Measuring: Dip and Sweep
(Image: Emma Christensen for the Kitchn)