Cognitive flexibility denotes the ability to disengage from a current task and shift one's focus to a different activity. An individual's level of flexibility is not fixed; rather, people adapt their readiness to switch tasks to changing circumstances. We here review recent studies in the task-switching literature that have produced new insights into the contextual factors that drive this adaptation of flexibility, as well as proposals regarding the underlying cognitive mechanisms and learning processes. A fast-growing literature suggests that there are several different means of learning the need for, and implementing, changes in one's level of flexibility. These, in turn, have distinct consequences for the degree to which adjustments in cognitive flexibility are transferrable to new stimuli and tasks.