Mentat CLI Cheatsheet - Terminal Multi-file AI Coding Agent Full Reference
Mentat is an AI coding agent that runs in the terminal, and its core artifact is not a code snippet pasted into a conversation but a unified diff spanning multiple files. You supply files and a requirement, it produces a patch, and you decide whether to apply it. That shape implies several concrete consequences. Review is a required step rather than an optional courtesy, because edits cross file boundaries and a fragment view hides the knock-on changes. It honours .gitignore and stays within the paths you pass, so the safety boundary is drawn by your arguments. And on a large repository, choosing files by hand is not realistic, so retrieval-driven context cuts down how much you have to feed it. Sections cover installation and first steps, context control, and interactive versus scripted use. For large refactors, state the scope once and apply diffs methodically rather than holding many single-file conversations.
Install and Start 4
pip install mentat-aimentatmentat --helpexport OPENAI_API_KEY=sk-xxxxContext Control 7
mentat src/main.py tests/mentat "scripts/**/*.py"mentat src/ --exclude tests/legacy/mentat --auto-contextmentat -a --auto-tokens 8000mentat --model claude-3-5-sonnetmentat --mcp-server "npx @modelcontextprotocol/server-postgres"Interaction and Scripting 9
/include/exclude/model gpt-4o:save:loadmentat --run "add docstrings"git initmentat --versionmentat src/ --exclude "**/*.test.ts"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