In this work, the automated generator environment for ORCA (ORCA-AGE) is described. It is a powerful toolchain for the automatic implementation of wavefunction-based quantum chemical methods. ORCA-AGE consists of three main modules: (1) generation of "raw" equations from a second quantized Ansatz for the wavefunction, (2) factorization and optimization of equations, and (3) generation of actual computer code. We generate code for the ORCA package, making use of the powerful functionality for wavefunction-based correlation calculations that is already present in the code. The equation generation makes use of the most elementary commutation relations and hence is extremely general. Consequently, code can be generated for single reference as well as multireference approaches and spin-independent as well as spin-dependent operators. The performance of the generated code is demonstrated through comparison with efficient hand-optimized code for some well-understood standard configuration interaction and coupled cluster methods. In general, the speed of the generated code is no more than 30% slower than the hand-optimized code, thus allowing for routine application of canonical ab initio methods to molecules with about 500-1000 basis functions. Using the toolchain, complicated methods, especially those surpassing human ability for handling complexity, can be efficiently and reliably implemented in very short times. This enables the developer to shift the attention from debugging code to the physical content of the chosen wavefunction Ansatz. Automatic code generation also has the desirable property that any improvement in the toolchain immediately applies to all generated code. © 2017 Wiley Periodicals, Inc.