------Lima is useful for running AI agents inside a VM, so as to prevent agents from directly reading, writing, or executing the host files.
For running AI agents, it is highly recommended to only mount your project directory (current directory) into the VM:
{{< tabpane text=true >}} {{% tab header="Lima v2.0+" %}}
Drop :w for read-only mode. {{% /tab %}} {{% tab header="Lima v1.x" %}}
Set writable to false for read-only mode. {{% /tab %}} {{< /tabpane >}}
{{< tabpane text=true >}} {{% tab header="Aider" %}}
Follow the guide shown in the first session for authentication.
Alternatively, you can set environmental variables via:
See also https://github.com/Aider-AI/aider. {{% /tab %}} {{% tab header="Claude Code" %}}
Follow the guide shown in the first session for authentication.
Alternatively, you can set export ANTHROPIC_API_KEY... via:
See also https://github.com/anthropics/claude-code. {{% /tab %}} {{% tab header="Codex" %}}
Follow the guide shown in the first session for authentication.
Alternatively, you can set export OPENAI_API_KEY... via:
See also https://github.com/openai/codex. {{% /tab %}} {{% tab header="Gemini" %}}
Follow the guide shown in the first session for authentication.
Alternatively, you can set export GEMINI_API_KEY... via:
See also https://github.com/google-gemini/gemini-cli. {{% /tab %}} {{% tab header="GitHub Copilot" %}}
Type /login in the first session for authentication.
Alternatively, you can set export GH_TOKEN=... via:
See also https://github.com/github/copilot-cli. {{% /tab %}} {{% tab header="OpenCode" %}}
Type /connect in the first session for authentication. Unlike other agents, this step is not necessary for OpenCode.
See also https://github.com/anomalyco/opencode. {{% /tab %}}
{{< /tabpane >}}
Syncing Working Directory
| ⚡ Requirement | Lima >= 2.1 |
|---|
The --sync flag for limactl shell enables bidirectional synchronization of your host working directory with the guest VM. This is particularly useful when running AI agents (like Claude, Copilot, or Gemini) inside VMs to prevent them from accidentally modifying or breaking files on your host system.
Comparison with mount
| Feature | Mounts (--mount/--mount-only) | Sync (--sync) |
|---|---|---|
| Purpose | Make host directories visible inside guest (bidirectional if write mode is enabled) | Temporary bidirectional sync of a working directory (guest changes merged back on accept) |
| Live updates | Yes | No |
| Safety | Lower (AI agents can access host files directly) | Higher (changes are reviewed before being applied to host) |
| Requires rsync | No | Yes |
Usecase - Running AI Code Assistants Safely
Create an isolated instance for AI agents which must be started without host mounts for
--syncto work:
Navigate to your project
Run an AI agent that modifies code:
Or simply shell into the instance and make changes:
After running commands, you'll see an interactive prompt:
Yes: Syncs changes back to your host and cleans up guest directory
No: Discards changes and cleans up guest directory
View the changed contents: Shows a diff of changes made by the agent
Requirements
rsync must be installed on both host and guest
The host working directory must be at least 4 levels deep (e.g.,
/Users/username/projects/myproject)The instance must not have any host mounts configured (use
--mount-nonewhen creating)