Skip to content

feat: add ROO_ACTIVE environment variable to terminal sessions for safety guardrails #11864

@ajjuaire

Description

@ajjuaire

Problem

When Roo Code executes commands in the terminal, there is no way for external CLI tools to know they are being invoked by an AI agent. This means destructive operations (e.g. rm -rf, git push --force, database mutations) cannot be guarded against when initiated by Roo.

Proposed Solution

Set a ROO_ACTIVE=true environment variable in all terminals spawned by Roo Code. This allows other CLI tools, shell aliases, and wrapper scripts to detect that a command is being run from a Roo Code session and optionally block or prompt for confirmation on destructive operations.

Example usage in a shell alias:

alias rm='if [ "$ROO_ACTIVE" = "true" ]; then echo "Destructive operation blocked in Roo session"; else command rm "$@"; fi'

Implementation

Add ROO_ACTIVE: "true" to the env object returned by Terminal.getEnv() in src/integrations/terminal/Terminal.ts.

Benefits

  • Zero cost to existing workflows — the env variable is inert unless explicitly checked
  • Enables users and organizations to build safety guardrails around AI-initiated terminal commands
  • Simple, minimal change

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions