Building Effective AI Coding Agents for the Terminal: Scaffolding, Harness, Context Engineering, and Lessons Learned
Organizations: OpenDev
Abstract
The landscape of AI coding assistance is undergoing a fundamental shift from complex IDE plugins to versatile, terminal-native agents. Operating directly where developers manage source control, execute builds, and deploy environments, CLI-based agents offer unprecedented autonomy for long-horizon development tasks. In this paper, we present OPENDEV, an open-source, command-line coding agent written in Rust, engineered specifically for this new paradigm. Effective autonomous assistance requires strict safety controls and highly efficient context management to prevent context bloat and reasoning degradation. OPENDEV overcomes these challenges through a compound AI system architecture with workload-specialized model routing, a dual-agent architecture separating planning from execution, lazy tool discovery, and adaptive context compaction that progressively reduces older observations. Furthermore, it employs an automated memory system to accumulate project-specific knowledge across sessions and counteracts instruction fade-out through event-driven system reminders. By enforcing explicit reasoning phases and prioritizing context efficiency, OPENDEV provides a secure, extensible foundation for terminal-first AI assistance, offering a blueprint for robust autonomous software engineering.
Figures & tables
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Category | Tool | Description |
|---|---|---|
| File Ops | read_file † | Read file contents with line-numbered output and optional offset/limit |
| write_file | Create new files (rejects overwrites; directs to edit_file ) | |
| edit_file | Apply targeted edits via 9-pass fuzzy matching chain | |
| list_files † | Directory listing and glob-based file search | |
| search † | Dual-mode search: regex (ripgrep) or structural (ast-grep) | |
| Process | run_command | Execute shell commands with auto-background for servers |
| Language | Server | Language | Server |
|---|---|---|---|
| Python | Pyright | Perl | Perl::LanguageServer |
| TypeScript/JS | tsserver | Clojure | clojure-lsp |
| Rust | rust-analyzer | Elm | elm-language-server |
| Go | gopls | Terraform | terraform-ls |
| Java | Eclipse JDT LS | Bash | bash-language-server |
| C/C++ | clangd | Nix | nixd |
| Section | Condition | Cache | Summary |
|---|---|---|---|
| mode-awareness | always | ✓ | Guides planner subagent usage for non-trivial tasks |
| security-policy | always | ✓ | Authorized security testing boundaries |
| tone-and-style | always | ✓ | Communication standards: concise, direct, no emojis |
| no-time-estimates | always | ✓ | Never provide duration estimates |
| interaction-pattern | always | ✓ | ReAct loop: Think Act Observe Complete |
| available-tools | always | ✓ | Tool category overview and descriptions |
| Section | Summary |
|---|---|
| thinking-available-tools | Tool awareness without invocation pressure |
| thinking-subagent-guide | Delegation reasoning: when and which subagent |
| thinking-code-references | Code reference format for navigation |
| thinking-output-rules | No actions, only reasoning; concise trace ( 100 words) |
| Template | Role | Key Output |
|---|---|---|
| compaction.md | Conversation compactor | Structured summary ( 800 words) with artifact index |
| critique.md | Reasoning critic | Actionable feedback on thinking traces ( 100 words) |
| init.md | Session initializer | OPENDEV.md generation via Code-Explorer |
| main.md | Core identity wrapper | Senior engineer persona with full tool access |
| thinking.md | Thinking wrapper | Concise internal reasoning trace ( 100 words) |
| # | Regex Pattern | Framework |
|---|---|---|
| 1 | flask\s+run | Flask |
| 2 | python.*app.py | Generic Python app |
| 3 | python.*manage.py\s+runserver | Django (manage.py) |
| 4 | django.*runserver | Django (direct) |
| 5 | uvicorn | Uvicorn (ASGI) |
| 6 | gunicorn | Gunicorn (WSGI) |
| Subagent | Tools Available | Use Case |
|---|---|---|
| Code-Explorer | read_file, search, list_files, find_symbol, find_referencing_symbols | Deep codebase exploration, architectural analysis, pattern discovery |
| Planner | All read-only + write_file, edit_file, spawn_subagent, ask_user, task_complete | Implementation planning with codebase analysis and plan file writing |
| PR-Reviewer | read_file, search, list_files, find_symbol, find_referencing_symbols, run_command | Pull request code review, diff analysis, pre-merge review |
| Security-Reviewer | read_file, search, list_files, find_symbol, find_referencing_symbols, run_command | Security audits, vulnerability assessment, severity/confidence scoring |
| Web-Clone | capture_web_screenshot, analyze_image, write_file, read_file, run_command, list_files | Visual website analysis and UI replication |
| Web-Generator | write_file, edit_file, run_command, list_files, read_file | Create web applications from specifications (React/TypeScript/Tailwind) |
| Field | Type | Description |
|---|---|---|
| model | str | LLM model identifier |
| provider | str | API provider (openai, azure, etc.) |
| max_context_tokens | int | Max context window size |
| temperature | float | LLM sampling temperature |
| max_tokens | int | Max response tokens |
| thinking_model | str | Model for thinking phase |
| Constant | Value | Rationale |
|---|---|---|
| Compaction stages | 70/80/90/99% | Four graduated thresholds: warn, mask, aggressive mask, full compaction |
| Max undo history | 50 ops | Bounded growth prevents OOM in long sessions |
| Max nudge attempts | 3 | Balance recovery opportunity vs. forcing progress |
| Doom-loop threshold | 3 repeats | Same (tool, args) fingerprint 3 in sliding window triggers warning |
| Doom-loop window | 20 calls | Sliding window of recent tool call fingerprints |
| Thinking levels | 4 (OFF–HIGH) | OFF, LOW, MEDIUM, HIGH (includes self-critique) |
AI Coding Agents
AI coding agents use language models and software tools to plan, edit, test, and maintain code with varying levels of autonomy.
See all 326 papers