Thin CLI agent. Trust the model, keep the harness light.
Project description
|
Trust the model. Keep the harness light.
A lightweight CLI coding agent. 6 tools, single loop, no sub-agents.
Philosophy
| Principle | Description |
|---|---|
| Trust the model | Minimal system prompt. No scaffolding, no CoT wrappers, no sub-agents. Let the model decide. |
| One file, one job | Every module does exactly one thing. Largest file is 330 lines. Average under 100. |
| Safe by default, always escapable | deny > allow > ask. Every guardrail has an off switch. |
Benchmark
Terminal-Bench 2.0
| Metric | Score |
|---|---|
| Pass Rate | 64/89 (71.9%) |
| Model | Claude Opus 4.6 |
| Provider | Vertex AI |
Installation
pip install -e .
Requires Python 3.10+ and an API key for your chosen provider:
# Claude (Anthropic)
export ANTHROPIC_API_KEY="sk-..."
# OpenAI
export OPENAI_API_KEY="sk-..."
# Vertex AI (Google Cloud - recommended for high-volume)
export VERTEXAI_LOCATION="us-east5"
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
Usage
# Run krim (shows provider selection menu)
krim
# Select provider:
# [1] claude (Anthropic Claude)
# [2] openai (OpenAI)
# [3] vertex_ai (Google Vertex AI)
# Single prompt (also shows provider menu)
krim "fix the failing test in test_api.py"
# Skip menu with --provider flag
krim --provider claude "refactor this"
krim --provider openai "add tests"
krim --provider vertex_ai "deploy to prod"
# Power user
krim --max-turns 20 "large refactor"
krim --skill deploy "ship it"
krim --auto-commit "fix and commit"
krim --no-safety "run anything"
krim --verbose "debug mode"
krim --log-dir ./logs "save conversation"
Ralph Wiggum Loop
Run the agent repeatedly until a condition passes. Each iteration starts fresh — state lives in git, not LLM memory.
# Loop until pytest passes (max 20 iterations)
krim --loop --exit-on "pytest" "implement the PRD"
# Limit iterations
krim --loop --max-iterations 10 --exit-on "ruff check ." "fix all lint errors"
Parallel Worktrees
Leverage git worktrees to run multiple independent tasks simultaneously.
# 3 agents work in parallel, auto-merge on completion
krim --parallel "add auth" "add payments" "add tests"
# Keep branches separate for manual review
krim --parallel --no-merge "feature A" "feature B"
Tools
| Tool | Description |
|---|---|
bash |
Shell execution with persistent cwd. Safety rules enforced. |
read |
File reading with line numbers. Supports offset/limit for large files. |
write |
File writing with auto parent directory creation. |
edit |
String replacement with exact → whitespace-normalized → fuzzy matching (0.8 threshold). |
grep |
Regex content search. Uses ripgrep when available, Python fallback otherwise. |
glob |
File pattern matching (e.g., **/*.py). Results sorted by modification time. |
Architecture
krim/
├── __main__.py # CLI entry, arg parsing, interactive/loop/parallel modes
├── agent.py # Core agent loop, doom loop detection, stats
├── ui.py # Banner, prompt_toolkit input
├── prompt.py # System prompt builder
├── config.py # Hierarchical config loader
├── context.py # Environment context (cwd, git, file tree)
├── safety.py # Bash command safety rules
├── compaction.py # Token tracking, conversation compression
├── truncate.py # Output truncation (head/tail)
├── retry.py # Exponential backoff
├── git.py # Auto-commit, undo, selective staging
├── worktree.py # Git worktree management for parallel execution
├── skills.py # Skill discovery and injection
├── mcp.py # MCP client (stdio, JSON-RPC)
├── models/
│ ├── base.py # Abstract Model, ToolCall, ModelResponse
│ ├── claude.py # Anthropic Claude provider
│ ├── openai.py # OpenAI provider
│ └── vertex.py # Vertex AI provider
└── tools/
├── base.py # Abstract Tool with auto schema generation
├── bash.py # Shell execution, persistent cwd
├── read.py # File reading with line numbers
├── write.py # File writing
├── edit.py # Fuzzy string replacement
├── grep.py # Regex search (ripgrep + fallback)
└── glob.py # File pattern matching
Loop Behavior
User Input
↓
[System Prompt + Context + History]
↓
Model → Text response? → Done
→ Tool calls? → Execute each → Append results → Loop
→ Doom loop 1st? → Recovery nudge (keep tools, suggest different strategy)
→ Doom loop 2nd? → Force exit with summary
→ Near max turns? → Inject last-turn warning
→ Max turns hit? → Force exit with wrap-up request
→ Token limit? → Compress history and continue
Single loop. No routing, no planning phase, no sub-agents.
Double Confirmation
When the agent responds with text only (no tool calls), KRIM asks for confirmation before exiting. This prevents premature exits when the agent says "I'll do X" but doesn't actually call a tool.
Agent: "I've completed the task."
KRIM: "Confirm by saying 'Task complete' or continue working."
Agent: "Task complete."
KRIM: [exits]
If the agent says "I haven't finished yet" or "Let me continue", KRIM resets and lets it keep working.
Configuration
Hierarchy: ~/.krim/ (global) < .krim/ (project) < CLI flags.
.krim/
├── config.json # Settings
├── KRIM.md # Instructions injected into system prompt
├── mcp.json # MCP server config
├── rules/
│ └── *.md # Additional rules
└── skills/
└── <name>/
└── SKILL.md # Skill instructions
config.json
{
"max_turns": 10,
"auto_commit": false,
"ask_by_default": true,
"allow_commands": ["ls", "cat", "grep", "git status", "git diff", "pytest"],
"deny_patterns": ["rm -rf /", "> /dev/sda", "mkfs."],
"max_tokens": 16384,
"bash_timeout": 120,
"token_limit": 120000
}
Default models (used when --model is not specified):
| Provider | Default Model |
|---|---|
| claude | claude-opus-4-6 |
| openai | gpt-5.2 |
| vertex_ai | claude-opus-4-6 |
Skills
Reusable prompt packages. Activate with --skill <name>:
krim --skill deploy "ship the new feature"
krim --list-skills
SKILL.md format (Anthropic standard):
---
name: my-skill
description: What this skill does and when to use it
---
# Skill Content
Instructions in markdown...
MCP
Connect external tool servers via Model Context Protocol:
{
"mcpServers": {
"web-search": {
"command": ["node", "search-server/index.js"],
"env": { "API_KEY": "..." }
}
}
}
Safety
Commands pass through 3-stage checks: deny > allow > ask.
- deny: Substring match on dangerous patterns. Blocked immediately.
- allow: Word-boundary match on safe prefixes. Auto-approved.
- ask: Everything else prompts for user confirmation.
Disable with --no-safety or "ask_by_default": false in config.
Interactive Commands
/help Show command help
/tokens Token usage and stats
/compact Force context compression
/config Show current configuration
/undo Revert last krim commit
/verbose Toggle verbose output
exit Quit
Arrow keys for history. Tab for command completion.
License
MIT
Project details
Release history Release notifications | RSS feed
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 krim-0.3.3.tar.gz.
File metadata
- Download URL: krim-0.3.3.tar.gz
- Upload date:
- Size: 54.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a71e88806385235a8a133c14d33df4f83f4008b4b622724a9d8f9939b6607074
|
|
| MD5 |
c5ff98c226ed632a56a0a4b04d4bac8a
|
|
| BLAKE2b-256 |
19ad1da5c269679085976e167d39a1b6f76054e36d63339d06330472c7dae822
|
File details
Details for the file krim-0.3.3-py3-none-any.whl.
File metadata
- Download URL: krim-0.3.3-py3-none-any.whl
- Upload date:
- Size: 62.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3daec9e5e79c7452755a2dd9020c067c282080bc7638c6c02cced1837c2d6296
|
|
| MD5 |
1967ee97cc9157159294049866ae0616
|
|
| BLAKE2b-256 |
ebb3e7af6a55a74bb9cd704daa486be71725671517019ddbcc1bae817dc50339
|