Skip to main content

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.

Marim fixing a bug with two parallel sub-agents: fan-out cards, an edit approval, and a verification run

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-only plan mode. Native shell tools support command policies. Project-local hooks and MCP require trust, remembered through the first-open prompt, /trust, or marim 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.

Release files for marim-harness 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marim-harness 0.13.0
File Size Uploaded
marim_harness-0.13.0.tar.gz 4.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for marim-harness 0.13.0
File Interpreter ABI Platform
marim_harness-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 MB

Release files / marim_harness-0.13.0.tar.gz

Download URL marim_harness-0.13.0.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
a5f84b3e066c6fec521e1672012b62243fc0f1cd4cbb953cd607ee9565614a23
BLAKE2b-256 checksum
How to use checksums
b735d710bc0782902ed6d94c32208b42692c08cbb19c2c3884cc7ceb8ac96b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}

Release files / marim_harness-0.13.0-py3-none-any.whl

Download URL marim_harness-0.13.0-py3-none-any.whl
Size 979.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
260a33e08818de4c4ea6c8499a9a9fbb54a6df13c93ed4213406cf25b2c3f1f4
BLAKE2b-256 checksum
How to use checksums
c2a5a41d9df187467e9eae1a4ace7fca2ebdb84873535e965c2412e92c9f36f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}

Release history Release notifications | RSS feed

0.18.9

2 release files

0.18.8

2 release files

0.18.7

2 release files

0.18.6

2 release files

0.18.5

2 release files

0.18.4

2 release files

0.18.3

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page