Skip to content
Free Tool Arena

AI & LLMs · Guide · AI & Prompt Tools

How to Use Mentat AI

Installing mentat, CLI usage, context control (/include, /exclude), diff-based edits, and git workflows.

Updated April 2026 · 6 min read

Mentat is an open-source command-line coding assistant from AbanteAI that plans and applies multi-file edits directly from your terminal.

Advertisement

Mentat predates the current wave of agent CLIs and is still a clean, scriptable option. You give it a set of files and a natural-language task; it proposes a diff covering all of them, shows you the patch, and applies it on confirmation. It’s BYO-API-key and works with OpenAI, Anthropic, or local models via LiteLLM.

What it is

Mentat is a Python CLI. It parses the files you include, builds a context window, and prompts the model for a structured edit. Unlike chat-first tools, its primary verb is “produce a diff,” which makes it feel closer to a human pair-programmer than a chatbot. The project has been a reference implementation for many later agent tools.

Install / sign up

# Requires Python 3.10+
pipx install mentat

# Set your API key
export OPENAI_API_KEY=sk-...
# or
export ANTHROPIC_API_KEY=sk-ant-...

First session

From your project root, run mentat with the files (or directories) you want in context. Type your request at the prompt, review the proposed diff, and approve.

$ mentat src/api/ tests/
> Add rate limiting to the /login endpoint using a token bucket
# Mentat prints a unified diff across 3 files
# y to accept, n to reject, e to edit the prompt

Everyday workflows

  • 1. Include only the directories relevant to a task — smaller context means cheaper, faster, more accurate edits.
  • 2. Use /include and /exclude mid-session to adjust context without restarting.
  • 3. Chain Mentat into a script: pipe a task description in, capture the diff, and gate it behind CI.

Gotchas and tips

Mentat respects .gitignore and will refuse to touch files outside the paths you pass, which is a nice safety default. For very large repos, combine it with a grep step to narrow context before invoking the agent.

Because it produces unified diffs, merge conflicts with uncommitted work will abort the apply step cleanly — commit or stash first. Switch models mid-session with /model gpt-4o or /model claude-sonnet-4.

Who it’s for

Terminal-native developers who prefer a lean, diff-first workflow over heavyweight IDE integrations, and anyone who wants to scrip agent edits into a pipeline.

Advertisement

Found this useful?Email