Skip to content

docs: add CLI Backend Protocol documentation#240

Merged
MervinPraison merged 1 commit intomainfrom
claude/issue-239-20260424-0617
Apr 28, 2026
Merged

docs: add CLI Backend Protocol documentation#240
MervinPraison merged 1 commit intomainfrom
claude/issue-239-20260424-0617

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

@MervinPraison MervinPraison commented Apr 24, 2026

Fixes #239

Summary

  • Created comprehensive documentation for the new CLI Backend Protocol feature
  • Documents three configuration surfaces: --cli-backend CLI flag, YAML string form, and YAML dict with overrides
  • Includes complete ClaudeCodeBackend configuration reference with all 15 sanitized environment variables
  • Added backends list subcommand documentation and mutual exclusion with --external-agent

Implementation

  • Created docs/features/cli-backend-protocol.mdx following AGENTS.md standards
  • Used required Mintlify components: Steps, AccordionGroup, CardGroup
  • Added hero Mermaid diagram and sequence diagram with standard color scheme
  • Documented all three YAML shapes (string, dict, missing) with exact behavior from _resolve_yaml_cli_backend()
  • Added page to docs.json navigation under Features group

SDK Source Coverage

Read all required SDK files:

  • protocols.py - Core dataclasses and Protocol
  • registry.py - Registration and resolution
  • claude.py - ClaudeCodeBackend implementation with DEFAULT_CONFIG
  • main.py - CLI flag and backends subcommand
  • agents_generator.py - YAML integration
  • cli_backend.yaml - Example usage

Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added new CLI Backend Protocol documentation providing comprehensive guidance on running agent turns through external CLI tools with a pluggable backend mechanism. Documentation includes quick-start examples, detailed YAML configuration options, instructions for custom backend registration, protocol specifications, built-in defaults, practical best practices, and comparison with legacy integration methods.

- Create comprehensive docs/features/cli-backend-protocol.mdx
- Document all three configuration surfaces: CLI flag, YAML string, YAML dict
- Include complete ClaudeCodeBackend configuration reference
- Add Mermaid diagrams with standard color scheme
- Follow AGENTS.md structure with Steps, AccordionGroup, CardGroup
- Document backends subcommand and mutual exclusion with --external-agent
- Add to docs.json navigation under Features group

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 24, 2026 06:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

A new documentation page for the CLI Backend Protocol has been added to explain how to run agent tasks via external CLI tools using a pluggable backend mechanism. The page is registered in docs.json under the "Integration & Infrastructure" feature group.

Changes

Cohort / File(s) Summary
Documentation Navigation
docs.json
Registers new CLI Backend Protocol documentation page in the Integration & Infrastructure feature group.
CLI Backend Protocol Guide
docs/features/cli-backend-protocol.mdx
New documentation page covering CLI Backend Protocol with quick-start examples, resolution flow diagrams, YAML configuration shapes, CLI flag semantics, built-in claude-code backend reference, custom backend registration, protocol reference for authors, best practices, and comparison with legacy --external-agent integration.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 Hop-hop, the docs now shine so bright,
CLI backends leap into the light!
With protocols clear and examples galore,
Agents shall integrate more and more! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: add CLI Backend Protocol documentation' accurately and concisely summarizes the main change—adding new documentation for the CLI Backend Protocol feature.
Linked Issues check ✅ Passed The pull request meets all primary coding requirements from issue #239: new MDX page with hero diagram, agent-first Quick Start, resolution flow diagrams, YAML field documentation, CLI flag semantics, complete claude-code backend config, custom backend registration example, CliBackendProtocol reference, Best Practices accordions, legacy feature distinction, and docs.json update under Features.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #239 requirements: only docs.json and the new cli-backend-protocol.mdx file were modified, with no alterations to docs/concepts/ or unrelated SDK files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-239-20260424-0617

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the CLI Backend Protocol, which enables external CLI tools such as Claude Code to serve as first-class agent backends. The changes include updating the documentation structure and adding a comprehensive guide on configuring these backends via CLI flags, YAML, and Python. Review feedback highlights the need to correct placeholder model identifiers for Claude and suggests adding clarification regarding the sanitization of environment variables in the CLI subprocess.

