Skip to main content
Back to Blog

Roo Code: Evolution from Cline to a Mode-Based AI Coding Agent

A comprehensive exploration of Roo Code's architecture—examining how it evolved from Cline to introduce custom modes, specialized workflows, enhanced context management, and a modular design that enables team-specific AI coding assistance.

8 min read
Share:

Introduction

Roo Code represents a significant evolution of the Cline codebase, adding substantial new capabilities while maintaining the solid foundation of VS Code integration. The most notable addition is the custom modes system, which allows the agent to adopt different personas and capabilities based on the task at hand—transforming a general-purpose coding agent into a team of specialized assistants.

This post explores Roo Code's architecture by examining its TypeScript implementation. We'll understand how the mode system works, how tools are scoped to modes, how the enhanced context management operates, and what distinguishes Roo Code from its predecessor.

Evolution from Cline

Roo Code started as a fork of Cline and has since diverged significantly with new features and architectural improvements. While maintaining backward compatibility with Cline's core patterns, Roo Code introduces custom modes, enhanced i18n support with 17+ languages, Roomote Control for remote operation, improved checkpoint management, and a more sophisticated tool permission system.

The project structure reflects this evolution. The src directory maintains Cline's organizational patterns but adds new modules for modes, enhanced context tracking, and improved service abstractions. The webview-ui directory houses an updated React-based interface with Shadcn components and Tailwind CSS styling.

The Custom Modes System

Custom modes are Roo Code's defining feature. Rather than having a single agent personality, modes allow the agent to adopt different roles with different capabilities, instructions, and tool access.

Mode Definition Structure

Modes are defined in YAML format (the .roomodes file) with several key properties. Each mode has a slug for programmatic identification, a name for display (often including an emoji for quick recognition), a roleDefinition that serves as the system prompt defining the agent's persona and expertise, a whenToUse description helping users understand when to select the mode, a groups array specifying tool access, and optional customInstructions providing mode-specific guidance.

The roleDefinition is particularly important—it shapes how the agent thinks about and approaches tasks. A "Test" mode might emphasize TDD practices and Vitest patterns, while a "Design Engineer" mode focuses on UI implementation and component creation.

Built-in Modes

Roo Code ships with several built-in modes that demonstrate the system's flexibility. Code Mode is for everyday coding tasks, file operations, and general development. Architect Mode focuses on system planning, specifications, and migration strategies. Ask Mode provides quick answers, explanations, and documentation assistance. Debug Mode specializes in tracing issues, adding logs, and isolating root causes.

Each built-in mode has carefully crafted roleDefinitions and tool access that optimize the agent's behavior for that specific use case.

Tool Access Control

The groups property controls which tools a mode can access. Groups can be simple strings like "read", "browser", or "command", or they can be tuples with restrictions. For example, an edit group might include a fileRegex to limit which files the mode can modify.

This enables powerful patterns like a "Test" mode that can read any file but only edit test files, or a "Design Engineer" mode that focuses on frontend files and SVGs. The restriction system prevents modes from accidentally modifying files outside their scope.

Project-Specific Modes

Beyond the built-in modes, teams can define project-specific modes in their .roomodes file. The examples show specialized modes for various workflows: Issue Fixer for working from GitHub issues, Integration Tester for E2E test development, Docs Extractor for documentation analysis, PR Fixer for addressing pull request feedback, and Merge Resolver for handling git conflicts.

These project-specific modes demonstrate how teams can encode their workflows and best practices into the agent's behavior.

Core Architecture

Roo Code's core directory contains the fundamental agent logic, organized into focused modules.

Task Management

The task directory handles the agent's main execution loop. Tasks represent conversations with the agent, tracking message history, tool calls, and progress. The task-persistence module ensures tasks survive VS Code restarts, allowing users to resume interrupted work.

The message-manager coordinates message flow between the agent and UI. The message-queue provides ordering guarantees when multiple messages or tool results arrive simultaneously.

Context Management

Understanding the codebase is crucial for effective assistance. The context-management module handles building and maintaining context. The context-tracking module monitors what files and symbols the agent has accessed, enabling better suggestions about what context to include.

The mentions system allows users to reference specific files, symbols, or code blocks in their messages, providing precise context without manual copy-paste.

Tool System

The tools directory contains implementations for file operations, shell commands, browser interaction, and more. Each tool defines its parameters, execution logic, and display formatting. Tools integrate with the auto-approval system, which can automatically approve certain operations based on user preferences.

The tool scoping for modes happens at the groups level—modes specify which tool groups they can access, and the runtime enforces these restrictions.

Checkpoints

The checkpoints module provides git-based snapshots of work in progress. Before making significant changes, the agent can create a checkpoint that users can restore to if something goes wrong. This safety mechanism reduces the risk of agent mistakes and encourages experimentation.

Prompt System

The prompts directory contains the system prompts that define agent behavior. These prompts are sophisticated, including detailed instructions for tool usage, communication style, and task execution. Modes override or extend these base prompts with their roleDefinitions and customInstructions.

Services Layer

The services directory provides higher-level abstractions used throughout the application.

API Integration

