Counterbalancing climate change is one of the biggest challenges for engineers around the world. One of the areas in which optimization techniques can be used to reduce energy needs, and with that the pollution derived from its production, is building design. With this study of a generic office located both in a northern country and in a temperate/Mediterranean site, we want to introduce a coding approach to dynamic energy simulation, able to suggest, from the early-design phases when the main building forms are defined, optimal configurations considering the energy needs for heating, cooling and lighting. Generally, early-design considerations of energy need reduction focus on the winter season only, in line with the current regulations; nevertheless a more holistic approach is needed to include other high consumption voices, e.g., for space cooling and lighting. The main considered design parameter is the WWR (window-to-wall ratio), even if further variables are considered in a set of parallel analyses (level of insulation, orientation, activation of low-cooling strategies including shading devices and ventilative cooling). Finally, the effect of different levels of occupancy was included in the analysis to regress results and compare the WWR with corresponding heating and cooling needs. This approach is adapted to Passivhaus design optimization, working on energy need minimisation acting on envelope design choices. The results demonstrate that it is essential to include, from the early-design configurations, a larger set of variables in order to optimize the expected energy needs on the basis of different aspects (cooling, heating, lighting, design choices). Coding is performed using Python scripting, while dynamic energy simulations are based on EnergyPlus.