/goto

Stack Mode State Control Production low usage

/goto

Overview

/goto is a production command in the Stack Mode category of the Prismatic Platform that restores the conversation state to a previously saved named checkpoint. The command is a critical component of the platform's stack-based conversation management system, enabling precise state navigation by allowing users to jump to any previously checkpointed frame in the conversation stack, effectively rewinding or branching the conversation to a known good state.

This command operates under the State Control authority level and is executed by the stack-conversation-manager agent. The State Control authority is a specialized permission tier that grants the ability to modify conversation state -- a capability that requires careful handling since state transitions affect the entire active context of the conversation. Unlike read-only commands that inspect state, /goto actively modifies the conversation stack by truncating frames above the target checkpoint and restoring the context that was active when the checkpoint was created. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard.

The stack-based conversation model treats each conversation exchange as an immutable frame pushed onto a stack data structure. Frames capture the user input, assistant response, key assumptions, key decisions, and any state changes that occurred during that exchange. Checkpoints are named markers attached to specific frames, serving as bookmarks that enable rapid navigation to significant conversation states. The /goto command uses these checkpoints as navigation targets, providing a mechanism analogous to git checkout for conversation state.

This command is particularly valuable in long, complex development sessions where multiple exploration paths are attempted before settling on a final approach. By checkpointing before major decisions or experimental changes, developers can quickly revert to a known state without losing the ability to reference the exploration that occurred. The command enforces the platform's frame immutability principle -- frames that existed when the checkpoint was created remain unchanged; only frames added after the checkpoint target are affected.

Architecture

/goto Command
    |
    +-- Checkpoint Resolver
    |       +-- Name Lookup (ETS-backed)
    |       +-- Frame ID Mapper
    |       +-- Ambiguity Detector
    |       +-- Validity Checker
    |
    +-- State Transition Engine
    |       +-- Frame Stack Manager
    |       +-- Context Restorer
    |       +-- Active State Calculator
    |       +-- Immutability Enforcer
    |
    +-- Safety Controller
    |       +-- Pre-transition Validation
    |       +-- Data Loss Warning Generator
    |       +-- Undo Buffer Manager
    |       +-- Audit Logger
    |
    +-- OTP Integration
            +-- StackConversation GenServer
            +-- ETS Table Manager
            +-- Disk Persistence Handler
            +-- Telemetry Emitter

The architecture is centered around the StackConversation GenServer (apps/prismatic_claude/lib/prismatic_claude/stack_conversation.ex), which maintains the authoritative state of the conversation stack. The GenServer provides atomic state transitions through OTP's message passing guarantees, ensuring that no concurrent operations can corrupt the stack during a goto operation. The ETS-backed checkpoint resolver provides O(1) lookup by checkpoint name, while the disk persistence handler ensures checkpoint data survives process restarts.

Usage

Basic Navigation

# Restore to a named checkpoint
/goto pre-refactor

# Restore to a checkpoint with spaces in the name
/goto "before database migration"

# List available checkpoints before navigating
/checkpoint --list
/goto my-checkpoint
# Navigate with explicit confirmation of frame loss
/goto pre-experiment --confirm

# Preview what frames would be lost
/goto pre-experiment --preview

# Navigate and log the transition reason
/goto pre-experiment --reason="Reverting experimental approach"

Checkpoint Discovery

# List all available checkpoints with frame details
/goto --list

# Show checkpoint details without navigating
/goto --info=pre-refactor

# Find checkpoints matching a pattern
/goto --search="database"

Options & Parameters

OptionTypeDefaultDescription
<name>stringrequiredName of the checkpoint to navigate to
--confirmflagfalseSkip confirmation prompt for frame loss
--previewflagfalseShow frames that would be affected without navigating
--reasonstringnoneLog reason for the state transition
--listflagfalseList all available checkpoints
--infostringnoneShow details for a specific checkpoint without navigating
--searchstringnoneSearch checkpoints by name pattern
--keep-historyflagfalsePreserve popped frames in a separate branch for reference
--forceflagfalseNavigate even if target checkpoint has integrity warnings

Execution Flow

  1. Checkpoint Resolution: Look up the specified checkpoint name in the ETS-backed checkpoint registry. Verify the checkpoint exists and is valid. If the name is ambiguous (multiple matches), prompt for clarification.

  2. Frame Identification: Map the checkpoint to its corresponding frame ID in the conversation stack. Verify the frame still exists in the current stack (it may have been popped by a previous operation).

  3. Impact Assessment: Calculate which frames would be affected by the goto operation. Count frames that would be removed from the active stack. Identify any decisions, assumptions, or state changes in those frames that would be lost.

  4. Data Loss Warning: If frames would be removed, generate a warning describing the potential data loss. Include summaries of affected frame decisions and assumptions. In non-interactive mode, require --confirm flag to proceed.

  5. State Transition: Execute the goto operation atomically through the StackConversation GenServer. Truncate the stack to the checkpoint frame. Restore the conversation context to the state that was active at the checkpoint. If --keep-history is set, save removed frames to a separate branch.

  6. Context Restoration: Recalculate the active conversation context from the remaining stack frames. Update the session's working assumptions, active decisions, and state dependencies based on the restored stack.

  7. Audit Logging: Log the state transition with the transition reason, affected frames, and resulting stack state. Emit telemetry events for conversation state tracking.

  8. Confirmation: Display the restored checkpoint information, new stack depth, and any context changes to the user.