Multiple services handle communication with LLM providers. Roo Code supports numerous providers including OpenAI, Anthropic, Google, Azure, AWS Bedrock, and local models through Ollama and LM Studio. The service abstraction allows switching providers without changing core logic.

File System Services

File operations are abstracted through services that handle VS Code's virtual file system, respect gitignore patterns, and integrate with the workspace context. The abstraction enables features like file previews and diff generation.

Terminal Integration

The terminal service manages shell command execution, handling output capture, error reporting, and integration with the VS Code terminal. Commands can run in the background with progress reporting or interactively with user input.

Integration Systems

The integrations directory handles connections with external systems.

MCP Integration

Model Context Protocol support allows Roo Code to connect with external tool servers. MCP servers can provide additional tools (database queries, API calls, specialized utilities) that the agent can use. The integration handles server lifecycle, capability discovery, and tool invocation.

IDE Integration

Deep VS Code integration goes beyond basic extension patterns. The agent can interact with the editor state, understand open files and cursor positions, and use VS Code features like code actions and refactoring tools.

Roomote Control

Roomote Control is a unique feature that allows remote control of Roo Code instances. This enables scenarios like controlling a local VS Code instance from a different device or automating agent interactions from external systems.

Webview UI

The webview-ui directory contains a React application that renders in VS Code's webview panel.

Component Library

The UI uses Shadcn components styled with Tailwind CSS. This provides a modern, consistent look while maintaining accessibility. Components include chat interfaces, file trees, diff viewers, and settings panels.

State Management

React state and context manage UI state, with VS Code extension messages handling communication between the webview and extension. The messaging protocol handles task updates, tool outputs, and user inputs.

Internationalization

Comprehensive i18n support with 17+ languages makes Roo Code accessible globally. Translation files in the locales directory provide strings for all UI text, and the i18n system handles locale detection and string interpolation.

The .roo Directory

Project-specific configuration lives in the .roo directory, which can contain mode definitions, custom instructions, ignore patterns, and other project-level settings. This directory allows teams to share configurations through version control.

Custom Mode Files

The .roomodes file defines project-specific modes. Teams can craft modes that encode their specific workflows, coding standards, and best practices. Modes can reference project-specific context like architecture documents or coding guidelines.

Ignore Patterns

The .rooignore file specifies patterns for files and directories the agent should ignore. This prevents the agent from accessing sensitive files, large generated directories, or irrelevant content.

Packages Architecture

Roo Code uses a monorepo structure with additional packages beyond the main extension.

Types Package

The types package provides shared TypeScript types used across packages. This ensures type consistency and enables better IDE support when developing multiple packages.

E2E Testing

The vscode-e2e package contains end-to-end tests that exercise the full extension in a real VS Code environment. These tests validate complete workflows from user input through agent execution to final output.

Comparison with Cline

While sharing a common ancestry, Roo Code has evolved substantially from Cline.

Modes are the most visible difference—Cline has a single agent personality, while Roo Code can switch between specialized personas with different capabilities and instructions.

Tool scoping in Roo Code allows fine-grained control over which tools modes can access, with file-level restrictions through regex patterns. Cline has more uniform tool access.

Internationalization support is comprehensive in Roo Code with 17+ languages, while Cline is primarily English-focused.

Roomote Control enables remote operation scenarios that Cline doesn't support.

The UI has diverged, with Roo Code adopting Shadcn and Tailwind for a more modern look, while Cline uses different styling approaches.

Frequently Asked Questions

Enrico Piovano, PhD

Co-founder & CTO at Goji AI. Former Applied Scientist at Amazon (Alexa & AGI), focused on Agentic AI and LLMs. PhD in Electrical Engineering from Imperial College London. Gold Medalist at the National Mathematical Olympiad.

Related Articles

Agentic AICoding

Cline: Deep Dive into the Open-Source AI Coding Agent

A comprehensive technical analysis of Cline—the open-source AI coding agent for VS Code. Understanding its agentic loop architecture, Plan/Act modes, 40+ LLM providers, Model Context Protocol integration, and how it orchestrates autonomous coding tasks with human oversight.

30 min read
Agentic AICoding

Gemini CLI: A Deep Dive into Google's Open-Source AI Coding Agent

A comprehensive exploration of Google's Gemini CLI architecture—examining its TypeScript-based core, local agent executor, tool system, MCP integration, policy engine, and the modular design that enables extensible AI coding assistance.

9 min read
Agentic AICoding

Building AI Coding Agents: From Code Understanding to Autonomous Development

A comprehensive guide to building AI coding agents—code understanding, edit planning, test generation, iterative debugging, sandboxed execution, and production patterns for autonomous software development.

23 min read
Agentic AILLMs

Building MCP Servers: Custom Tool Integrations for AI Agents

A comprehensive guide to building Model Context Protocol (MCP) servers—from basic tool exposure to production-grade integrations with authentication, streaming, and error handling.

18 min read
Agentic AIML Engineering

Agent Evaluation and Testing: From Development to Production

A comprehensive guide to evaluating AI agents—task success metrics, trajectory analysis, tool use correctness, sandboxing, and building robust testing pipelines for production agent systems.

11 min read