P13: Tangent Mode Explorer (Context Isolation)
type: project id: P13 title: Tangent Mode Explorer track: Kiro CLI Mastery difficulty: Intermediate time_estimate: Weekend prerequisites: [P01-P05] knowledge_areas: [Context Management, Experimental Features, Workflow Optimization] tools: [Kiro CLI] main_book: “AI Engineering by Chip Huyen” —
Learning Objectives
By completing this project, you will:
- Understand context as a finite resource and why it must be managed carefully
- Master tangent mode for isolated side-conversations that don’t pollute main context
- Learn when to use tangent versus main context for different types of questions
- Develop workflows that maximize context lifetime for complex, multi-day tasks
- Understand the relationship between tangent mode and checkpoints
Deep Theoretical Foundation
The Context Window Problem
Every AI conversation has a finite context window - the total amount of text the model can “see” at once:
┌─────────────────────────────────────────────────────────────────┐
│ CONTEXT WINDOW (128K tokens) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ System Prompt + Steering ~2K tokens │ │
│ └────────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ Conversation History │ │
│ │ ├── Turn 1: "Refactor the auth module" ~500 tokens │ │
│ │ ├── Turn 2: [Kiro analyzes files] ~3,000 tokens │ │
│ │ ├── Turn 3: "What's async/await syntax?" ~200 tokens │ │
│ │ ├── Turn 4: [Kiro explains async] ~1,000 tokens │ │ ◄── Tangent!
│ │ ├── Turn 5: "Back to auth - add OAuth" ~300 tokens │ │
│ │ └── ...more turns... │ │
│ └────────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ Current File Contents ~10,000 tokens│ │
│ └────────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ Available Space for New Content ~112K tokens │ │
│ └────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
The problem: Side questions consume main context forever.
Context Pollution: The Silent Killer
When you ask a tangential question in the main conversation:
Turn 1: "Help me build a payment system"
[Kiro builds mental model of payment system]
Turn 2: "Actually, quick question - what's the syntax for Python decorators?"
[Kiro explains decorators - NOTHING to do with payments]
[This explanation is now PERMANENTLY in context]
Turn 3: "Back to payments - add Stripe integration"
[Context now includes irrelevant decorator explanation]
[Less space for payment-related context]
This is context pollution - irrelevant information crowding out relevant context.
Tangent Mode: The Solution
Tangent mode creates an isolated conversation branch:
MAIN CONTEXT
│
Turn 1: "Build payment system"
│
Turn 2: [Analysis] │
│
Turn 3: ──────────── ├ ──────────── TANGENT BRANCH
Enter tangent│ │
│ "What's decorator syntax?"
│ │
│ [Explanation]
│ │
│ Exit tangent
Turn 4: ◄────────────┤──────────────┘
(context │
restored) │
│
Turn 5: "Add Stripe" │
[Full payment context intact]
How Tangent Mode Works Internally
┌─────────────────────────────────────────────────────────────────┐
│ TANGENT MODE ARCHITECTURE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ MAIN CONTEXT STACK │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ system_prompt ││
│ │ steering_files ││
│ │ turn_1: user_message + assistant_response ││
│ │ turn_2: user_message + assistant_response ││
│ │ turn_3: [TANGENT MARKER - context paused] ││
│ │ ... ││
│ └─────────────────────────────────────────────────────────────┘│
│ │ │
│ Ctrl+T │ /tangent exit │
│ (enter) ▼ (return) │
│ │
│ TANGENT CONTEXT (isolated) │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ system_prompt (fresh) ││
│ │ tangent_turn_1: "What's decorator syntax?" ││
│ │ tangent_turn_2: [explanation] ││
│ │ [DISCARDED ON EXIT] ││
│ └─────────────────────────────────────────────────────────────┘│
│ │
│ On exit: Tangent context discarded, main context restored │
│ │
└─────────────────────────────────────────────────────────────────┘
Key insight: Tangent context is temporary and disposable.
Real-World Analogy: The Mental Whiteboard
Imagine you’re solving a complex math problem on a whiteboard:
- Main whiteboard: Your solution with all the important steps
- Side sticky note: A quick calculation you need to verify a formula
Without tangent mode: You write the side calculation ON the main whiteboard, cluttering it.
With tangent mode: You use a sticky note, get the answer, then throw it away. The main whiteboard stays clean.
When to Use Tangent Mode
| Situation | Use Tangent? | Reason |
|---|---|---|
| Syntax question | Yes | Pure reference, no task context |
| Library lookup | Yes | One-off information retrieval |
| Concept clarification | Maybe | Depends if it affects main task |
| Alternative approach exploration | Yes | Research before committing |
| Continuing main task | No | Needs full context |
| Debugging current code | No | Related to main context |
The Context Budget Mental Model
Think of context like a bank account:
Context Budget: 128,000 tokens
Mandatory Expenses (fixed):
- System prompt: 2,000 tokens
- Steering files: 3,000 tokens
- Current file content: 10,000 tokens
─────────────────────────────────────
Available: 113,000 tokens
Each conversation turn costs ~500-2000 tokens.
A long session might have 50+ turns = 50,000+ tokens.
Remaining budget shrinks with every tangent question asked in main context.
Tangent mode lets you “spend” tokens without withdrawing from the main account.
Historical Context: Context Management Evolution
2022: Basic Chat (no context management)
└── Everything in one context, hope it fits
2023: Context Windows Expand (32K → 128K)
└── More space, but same pollution problem
2024: RAG and Knowledge Bases
└── Retrieve relevant context dynamically
2025: Tangent Mode and Context Isolation
└── Explicit user control over context usage
Tangent mode represents the user taking control of context management.
Book Reference
“AI Engineering” by Chip Huyen discusses context management as a core challenge in AI system design. She emphasizes that “context is compute” - every token in context costs processing time and impacts response quality. Tangent mode is a user-facing implementation of context engineering principles.
Complete Project Specification
What You’re Building
A workflow mastery project that demonstrates:
- Enabling tangent mode in Kiro CLI settings
- Entering and exiting tangent using keyboard shortcuts and commands
- Recognizing tangent-worthy questions during complex tasks
- Maintaining long-running sessions with effective context management
- Understanding tangent + checkpoint interactions
Expected Behavior
$ kiro-cli chat
# Deep in a complex refactoring...
> "Refactor the UserService to use dependency injection"
[Kiro] Analyzing UserService...
Found 5 files with dependencies:
- src/services/UserService.ts
- src/controllers/UserController.ts
...
> "Create the injection container"
[Kiro] Creating container...
[Shows implementation plan]
# Wait, I need to remember TypeScript generics syntax...
> [Ctrl+T] # Enter tangent mode
[Tangent Mode] Context saved. Starting isolated conversation.
Main context will be preserved.
> "What's the syntax for TypeScript generic constraints?"
[Tangent] Generic constraints use the extends keyword:
function process<T extends BaseType>(item: T): T {
// T must extend BaseType
}
For multiple constraints:
function merge<T extends A & B>(obj: T): T { ... }
> "Thanks, one more - how do I use conditional types?"
[Tangent] Conditional types follow the pattern:
T extends U ? X : Y
Example:
type IsString<T> = T extends string ? 'yes' : 'no';
> /tangent exit
[Tangent Mode] Exiting. Main context restored.
You were working on: Refactoring UserService with dependency injection
> "Great, now add generic typing to the container"
[Kiro] Continuing with full context of the refactoring...
[No tangent pollution - proceeds with DI implementation]
Key Behaviors to Verify
- Context preservation: Main context untouched during tangent
- Clean exit: Return message reminds you what you were doing
- Full isolation: Tangent questions don’t appear in main history
- Shortcut functionality: Ctrl+T works as expected
- Command functionality:
/tangentand/tangent exitwork
Solution Architecture
State Machine
┌─────────────────────────────────────────────────────────────────┐
│ TANGENT MODE STATE MACHINE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ │
│ │ │ │
│ ┌───────────────►│ MAIN MODE │◄───────────────┐ │
│ │ │ │ │ │
│ │ └──────┬───────┘ │ │
│ │ │ │ │
│ │ Ctrl+T or /tangent │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌──────────────┐ │ │
│ │ │ │ │ │
│ │ │ SAVING │ │ │
│ │ │ CONTEXT │ │ │
│ │ │ │ │ │
│ │ └──────┬───────┘ │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌──────────────┐ │ │
│ │ │ │ /tangent exit │
│ │ │ TANGENT │ or Ctrl+T again │
│ │ │ MODE │────────────────┘ │
│ │ │ │ │
│ │ └──────┬───────┘ │
│ │ │ │
│ │ Session ends or │
│ │ /clear │
│ │ │ │
│ │ ▼ │
│ │ ┌──────────────┐ │
│ └────────────────│ CLEARED │ │
│ │ (tangent │ │
│ │ discarded) │ │
│ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Data Flow
ENTERING TANGENT:
┌─────────────────┐
│ User: Ctrl+T │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Serialize Main │ ──► Store current conversation state
│ Context │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Create Fresh │ ──► New context with only system prompt
│ Tangent Context │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Switch Active │ ──► All input/output uses tangent context
│ Context │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Show Indicator │ ──► [Tangent Mode] prefix
└─────────────────┘
EXITING TANGENT:
┌─────────────────┐
│ User: /tangent │
│ exit │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Discard Tangent │ ──► Tangent context thrown away
│ Context │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Restore Main │ ──► Deserialize saved state
│ Context │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Show Summary │ ──► "You were working on: [task]"
└─────────────────┘
Integration Points
┌─────────────────────────────────────────────────────────────────┐
│ TANGENT MODE INTEGRATION │
├─────────────────────────────────────────────────────────────────┤
│ │
│ SETTINGS │
│ kiro-cli settings chat.enableTangentMode true │
│ │
│ KEYBOARD SHORTCUTS │
│ Ctrl+T ──────────► Toggle tangent mode │
│ │
│ COMMANDS │
│ /tangent ────────► Enter tangent mode │
│ /tangent exit ──► Exit tangent mode │
│ /tangent status ► Check current mode │
│ │
│ VISUAL INDICATORS │
│ [Tangent Mode] ── Prefix on all tangent responses │
│ Prompt change ─── Different prompt character in tangent │
│ │
│ LIMITATIONS │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ • Cannot checkpoint while in tangent (exit first) ││
│ │ • Cannot use /plan in tangent (planning needs main context) ││
│ │ • MCP tools work but results don't persist to main ││
│ └─────────────────────────────────────────────────────────────┘│
│ │
└─────────────────────────────────────────────────────────────────┘
Phased Implementation Guide
Phase 1: Foundation - Enabling and Entering Tangent Mode
Goal: Successfully enter and exit tangent mode.
Step 1.1: Enable Tangent Mode
$ kiro-cli settings chat.enableTangentMode true
Setting updated: chat.enableTangentMode = true
Tangent mode is now available.
Use Ctrl+T or /tangent to enter tangent mode.
Hint: This is an experimental feature. Enable it explicitly.
Step 1.2: Practice Entry and Exit
$ kiro-cli chat
> "Hello, I'm starting a complex task"
[Kiro] Ready to help with your task.
> [Press Ctrl+T]
[Tangent Mode] Context saved. Isolated conversation started.
> "Quick question - what's 2+2?"
[Tangent] 4
> /tangent exit
[Tangent Mode] Returning to main context.
Context restored: conversation about starting a task.
> "Okay, let's continue"
[Kiro] (Has no memory of the 2+2 question)
Hint: Notice that after exiting, Kiro has no knowledge of the tangent conversation.
Step 1.3: Verify Context Isolation
Test that tangent truly isolates:
# In main context
> "Remember this: the secret code is ALPHA123"
[Kiro] Got it, I'll remember the secret code is ALPHA123.
> [Ctrl+T]
[Tangent Mode] Started.
> "What was the secret code?"
[Tangent] I don't have any information about a secret code.
What secret code are you referring to?
> /tangent exit
# Back in main
> "What was the secret code?"
[Kiro] The secret code is ALPHA123.
Hint: The tangent context doesn’t have access to main context content.
Phase 2: Core Functionality - Practical Usage Patterns
Goal: Develop intuition for when to use tangent mode.
Step 2.1: Syntax Lookup Pattern
# In the middle of a complex implementation
> "Refactor this to use async iterators"
[Kiro] I'll refactor to use async iterators. Here's the plan:
1. Convert the data source to AsyncIterable
2. Update the consumer to use for-await-of
...
# You forgot async iterator syntax
> [Ctrl+T]
[Tangent Mode] Started.
> "Show me async iterator syntax in TypeScript"
[Tangent] Async iterators use Symbol.asyncIterator:
async function* generateAsync() {
yield await fetch('/api/1');
yield await fetch('/api/2');
}
for await (const item of generateAsync()) {
console.log(item);
}
> /tangent exit
# Continue with full refactoring context
> "Proceed with the async iterator refactor"
Step 2.2: Research Before Committing Pattern
> "Should I use Redis or Memcached for this caching layer?"
[Kiro] Both are valid options. What's your priority?
# Research in tangent before polluting main context
> [Ctrl+T]
[Tangent Mode] Started.
> "Compare Redis vs Memcached for session storage"
[Tangent] Key differences:
Redis:
- Persistence options
- Rich data structures
- Pub/sub support
Memcached:
- Simpler, faster for basic key-value
- Multi-threaded
- Lower memory overhead
For session storage, Redis is typically preferred because...
> "What about connection overhead?"
[Tangent] Redis uses a single connection per client...
> /tangent exit
# Decision made, continue in main without research clutter
> "Let's use Redis for the caching layer"
[Kiro] Great choice. I'll implement Redis caching...
Hint: Research tangents can be long. Keep them isolated from the main task.
Step 2.3: Alternative Exploration Pattern
> "Implement user authentication"
[Kiro] I'll implement authentication. Starting with:
1. User model
2. Password hashing
3. JWT tokens
...
# What if we used a different approach?
> [Ctrl+T]
[Tangent Mode] Started.
> "What if we used Passport.js instead of manual JWT?"
[Tangent] Passport.js provides:
- Strategy-based authentication
- Built-in session handling
- Many OAuth strategies
Implementation would look like:
[Shows Passport approach]
> "What about Auth0 as a third option?"
[Tangent] Auth0 provides:
- Managed authentication
- Less code to maintain
- Enterprise features
Tradeoff: External dependency, cost at scale.
> /tangent exit
# Return with decision clarity
> "Let's stick with manual JWT - I want full control"
[Kiro] Continuing with manual JWT implementation...
Phase 3: Polish and Edge Cases
Goal: Master advanced tangent patterns and understand limitations.
Step 3.1: Nested Questions in Tangent
You can ask multiple questions in a single tangent session:
> [Ctrl+T]
[Tangent Mode] Started.
> "What's the difference between map and flatMap?"
[Tangent] map transforms each element...
flatMap transforms and flattens...
> "And reduce vs reduceRight?"
[Tangent] reduce processes left-to-right...
reduceRight processes right-to-left...
> "One more - what about filter vs find?"
[Tangent] filter returns all matches...
find returns first match or undefined...
> /tangent exit
# One tangent session, multiple questions, zero main context pollution
Hint: Use tangent for a batch of quick questions, then exit once.
Step 3.2: Tangent + Checkpoint Interaction
Tangent and checkpoints are mutually exclusive:
> /checkpoint create --tag "before-refactor"
Checkpoint created: before-refactor
> [Ctrl+T]
[Tangent Mode] Started.
> /checkpoint create --tag "in-tangent"
Error: Cannot create checkpoint while in tangent mode.
Exit tangent first with /tangent exit.
> /tangent exit
> /checkpoint create --tag "after-tangent"
Checkpoint created: after-tangent
Hint: Always exit tangent before checkpointing. The tangent context isn’t saved.
Step 3.3: Long-Running Session Management
For multi-day tasks, use tangent to preserve main context:
# Day 1
> "Start building the inventory management system"
[Kiro establishes context for inventory system]
# Day 2 (same session)
> [Ctrl+T]
> "Quick reminder - what's the SQL syntax for UPSERT?"
[Gets answer in tangent]
> /tangent exit
# Day 3 (same session)
> "Add the warehouse module to the inventory system"
[Kiro remembers all inventory context from Day 1]
Hint: Tangent mode is your friend for long sessions. Use it liberally for lookups.
Testing Strategy
Functional Tests
| Test | Expected Result |
|---|---|
| Ctrl+T enters tangent | “[Tangent Mode] Started” message |
| /tangent enters tangent | Same as Ctrl+T |
| /tangent exit returns | Main context restored |
| Tangent question isolated | Main context doesn’t see tangent content |
| Multiple tangent questions | All isolated from main |
| Checkpoint in tangent | Error message |
| Exit tangent after long session | Main context intact |
Context Isolation Test
# Test procedure:
1. In main: Define a variable ("secret is X")
2. Enter tangent
3. In tangent: Ask about the secret
4. Verify: Tangent doesn't know it
5. In tangent: Define different info ("color is blue")
6. Exit tangent
7. In main: Ask about the color
8. Verify: Main doesn't know it
Validation Checklist
[ ] Tangent mode enabled via settings
[ ] Ctrl+T shortcut works
[ ] /tangent command works
[ ] /tangent exit works
[ ] Visual indicator shows tangent mode
[ ] Main context preserved across tangent
[ ] Tangent content discarded on exit
[ ] Checkpoint blocked in tangent mode
[ ] Multiple questions work in tangent
[ ] Context reminder on exit
Common Pitfalls & Debugging
Pitfall 1: Forgetting to Exit Tangent
Problem: You’re in tangent mode without realizing it.
# Bad: Working on main task while in tangent
[Tangent Mode]
> "Now implement the payment module"
[Implementation lost when you eventually exit]
Solution: Watch for the [Tangent Mode] indicator. Exit before continuing main work.
Pitfall 2: Using Tangent for Related Questions
Problem: Using tangent for questions that should inform the main task.
# Bad: This question affects the implementation
> [Ctrl+T]
> "Which payment provider should we use?"
[Answer in tangent]
> /tangent exit
# Now main context doesn't know about the decision
Solution: If the answer affects the main task, ask in main context.
Pitfall 3: Over-Using Tangent
Problem: Entering tangent for every question, even brief ones.
# Overkill for a one-word answer
> [Ctrl+T]
> "Is TypeScript strict mode enabled?"
> /tangent exit
Solution: Quick, task-relevant questions can stay in main. Reserve tangent for longer explorations.
Debugging: Check Current Mode
> /tangent status
Current mode: TANGENT
Entered: 3 turns ago
Main context: Paused (45 turns preserved)
# Or in main:
> /tangent status
Current mode: MAIN
Tangent mode: Available (not active)
Extensions & Challenges
Extension 1: Named Tangents
Create named tangent sessions you can return to:
> /tangent start --name "research"
[Tangent: research] Started.
> "Compare different ORMs"
[Discussion...]
> /tangent suspend research
> /tangent start --name "syntax"
[Tangent: syntax] Started.
> /tangent resume research
[Tangent: research] Resumed with previous context.
Extension 2: Tangent History
Keep a log of tangent topics for reference:
> /tangent history
Recent Tangents:
1. TypeScript generics (10 mins ago)
2. Redis vs Memcached comparison (2 hours ago)
3. SQL UPSERT syntax (yesterday)
Extension 3: Auto-Tangent Detection
Train yourself to recognize tangent-worthy patterns:
TANGENT SIGNALS:
- "Quick question..."
- "I forgot how to..."
- "What's the syntax for..."
- "Compare X vs Y..."
- "Unrelated, but..."
Challenge: Zero-Pollution Session
Complete a complex task (e.g., full CRUD API) where:
- All syntax lookups are in tangent
- All research is in tangent
- Only task-relevant discussion in main
- Session lasts 50+ turns with context remaining
Real-World Connections
How Professionals Use This
At Large Tech Companies: Developers maintain week-long Kiro sessions for major features, using tangent mode for all side research.
In Pair Programming: One developer stays in main context (the task) while the other handles tangent lookups.
In Learning: Students use tangent for concept clarification without losing their assignment context.
The Context Management Discipline
Professional AI-assisted development requires context hygiene:
┌─────────────────────────────────────────────────────────────────┐
│ CONTEXT HYGIENE PRACTICES │
├─────────────────────────────────────────────────────────────────┤
│ │
│ DO: │
│ ✓ Use tangent for syntax lookups │
│ ✓ Use tangent for alternative research │
│ ✓ Use tangent for unrelated questions │
│ ✓ Exit tangent before continuing main work │
│ ✓ Checkpoint main context before risky changes │
│ │
│ DON'T: │
│ ✗ Ask task-relevant questions in tangent │
│ ✗ Make implementation decisions in tangent │
│ ✗ Forget to exit tangent │
│ ✗ Try to checkpoint while in tangent │
│ │
└─────────────────────────────────────────────────────────────────┘
Self-Assessment Checklist
Conceptual Understanding
- Can you explain why context is a finite resource that must be managed?
- What is “context pollution” and how does tangent mode prevent it?
- When should you use tangent mode vs staying in main context?
- Why can’t you create checkpoints while in tangent mode?
Practical Skills
- Can you enable tangent mode in Kiro CLI settings?
- Can you enter tangent mode with both Ctrl+T and /tangent?
- Can you exit tangent mode and verify main context is restored?
- Can you maintain a long session using tangent for lookups?
Advanced Competency
- Can you recognize tangent-worthy questions during complex tasks?
- Can you use tangent for research without losing decision context?
- Can you manage multi-day sessions with effective context hygiene?
- Can you explain tangent mode to a colleague?
Mastery Indicators
- You instinctively press Ctrl+T before syntax lookups
- Your sessions last longer with more context remaining
- You never accidentally lose work by forgetting to exit tangent
- You teach others about context management
- You complete complex tasks in single sessions
Summary
Tangent mode is a context preservation superpower. By isolating side-conversations:
- Your main context stays focused on the task
- You can ask unlimited questions without pollution
- Long sessions remain productive
- You maintain full context for complex tasks
Master tangent mode, and you’ll wonder how you ever managed context without it.
Next Project: P14: Checkpoint System - Version control for AI sessions