| `input` | `str` | `"stdin"` | How to pass prompts to CLI |
| `live_session` | `str` | `"claude-stdio"` | Live session mode |
| `model_arg` | `str` | `"--model"` | CLI argument for model selection |
| `model_aliases` | `Dict[str, str]` | `{"opus": "claude-opus-4-5", "sonnet": "claude-sonnet-4-5", "haiku": "claude-haiku-3-5"}` | Model name shortcuts |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The model identifiers claude-opus-4-5, claude-sonnet-4-5, and claude-haiku-3-5 appear to be placeholders or incorrect, as Claude 4.5 has not been released. It is recommended to update these to valid Claude 3.5 identifiers (e.g., claude-3-5-sonnet-20241022) to ensure the documentation is accurate. Note that this change should also be reflected in the DEFAULT_CONFIG of praisonai/cli_backends/claude.py to maintain consistency.

| `system_prompt_arg` | `str` | `"--append-system-prompt"` | CLI argument for system prompts |
| `system_prompt_when` | `str` | `"first"` | When to add system prompts |
| `image_arg` | `str` | `"--image"` | CLI argument for images |
| `clear_env` | `List[str]` | `["ANTHROPIC_API_KEY", "ANTHROPIC_BASE_URL", "ANTHROPIC_OAUTH_TOKEN", "CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CONFIG_DIR", "CLAUDE_CODE_OAUTH_TOKEN", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_EXPORTER_OTLP_HEADERS", "OTEL_RESOURCE_ATTRIBUTES", "GOOGLE_APPLICATION_CREDENTIALS", "AWS_PROFILE", "AWS_REGION", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]` | Environment variables sanitized before subprocess |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The clear_env list includes critical variables like ANTHROPIC_API_KEY and AWS_ACCESS_KEY_ID. While this is a good security practice for sanitization, it means these variables will be unavailable to the CLI subprocess by default. It would be helpful to explicitly mention that users may need to re-provide these via the env override if their CLI tool requires them and does not manage its own authentication state.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/features/cli-backend-protocol.mdx (1)

84-86: Consider adding a one-sentence introduction.

The section jumps directly to the diagram. Adding a brief one-sentence introduction would improve readability and match the pattern used in other sections.

✨ Suggested addition
 ## How It Works
 
