debug-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCLI Debug Skill
CLI调试技能
This skill provides a systematic workflow for debugging and verifying changes to the forge CLI application.
本技能为调试和验证forge CLI应用的更改提供了系统化的工作流。
Core Principles
核心原则
- Always get latest docs first: Run to see current commands and options
--help - Use for testing: Test forge by giving it tasks with the
-pflag-p - Never commit: This is for debugging only - don't commit changes
- Clone conversations: When debugging conversation bugs, clone the source conversation before reproducing
- 先获取最新文档:运行查看当前命令和选项
--help - 使用进行测试:通过
-p标志给forge分配任务来进行测试-p - 切勿提交代码:这仅用于调试 - 不要提交更改
- 克隆对话:调试对话相关bug时,先克隆源对话再复现问题
Workflow
工作流
1. Build the Application
1. 构建应用
Always build in debug mode after making changes:
bash
cargo buildNever use for debugging - it's significantly slower and unnecessary for verification.
cargo build --release修改代码后,始终以调试模式构建:
bash
cargo build绝对不要在调试时使用——它的速度明显更慢,而且验证时完全没必要。
cargo build --release2. Get Latest Documentation
2. 获取最新文档
Always start by checking the latest help to understand current commands and options:
bash
undefined务必先查看最新帮助文档,了解当前的命令和选项:
bash
undefinedMain help - do this first
主帮助文档 - 先执行这个
./target/debug/forge --help
./target/debug/forge --help
Command-specific help
命令专属帮助文档
./target/debug/forge [COMMAND] --help
./target/debug/forge [COMMAND] --help
Subcommand help
子命令帮助文档
./target/debug/forge [COMMAND] [SUBCOMMAND] --help
undefined./target/debug/forge [COMMAND] [SUBCOMMAND] --help
undefined3. Test with -p
Flag
-p3. 使用-p
标志进行测试
-pUse the flag to give forge a task to complete without interactive mode:
-pbash
undefined使用标志给forge分配任务,无需进入交互模式:
-pbash
undefinedTest with a simple prompt
用简单提示测试
./target/debug/forge -p "create a hello world rust program"
./target/debug/forge -p "create a hello world rust program"
Test with specific functionality
测试特定功能
./target/debug/forge -p "read the README.md file and summarize it"
./target/debug/forge -p "read the README.md file and summarize it"
Test with complex tasks
测试复杂任务
./target/debug/forge -p "analyze the code structure and suggest improvements"
undefined./target/debug/forge -p "analyze the code structure and suggest improvements"
undefined4. Debug with Conversation Dumps
4. 借助对话转储调试
When debugging prompts or conversation issues, use to export conversations. The command automatically creates a timestamped file:
conversation dumpbash
undefined调试提示词或对话相关问题时,使用导出对话。该命令会自动创建带时间戳的文件:
conversation dumpbash
undefinedDump conversation as JSON (creates: YYYY-MM-DD_HH-MM-SS-dump.json)
将对话导出为JSON(生成:YYYY-MM-DD_HH-MM-SS-dump.json)
./target/debug/forge conversation dump <conversation-id>
./target/debug/forge conversation dump <conversation-id>
Export as HTML for human-readable format (creates: YYYY-MM-DD_HH-MM-SS-dump.html)
导出为HTML格式以便人类阅读(生成:YYYY-MM-DD_HH-MM-SS-dump.html)
./target/debug/forge conversation dump --html <conversation-id>
./target/debug/forge conversation dump --html <conversation-id>
Use dumped JSON to reproduce issues
使用导出的JSON对话复现问题
./target/debug/forge --conversation 2025-11-23_12-28-52-dump.json
undefined./target/debug/forge --conversation 2025-11-23_12-28-52-dump.json
undefined5. Clone Before Reproducing Bugs
5. 复现bug前先克隆对话
Critical: When a user provides a conversation with a bug, always clone it first:
bash
undefined关键步骤:当用户提供存在bug的对话时,务必先克隆它:
bash
undefinedClone the conversation
克隆对话
./target/debug/forge conversation clone <source-conversation-id>
./target/debug/forge conversation clone <source-conversation-id>
This creates a new conversation ID - use that for testing
这会生成一个新的对话ID - 使用该ID进行测试
./target/debug/forge --conversation-id <new-cloned-id>
./target/debug/forge --conversation-id <new-cloned-id>
Keep cloning the source until the fix is verified
在修复验证完成前,持续克隆源对话
Never modify the original conversation
绝对不要修改原始对话
**Why clone?**
- Preserves original bug evidence
- Allows multiple reproduction attempts
- Enables A/B testing of fixes
- Keeps source conversation clean
**为什么要克隆?**
- 保留原始bug证据
- 允许多次复现尝试
- 支持修复方案的A/B测试
- 保持源对话干净无修改Common Testing Patterns
常见测试模式
Test New Features
测试新功能
bash
undefinedbash
undefinedBuild and test new command
构建并测试新命令
cargo build
./target/debug/forge --help # Verify new command appears
./target/debug/forge new-command --help # Check command docs
./target/debug/forge -p "test the new feature"
undefinedcargo build
./target/debug/forge --help # 验证新命令是否显示
./target/debug/forge new-command --help # 检查命令文档
./target/debug/forge -p "test the new feature"
undefinedReproduce Reported Bugs
复现上报的bug
bash
undefinedbash
undefined1. Dump the conversation (creates timestamped JSON file)
1. 导出对话(生成带时间戳的JSON文件)
./target/debug/forge conversation dump <bug-conversation-id>
./target/debug/forge conversation dump <bug-conversation-id>
2. Clone it for testing (preserves original)
2. 克隆对话用于测试(保留原始对话)
./target/debug/forge conversation clone <bug-conversation-id>
./target/debug/forge conversation clone <bug-conversation-id>
3. Reproduce with the cloned conversation
3. 使用克隆的对话复现问题
./target/debug/forge --conversation-id <cloned-id> -p "reproduce the issue"
./target/debug/forge --conversation-id <cloned-id> -p "reproduce the issue"
4. After fix, verify with new clone
4. 修复后,用新克隆的对话验证
./target/debug/forge conversation clone <bug-conversation-id>
./target/debug/forge --conversation-id <new-clone-id> -p "verify fix"
undefined./target/debug/forge conversation clone <bug-conversation-id>
./target/debug/forge --conversation-id <new-clone-id> -p "verify fix"
undefinedTest Edge Cases
测试边缘情况
bash
undefinedbash
undefinedTest with missing arguments
测试缺失参数的情况
./target/debug/forge command
./target/debug/forge command
Test with invalid input
测试无效输入
./target/debug/forge -p "invalid task with special chars: <>|&"
./target/debug/forge -p "invalid task with special chars: <>|&"
Test with boundary values
测试边界值
./target/debug/forge -p "create a file with a very long name..."
undefined./target/debug/forge -p "create a file with a very long name..."
undefinedDebug Prompt Optimization
调试提示词优化
bash
undefinedbash
undefined1. Dump conversation to analyze prompts (creates timestamped JSON)
1. 导出对话以分析提示词(生成带时间戳的JSON)
./target/debug/forge conversation dump <id>
./target/debug/forge conversation dump <id>
2. Review the conversation structure
2. 查看对话结构
cat 2025-11-23_12-28-52-dump.json | jq '.messages[] | {role, content}'
cat 2025-11-23_12-28-52-dump.json | jq '.messages[] | {role, content}'
3. Export as HTML for easier reading
3. 导出为HTML以便更易阅读
./target/debug/forge conversation dump --html <id>
./target/debug/forge conversation dump --html <id>
4. Test modified prompts
4. 测试修改后的提示词
./target/debug/forge -p "your optimized prompt here"
undefined./target/debug/forge -p "your optimized prompt here"
undefinedIntegration with Development Workflow
与开发工作流集成
After Code Changes
代码修改后
- Build:
cargo build - Docs: (verify documentation)
./target/debug/forge --help - Test:
./target/debug/forge -p "relevant task" - Verify: Check output matches expectations
- 构建:
cargo build - 文档:(验证文档)
./target/debug/forge --help - 测试:
./target/debug/forge -p "relevant task" - 验证:检查输出是否符合预期
Debugging a Bug Report
调试bug报告
- Clone:
./target/debug/forge conversation clone <source-id> - Build: (with potential fixes)
cargo build - Test:
./target/debug/forge --conversation-id <cloned-id> -p "reproduce" - Iterate: Repeat until verified
- Never commit during debugging - only after full verification
- 克隆:
./target/debug/forge conversation clone <source-id> - 构建:(包含潜在修复)
cargo build - 测试:
./target/debug/forge --conversation-id <cloned-id> -p "reproduce" - 迭代:重复直到验证通过
- 切勿提交:调试期间不要提交代码 - 仅在完全验证后提交
Quick Reference
快速参考
bash
undefinedbash
undefinedStandard debug workflow
标准调试工作流
cargo build
./target/debug/forge --help # Always check docs first
./target/debug/forge -p "your test task"
cargo build
./target/debug/forge --help # 始终先检查文档
./target/debug/forge -p "your test task"
Dump conversation (creates timestamped file)
导出对话(生成带时间戳的文件)
./target/debug/forge conversation dump <id>
./target/debug/forge conversation dump <id>
Output: 2025-11-23_12-28-52-dump.json
输出:2025-11-23_12-28-52-dump.json
Export as HTML for review
导出为HTML以便查看
./target/debug/forge conversation dump --html <id>
./target/debug/forge conversation dump --html <id>
Output: 2025-11-23_12-28-52-dump.html
输出:2025-11-23_12-28-52-dump.html
Use dumped conversation
使用导出的对话
./target/debug/forge --conversation 2025-11-23_12-28-52-dump.json
./target/debug/forge --conversation 2025-11-23_12-28-52-dump.json
Clone and test bug
克隆并测试bug
./target/debug/forge conversation clone <source-id>
./target/debug/forge --conversation-id <cloned-id> -p "reproduce bug"
./target/debug/forge conversation clone <source-id>
./target/debug/forge --conversation-id <cloned-id> -p "reproduce bug"
Debug prompts with jq (use actual filename)
使用jq调试提示词(使用实际文件名)
cat 2025-11-23_12-28-52-dump.json | jq '.messages[] | {role, content}'
cat 2025-11-23_12-28-52-dump.json | jq '.messages[] | {role, content}'
Test with verbose output
带详细输出的测试
./target/debug/forge --verbose -p "test task"
undefined./target/debug/forge --verbose -p "test task"
undefinedTips
提示
- Always first: Get latest docs before testing
--help - Use for testing: Don't test interactively, use prompts
-p - Clone conversations: Never modify original bug conversations
- Never commit: This is for debugging only
- Dump creates files: automatically creates timestamped files (no
dumpneeded)> - HTML exports: Use flag for human-readable conversation views
--html - Use relative paths: Binary is at from project root
./target/debug/forge - Check exit codes: Use to verify exit codes
echo $? - Watch for warnings: Build warnings often indicate issues
- 始终先执行:测试前先获取最新文档
--help - 使用进行测试:不要在交互模式下测试,使用提示词
-p - 克隆对话:永远不要修改原始bug对话
- 切勿提交代码:这仅用于调试
- 导出会生成文件:会自动生成带时间戳的文件(无需使用
dump)> - HTML导出:使用标志获取人类可读的对话视图
--html - 使用相对路径:二进制文件位于项目根目录下的
./target/debug/forge - 检查退出码:使用验证退出码
echo $? - 注意构建警告:构建警告通常预示着问题