The process in which the migration of an axon growth cone of a pyramidal cell that is part of the corticospinal tract is directed from its cell body in layer V through the cerebral cortex in response to a combination of attractive and repulsive cues.