关于 repoprompt
通过 RepoPrompt CLI 探索代码库并整理任务上下文的技能。它提供结构视图、定向搜索和文件片段,减少上下文中不必要的文件内容。
主要功能
- 01浏览文件树和代码结构
- 02搜索匹配内容及上下文
- 03读取指定文件行范围
- 04管理文件选择与工作区
- 05构建并导出任务上下文
适用场景
- 01梳理陌生代码库
- 02查找代码并检查相关行
- 03为编码任务准备上下文
MCP 相关
需要运行并启用 MCP Server 的 RepoPrompt 应用;CLI 通过该服务器进行通信。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ parcadei/ continuous-claude-v3 --skill repoprompt安装后在 Claude Code 中输入/repoprompt确认已加载。
详细介绍
RepoPrompt 技能
适用场景
- 探索代码库结构(tree、codemaps)
- 搜索代码并显示上下文行
- 获取代码签名,无需读取完整文件内容(节省 Token)
- 读取文件片段(指定行范围)
- 为任务构建上下文
Token 优化
RepoPrompt 比直接读取文件更节省 Token:
structure→ 仅显示签名(不包含完整内容)read --start-line --limit→ 读取片段,而非完整文件search --context-lines→ 显示相关匹配项及其上下文
CLI 用法
# If installed to PATH (Settings → MCP Server → Install CLI to PATH)
rp-cli -e 'command'
# Or use the alias (configure in your shell)
repoprompt_cli -e 'command'
命令参考
文件树
# Full tree
rp-cli -e 'tree'
# Folders only
rp-cli -e 'tree --mode folders'
# Selected files only
rp-cli -e 'tree --mode selected'
代码结构(Codemaps)- 节省 Token
# Structure of specific paths
rp-cli -e 'structure src/auth/'
# Structure of selected files
rp-cli -e 'structure --scope selected'
# Limit results
rp-cli -e 'structure src/ --max-results 10'
搜索
# Basic search
rp-cli -e 'search "pattern"'
# With context lines
rp-cli -e 'search "error" --context-lines 3'
# Filter by extension
rp-cli -e 'search "TODO" --extensions .ts,.tsx'
# Limit results
rp-cli -e 'search "function" --max-results 20'
读取文件 - 节省 Token
# Full file
rp-cli -e 'read path/to/file.ts'
# Line range (slice)
rp-cli -e 'read path/to/file.ts --start-line 50 --limit 30'
# Last N lines (tail)
rp-cli -e 'read path/to/file.ts --start-line -20'
选择管理
# Add files to selection
rp-cli -e 'select add src/auth/'
# Set selection (replace)
rp-cli -e 'select set src/api/ src/types/'
# Clear selection
rp-cli -e 'select clear'
# View current selection
rp-cli -e 'select get'
工作区上下文
# Get full context
rp-cli -e 'context'
# Specific includes
rp-cli -e 'context --include prompt,selection,tree'
链式命令
# Multiple operations
rp-cli -e 'select set src/auth/ && structure --scope selected && context'
工作区
# List workspaces
rp-cli -e 'workspace list'
# List tabs
rp-cli -e 'workspace tabs'
# Switch workspace
rp-cli -e 'workspace switch "ProjectName"'
AI 聊天(使用 RepoPrompt 的模型)
# Send to chat
rp-cli -e 'chat "How does the auth system work?"'
# Plan mode
rp-cli -e 'chat "Design a new feature" --mode plan'
上下文构建器(AI 驱动的文件选择)
# Auto-select relevant files for a task
rp-cli -e 'builder "implement user authentication"'
工作流简写标志
# Quick operations without -e syntax
rp-cli --workspace MyProject --select-set src/ --export-context ~/out.md
rp-cli --chat "How does auth work?"
rp-cli --builder "implement user authentication"
脚本文件(.rp)
对于可重复的工作流,可将命令保存到脚本中:
# daily-export.rp
workspace switch Frontend
select set src/components/
context --all > ~/exports/frontend.md
运行方式:
rp-cli --exec-file ~/scripts/daily-export.rp
CLI 标志
| 标志 | 用途 |
|---|---|
-e 'cmd' | 执行命令 |
-w <id> | 指定目标窗口 ID |
-q | 静默模式 |
-d <cmd> | 查看命令的详细帮助 |
--wait-for-server 5 | 等待连接(脚本) |
异步操作(tmux)
对于 builder 等长时间运行的操作,请使用异步脚本:
# Start context builder async
uv run python -m runtime.harness scripts/repoprompt_async.py \
--action start --task "understand the auth system"
# With workspace switch
uv run python -m runtime.harness scripts/repoprompt_async.py \
--action start --workspace "MyProject" --task "explore API patterns"
# Check status
uv run python -m runtime.harness scripts/repoprompt_async.py --action status
# Get result when done
uv run python -m runtime.harness scripts/repoprompt_async.py --action result
# Kill if needed
uv run python -m runtime.harness scripts/repoprompt_async.py --action kill
注意
需要 RepoPrompt 应用正在运行,并已启用 MCP Server。
评论
支持 Markdown