<p>In a normal conversation, you can't. The history is linear. If you change direction, the old approach is gone — buried under new messages, eventually compacted away.</p><p>Elyra's <code>/tree</code> command turns your session into a tree. Branch at any point, explore alternatives, and switch between them without losing anything.</p><h2>The problem with linear conversations</h2><p>You're building an authentication system. You've spent twenty minutes with the agent implementing JWT-based auth. The controllers are written, the middleware is in place, the tests pass. Then you realize: maybe session-based auth would be simpler for this use case.</p><p>In a linear conversation, you have two options:</p><ol><li><p>Keep going. Commit to JWT even though you have doubts. The sunk cost fallacy in action.</p></li><li><p>Start over. Tell the agent to undo everything and try sessions instead. You lose the JWT implementation and can't easily go back if sessions turn out to be worse.</p></li></ol><p>Neither is good. What you want is to branch: keep the JWT work on one path, explore session auth on another, and compare them before deciding.</p><h2>How /tree works</h2><pre><code>/tree
</code></pre><p>Opens a visual navigator showing your session's structure as a tree. Every user message is a node. Every branch point is visible. You can see where the conversation split and navigate to any point.</p><p>The tree looks something like this:</p><pre><code>● Set up the project structure
├── ● Add user registration
│   ├── ● Implement JWT authentication ← you are here
│   │   └── ● Add refresh token rotation
│   └── ● Implement session authentication
└── ● Set up the database schema
</code></pre><p>Navigate with arrow keys. Press Enter to switch to that branch. The entire conversation context shifts to that point — the agent sees the history as if you'd taken that path from the beginning.</p><h2>Creating branches with /fork</h2><pre><code>/fork
</code></pre><p>Opens a selector showing all your previous messages. Pick one, and Elyra creates a new branch from that point. The original branch is preserved. You're now on a fresh path starting from that message.</p><p>Say you sent "Implement JWT authentication" and the agent built it. Now you want to try sessions instead:</p><pre><code>/fork
</code></pre><p>Select the "Add user registration" message. Elyra forks from there. Now type:</p><pre><code>Implement session-based authentication instead of JWT
</code></pre><p>The agent sees the conversation up to "Add user registration" but not the JWT work. It builds session auth from scratch. The JWT branch still exists — you can switch back anytime with <code>/tree</code>.</p><h2>Practical scenarios</h2><h3>Comparing approaches</h3><p>You're not sure whether to use a SQL query builder or an ORM for a complex report:</p><pre><code>Build the sales report using raw SQL queries
</code></pre><p>Agent builds it. You fork back:</p><pre><code>/fork
Build the same sales report using Eloquent
</code></pre><p>Now you have both implementations. Switch between them with <code>/tree</code>, compare the code, pick the one that's cleaner.</p><h3>Recovering from a wrong turn</h3><p>The agent went down a path that isn't working. Instead of trying to undo fifteen tool calls:</p><pre><code>/fork
</code></pre><p>Go back to the last message before things went wrong. Continue from there. The broken branch stays in the tree as a record of what didn't work — which is useful context if you're debugging why.</p><h3>Exploring with confidence</h3><p>You want to try a risky refactor but you're not sure it'll work:</p><pre><code>/fork
Refactor the notification system to use events instead of direct calls
</code></pre><p>If it works, great. If it doesn't, switch back to the pre-refactor branch. No damage done, no time wasted on reverting.</p><h3>A/B testing prompts</h3><p>You're not sure how to phrase a request to get the best result:</p><pre><code>Build a dashboard with charts for user activity
</code></pre><p>Fork back, try a different prompt:</p><pre><code>/fork
Create an analytics dashboard showing daily active users, retention curve, and revenue per user. Use Chart.js. Include date range filters.
</code></pre><p>Compare the outputs. The more specific prompt probably produced better results — and now you can see exactly how much difference the phrasing made.</p><h2>Cloning sessions</h2><pre><code>/clone
</code></pre><p>Duplicates the entire current session at the current position. Unlike <code>/fork</code> (which branches from a past message), <code>/clone</code> creates an exact copy of where you are right now.</p><p>This is useful when:</p><ul><li><p>You want to continue in two different directions from the same point</p></li><li><p>You want a "save point" before trying something experimental</p></li><li><p>You want to hand a session state to a colleague (export the clone)</p></li></ul><h2>The tree is persistent</h2><p>Branches survive across restarts. When you resume a session, the full tree is there. You can navigate back to any branch, any message, any point in the conversation's history.</p><p>This means branches aren't just for in-session exploration. You can close Elyra, come back tomorrow, and pick up a different branch. The JWT auth branch from last week is still there if you change your mind about sessions.</p><h2>Combining with other features</h2><p><code>/tree</code><strong> + </strong><code>/diff</code> — Switch to a branch, run <code>/diff</code> to see what files that branch changed. Switch to another branch, <code>/diff</code> again. Compare the file-level impact of each approach.</p><p><code>/tree</code><strong> + </strong><code>/cost</code> — Each branch has its own token history. After exploring two approaches, check <code>/cost</code> on each branch to see which one burned more tokens. Sometimes the "simpler" approach costs more because it required more back-and-forth to get right.</p><p><code>/tree</code><strong> + </strong><code>/compact</code> — Compaction works per-branch. If one branch gets long, compact it without affecting other branches. The compaction summary preserves the branch's context, and other branches keep their full history.</p><p><code>/tree</code><strong> + </strong><code>/export</code> — Export a specific branch as HTML. Useful for documentation: "Here's the exploration we did on auth approaches, with the JWT branch and the session branch side by side."</p><h2>When not to use it</h2><p>For most sessions, you don't need branches. The linear conversation works fine. Branches add value when:</p><ul><li><p>You're genuinely uncertain between approaches</p></li><li><p>The cost of being wrong is high (large refactors, architecture decisions)</p></li><li><p>You want to compare prompt strategies</p></li><li><p>You need a safe rollback point before something risky</p></li></ul><p>If you're just building a feature and the path is clear, skip the branching. It's a tool for uncertainty, not a requirement for every session.</p>