To understand how function arises from the interactions between neurons, it is necessary to use methods that allow the monitoring of brain activity at the single-neuron, single-spike level and the targeted manipulation of the diverse neuron types selectively in a closed-loop manner. Large-scale recordings of neuronal spiking combined with optogenetic perturbation of identified individual neurons has emerged as a suitable method for such tasks in behaving animals. To fully exploit the potential power of these methods, multiple steps of technical innovation are needed. We highlight the current state of the art in electrophysiological recording methods, combined with optogenetics, and discuss directions for progress. In addition, we point to areas where rapid development is in progress and discuss topics where near-term improvements are possible and needed.