tldr-code by parcadei/continuous-claude-v3
npx skills add https://github.com/parcadei/continuous-claude-v3 --skill tldr-code高效利用令牌的代码分析工具。相比直接读取原始文件,节省 95% 的令牌消耗。
| 任务 | 命令 |
|---|---|
| 文件树 | tldr tree src/ |
| 代码结构 | tldr structure . --lang python |
| 搜索代码 | tldr search "pattern" . |
| 调用图 | tldr calls src/ |
| 谁调用了 X? | tldr impact func_name . |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 控制流 | tldr cfg file.py func |
| 数据流 | tldr dfg file.py func |
| 程序切片 | tldr slice file.py func 42 |
| 死代码 | tldr dead src/ |
| 架构分析 | tldr arch src/ |
| 导入分析 | tldr imports file.py |
| 谁导入了 X? | tldr importers module_name . |
| 受影响的测试 | tldr change-impact --git |
| 类型检查 | tldr diagnostics file.py |
| 语义搜索 | tldr semantic search "auth flow" |
Layer 1: AST ~500 tokens 函数签名,导入
Layer 2: Call Graph +440 tokens 调用关系(跨文件)
Layer 3: CFG +110 tokens 复杂度,分支,循环
Layer 4: DFG +130 tokens 变量定义/使用
Layer 5: PDG +150 tokens 依赖关系,切片
───────────────────────────────────────────────────────────────
Total: ~1,200 tokens vs 23,000 raw = 95% savings
# 文件树
tldr tree [path]
tldr tree src/ --ext .py .ts # 过滤扩展名
tldr tree . --show-hidden # 包含隐藏文件
# 代码结构(代码地图)
tldr structure [path] --lang python
tldr structure src/ --max 100 # 最大分析文件数
# 文本搜索
tldr search <pattern> [path]
tldr search "def process" src/
tldr search "class.*Error" . --ext .py
tldr search "TODO" . -C 3 # 3 行上下文
tldr search "func" . --max 50 # 限制结果数量
# 语义搜索(自然语言)
tldr semantic search "authentication flow"
tldr semantic search "error handling" --k 10
tldr semantic search "database queries" --expand # 包含调用图
# 完整文件信息
tldr extract <file>
tldr extract src/api.py
tldr extract src/api.py --class UserService # 过滤到类
tldr extract src/api.py --function process # 过滤到函数
tldr extract src/api.py --method UserService.get # 过滤到方法
# 相关上下文(遵循调用图)
tldr context <entry> --project <path>
tldr context main --project src/ --depth 3
tldr context UserService.create --project . --lang typescript
# 控制流图(复杂度)
tldr cfg <file> <function>
tldr cfg src/processor.py process_data
# 返回:圈复杂度,基本块,分支,循环
# 数据流图(变量追踪)
tldr dfg <file> <function>
tldr dfg src/processor.py process_data
# 返回:变量在何处定义、读取、修改
# 程序切片(哪些内容影响第 X 行)
tldr slice <file> <function> <line>
tldr slice src/processor.py process_data 42
tldr slice src/processor.py process_data 42 --direction forward
tldr slice src/processor.py process_data 42 --var result
# 构建跨文件调用图
tldr calls [path]
tldr calls src/ --lang python
# 反向调用图(谁调用了这个函数?)
tldr impact <func> [path]
tldr impact process_data src/ --depth 5
tldr impact authenticate . --file auth # 按文件过滤
# 查找死代码/不可达代码
tldr dead [path]
tldr dead src/ --entry main cli test_ # 指定入口点
tldr dead . --lang typescript
# 检测架构层次
tldr arch [path]
tldr arch src/ --lang python
# 返回:入口层,中间层,叶子层,循环依赖
# 解析文件中的导入
tldr imports <file>
tldr imports src/api.py
tldr imports src/api.ts --lang typescript
# 反向导入查找(谁导入了这个模块?)
tldr importers <module> [path]
tldr importers datetime src/
tldr importers UserService . --lang typescript
# 类型检查 + 代码检查
tldr diagnostics <file|path>
tldr diagnostics src/api.py
tldr diagnostics . --project # 整个项目
tldr diagnostics src/ --no-lint # 仅类型检查
tldr diagnostics src/ --format text # 人类可读格式
# 查找受影响的测试
tldr change-impact [files...]
tldr change-impact # 自动检测(会话/git)
tldr change-impact src/api.py # 显式指定文件
tldr change-impact --session # 会话中修改的文件
tldr change-impact --git # Git 差异文件
tldr change-impact --git --git-base main # 与分支比较差异
tldr change-impact --run # 实际运行受影响的测试
# 预构建调用图缓存
tldr warm <path>
tldr warm src/ --lang python
tldr warm . --background # 后台构建
# 构建语义索引(一次性)
tldr semantic index [path]
tldr semantic index . --lang python
tldr semantic index . --model all-MiniLM-L6-v2 # 更小的模型 (80MB)
守护进程将索引保存在内存中,以实现即时重复查询。
# 启动守护进程(自动后台运行)
tldr daemon start
tldr daemon start --project /path/to/project
# 检查状态
tldr daemon status
# 停止守护进程
tldr daemon stop
# 发送原始命令
tldr daemon query ping
tldr daemon query status
# 通知文件变更(用于钩子)
tldr daemon notify <file>
tldr daemon notify src/api.py
| 特性 | 描述 |
|---|---|
| 自动关闭 | 空闲 30 分钟后 |
| 查询缓存 | SalsaDB 记忆化 |
| 内容哈希 | 跳过未更改的文件 |
| 脏数据追踪 | 增量重新索引 |
| 跨平台 | Unix 套接字 / Windows TCP |
向套接字发送 JSON,接收 JSON 响应:
// 请求
{"cmd": "search", "pattern": "process", "max_results": 10}
// 响应
{"status": "ok", "results": [...]}
所有 22 个守护进程命令:
ping, status, shutdown, search, extract, impact, dead, arch,
cfg, dfg, slice, calls, warm, semantic, tree, structure,
context, imports, importers, notify, diagnostics, change_impact
使用嵌入向量进行自然语言代码搜索。
# 构建索引(首次运行时下载模型)
tldr semantic index .
# 默认模型:bge-large-en-v1.5 (1.3GB,最佳质量)
# 较小模型:all-MiniLM-L6-v2 (80MB,更快)
tldr semantic index . --model all-MiniLM-L6-v2
tldr semantic search "authentication flow"
tldr semantic search "error handling patterns" --k 10
tldr semantic search "database connection" --expand # 遵循调用图
在 .claude/settings.json 中:
{
"semantic_search": {
"enabled": true,
"auto_reindex_threshold": 20,
"model": "bge-large-en-v1.5"
}
}
| 语言 | AST | 调用图 | CFG | DFG | PDG |
|---|---|---|---|---|---|
| Python | Yes | Yes | Yes | Yes | Yes |
| TypeScript | Yes | Yes | Yes | Yes | Yes |
| JavaScript | Yes | Yes | Yes | Yes | Yes |
| Go | Yes | Yes | Yes | Yes | Yes |
| Rust | Yes | Yes | Yes | Yes | Yes |
| Java | Yes | Yes | - | - | - |
| C/C++ | Yes | Yes | - | - | - |
| Ruby | Yes | - | - | - | - |
| PHP | Yes | - | - | - | - |
| Kotlin | Yes | - | - | - | - |
| Swift | Yes | - | - | - | - |
| C# | Yes | - | - | - | - |
| Scala | Yes | - | - | - | - |
| Lua | Yes | - | - | - | - |
| Elixir | Yes | - | - | - | - |
TLDR 遵循 .tldrignore(gitignore 语法):
# .tldrignore
.venv/
__pycache__/
node_modules/
*.min.js
dist/
首次运行会创建带有合理默认值的 .tldrignore。使用 --no-ignore 来绕过。
| 任务 | 使用 TLDR | 使用 Grep |
|---|---|---|
| 查找函数定义 | tldr extract file --function X | - |
| 搜索代码模式 | tldr search "pattern" | - |
| 字符串字面量搜索 | - | grep "literal" |
| 配置值 | - | grep "KEY=" |
| 跨文件调用 | tldr calls | - |
| 反向依赖 | tldr impact func | - |
| 复杂度分析 | tldr cfg file func | - |
| 变量追踪 | tldr dfg file func | - |
| 自然语言查询 | tldr semantic search | - |
from tldr.api import (
# L1: AST
extract_file, extract_functions, get_imports,
# L2: Call Graph
build_project_call_graph, get_intra_file_calls,
# L3: CFG
get_cfg_context,
# L4: DFG
get_dfg_context,
# L5: PDG
get_slice, get_pdg_context,
# Unified
get_relevant_context,
# Analysis
analyze_dead_code, analyze_architecture, analyze_impact,
)
# 示例:为 LLM 获取上下文
ctx = get_relevant_context("src/", "main", depth=2, language="python")
print(ctx.to_llm_string())
关键洞察: TLDR 负责导航,然后你负责阅读。不要试图仅从摘要中修复 Bug。
# 1. 导航:找出哪些文件重要
tldr imports file.py # 有问题的文件依赖什么?
tldr impact func_name . # 谁调用了有问题的函数?
tldr calls . # 跨文件边(对于模型,遵循 2 跳)
# 2. 阅读:获取关键文件的实际代码(2-4 个文件,而不是全部 50 个)
# 使用 Read 工具或 tldr search -C 获取带上下文的代码
tldr search "def buggy_func" . -C 20
对于跨文件 Bug(例如,错误的字段名,类型不匹配),你需要看到:
task.user_id)owner_id)TLDR 找出哪些文件重要。然后你阅读它们。
如果 TLDR 输出不够:
tldr search "pattern" . -C 20 - 获取带 20 行上下文的实际代码tldr imports file.py - 查看文件依赖什么Raw file read: 23,314 tokens
TLDR all layers: 1,189 tokens
─────────────────────────────────
Savings: 95%
洞察:调用图导航到相关代码,然后各层提供结构化摘要。你不会阅读无关的代码。
每周安装量
202
代码仓库
GitHub 星标数
3.6K
首次出现
2026年1月22日
安全审计
安装于
opencode195
codex193
gemini-cli191
cursor189
github-copilot188
amp185
Token-efficient code analysis. 95% savings vs raw file reads.
| Task | Command |
|---|---|
| File tree | tldr tree src/ |
| Code structure | tldr structure . --lang python |
| Search code | tldr search "pattern" . |
| Call graph | tldr calls src/ |
| Who calls X? | tldr impact func_name . |
| Control flow | tldr cfg file.py func |
| Data flow | tldr dfg file.py func |
| Program slice | tldr slice file.py func 42 |
| Dead code | tldr dead src/ |
| Architecture | tldr arch src/ |
| Imports | tldr imports file.py |
| Who imports X? | tldr importers module_name . |
| Affected tests | tldr change-impact --git |
| Type check | tldr diagnostics file.py |
| Semantic search | tldr semantic search "auth flow" |
Layer 1: AST ~500 tokens Function signatures, imports
Layer 2: Call Graph +440 tokens What calls what (cross-file)
Layer 3: CFG +110 tokens Complexity, branches, loops
Layer 4: DFG +130 tokens Variable definitions/uses
Layer 5: PDG +150 tokens Dependencies, slicing
───────────────────────────────────────────────────────────────
Total: ~1,200 tokens vs 23,000 raw = 95% savings
# File tree
tldr tree [path]
tldr tree src/ --ext .py .ts # Filter extensions
tldr tree . --show-hidden # Include hidden files
# Code structure (codemaps)
tldr structure [path] --lang python
tldr structure src/ --max 100 # Max files to analyze
# Text search
tldr search <pattern> [path]
tldr search "def process" src/
tldr search "class.*Error" . --ext .py
tldr search "TODO" . -C 3 # 3 lines context
tldr search "func" . --max 50 # Limit results
# Semantic search (natural language)
tldr semantic search "authentication flow"
tldr semantic search "error handling" --k 10
tldr semantic search "database queries" --expand # Include call graph
# Full file info
tldr extract <file>
tldr extract src/api.py
tldr extract src/api.py --class UserService # Filter to class
tldr extract src/api.py --function process # Filter to function
tldr extract src/api.py --method UserService.get # Filter to method
# Relevant context (follows call graph)
tldr context <entry> --project <path>
tldr context main --project src/ --depth 3
tldr context UserService.create --project . --lang typescript
# Control flow graph (complexity)
tldr cfg <file> <function>
tldr cfg src/processor.py process_data
# Returns: cyclomatic complexity, blocks, branches, loops
# Data flow graph (variable tracking)
tldr dfg <file> <function>
tldr dfg src/processor.py process_data
# Returns: where variables are defined, read, modified
# Program slice (what affects line X)
tldr slice <file> <function> <line>
tldr slice src/processor.py process_data 42
tldr slice src/processor.py process_data 42 --direction forward
tldr slice src/processor.py process_data 42 --var result
# Build cross-file call graph
tldr calls [path]
tldr calls src/ --lang python
# Reverse call graph (who calls this function?)
tldr impact <func> [path]
tldr impact process_data src/ --depth 5
tldr impact authenticate . --file auth # Filter by file
# Find dead/unreachable code
tldr dead [path]
tldr dead src/ --entry main cli test_ # Specify entry points
tldr dead . --lang typescript
# Detect architectural layers
tldr arch [path]
tldr arch src/ --lang python
# Returns: entry layer, middle layer, leaf layer, circular deps
# Parse imports from file
tldr imports <file>
tldr imports src/api.py
tldr imports src/api.ts --lang typescript
# Reverse import lookup (who imports this module?)
tldr importers <module> [path]
tldr importers datetime src/
tldr importers UserService . --lang typescript
# Type check + lint
tldr diagnostics <file|path>
tldr diagnostics src/api.py
tldr diagnostics . --project # Whole project
tldr diagnostics src/ --no-lint # Type check only
tldr diagnostics src/ --format text # Human-readable
# Find affected tests
tldr change-impact [files...]
tldr change-impact # Auto-detect (session/git)
tldr change-impact src/api.py # Explicit files
tldr change-impact --session # Session-modified files
tldr change-impact --git # Git diff files
tldr change-impact --git --git-base main # Diff against branch
tldr change-impact --run # Actually run affected tests
# Pre-build call graph cache
tldr warm <path>
tldr warm src/ --lang python
tldr warm . --background # Build in background
# Build semantic index (one-time)
tldr semantic index [path]
tldr semantic index . --lang python
tldr semantic index . --model all-MiniLM-L6-v2 # Smaller model (80MB)
The daemon holds indexes in memory for instant repeated queries.
# Start daemon (backgrounds automatically)
tldr daemon start
tldr daemon start --project /path/to/project
# Check status
tldr daemon status
# Stop daemon
tldr daemon stop
# Send raw command
tldr daemon query ping
tldr daemon query status
# Notify file change (for hooks)
tldr daemon notify <file>
tldr daemon notify src/api.py
| Feature | Description |
|---|---|
| Auto-shutdown | 30 minutes idle |
| Query caching | SalsaDB memoization |
| Content hashing | Skip unchanged files |
| Dirty tracking | Incremental re-indexing |
| Cross-platform | Unix sockets / Windows TCP |
Send JSON to socket, receive JSON response:
// Request
{"cmd": "search", "pattern": "process", "max_results": 10}
// Response
{"status": "ok", "results": [...]}
All 22 daemon commands:
ping, status, shutdown, search, extract, impact, dead, arch,
cfg, dfg, slice, calls, warm, semantic, tree, structure,
context, imports, importers, notify, diagnostics, change_impact
Natural language code search using embeddings.
# Build index (downloads model on first run)
tldr semantic index .
# Default model: bge-large-en-v1.5 (1.3GB, best quality)
# Smaller model: all-MiniLM-L6-v2 (80MB, faster)
tldr semantic index . --model all-MiniLM-L6-v2
tldr semantic search "authentication flow"
tldr semantic search "error handling patterns" --k 10
tldr semantic search "database connection" --expand # Follow call graph
In .claude/settings.json:
{
"semantic_search": {
"enabled": true,
"auto_reindex_threshold": 20,
"model": "bge-large-en-v1.5"
}
}
| Language | AST | Call Graph | CFG | DFG | PDG |
|---|---|---|---|---|---|
| Python | Yes | Yes | Yes | Yes | Yes |
| TypeScript | Yes | Yes | Yes | Yes | Yes |
| JavaScript | Yes | Yes | Yes | Yes | Yes |
| Go | Yes | Yes | Yes | Yes | Yes |
| Rust | Yes | Yes | Yes | Yes |
TLDR respects .tldrignore (gitignore syntax):
# .tldrignore
.venv/
__pycache__/
node_modules/
*.min.js
dist/
First run creates .tldrignore with sensible defaults. Use --no-ignore to bypass.
| Task | Use TLDR | Use Grep |
|---|---|---|
| Find function definition | tldr extract file --function X | - |
| Search code patterns | tldr search "pattern" | - |
| String literal search | - | grep "literal" |
| Config values | - | grep "KEY=" |
| Cross-file calls | tldr calls |
from tldr.api import (
# L1: AST
extract_file, extract_functions, get_imports,
# L2: Call Graph
build_project_call_graph, get_intra_file_calls,
# L3: CFG
get_cfg_context,
# L4: DFG
get_dfg_context,
# L5: PDG
get_slice, get_pdg_context,
# Unified
get_relevant_context,
# Analysis
analyze_dead_code, analyze_architecture, analyze_impact,
)
# Example: Get context for LLM
ctx = get_relevant_context("src/", "main", depth=2, language="python")
print(ctx.to_llm_string())
Key insight: TLDR navigates, then you read. Don't try to fix bugs from summaries alone.
# 1. NAVIGATE: Find which files matter
tldr imports file.py # What does buggy file depend on?
tldr impact func_name . # Who calls the buggy function?
tldr calls . # Cross-file edges (follow 2-hop for models)
# 2. READ: Get actual code for critical files (2-4 files, not all 50)
# Use Read tool or tldr search -C for code with context
tldr search "def buggy_func" . -C 20
For cross-file bugs (e.g., wrong field name, type mismatch), you need to see:
task.user_id)owner_id)TLDR finds which files matter. Then you read them.
If TLDR output isn't enough:
tldr search "pattern" . -C 20 - Get actual code with 20 lines contexttldr imports file.py - See what a file depends onRaw file read: 23,314 tokens
TLDR all layers: 1,189 tokens
─────────────────────────────────
Savings: 95%
The insight: Call graph navigates to relevant code, then layers give structured summaries. You don't read irrelevant code.
Weekly Installs
202
Repository
GitHub Stars
3.6K
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode195
codex193
gemini-cli191
cursor189
github-copilot188
amp185
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
111,800 周安装
| Yes |
| Java | Yes | Yes | - | - | - |
| C/C++ | Yes | Yes | - | - | - |
| Ruby | Yes | - | - | - | - |
| PHP | Yes | - | - | - | - |
| Kotlin | Yes | - | - | - | - |
| Swift | Yes | - | - | - | - |
| C# | Yes | - | - | - | - |
| Scala | Yes | - | - | - | - |
| Lua | Yes | - | - | - | - |
| Elixir | Yes | - | - | - | - |
| - |
| Reverse deps | tldr impact func | - |
| Complexity analysis | tldr cfg file func | - |
| Variable tracking | tldr dfg file func | - |
| Natural language query | tldr semantic search | - |