Skip to content

CommandBuilder

Configures metadata and behavior for a mapped command.

public sealed class CommandBuilder

Marks this command as a prompt source. The handler return value becomes the prompt message template. Handler parameters become prompt arguments.

public CommandBuilder AsPrompt()

CommandBuilder - The same builder instance.

Marks this command as protocol passthrough. In this mode, repl diagnostics are routed to stderr and interactive stdin reads are skipped. When handlers request IReplIoContext, Output remains the protocol stream (stdout in local CLI passthrough), while framework output stays on stderr. For hosted sessions, handlers should request IReplIoContext to access transport streams explicitly.

public CommandBuilder AsProtocolPassthrough()

CommandBuilder - The same builder instance.

Marks this command as a resource (data to consult, not an operation to perform). Resources appear in a separate help section and are auto-exposed as MCP resources.

public CommandBuilder AsResource()

CommandBuilder - The same builder instance.

Hides the command from programmatic/automation surfaces only.

public CommandBuilder AutomationHidden(bool value = true)
  • value (bool): True to hide from automation.

CommandBuilder - The same builder instance.

Marks the command as destructive (deletes, modifies state).

public CommandBuilder Destructive(bool value = true)
  • value (bool): True to mark as destructive.

CommandBuilder - The same builder instance.

Marks a command as hidden or visible.

public CommandBuilder Hidden(bool isHidden = true)
  • isHidden (bool): True to hide the command.

CommandBuilder - The same builder instance.

Marks the command as safely retriable.

public CommandBuilder Idempotent(bool value = true)
  • value (bool): True to mark as idempotent.

CommandBuilder - The same builder instance.

Marks the command as long-running (enables task-based execution).

public CommandBuilder LongRunning(bool value = true)
  • value (bool): True to mark as long-running.

CommandBuilder - The same builder instance.

Marks the command as interacting with external systems.

public CommandBuilder OpenWorld(bool value = true)
  • value (bool): True to mark as open-world.

CommandBuilder - The same builder instance.

Marks the command as read-only (no side effects).

public CommandBuilder ReadOnly(bool value = true)
  • value (bool): True to mark as read-only.

CommandBuilder - The same builder instance.

Sets aliases for the command.

public CommandBuilder WithAlias(params string[] aliases)

CommandBuilder - The same builder instance.

WithAnnotations(Action<CommandAnnotationsBuilder>)

Section titled “WithAnnotations(Action<CommandAnnotationsBuilder>)”

Configures annotations via builder — escape hatch for complex scenarios. Overwrites any annotations set by individual shortcuts.

public CommandBuilder WithAnnotations(Action<CommandAnnotationsBuilder> configure)
  • configure (Action<CommandAnnotationsBuilder>): Builder configuration callback.

CommandBuilder - The same builder instance.

Declares an interactive answer slot that can be pre-filled via --answer:{name}=value on the CLI or answer:{name} in MCP tool calls.

public CommandBuilder WithAnswer(string name, string type = "string", string? description = null)
  • name (string): Answer name (matches the name parameter in AskConfirmationAsync, AskChoiceAsync, etc.).
  • type (string): Value type using route constraint names: string, bool, int, guid, email, etc.
  • description (string): Optional description for help text and agent tool schemas.

CommandBuilder - The same builder instance.

Registers a banner delegate displayed before command execution. Unlike WithDescription(string), which is structural metadata visible in help and documentation, banners are display-only messages that appear at runtime.

public CommandBuilder WithBanner(Delegate bannerProvider)
  • bannerProvider (Delegate): Banner delegate with injectable parameters.

CommandBuilder - The same builder instance.

Registers a static banner string displayed before command execution. Unlike WithDescription(string), which is structural metadata visible in help and documentation, banners are display-only messages that appear at runtime.

public CommandBuilder WithBanner(string text)

CommandBuilder - The same builder instance.

WithCompletion(string, CompletionDelegate)

Section titled “WithCompletion(string, CompletionDelegate)”

Adds a completion provider for a target parameter.

public CommandBuilder WithCompletion(string targetName, CompletionDelegate provider)

CommandBuilder - The same builder instance.

Sets a command description.

public CommandBuilder WithDescription(string text)
  • text (string): Description text.

CommandBuilder - The same builder instance.

Sets a rich markdown description body for agent tool descriptions and documentation export.

public CommandBuilder WithDetails(string markdown)
  • markdown (string): Markdown content.

CommandBuilder - The same builder instance.

Adds a generic metadata entry.

public CommandBuilder WithMetadata(string key, object value)
  • key (string): Metadata key.
  • value (object): Metadata value.

CommandBuilder - The same builder instance.

Gets the configured aliases.

public IReadOnlyList<string> Aliases { get; }

IReadOnlyList<string>

Gets the structured behavioral annotations for this command.

public CommandAnnotations? Annotations { get; }

CommandAnnotations

Gets declared answer slots for interactive prompts.

public IReadOnlyList<AnswerDeclaration> Answers { get; }

IReadOnlyList<AnswerDeclaration>

Gets the banner delegate rendered before command execution.

public Delegate? Banner { get; }

Delegate

Gets parameter completion providers keyed by target name.

public IReadOnlyDictionary<string, CompletionDelegate> Completions { get; }

IReadOnlyDictionary<string, CompletionDelegate>

Gets the command description.

public string? Description { get; }

string

Gets the rich markdown description body. Used for agent tool descriptions and documentation export.

public string? Details { get; }

string

Gets the command handler.

public Delegate Handler { get; }

Delegate

Gets a value indicating whether this command is hidden from discovery surfaces.

public bool IsHidden { get; }

bool

Gets a value indicating whether this command is a prompt source.

public bool IsPrompt { get; }

bool

Gets a value indicating whether this command reserves stdin/stdout for a protocol handler.

public bool IsProtocolPassthrough { get; }

bool

Gets a value indicating whether this command is a resource (data to consult).

public bool IsResource { get; }

bool

Gets generic metadata entries for extensibility.

public IReadOnlyDictionary<string, object> Metadata { get; }

IReadOnlyDictionary<string, object>

Gets the command route.

public string Route { get; }

string