Skip to content

feat: Group-level execution mode control (Plan/Normal/Auto-accept mode switching) #718

Description

@breaking-brake

Summary

Add an execution mode property (plan / normal / auto-accept) to workflow group nodes, enabling automatic mode verification at group entry with user-guided mode switching when a mismatch is detected.

This feature applies only to Claude Code Export/Run — it does not affect other AI agent integrations (Copilot CLI, Codex CLI, etc.) or the MCP-based AI editing workflow.

Motivation

Different phases of a workflow require different levels of Claude Code's execution mode:

  • Phase A (design/review): Plan mode — read-only planning, no file modifications
  • Phase B (implementation): Auto-accept mode — execute changes without confirmation prompts

By associating an expected mode with each group, workflows can enforce the appropriate safety level per phase.

Investigation Results

Mode Control Feasibility

Mode CLI/API Control Prompt Control Feasibility
Plan mode EnterPlanMode tool is invoked by Claude itself; no external CLI flag Can be prompted via instructions ○ Feasible
Normal mode ExitPlanMode is registered in AVAILABLE_TOOLS Default behavior ◎ Feasible
Auto-accept CLI flag (--dangerously-skip-permissions) only at session startup; no dynamic toggle Cannot be controlled via prompt × Not programmable

Mode Detection

  • Claude Code can self-report its current mode (Plan / Normal) at runtime
  • There is no dedicated API/tool to return the mode, but prompting "check your current mode" reliably works
  • Auto-accept mode status is not detectable from within the session

Key Constraint

Auto-accept cannot be toggled mid-session. The proposed UX handles this by prompting the user to switch modes manually and verifying the result, rather than attempting programmatic control.

Proposed UX Flow

Group entry
  ↓
Check current mode → Compare with expected mode
  ↓
  ├─ Match → Proceed with execution
  └─ Mismatch
       ↓
     Display: "Expected: Plan mode / Current: Normal mode"
              "Please press Shift+Tab to switch to Plan mode"
       ↓
     AskUserQuestion:
       1. I've switched — re-check
       2. Ignore and proceed as-is
       ↓
       ├─ 1 → Re-check mode (loop)
       └─ 2 → Continue with current mode

Implementation Plan

1. Schema Update (resources/workflow-schema.json)

Add mode property to group.fields:

"group": {
  "fields": {
    "label": { "type": "string", "required": true, "default": "Group" },
    "mode": {
      "type": "enum",
      "values": ["plan", "normal", "auto-accept", "none"],
      "required": false,
      "default": "none",
      "description": "Expected Claude Code execution mode for this group. Only used during Claude Code Export/Run."
    }
  }
}

2. Type Update (src/shared/types/workflow-definition.ts)

export interface GroupNodeData {
  label: string;
  mode?: 'plan' | 'normal' | 'auto-accept' | 'none';
}

3. Prompt Generation (src/extension/services/workflow-prompt-generator.ts)

Claude Code Export/Run only. When a group has a mode set, generate instructions at group entry to:

  1. Self-check current mode
  2. Compare with expected mode
  3. If mismatch: display switching instructions and present re-check / skip options via AskUserQuestion

Other AI agent export formats (Copilot, Codex, etc.) will ignore the mode property.

4. UI (Webview)

Add a mode dropdown to the group node configuration panel.

Scope

  • In scope: Plan / Normal / Auto-accept mode verification and user-guided switching during Claude Code Export/Run
  • Out of scope:
    • Programmatic auto-accept toggling (technically impossible mid-session)
    • Mode control for non-Claude Code agents (Copilot CLI, Codex CLI, etc.)
    • MCP-based AI editing workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions