AI & LLMs · Guide · AI & Prompt Tools
How to Use Mentat AI
Install Mentat, control file context with /include and /exclude, apply diff-based edits, and integrate with your git workflow. Free to use in your browser.
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.
Use these while you read
Tools that pair with this guide
- System Prompt BuilderCompose a focused system prompt from a role, tone, constraints, and output format — copy-ready for any LLM.AI & Prompt Tools
- AI Prompt GeneratorTurn a vague idea into a structured prompt. Pick role, task, context, constraints, and output format. Works with ChatGPT, Claude, and Gemini.AI & Prompt Tools
- AI Token CounterEstimate tokens, characters, words, and approximate API cost for GPT-4o, GPT-4, Claude, and Gemini — before you hit send.AI & Prompt Tools
- AI Regex GeneratorDescribe what you want to match in plain English — get a canonical regex (email, URL, phone, UUID, etc.) plus a live test.AI & Prompt Tools
Advertisement
Continue reading
- AI & LLMsGitHub Copilot Pricing and ComparisonCompare free vs paid GitHub Copilot tiers and analyze it against ChatGPT, Cursor, and Tabnine. Find the best value plan instantly with this free online guide.
- AI & LLMsGitHub Copilot Features and CapabilitiesTest what Copilot really does — code accuracy, scope limits, debugging, web dev, legacy code, tests, docs, team customization. Free guide, no sign-up.
- AI & LLMsGitHub Copilot Security and Data HandlingAudit where your code goes, who sees it, training-data policy, network needs, and what happens when Copilot suggests broken code. Free, no sign-up.
- AI & LLMsAI Fluency SkillsThe 8 sub-skills of AI fluency: prompt structure, model selection, tool use, quality calibration, iteration, context management, cost awareness, privacy.
- AI & LLMsAnthropic Skills ExplainedSkills as Anthropic's answer to Custom GPTs — markdown-defined, version-controlled in git, work in terminal. Anatomy + Skills vs Custom GPTs.
- AI & LLMsKimi K2 vs DeepSeek V3Two open-weight Chinese flagships. Kimi K2 = 1M context, DeepSeek V3.2 = top-tier reasoning + coding. Pick by use case.