mcpField
T
tldr-deep

tldr-deep

github.com/parcadei开发3.9k484 次安装39 周前更新
代码仓库

关于 tldr-deep

tldr-deep 是面向开发者的代码分析 Skill,用于调试或深入理解函数。它通过五个层次检查代码结构、调用关系、控制流、数据流和依赖。

主要功能

  1. 01五层函数分析
  2. 02检查 AST 结构
  3. 03浏览调用图
  4. 04分析控制流与数据流
  5. 05切片追踪依赖
  6. 06通过 Python API 调用

适用场景

  1. 01追踪复杂函数的执行路径
  2. 02重构前检查依赖
  3. 03审查复杂代码
  4. 04查找高复杂度热点

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill tldr-deep

安装后在 Claude Code 中输入/tldr-deep确认已加载。

详细介绍

TLDR 深度分析

对特定函数进行完整的 5 层分析。适用于调试或深入理解代码。

触发方式

  • /tldr-deep <function_name>
  • “详细分析函数 X”
  • “我需要深入了解 Y 的工作原理”
  • 调试复杂函数

分层

层用途命令
L1:AST结构tldr extract <file>
L2:调用图导航tldr context <func> --depth 2
L3:CFG复杂度tldr cfg <file> <func>
L4:DFG数据流tldr dfg <file> <func>
L5:切片依赖关系tldr slice <file> <func> <line>

执行

给定函数名,运行所有层:

# First find the file
tldr search "def <function_name>" .

# Then run each layer
tldr extract <found_file>              # L1: Full file structure
tldr context <function_name> --project . --depth 2  # L2: Call graph
tldr cfg <found_file> <function_name>  # L3: Control flow
tldr dfg <found_file> <function_name>  # L4: Data flow
tldr slice <found_file> <function_name> <target_line>  # L5: Slice

输出格式

## Deep Analysis: {function_name}

### L1: Structure (AST)
File: {file_path}
Signature: {signature}
Docstring: {docstring}

### L2: Call Graph
Calls: {list of functions this calls}
Called by: {list of functions that call this}

### L3: Control Flow (CFG)
Blocks: {N}
Cyclomatic Complexity: {M}
[Hot if M > 10]
Branches:
  - if: line X
  - for: line Y
  - ...

### L4: Data Flow (DFG)
Variables defined:
  - {var1} @ line X
  - {var2} @ line Y
Variables used:
  - {var1} @ lines [A, B, C]
  - {var2} @ lines [D, E]

### L5: Program Slice (affecting line {target})
Lines in slice: {N}
Key dependencies:
  - line X → line Y (data)
  - line A → line B (control)

---
Total: ~{tokens} tokens (95% savings vs raw file)

适用场景

  1. 调试 - 需要了解函数的所有执行路径
  2. 重构 - 需要了解各项内容之间的依赖关系
  3. 代码审查 - 分析复杂函数
  4. 性能 - 查找热点(圈复杂度高)

编程 API

from tldr.api import (
    extract_file,
    get_relevant_context,
    get_cfg_context,
    get_dfg_context,
    get_slice
)

# All layers for one function
file_info = extract_file("src/processor.py")
context = get_relevant_context("src/", "process_data", depth=2)
cfg = get_cfg_context("src/processor.py", "process_data")
dfg = get_dfg_context("src/processor.py", "process_data")
slice_lines = get_slice("src/processor.py", "process_data", target_line=42)

评论

支持 Markdown