code-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese代码生成技能
Code Generation Skill
概述
Overview
本技能帮助您生成高质量的代码,支持多种编程语言,遵循最佳实践和设计模式。
关键词: 代码生成、编程、函数、类、模块、项目开发、代码示例
This skill helps you generate high-quality code, supports multiple programming languages, and adheres to best practices and design patterns.
Keywords: Code Generation, Programming, Functions, Classes, Modules, Project Development, Code Examples
核心功能
Core Features
1. 函数和类生成
1. Function and Class Generation
- 生成符合规范的函数和类
- 添加完整的文档注释
- 实现错误处理和边界检查
- 遵循语言特定的最佳实践
- Generate standardized functions and classes
- Add comprehensive documentation comments
- Implement error handling and boundary checks
- Adhere to language-specific best practices
2. 模块和包开发
2. Module and Package Development
- 创建结构化的模块和包
- 设计清晰的 API 接口
- 实现模块间的依赖管理
- 创建配置文件和初始化代码
- Create structured modules and packages
- Design clear API interfaces
- Implement dependency management between modules
- Create configuration files and initialization code
3. 项目脚手架
3. Project Scaffolding
- 生成完整的项目结构
- 创建配置文件(package.json, requirements.txt 等)
- 设置构建和测试环境
- 添加 README 和文档
- Generate complete project structures
- Create configuration files (package.json, requirements.txt, etc.)
- Set up build and testing environments
- Add README and documentation
4. 代码优化和重构
4. Code Optimization and Refactoring
- 优化代码性能和可读性
- 应用设计模式和最佳实践
- 重构代码结构
- 添加单元测试
- Optimize code performance and readability
- Apply design patterns and best practices
- Refactor code structure
- Add unit tests
使用指南
Usage Guidelines
代码生成原则
Code Generation Principles
- 清晰性: 代码应清晰易懂,命名规范
- 可维护性: 结构良好,易于修改和扩展
- 健壮性: 包含错误处理和边界检查
- 文档化: 提供完整的注释和文档
- 测试性: 代码应易于测试
- Clarity: Code should be clear and easy to understand, with standardized naming
- Maintainability: Well-structured, easy to modify and extend
- Robustness: Includes error handling and boundary checks
- Documentation: Provide complete comments and documentation
- Testability: Code should be easy to test
支持的编程语言
Supported Programming Languages
- Python
- JavaScript/TypeScript
- Java
- Go
- Rust
- 其他常见编程语言
- Python
- JavaScript/TypeScript
- Java
- Go
- Rust
- Other common programming languages
代码结构要求
Code Structure Requirements
- 导入部分: 清晰的导入语句
- 文档字符串: 函数和类的文档
- 实现代码: 核心逻辑实现
- 测试代码: 单元测试(如需要)
- 示例代码: 使用示例(如需要)
- Imports: Clear import statements
- Docstrings: Documentation for functions and classes
- Implementation Code: Core logic implementation
- Test Code: Unit tests (if required)
- Example Code: Usage examples (if required)
输出格式
Output Format
生成的代码应包含:
- 代码文件: 完整的源代码文件
- 文档注释: 函数、类、模块的文档
- 使用示例: 代码使用示例
- 依赖说明: 所需的依赖和版本
- 测试代码: 相关的测试用例
Generated code should include:
- Code Files: Complete source code files
- Documentation Comments: Documentation for functions, classes, and modules
- Usage Examples: Code usage examples
- Dependency Instructions: Required dependencies and versions
- Test Code: Relevant test cases
最佳实践
Best Practices
- 遵循语言的编码规范和风格指南
- 使用有意义的变量和函数名
- 添加类型提示(如适用)
- 实现适当的错误处理
- 编写清晰的文档注释
- 考虑性能和可扩展性
- 遵循 SOLID 原则和设计模式
- Follow language coding standards and style guides
- Use meaningful variable and function names
- Add type hints (where applicable)
- Implement appropriate error handling
- Write clear documentation comments
- Consider performance and scalability
- Adhere to SOLID principles and design patterns