Issue 04 | Interactive Foundations: Exploring Magic Modes in the Terminal (Modes)
🎯 Learning Objectives
By the end of this issue, you will master:
- Practical scenarios for switching between Plan Mode and Default Mode
- Enabling and effects of Extended Thinking mode
- Scripted usage of Headless / Print Mode
- Session recovery techniques (
--continue,--resume)
📖 Core Concepts Explained
4.1 Mode Overview
╭─ Claude Code Mode System ─────────────────────────────╮
│ │
│ ┌─────────────┐ ┌──────────────┐ │
│ │ Plan Mode │◄──►│ Default Mode │ Shift+Tab │
│ │ Read-only Analysis │ │ Read/Write Execution │ │
│ └─────────────┘ └──────────────┘ │
│ │
│ ┌──────────────────────────────────────────┐ │
│ │ Extended Thinking │ │
│ │ For complex reasoning, architectural design │ │
│ │ Enable: Press `!` prefix in terminal or set thinking=on │ │
│ └──────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────┐ │
│ │ Print Mode (-p) (Script Mode) │ │
│ │ Single execution, no interaction, output to stdout │ │
│ │ Usage: claude -p "query" │ │
│ └──────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────┐ │
│ │ Bare Mode (--bare) (Minimal Startup) │ │
│ │ Skips loading CLAUDE.md / Skills │ │
│ │ For quick one-off tasks │ │
│ └──────────────────────────────────────────┘ │
│ │
╰─────────────────────────────────────────────────────╯
4.2 Extended Thinking
When encountering complex architectural decisions or multi-step reasoning problems, you can enable Extended Thinking mode:
# Enable globally
claude --effort max
# Or configure in settings
# ~/.claude/settings.json
{
"preferences": {
"thinkingMode": "on"
}
}
Effort Level:
| Level | Description | Use Case |
|---|---|---|
low |
Fast response, minimal reasoning | Simple file operations |
medium |
Default level | Daily coding |
high |
Deep reasoning | Bug fixing, refactoring |
max |
Maximum reasoning depth | Architectural design, complex algorithms |
💻 Simulating Claude TUI Interaction
Scenario 1: Plan Mode for Exploring Unfamiliar Codebases
> (Shift+Tab to switch to Plan Mode)
╭─ 🔒 Plan Mode ──────────────────────────────────────╮
│ Only read-only tools are available │
╰──────────────────────────────────────────────────────╯
> Starting from the cart page, explain how the checkout process works
╭─ Claude (Plan Mode) ────────────────────────────────╮
│ │
│ 🔍 Using tool: Glob (src/pages/cart**) │
│ 🔍 Using tool: Read (src/pages/cart/index.tsx) │
│ 🔍 Using tool: Grep ("checkout" across src/**) │
│ 🔍 Using tool: Read (src/api/checkout.ts) │
│ 🔍 Using tool: Read (src/hooks/useCheckout.ts) │
│ 🔍 Using tool: Read (src/services/payment.ts) │
│ │
│ ## Checkout Process Analysis │
│ │
│ ```mermaid │
│ sequenceDiagram │
│ Cart->>CheckoutAPI: POST /api/checkout │
│ CheckoutAPI->>Stripe: Create PaymentIntent │
│ Stripe-->>CheckoutAPI: clientSecret │
│ CheckoutAPI-->>Cart: { clientSecret, orderId } │
│ Cart->>Stripe.js: confirmPayment(clientSecret) │
│ Stripe.js-->>Cart: Success / Failure │
│ Cart->>CheckoutAPI: PATCH /api/orders/{id} │
│ ``` │
│ │
│ Key files: │
│ • `src/pages/cart/index.tsx` → Cart UI │
│ • `src/api/checkout.ts` → Create Order + Stripe Intent │
│ • `src/services/payment.ts` → Stripe SDK Wrapper │
│ • `src/hooks/useCheckout.ts` → Frontend State Management │
│ │
│ 💡 The entire process did not modify any files, pure analysis. │
│ │
╰──────────────────────────────────────────────────────╯
Scenario 2: Scripted Usage of Print Mode
# Single execution, output results to terminal
$ claude -p "Explain the purpose of src/auth/jwt.ts"
This file implements JWT authentication middleware:
- generateToken(): Generates a JWT containing userId
- verifyToken(): Verifies the Bearer token in the request header
- refreshToken(): Refreshes an expiring token
...
# Piped usage: Analyze logs
$ tail -200 app.log | claude -p "Analyze anomalies in these logs"
# Piped usage: Code review
$ git diff main --name-only | claude -p "Review these changed files for security issues"
# Output in JSON format
$ claude -p --output-format json "List all API endpoints in the project"
Scenario 3: Recovering Previous Sessions
# Resume last session
$ claude -c
✓ Resuming previous session...
✓ Context restored: "auth module refactoring"
✓ 12 messages in history
# Resume named session
$ claude -r "auth-refactor" "Continue implementing refresh token"
# Fork session (keep original, work on copy)
$ claude --resume abc123 --fork-session
💻 Code Demo: Advanced Pipe Usage
# 🔥 Practical combination: Automatically translate new strings in the project
claude -p "translate new strings into French and raise a PR for review"
# 🔥 Batch processing: Check all changed files for security issues
git diff main --name-only | claude -p "review these changed files for security issues"
# 🔥 Log analysis: Find anomalies and automatically notify
tail -200 app.log | claude -p "Slack me if you see any anomalies"
# 🔥 Control output format
claude -p --output-format json "List all TODO comments" > todos.json
# 🔥 Limit budget and turns
claude -p --max-turns 3 --max-budget-usd 0.50 "Quickly fix this lint error"
🔧 Involved CLI Flags
| Flag | Purpose | Example |
|---|---|---|
-p / --print |
Print Mode, non-interactive execution | claude -p "query" |
-c / --continue |
Resume last session | claude -c |
-r / --resume |
Resume specified session | claude -r "session-name" |
--fork-session |
Fork session | claude --resume id --fork-session |
--effort |
Set reasoning depth | claude --effort max |
--bare |
Minimal startup | claude --bare -p "query" |
--max-turns |
Limit maximum execution turns | claude -p --max-turns 3 |
--max-budget-usd |
Limit spending cap | claude -p --max-budget-usd 5.00 |
--model |
Specify model | claude --model sonnet |
--output-format |
Output format | json, text, stream-json |
📝 Key Takeaways from this Issue
- Plan Mode is the "safe first step" for exploring unfamiliar codebases
- Print Mode (
-p) turns Claude Code into an intelligent component in Unix pipes - Extended Thinking can improve reasoning quality in complex scenarios
- Use
--continueand--resumeto continue work across sessions --max-budget-usdand--max-turnsare safety valves for cost control