cclens-trace-analyzer
Original:🇨🇳 Chinese
Translated
Analyze traces of Claude Code sessions. Use this Skill when users mention session IDs in UUID format (composed of numbers and lowercase letters), time clues such as "just now", "today", "last time", troubleshooting Agent behavior reasons, wanting to view the content of a specific Claude Code session, or analyzing trace content.
4installs
Added on
NPX Install
npx skill4agent add ningzimu/claude-code-lens cclens-trace-analyzerTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →CCLens Trace Analyzer
cclens tracelist → show → export → Read markdownPre-check
Before executing any trace commands, first confirm if is available:
cclens tracebash
cclens trace --help 2>&1- If the output starts with → Use
Usage: cclens tracenormally.cclens trace - If the output shows Claude Code's help () → The currently installed
Usage: claude [options]version does not include the trace feature. Upgrade to the latest version:cclens
bash
npm install -g claude-code-lensRun again after installation to confirm availability.
cclens trace --help 2>&1Core Principles
- is the only trusted source. Do not open the browser UI or guess raw log paths.
cclens trace - Always use . Treat CLI output as structured data, not natural language.
-f json - By default, select the narrowest scope that can answer the user's question — first check the or a single subagent, and export both for comparison if necessary.
lead - is only used when troubleshooting attribution statistics, log file paths, or per-agent tool call distribution; do not add it for routine analysis.
--debug - When multiple sessions are matched, distinguish them using ,
startedAt, andcontextbefore proceeding.status
Workflow
1. List Candidate Sessions
bash
cclens trace list -f json| Parameter | Purpose |
|---|---|
| Match sessionId, context, status, agents, or agent names |
| Only return sessions after the specified ISO 8601 timestamp |
| Limit the number of returns (truncate before building summaries; non-positive integers will trigger |
| Truncate summary fields such as context, status, does, outcome (default 120–220 characters) |
If returns an empty list, or the user's mentioned session cannot be found in the list, it means the session is a Claude Code session not started via cclens, and trace data cannot be obtained. In this case, directly inform the user: This session lacks trace records, possibly because it was not started using cclens. It is recommended to start Claude Code via cclens in the future to capture traces.
cclens trace listKey fields of each session:
- — Primary key for
sessionIdandshowexport - — Distinguish multiple runs of the same task
startedAt - — The first model thinking or fallback session context, used to confirm the target trace
context - — Current or final result summary of the session
status - — Overview of the number of agents, e.g.,
agentslead + 6 subagents
2. View Agents in the Session
bash
cclens trace show --session <sessionId> -f jsonKey fields of each agent:
- — Passed to
idexport --agent - —
roleorleadsubagent - — Compact and recognizable name; subagent format is
name<type> · <description> - — What the agent was assigned to do
does - — What the agent delivered
outcome
Select export targets based on user intent:
| User Intent | Export Target | Matching Method |
|---|---|---|
| Troubleshoot overall process or task orchestration issues | | Directly specify |
| Investigate the behavior or failure cause of a specific subagent | | Match by |
| Compare collaboration between Lead and Subagent | Export | First use |
Read the and in the output before running to avoid invalid operations on the wrong session.
contextstatuslistshow3. Export Trace as Markdown
bash
cclens trace export --session <sessionId> --agent <agentId|lead> -f json| Value | Scope |
|---|---|
| Only the main Agent |
| Specified subagent (id comes from |
Specify output path:
bash
cclens trace export --session <sessionId> --agent <id> --out /tmp/cclens-<session>-<agent>.md -f jsonThe in the returned JSON is the absolute path to read in the next step. It also returns and . Confirm that the exported object matches the target before reading.
markdownPathagent.doesagent.outcomeWhen is not specified, the default output path is .
--out~/.claude-code-lens/exports/trace-<first 8 digits of session>-<agentId>.md4. Read and Analyze Markdown
Use the tool to read .
ReadmarkdownPathKey analysis points:
- Overly broad, repetitive, or avoidable tool calls
- Subagents where does not match actual behavior
does - Excessively long thinking paths caused by unclear Skill instructions
- Missing constraints, decision rules, or examples in Skills
- Opportunities to reduce steps, tool calls, or agent handovers
Error Handling
All errors are returned as structured JSON. Read to determine the recovery path; do not parse for judgment.
error.codemessage| Error Code | Trigger Condition | Recovery Method |
|---|---|---|
| No sessions captured in | Prompt the user to run CCLens to capture a session first |
| Empty list | | Inform the user: This session was not started via cclens, so trace data cannot be obtained. It is recommended to start Claude Code using cclens in the future |
| The specified | Re-run |
| The specified agent id does not exist in the session | Re-run |
| Markdown writing failed | Retry with |
| Formats other than | Use |
| | Check parameter values and pass a valid positive integer |
Reporting Requirements
Include the following elements in the report results; none can be missing:
- Target session: and
sessionIdstartedAt - Target agent: ,
id,role,namedoes - Evidence: Short quoted fragments from the exported Markdown; do not assert without basis
- Recommendations: Specific modification plans for Skills or workflows, rather than general observations
- Confidence: Indicate whether was used, and whether the analysis covered the
--debug, a single subagent, or bothlead