from fabric.api import run, env
from fabric.context_managers import cd
env.use_ssh_config = True

def list_files():
    with cd('/tmp'):
        run('ls')
How to set the working directory for a Fabric task?