Programming Assistant Skill
Overview
This skill enables OpenClaw to leverage Claude CLI for sophisticated programming tasks. It provides structured workflows for coding activities including project creation, code modification, debugging, and optimization.
When to Use This Skill
Use this skill when OpenClaw encounters tasks such as:
- - Creating new programs or scripts
- Modifying existing code files
- Debugging code issues
- Refactoring code for better performance/readability
- Performing code reviews
- Setting up new projects or adding features
- Converting code between languages or formats
- Generating documentation for code
Prerequisites
- - Claude CLI must be installed (
claude command available) - Claude desktop application should be accessible for IDE integration
- Sufficient permissions to read/write files in the target directory
Basic Usage Patterns
Pattern 1: Simple Code Generation
When tasked with creating new code:
- 1. Identify the target directory for the project
- Use
claude --ide to initiate the coding session - Provide specific instructions about the desired functionality
- Review the generated code for correctness
Pattern 2: Code Modification
When modifying existing code:
- 1. Determine the files that need to be changed
- Use
claude --ide --add-dir <project-path> to focus on the specific project - Request specific changes while preserving existing functionality
- Verify the changes meet requirements
Pattern 3: Project Setup
When setting up new projects:
- 1. Create the necessary directory structure
- Generate initial configuration files
- Set up basic file templates
- Ensure dependencies are properly documented
Workflow Steps
1. Assessment
- - Determine the scope of the programming task
- Identify the target directory and relevant files
- Assess complexity and potential challenges
2. Preparation
- - Ensure Claude CLI is available and authenticated
- Prepare any necessary context about the codebase
- Gather requirements and constraints
3. Execution
- - Use appropriate Claude CLI commands based on the task
- Monitor progress and intervene if needed
- Ensure code quality and adherence to requirements
4. Verification
- - Review generated code for correctness
- Test functionality if possible
- Validate that requirements were met
Available Tools Integration
The skill integrates with Claude CLI tools:
- - Bash: For running commands, tests, and system operations
- Edit: For modifying files directly
- Read: For reading files to understand context
- IDE Integration: For seamless code editing experience
Error Handling
- - If Claude CLI is unavailable, suggest alternative approaches
- If authentication is required, guide through setup process
- For complex projects, break tasks into smaller manageable pieces
- When facing permission issues, suggest alternative approaches
Best Practices
- 1. Always consider security implications when generating code
- Follow language-specific best practices and conventions
- Include appropriate error handling in generated code
- Add comments and documentation where appropriate
- Ensure generated code is maintainable and readable
编程助手技能
概述
本技能使OpenClaw能够利用Claude CLI执行复杂的编程任务。它为编码活动提供结构化工作流程,包括项目创建、代码修改、调试和优化。
何时使用此技能
当OpenClaw遇到以下任务时使用此技能:
- - 创建新程序或脚本
- 修改现有代码文件
- 调试代码问题
- 重构代码以提高性能/可读性
- 执行代码审查
- 设置新项目或添加功能
- 在不同语言或格式之间转换代码
- 为代码生成文档
前提条件
- - 必须安装Claude CLI(claude命令可用)
- Claude桌面应用程序应可访问以实现IDE集成
- 具有目标目录中读写文件的足够权限
基本使用模式
模式1:简单代码生成
当需要创建新代码时:
- 1. 确定项目的目标目录
- 使用claude --ide启动编码会话
- 提供关于所需功能的具体说明
- 检查生成的代码是否正确
模式2:代码修改
当修改现有代码时:
- 1. 确定需要更改的文件
- 使用claude --ide --add-dir <项目路径>聚焦于特定项目
- 在保留现有功能的同时请求特定更改
- 验证更改是否符合要求
模式3:项目设置
当设置新项目时:
- 1. 创建必要的目录结构
- 生成初始配置文件
- 设置基本文件模板
- 确保依赖项得到正确记录
工作流程步骤
1. 评估
- - 确定编程任务的范围
- 识别目标目录和相关文件
- 评估复杂性和潜在挑战
2. 准备
- - 确保Claude CLI可用且已认证
- 准备关于代码库的任何必要上下文
- 收集需求和约束条件
3. 执行
- - 根据任务使用适当的Claude CLI命令
- 监控进度并在必要时进行干预
- 确保代码质量并符合要求
4. 验证
- - 检查生成的代码是否正确
- 尽可能测试功能
- 验证是否满足需求
可用工具集成
本技能与Claude CLI工具集成:
- - Bash:用于运行命令、测试和系统操作
- 编辑:用于直接修改文件
- 读取:用于读取文件以理解上下文
- IDE集成:用于无缝代码编辑体验
错误处理
- - 如果Claude CLI不可用,建议替代方法
- 如果需要认证,引导完成设置过程
- 对于复杂项目,将任务分解为更小的可管理部分
- 当遇到权限问题时,建议替代方法
最佳实践
- 1. 生成代码时始终考虑安全影响
- 遵循特定语言的最佳实践和约定
- 在生成的代码中包含适当的错误处理
- 在适当的地方添加注释和文档
- 确保生成的代码可维护且可读