DEV Community

Cover image for How to Resume CLI AI Coding Agent Sessions on macOS
Dinesh Rajendran
Dinesh Rajendran

Posted on

How to Resume CLI AI Coding Agent Sessions on macOS

Autonomous AI coding agents like Claude Code and Codex have transformed how software engineers refactor code, write test suites, and debug complex multi-file repositories. Instead of copying individual code snippets into web chat interfaces, developers run multi-turn CLI agent sessions directly inside their terminal.

However, as engineers run dozens of agent tasks daily across different terminal tabs and project directories, managing session context creates major developer friction. Closing a terminal window, switching git branches, or restarting a laptop often leaves developers asking: “How do I resume my exact Claude Code session without losing state?”

Option 1: Native CLI Session Resumption (claude — resume)

Claude Code CLI includes native session resumption capabilities:

Interactive terminal session picker: claude — resume
Press enter or click to view image in full size

Direct session resumption by ID: claude — resume
Press enter or click to view image in full size

Running claude — resume without arguments launches an interactive CLI selector listing recent sessions in your current terminal workspace. Alternatively, passing a specific resumes that exact conversation state immediately.

The Practical Friction: While the interactive CLI picker works for quick session switches, it only displays the initial prompt of each session. You cannot search across middle turns, tool outputs, terminal commands, error tracebacks, or file names modified in turn 5 or 10. Furthermore, finding a specific past session across multiple project directories requires manually grepping hidden JSONL files in ~/.claude/projects/.

Option 2: Re-Prompting Claude for Past Context (The Token-Burn Trap)

When developers can’t find their session UUID, a common workaround is starting a brand-new Claude session and prompting:

“Where did we leave off on the ClipRowView refactor yesterday?”

While this sometimes works, it introduces two major drawbacks:

Wasted API Tokens: You pay input tokens for the agent to re-analyze files, read logs, and reconstruct state from scratch.
Prompt Cache Invalidation: Cold-starting a new session loses LLM prompt cache warm-state, increasing Time-To-First-Token (TTFT) latency and inflating costs.
Option 3: How L2Cache Solves It (Visual 1-Click Terminal Session Replay)

Press enter or click to view image in full size

In L2Cache, we built a native macOS AI Agent History & Analytics engine that turns hidden CLI log files into a fast, visual session layer:

Full-Text Search Across ALL Conversation Turns (SQLite FTS5) Unlike the native CLI picker which only shows the first prompt, L2Cache uses SQLite FTS5 full-text indexing to index every single turn, middle prompt, bash execution, error traceback, and file modification across your entire agent history. Search for an error message or terminal command from turn 15 of a session from 2 weeks ago in under 100ms.
L2Cache’s background services monitor local log directories (~/.claude/projects/ JSONL files and ~/.codex/memories.sqlite databases) on Apple Silicon hardware. Without sending data to external servers, L2Cache indexes: • Turn-by-turn user prompts and AI responses • Tool executions, bash commands, and file diffs • Input tokens, output tokens, and cacheReadTokens • Git branch context and working directory paths

1-Click “Resume in Terminal” Press ⌥Space or click the L2Cache menu bar item to open the Agent History panel. Browse past sessions visually with rich summaries, sort by token consumption or duration, and click “Resume in Terminal”. L2Cache automatically spawns a fresh terminal window attached directly to claude — resume .
Prompt Cache Efficiency & “Human Scale” Analytics L2Cache displays your prompt cache hit ratio (cacheReadTokens vs total input tokens) for every session, helping developers structure prompts to maximize Anthropic’s prompt caching discounts. Additionally, The Human Scale telemetry converts abstract token totals into real-world milestones: book pages read, novels written, and developer reading hours saved.
Automated Knowledge Graph & AGENTS.md Promotion When Claude uncovers a repository gotcha during a 20-turn debugging session (e.g. an AppKit threading bug or SQLite FTS5 tokenization constraint), L2Cache extracts the discovered rule into the Repository Knowledge Graph. With 1 click, developers can append the constraint directly into their repository’s AGENTS.md or CLAUDE.md, ensuring all future Claude CLI and Claude Desktop sessions obey the rule automatically.

Summary: The Ultimate AI Pair-Programming Setup

By pairing native CLI tools with L2Cache’s local memory layer, macOS developers get the best of both worlds: unconstrained terminal agent power combined with sub-100ms visual session replay, 1-click terminal resumption, and 100% on-device privacy.

More Than Just AI Tracking: A Complete Developer Memory Layer
While Claude and Codex session replay solves terminal context loss, L2Cache is designed as a complete, ambient Developer Memory Layer for macOS:

Smart Bubble at Cursor (⌘C): Press ⌘C on any code snippet (JWT, SQL, cURL, Base64, JSON) and a floating action bubble blooms right beside your cursor to format, decode, convert, or execute in 1 click without leaving your editor.
• Sub-100ms Terminal History Search: Indexes your entire Zsh/Bash/Fish shell execution history into local SQLite FTS5 with 1-click command replay and directory context.
• Real-Time Regex Tester: Test, debug, and match complex regex patterns against copied text instantly with string auto-escaping ("\d+"). • 50+ Smart Actions & Custom Extensions: Format SQL queries, JSON ⇄ YAML, cURL to Fetch/Python/Go, JWT claim verification, plus custom Shell, Ruby, or Python scripts.
• On-Device Vision OCR: Instantly extracts clean, selectable code from screenshots.
• Touch ID & Sensitive Data Lock: Automatic regex-redaction for API keys, AWS tokens, and database connection strings, backed by Touch ID biometric lock.
• Pure Native Swift Performance: Built 100% in native Swift (<40MB RAM, sub-100ms search speed, zero battery drain).
Try L2Cache for macOS
Ready to supercharge your AI coding workflow and eliminate context switching?

• 15-Day Free Trial (Full unrestricted access, no credit card required) • $4.99 Lifetime Purchase (Pay once, keep forever, zero subscriptions)

🌐 Website: https://l2cache.amvo.store
📲 Mac App Store: https://apps.apple.com/us/app/l2cache-developer-memory/id6774423992?mt=12

Top comments (0)