marim-harness
A terminal coding agent you can also build on.
Use Marim to work on your code with streaming responses, tool approvals, and resumable sessions—or embed its agent loop in your own Python application. Connect Claude Code or Codex through their CLI backends, or use models through API providers and local servers.
Quickstart · Build with Marim · Documentation · Examples
Quickstart
Requires Python 3.10+ and uv. Install the interactive terminal UI:
uv tool install 'marim-harness[tui]'
In your project directory, choose one of the setups below. Each launches
Marim in ask mode so you can review approval requests. Then try:
“Explain how this project is organized and where its tests live.”
Claude Code
Install Claude Code 2.1+ and sign in through claude first. The claude
executable must be on your PATH; Marim uses the CLI's authentication.
export MARIM_PROVIDER=claude-cli
marim --mode ask
Codex
Install Codex CLI 0.152+ and sign in with codex login first. The codex
executable must be on your PATH; Marim uses the CLI's authentication.
export MARIM_PROVIDER=codex-cli
marim --mode ask
API provider
For OpenRouter, supply your API key:
export MARIM_PROVIDER=openrouter
export OPENROUTER_API_KEY='your-api-key'
marim --mode ask
Google, OpenCode Zen, and Zen Go are also supported. See provider configuration for credentials and model selection.
Local model
Start an OpenAI-compatible server such as Ollama or LM Studio with a model available before launching Marim. No cloud API key is needed:
export MARIM_PROVIDER=local
export MARIM_BASE_URL=http://localhost:11434/v1 # LM Studio: http://localhost:1234/v1
export MARIM_API_KEY=local
marim --mode ask
Choose a model from the server in Marim's model picker. Set MARIM_MODEL
explicitly for headless runs.
Choose your backend
| Backend | Marim manages | Backend manages |
|---|---|---|
| API providers / local models | Agent loop, tools, approvals, sessions, and configured MCP/LSP integrations | Model inference |
Claude Code (claude-cli) |
Terminal UI, approval requests, and session resume | Claude's agent loop, tools, and authentication |
Codex (codex-cli) |
Terminal UI, approval requests, and session resume | Codex's agent loop, tools, sandbox, and authentication |
Marim's native tools and MCP/LSP configuration apply to API/local backends. The CLI backends have separate integration and configuration limits; see provider details.
Other installation options
A bare uv tool install marim-harness provides headless mode. Add extras as
needed; they can be combined, for example marim-harness[tui,serve,workflows].
| Extra | Adds |
|---|---|
tui |
Interactive terminal UI |
serve |
HTTP daemon with REST and WebSocket access |
workflows |
Sandboxed orchestration scripts |
lsp-python |
The basedpyright Python language server |
Both marim and marim-harness invoke the same console app.
Why Marim?
- An agent loop you can embed. Compose a Python application with
HarnessBuilder, your model, and your tools. Built on Pydantic AI, with a Textual terminal UI. - Continuity across tasks. Resume conversations, steer running work,
and rewind conversation and workspace checkpoints. File snapshots require
Git and honor
.gitignore. - Delegation with control. Run background jobs and sub-agents with selected tools and model tiers. Add workflows for scripted orchestration.
- Context and extensions. Configure language servers for definitions, references, and diagnostics; connect MCP tools; add instructions, skills, persistent memory, and plugins.
- Explicit permissions. Choose
ask,auto, or read-onlyplanmode. Native shell tools support command policies. Project-local hooks and MCP require trust, remembered through the first-open prompt,/trust, ormarim trust grant. See the trust guide.
Everyday use
After configuring a provider:
marim /path/to/workspace # work in a specific project
marim --resume # resume this workspace's latest session
marim sessions # inspect saved sessions
marim config # view configuration
# Headless prompts for scripts and CI
marim -p "Explain this project's test setup" --mode plan
marim -p "Summarize the README" --output-format json --mode plan
In the TUI, use /model, /settings, and /help to explore. Configuration
can live in shell variables or .env files; shell variables take precedence.
See the configuration reference for defaults.
Build with Marim
Add the library to your Python project:
uv add marim-harness
With OPENROUTER_API_KEY exported, this runs a turn using the same native
agent engine that powers the terminal app:
import asyncio
from pathlib import Path
from marim_harness import HarnessBuilder
async def main() -> None:
harness = HarnessBuilder(
workspace=Path("."),
model="openrouter:anthropic/claude-sonnet-4-6",
).build()
outcome = await harness.run_turn("Explain what the README says this project does")
print(outcome.result)
asyncio.run(main())
A bare builder provides file tools and an in-memory session in auto mode.
Add shell tools, sessions, sub-agents, and integrations explicitly. Builder
configuration is explicit; model credentials follow Pydantic AI's provider
conventions, without loading Marim's .env files.
Start with the SDK guide, custom tools, or embedding examples.
Documentation
| I want to… | Start here |
|---|---|
| Learn shortcuts, image input, and notifications | Terminal UI |
| Automate tasks or consume JSON output | Headless mode |
| Resume, compact, or rewind a session | Sessions |
| Configure providers, models, and environment variables | Configuration |
| Set permissions and project trust | Trust · Security |
| Delegate work or orchestrate agents | Sub-agents · Workflows |
| Add instructions, skills, memory, or plugins | Skills and memory · Plugins |
| Connect tools or lifecycle hooks | MCP · Hooks |
| Run Marim as a service | HTTP API |
See the full documentation index for more.
Contributing
See CONTRIBUTING.md for development setup and checks, architecture for the codebase map, and the quality gate for maintained quality checks. Changes and planned work have their own pages.
License
MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marim_harness-0.9.1.tar.gz.
File metadata
- Download URL: marim_harness-0.9.1.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f45e5e74e436a60ded3cd89e53aa3dea4c1052d08a35383fd579e1b7bf08e18
|
|
| MD5 |
ff6971c0db5a02acd79fcce56d1e5bba
|
|
| BLAKE2b-256 |
f8d58883930917a0ecc451594d2950d85e002e92e9ef98cc07df60b1021c591a
|
File details
Details for the file marim_harness-0.9.1-py3-none-any.whl.
File metadata
- Download URL: marim_harness-0.9.1-py3-none-any.whl
- Upload date:
- Size: 988.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29a3c0f0352afe3e2a24f59c84d2d4eeab9db48891edb87a059fd00529f0d09c
|
|
| MD5 |
043a7df98950835642e10204ee3cdc9b
|
|
| BLAKE2b-256 |
020e4466dacc04939ab378e5deb333380eaaa87ed59517aced0e44cbdeac2f85
|