Integration Points

ComponentIntegration TypeDescription
Prismatic AgentsAgent ExecutionExecuted by stack-conversation-manager agent
StackConversation GenServerState ManagementAtomic state transitions via OTP GenServer calls
ETS TablesCheckpoint StorageO(1) checkpoint name lookup and frame data
Disk PersistenceDurabilityCheckpoint data persisted to .claude/stack-conversation/
TelemetryEvent TrackingState transition events: [:prismatic_claude, :stack_conversation, :goto]
/checkpointCheckpoint CreationCreates the named checkpoints that /goto navigates to
/stackStack InspectionDisplays the full stack for context before navigation
/frameFrame InspectionExamines specific frames before deciding to navigate
/popFrame RemovalAlternative destructive operation for removing frames
/forkBranch CreationCreates new branches from specific frames

Best Practices

Checkpoint Before Experiments: Always create a checkpoint (/checkpoint experiment-start) before beginning experimental or exploratory work. This ensures a clean return point if the experiment does not produce desired results.

Descriptive Names: Use descriptive checkpoint names that capture the conversation state at the time of creation. Names like pre-database-migration or after-api-design-complete are more navigable than generic names like checkpoint-1.

Preview Before Navigating: Use --preview before executing a goto to understand the impact. This follows the NO DOUBTS principle of full investigation before action, ensuring you understand what context will be lost.

Document Transition Reasons: Always provide a --reason when navigating to a checkpoint. This creates an audit trail that explains why state was restored, which is valuable for understanding conversation history during reviews.

Keep History for Complex Sessions: Use --keep-history during complex development sessions to preserve popped frames in a separate branch. This allows you to reference previous exploration paths without polluting the active stack.

Error Handling

ErrorCauseResolution
Checkpoint not foundNo checkpoint with the specified nameUse /goto --list to see available checkpoints
Frame no longer in stackTarget frame was previously poppedThe checkpoint is orphaned; create a new checkpoint from current state
Ambiguous checkpoint nameMultiple checkpoints matchProvide the full checkpoint name or use --info to identify the correct one
Stack integrity violationCorrupted frame data detectedUse --force to navigate despite integrity warnings
Active operation in progressAnother state-modifying command is runningWait for the current operation to complete
Confirmation requiredFrames would be lost without --confirmAdd --confirm flag or respond to the interactive prompt

Advanced Usage

Branch-Based Navigation

# Navigate to checkpoint and keep removed frames as a branch
/goto pre-experiment --keep-history

# Later, review what was in the removed frames
/fork --list-branches

# Compare current state with the preserved branch
/goto --compare=pre-experiment

Programmatic Integration

The /goto command's functionality is available programmatically through the StackConversation GenServer.

# Programmatic goto via GenServer
{:ok, result} = PrismaticClaude.StackConversation.goto("pre-refactor")
# => {:ok, %{frame_id: 5, frames_removed: 3, checkpoint: "pre-refactor"}}

# List available checkpoints
{:ok, checkpoints} = PrismaticClaude.StackConversation.list_checkpoints()
# => {:ok, [%{name: "pre-refactor", frame_id: 5, created_at: ~U[...]}]}

State Recovery Patterns

# Recovery pattern: checkpoint -> experiment -> evaluate -> goto if failed
/checkpoint before-optimization
# ... attempt optimization ...
# If optimization fails:
/goto before-optimization --reason="Optimization introduced regression"

Doctrine Compliance

All state navigation operations enforce the NO MERCY, NO DOUBTS doctrine.

  • NO MERCY: State transitions are atomic -- they either complete fully or not at all. There is no partial state restoration. The command enforces frame immutability: restored frames are identical to their state when originally created.
  • NO DOUBTS: Every goto operation produces a clear audit trail including the source state, target state, affected frames, and transition reason. The --preview option enables full investigation before action. No state modification occurs without explicit user intent.

The command enforces the Stack-Based Conversation Mode Protocol's behavioral rules: frame immutability (frames cannot be modified), stack-only context (active state defined only by current stack), and explicit state dependencies (dependencies on popped frames are explicitly noted).

  • /stack - Display complete conversation stack with all frames
  • /frame - Inspect specific conversation frame by ID
  • /pop - Remove last N frames from conversation stack (DESTRUCTIVE)
  • /fork - Branch from frame N (DESTRUCTIVE)
  • /checkpoint - Mark current frame with a named checkpoint
  • /agents - List and manage agent ecosystem with status monitoring
  • /commit - Smart commit with quality gates and conventional format

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL