Mentat CLI Cheatsheet - Terminal Multi-file AI Coding Agent Full Reference

Mentat is a terminal-native AI coding agent whose core verb is producing a multi-file diff: give it files and a task, it proposes a unified patch, you review and apply. It respects .gitignore, supports auto-context retrieval and MCP tools. This sheet covers context control, models, and interactive commands so you can refactor at scale from the terminal.

AI CLI·20 commands·Last updated 2026-09-10
mentataicoding-agentmulti-fileclidiffmcp

Install and Start 4

pip install mentat-ai
Install Mentat
mentat
Start an interactive session in the project
mentat --help
Show all flags
export OPENAI_API_KEY=sk-xxxx
Set the API key

Context Control 7

mentat src/main.py tests/
Add files or dirs to context
mentat "scripts/**/*.py"
Add files via glob
mentat src/ --exclude tests/legacy/
Include a dir but exclude a subpath
mentat --auto-context
Enable auto-context retrieval
mentat -a --auto-tokens 8000
Cap auto-context tokens
mentat --model claude-3-5-sonnet
Select a model
mentat --mcp-server "npx @modelcontextprotocol/server-postgres"
Connect an MCP tool server

Interaction and Scripting 9

/include
Add a file to context mid-session
/exclude
Exclude a file mid-session
/model gpt-4o
Switch model mid-session
:save
Save the current session
:load
Load a saved session
mentat --run "add docstrings"
Run non-interactively
git init
Init git before first use (Mentat relies on git)
mentat --version
Show version
mentat src/ --exclude "**/*.test.ts"
Exclude test files from context

Tips

  • Mentat produces a unified diff you review before applying, closer to pair programming than chat tools.
  • --auto-context uses RAG to find relevant snippets, sparing manual file picking in large repos.
  • It respects .gitignore and only touches files you pass in, a good safety default.

FAQ

How is Mentat different from Aider?

Both are terminal multi-file coding agents; Mentat centers on a unified diff plus review, while Aider emphasizes git-style /add and a chat loop. Pick by feel.

Must it use a cloud model online?

OpenAI by default, also Anthropic or local models via LiteLLM; keys come from env vars or .env.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Sep 10, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us