Skip to main content

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.

PyPI Python 3.10+ CI License: MIT

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:

  1. ๐Ÿ“‚ Scan logs โ†’ discover conversation sessions
  2. ๐Ÿ” Browse sessions โ†’ drill down like a debugger (overview โ†’ turn โ†’ tool call)
  3. ๐Ÿงฌ Extract workflows โ†’ identify phases, steps, decision points โ†’ output YAML DSL
  4. ๐Ÿค– Generate agents โ†’ auto-generate LangGraph executable code from YAML DSL
  5. ๐Ÿ’ก 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., fb48c matches fb48c98d-5233-...) and the latest keyword.

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

retrolens-0.5.1.tar.gz (279.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

retrolens-0.5.1-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

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

Hashes for retrolens-0.5.1.tar.gz
Algorithm Hash digest
SHA256 82285270ab7def92a1d3484082985fe7d9d6f0fa400d138a3f7d2dce67dd2a00
MD5 17b6bca479e6312685c5aff167a246e1
BLAKE2b-256 0c051bcabd0b4b0ba4bb1978fbc577dc3258c20bd9a271043a072e933ae55e8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for retrolens-0.5.1.tar.gz:

Publisher: release.yml on JoelYYoung/retrolens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for retrolens-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f1b824b95459d5d6141011b9cd4e681a2fb2d1c54436beca7901a7b2bfdb5d
MD5 614aaf318be8a81efc875f6fc1e058bc
BLAKE2b-256 a8d2a35dfb4b9ee5614001cbb043837717b282c5b5c714864695725b6aa8d84d

See more details on using hashes here.

Provenance

The following attestation bundles were made for retrolens-0.5.1-py3-none-any.whl:

Publisher: release.yml on JoelYYoung/retrolens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page