+The backend resolution flow starts at the CLI or YAML layer and delegates execution to the external subprocess.
+
 ```mermaid
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/features/cli-backend-protocol.mdx` around lines 84 - 86, Add a brief
one-sentence introductory line under the "## How It Works" header and before the
mermaid code block to explain what the diagram illustrates (e.g., "The following
diagram shows the high-level interaction between the CLI and backend
protocol."). Locate the "## How It Works" heading and the opening "```mermaid"
block in the document and insert the single-sentence intro there so it matches
the pattern used in other sections.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/features/cli-backend-protocol.mdx`:
- Line 8: The page docs/features/cli-backend-protocol.mdx is missing the
required agent-centric code example at the top; move the simplified Quick Start
YAML example (the agent-centric CLI backend example currently shown later in the
file) to immediately after the frontmatter and before the prose line that begins
"CLI Backends let you run an agent's turn...", so the page begins with a
concrete agent/Task API example demonstrating how to use a CLI backend; ensure
the relocated snippet remains intact and update any surrounding headings or
references so the intro prose now follows that example.
- Around line 19-27: The Mermaid diagram uses the wrong hex colors for concept
types: update the classDef entries so that classDef input uses Dark Red `#8B0000`
(for Agent Input/agents/outputs) and classDef resolver uses Teal `#189AB4` (for
tools/processes); keep classDef backend as `#189AB4`, classDef result as `#10B981`
and classDef warning/other as `#F59E0B` per the project's Mermaid color scheme,
and ensure the class declarations (e.g., "class A input", "class B resolver")
continue to reference those classDef names.

---

Nitpick comments:
In `@docs/features/cli-backend-protocol.mdx`:
- Around line 84-86: Add a brief one-sentence introductory line under the "##
How It Works" header and before the mermaid code block to explain what the
diagram illustrates (e.g., "The following diagram shows the high-level
interaction between the CLI and backend protocol."). Locate the "## How It
Works" heading and the opening "```mermaid" block in the document and insert the
single-sentence intro there so it matches the pattern used in other sections.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6bb9d1a4-a449-43e7-97cd-908fa16e39b3

📥 Commits

Reviewing files that changed from the base of the PR and between 9480b78 and dabbf4f.

📒 Files selected for processing (2)
  • docs.json
  • docs/features/cli-backend-protocol.mdx

icon: "plug"
---

CLI Backends let you run an agent's turn through an external CLI tool (like Claude Code) instead of a Python LLM client, while keeping the same `Agent`/`Task` API.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing agent-centric code example at the top.

The page starts with a prose description, but per the documentation guidelines, pages must begin with an agent-centric code example showing how to implement from the agent perspective. Consider moving a simplified Quick Start code example (e.g., the YAML example from lines 40-53) to the top of the page, immediately after the frontmatter and before this description line.

Based on learnings: "Documentation pages must start with an agent-centric code example at the top, showing how to implement from the agent perspective"

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/features/cli-backend-protocol.mdx` at line 8, The page
docs/features/cli-backend-protocol.mdx is missing the required agent-centric
code example at the top; move the simplified Quick Start YAML example (the
agent-centric CLI backend example currently shown later in the file) to
immediately after the frontmatter and before the prose line that begins "CLI
Backends let you run an agent's turn...", so the page begins with a concrete
agent/Task API example demonstrating how to use a CLI backend; ensure the
relocated snippet remains intact and update any surrounding headings or
references so the intro prose now follows that example.

Comment on lines +19 to +27
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef resolver fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef backend fill:#189AB4,stroke:#7C90A0,color:#fff
classDef result fill:#10B981,stroke:#7C90A0,color:#fff

class A input
class B resolver
class C,D backend
class E result
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix Mermaid diagram color scheme to match guidelines.

The diagram uses incorrect colors for the concept types:

  • Agent Input (line 24) uses Indigo #6366F1, but inputs should use Dark Red #8B0000
  • Resolver (line 25) uses Amber #F59E0B, but process/tool components should use Teal #189AB4

As per coding guidelines: "Use exact Mermaid color scheme for diagrams: #8B0000 (Dark Red) for agents/inputs/outputs, #189AB4 (Teal) for tools/processes, #10B981 (Green) for success, #F59E0B (Amber) for warnings, #6366F1 (Indigo) for configuration"

🎨 Proposed fix for color scheme
-    classDef input fill:`#6366F1`,stroke:`#7C90A0`,color:`#fff`
-    classDef resolver fill:`#F59E0B`,stroke:`#7C90A0`,color:`#fff`
+    classDef input fill:`#8B0000`,stroke:`#7C90A0`,color:`#fff`
+    classDef resolver fill:`#189AB4`,stroke:`#7C90A0`,color:`#fff`
     classDef backend fill:`#189AB4`,stroke:`#7C90A0`,color:`#fff`
     classDef result fill:`#10B981`,stroke:`#7C90A0`,color:`#fff`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/features/cli-backend-protocol.mdx` around lines 19 - 27, The Mermaid
diagram uses the wrong hex colors for concept types: update the classDef entries
so that classDef input uses Dark Red `#8B0000` (for Agent Input/agents/outputs)
and classDef resolver uses Teal `#189AB4` (for tools/processes); keep classDef
backend as `#189AB4`, classDef result as `#10B981` and classDef warning/other as
`#F59E0B` per the project's Mermaid color scheme, and ensure the class
declarations (e.g., "class A input", "class B resolver") continue to reference
those classDef names.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@MervinPraison MervinPraison merged commit 344deb7 into main Apr 28, 2026
36 checks passed
@MervinPraison MervinPraison deleted the claude/issue-239-20260424-0617 branch April 28, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add new page for CLI Backend Protocol (--cli-backend, backends list, YAML cli_backend)

2 participants