Abstract. We present a domain-independent algorithm for planning that computes macros in a novel way. Our algorithm computes macros “on-the-fly” for a given set of states and does not require previously learned or inferred information, nor prior domain knowledge. The algorithm is used to define new domainindependent tractable classes of classical planning that are proved to include Blocksworld-arm and Towers of Hanoi.