There currently isn't any way to have a "%cython" mode at the command-line. One could imagine using IPython's magic commands, but they seem to just take a single line of input which isn't that useful when writing Cython code. Honestly, your best option is to do something like Mike Witt posted above and write the Cython code in a separate file and use the load or attach commands to load it into your command-line session.