While the setting of the countercyclical capital buffer (CCyB) is not an automatic decision, insights from indicators, such as the credit‐to‐GDP gap, are a starting point to inform the policy decision. This paper identifies an optimal rule to map the credit‐to‐GDP gap to the guide to set the CCyB. We use Italian data and follow two alternative procedures. First, we apply the criteria suggested by the Basel Committee on Banking Supervision (BCBS). Then we depart from the BCBS approach by proposing a procedure based on the maximization of the area under the receiver operating characteristic curve. We also explore whether the CCyB, had it been in place, would have mitigated the repercussions of the Great Financial Crisis on the Italian banking system. Based on a stylized exercise, the full release of the CCyB at the outbreak of the crisis would have freed around €40 billion of capital, a value close to the total amount of banks' credit provisions during the 3 following years.