Skip to main content

Module mode

Module mode 

Source
Expand description

Output mode detection for agent-safe console output.

This module provides automatic detection of whether output should be plain text (for AI agents and CI) or richly formatted (for humans).

§Detection Priority

The detection follows this priority order (first match wins):

  1. SQLMODEL_PLAIN=1 - Force plain output
  2. SQLMODEL_JSON=1 - Force JSON output
  3. SQLMODEL_RICH=1 - Force rich output (overrides agent detection!)
  4. NO_COLOR - Standard env var for disabling colors
  5. CI=true - CI environment detection
  6. TERM=dumb - Dumb terminal
  7. Agent env vars - Claude Code, Codex CLI, Cursor, etc.
  8. !is_terminal(stdout) - Piped or redirected output
  9. Default: Rich output

§Agent Detection

The following AI coding agents are detected:

  • Claude Code (CLAUDE_CODE)
  • OpenAI Codex CLI (CODEX_CLI)
  • Cursor IDE (CURSOR_SESSION)
  • Aider (AIDER_MODEL, AIDER_REPO)
  • GitHub Copilot (GITHUB_COPILOT)
  • Continue.dev (CONTINUE_SESSION)
  • Generic agent marker (AGENT_MODE)

Enums§

OutputMode
Output mode for console rendering.