Debugger-style AI conversation log navigator โ let any agent extract lessons and workflows from chat sessions
Project description
RetroLens ๐ฌ
Learn from your AI agent conversations โ extract workflows, generate executable agents, accumulate lessons learned.
What is this?
Every day you use AI agents like VS Code Copilot, Claude Code, or Cursor to write code. These conversation logs contain reusable workflows and hard-won lessons โ but they're locked inside log files, inaccessible for reuse.
RetroLens provides a lightweight CLI + a SKILL.md guide that enables any general-purpose agent to:
- ๐ Scan logs โ discover conversation sessions
- ๐ Browse sessions โ drill down like a debugger (overview โ turn โ tool call)
- ๐งฌ Extract workflows โ identify phases, steps, decision points โ output YAML DSL
- ๐ค Generate agents โ auto-generate LangGraph executable code from YAML DSL
- ๐ก Reflect on lessons โ analyze errors, inefficiencies, best practices โ output LESSONS.md
Conversation Logs โ scan โ read โ extract โ YAML DSL โ LangGraph Agent
โ
reflect โ LESSONS.md / AGENTS.md
Installation
# Recommended: using uv
uv pip install -e .
# Or using pip
pip install -e .
Verify installation:
retrolens --version
Quick Start: 5-Minute Walkthrough
1. Scan your VS Code conversation logs
retrolens scan
Found 5 session(s):
# ID Source Date Model Turns Title
โโโโ โโโโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโ
1 fb48c98d-523.. vscode 2026-04-09 claude-opus-4.6 9 Workflow extraction
2 b1ab08d7-be1.. vscode 2026-04-01 claude-sonnet-4.. 1 Traceback analysis
2. Browse a session
retrolens read fb48c # prefix matching works
=== Session: fb48c98d-523 ===
Total Turns: 9
#1 [User] The main goal of this project is...
[Tools: 568] findFiles, readFile, runSubagent...
#2 [User] I think it should be...
[Tools: 8] memory, readFile
...
3. Drill into a specific turn
retrolens read fb48c --turn 5 # turn 5 details
retrolens read fb48c -t 5 --tool 0 # first tool call in turn 5
4. Extract workflow digest
retrolens extract fb48c --json # structured SessionDigest output
5. Reflect on lessons learned
retrolens reflect fb48c --focus errors --json # focus on error analysis
โญ Core Feature: Refine Workflows with SKILL
This is RetroLens's most important capability. It works as a Skill โ a standardized document that guides any general-purpose agent through analyzing conversation logs and distilling reusable workflows.
How It Works
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ General Agent (VS Code Copilot / Claude...) โ
โ โ
โ Reads SKILL.md โ knows how to use CLI tools โ
โ Calls CLI โ gets structured log data โ
โ Analyzes data โ uses its own LLM reasoning โ
โ Writes files โ .retrolens/LESSONS.md etc. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ โ
SKILL.md guidance CLI calls
โ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ retrolens CLI (lightweight) โ
โ โ
โ scan โ discover log sessions โ
โ read โ traverse session data โ
โ extract โ output SessionDigest (JSON) โ
โ reflect โ output SessionDigest + hints โ
โ show โ view existing artifacts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
Parses log files
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Log Files โ
โ VS Code Copilot: JSONL (incremental state) โ
โ Claude Code: JSONL (event stream) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Workflow A: Extract Workflow & Generate Agent
The core use case. Full pipeline:
# Step 1: Find the target session
retrolens scan --json
# Step 2: Get structured digest
retrolens extract <ID> --json
# Output includes: user messages, tools used, files touched, commands run per turn
# Step 3: Agent analyzes the digest and identifies workflow phases
# Research phase โ read_file, semantic_search dominant
# Planning phase โ user discussion, agent asks questions
# Implementation โ create_file, replace_string dominant
# Testing phase โ run_in_terminal running tests
# Documentation โ writing .md files
# Step 4: Agent writes analysis as YAML DSL
# โ .retrolens/my-workflow.workflow.yaml
# Step 5: Generate LangGraph code
retrolens extract --from-yaml .retrolens/my-workflow.workflow.yaml --langgraph
# โ .retrolens/my_workflow_agent.py
Generated LangGraph code includes:
- TypedDict state class โ with phase field and custom variables
- Phase node functions โ one per workflow phase, with step comments
- Tool function stubs โ placeholder implementations for each tool used
- Phase router โ state-based phase transitions
- Graph builder โ StateGraph + edges + compilation
- Main entry point โ ready to run
Workflow B: Reflect & Extract Lessons Learned
# Get reflection digest (with analysis hints)
retrolens reflect <ID> --focus errors --json
# Agent analyzes across 5 dimensions:
# ๐ด Errors & Fixes โ tool call failures, user corrections
# ๐ก Inefficiency Patterns โ repeated operations, unnecessary exploration
# ๐ข Effective Practices โ correct tool selection, progressive exploration
# โ ๏ธ Environment Traps โ API quotas, network issues, version compat
# ๐ Agent Directives โ explicit rules stated by the user
# Agent writes results to:
# โ .retrolens/LESSONS.md (lessons learned)
# โ AGENTS.md / CLAUDE.md (persistent agent directives)
Workflow C: Navigate Logs Like a Debugger
retrolens read <ID> # overview of all turns
retrolens read <ID> --turn 3 # turn 3 details
retrolens read <ID> -t 3 --tool 2 # 3rd tool call in turn 3
retrolens read <ID> --turns 1-5 # turns 1-5 comparison
retrolens read <ID> --diff 1,5 # diff between turns 1 and 5
Workflow D: Cross-Session Mining
# Scan all sessions
retrolens scan --json
# For each relevant session: extract + reflect
for id in fb48c a1b2c d3e4f; do
retrolens extract $id --json
retrolens reflect $id --json
done
# Agent synthesizes findings across multiple sessions into consolidated lessons
YAML Workflow DSL Format
workflow:
name: "Bug Fix Workflow"
goal: "Fix a reported bug with tests"
inputs: ["Bug description", "Affected file path"]
outputs: ["Fixed code", "Updated tests"]
phases:
- name: Investigation
description: Read the affected code and understand the bug
entry_condition: Bug report received
exit_condition: Root cause identified
steps:
- description: Read the affected file
tools: [read_file]
- description: Analyze the code for the bug
decision: Is it a logic bug or data bug?
- name: Fix
description: Implement the fix
steps:
- description: Modify the code
tools: [replace_string_in_file]
- description: Add input validation
tools: [replace_string_in_file]
- name: Verification
description: Run tests to verify the fix
steps:
- description: Run test suite
tools: [run_in_terminal]
- description: Check for regressions
decision: All tests pass?
dependencies:
- "Fix requires Investigation results"
- "Verification requires Fix to be complete"
Integrating the SKILL into Your Project
RetroLens is designed as a Skill for any general-purpose agent. Here's how to integrate with each platform:
VS Code Copilot Chat
Add to your project's AGENTS.md:
## Conversation Analysis Skill
Use `retrolens` CLI to analyze conversation logs and extract workflows.
- Extract workflow: `retrolens extract <ID> --json`
- Reflect on lessons: `retrolens reflect <ID> --json`
- Browse session: `retrolens read <ID> --turn N`
Always use `--json` for structured output.
Claude Code
Add to CLAUDE.md:
Use `retrolens` CLI to navigate conversation logs.
Key commands: cfg, ls, read. Always use --json.
Cursor
Add to .cursorrules:
When reviewing past sessions, use the retrolens CLI.
Commands: scan, extract, reflect, read, show. Always use --json flag.
CLI Command Reference
| Command | Purpose | Key Options |
|---|---|---|
scan |
Discover sessions | --source vscode, --limit N, --json |
read <ID> |
Browse session | --turn N, --tool M, --turns 1-5, --diff 1,3, --raw, --json |
extract <ID> |
Extract workflow digest | --max-turns N, --from-yaml <file>, --langgraph, --json |
reflect <ID> |
Reflect on lessons | --focus {all,errors,inefficiency,practices,traps}, --json |
show |
View existing artifacts | --type {all,lessons,workflow}, --dir <path>, --json |
Tip: Session IDs support prefix matching (e.g.,
fb48cmatchesfb48c98d-5233-...) and thelatestkeyword.
Supported Log Formats
| Source | Format | Log Location (macOS) |
|---|---|---|
| VS Code Copilot Chat | JSONL (incremental state machine) | ~/Library/.../Code/User/workspaceStorage/*/GitHub.copilot-chat/debug-logs/*.jsonl |
| Claude Code | JSONL (event stream) | ~/.claude/projects/<encoded-path>/ |
Project Structure
src/retrolens/
โโโ __init__.py # Version info
โโโ cli.py # Click CLI (5 commands)
โโโ models.py # Pydantic v2 data models (16+ models)
โโโ formatters.py # Text/JSON dual-mode output
โโโ workflow_dsl.py # YAML DSL serialization + LangGraph codegen
โโโ readers/
โ โโโ __init__.py # BaseReader ABC + ReaderRegistry
โ โโโ vscode_copilot.py # VS Code Copilot JSONL parser
โ โโโ claude_code.py # Claude Code JSONL parser
โโโ skills/
โโโ SKILL.md # โญ Agent skill document (core artifact)
tests/
โโโ conftest.py
โโโ test_models.py # 20 tests
โโโ test_workflow_dsl.py # 38 tests
โโโ test_readers.py # 36 tests
โโโ test_distill_cli.py # 32 tests
โโโ fixtures/ # Test data
Development
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests (126 tests)
python -m pytest tests/ -v
# Lint
ruff check src/
๐ License
MIT License โ see LICENSE
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file retrolens-0.5.1.tar.gz.
File metadata
- Download URL: retrolens-0.5.1.tar.gz
- Upload date:
- Size: 279.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82285270ab7def92a1d3484082985fe7d9d6f0fa400d138a3f7d2dce67dd2a00
|
|
| MD5 |
17b6bca479e6312685c5aff167a246e1
|
|
| BLAKE2b-256 |
0c051bcabd0b4b0ba4bb1978fbc577dc3258c20bd9a271043a072e933ae55e8d
|
Provenance
The following attestation bundles were made for retrolens-0.5.1.tar.gz:
Publisher:
release.yml on JoelYYoung/retrolens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
retrolens-0.5.1.tar.gz -
Subject digest:
82285270ab7def92a1d3484082985fe7d9d6f0fa400d138a3f7d2dce67dd2a00 - Sigstore transparency entry: 1272451671
- Sigstore integration time:
-
Permalink:
JoelYYoung/retrolens@baaa818f17b5b273afec468cd530024a933fe189 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/JoelYYoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@baaa818f17b5b273afec468cd530024a933fe189 -
Trigger Event:
push
-
Statement type:
File details
Details for the file retrolens-0.5.1-py3-none-any.whl.
File metadata
- Download URL: retrolens-0.5.1-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6f1b824b95459d5d6141011b9cd4e681a2fb2d1c54436beca7901a7b2bfdb5d
|
|
| MD5 |
614aaf318be8a81efc875f6fc1e058bc
|
|
| BLAKE2b-256 |
a8d2a35dfb4b9ee5614001cbb043837717b282c5b5c714864695725b6aa8d84d
|
Provenance
The following attestation bundles were made for retrolens-0.5.1-py3-none-any.whl:
Publisher:
release.yml on JoelYYoung/retrolens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
retrolens-0.5.1-py3-none-any.whl -
Subject digest:
a6f1b824b95459d5d6141011b9cd4e681a2fb2d1c54436beca7901a7b2bfdb5d - Sigstore transparency entry: 1272451695
- Sigstore integration time:
-
Permalink:
JoelYYoung/retrolens@baaa818f17b5b273afec468cd530024a933fe189 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/JoelYYoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@baaa818f17b5b273afec468cd530024a933fe189 -
Trigger Event:
push
-
Statement type: