使用示例
实用示例,展示如何使用 Bob Shell 进行调试、代码改进、文件创建、文档生成和学习新概念。
修复 shell 命令中的错误
当您在 shell 命令中遇到错误时,Bob Shell 可以帮助诊断和修复:
# 导航到项目目录
cd your-project/
# 启动 Bob Shell
bob chat
# 切换到 shell 模式
> !
# 输入导致错误的命令
> make build
# 当您看到类似 'No rule to make target `xxx', needed by `yyy'.' 的错误消息时
# 按 ESC 或再次输入 '!' 退出 shell 模式
# 向 Bob Shell 寻求帮助
> Help me to fix the error代码解释与改进
Bob Shell 可以帮助您理解和改进现有代码:
# 在项目目录中启动 Bob Shell
bob chat
# 请求解释特定文件
> Explain what @src/utils.js does and how it works
# 请求对代码进行改进
> Review @src/api.js and suggest improvements for error handling创建新文件和功能
使用 Bob Shell 帮助您创建新组件或功能:
# 在项目目录中启动 Bob Shell
bob chat
# 请求帮助创建新组件
> Create a React component for a user profile page that displays name, email, and avatar
# 生成工具函数
> Write a utility function that formats dates in YYYY-MM-DD format调试协助
Bob Shell 可以帮助您调试代码中的问题:
# 在项目目录中启动 Bob Shell
bob chat
# 与 Bob Shell 共享错误日志
> I'm getting this error when running my app: "TypeError: Cannot read property 'map' of undefined". Here's the relevant code: @src/components/List.js
# 或直接将错误输出管道传给 Bob Shell
# 在终端中(不是在 Bob Shell 中)
npm run start 2>&1 | bob run "Help me understand and fix this error"文档生成
使用 Bob Shell 为代码生成文档:
# 在项目目录中启动 Bob Shell
bob chat
# 为特定文件生成文档
> Create JSDoc comments for all functions in @src/helpers.js
# 为项目生成 README
> Create a README.md file for my project based on the code in @src/index.js学习新概念
使用 Bob Shell 学习新技术或概念:
# 启动 Bob Shell
bob chat
# 询问特定技术
> Explain how React hooks work and give me examples of useState and useEffect
# 了解设计模式
> Explain the Observer pattern and how I might implement it in JavaScript这个主题怎么样?