Metaheuristics are gradient-free and problem-independent search algorithms. They have gained huge success in solving various optimization problems in academia and industry. Automated metaheuristic design is a promising alternative to human-made design. This paper proposes a general and comprehensive methodological framework, AutoOpt, for automatically designing metaheuristics for various optimization problems. AutoOpt consists of: (1) a bi-level criterion to evaluate the designed algorithms' performance; (2) a general schema of the decision space from where the algorithms will be designed; (3) a mixed graph- and real number-based representation to represent the designed algorithms; and (4) a model-free method to conduct the design process. AutoOpt benefits academic researchers and practical users struggling to design metaheuristics for optimization problems. A real-world case study demonstrates AutoOpt's effectiveness and efficiency.