code-generator
代码生成技能
概述
本技能帮助您生成高质量的代码,支持多种编程语言,遵循最佳实践和设计模式。
关键词: 代码生成、编程、函数、类、模块、项目开发、代码示例
核心功能
1. 函数和类生成
- 生成符合规范的函数和类
- 添加完整的文档注释
- 实现错误处理和边界检查
- 遵循语言特定的最佳实践
2. 模块和包开发
- 创建结构化的模块和包
- 设计清晰的 API 接口
- 实现模块间的依赖管理
- 创建配置文件和初始化代码
3. 项目脚手架
- 生成完整的项目结构
- 创建配置文件(package.json, requirements.txt 等)
- 设置构建和测试环境
- 添加 README 和文档
4. 代码优化和重构
- 优化代码性能和可读性
- 应用设计模式和最佳实践
- 重构代码结构
- 添加单元测试
使用指南
代码生成原则
- 清晰性: 代码应清晰易懂,命名规范
- 可维护性: 结构良好,易于修改和扩展
- 健壮性: 包含错误处理和边界检查
- 文档化: 提供完整的注释和文档
- 测试性: 代码应易于测试
支持的编程语言
- Python
- JavaScript/TypeScript
- Java
- Go
- Rust
- 其他常见编程语言
代码结构要求
- 导入部分: 清晰的导入语句
- 文档字符串: 函数和类的文档
- 实现代码: 核心逻辑实现
- 测试代码: 单元测试(如需要)
- 示例代码: 使用示例(如需要)
输出格式
生成的代码应包含:
- 代码文件: 完整的源代码文件
- 文档注释: 函数、类、模块的文档
- 使用示例: 代码使用示例
- 依赖说明: 所需的依赖和版本
- 测试代码: 相关的测试用例
最佳实践
- 遵循语言的编码规范和风格指南
- 使用有意义的变量和函数名
- 添加类型提示(如适用)
- 实现适当的错误处理
- 编写清晰的文档注释
- 考虑性能和可扩展性
- 遵循 SOLID 原则和设计模式
More from teachingai/agent-skills
element-plus-vue3
Provides comprehensive guidance for Element Plus Vue 3 component library including installation, components, themes, internationalization, and API reference. Use when the user asks about Element Plus for Vue 3, needs to build Vue 3 applications with Element Plus, or customize component styles.
9vue2
Provides comprehensive guidance for Vue 2.x development including Options API, components, directives, lifecycle hooks, computed properties, watchers, Vuex state management, and Vue Router. Use when the user asks about Vue 2, needs to create Vue 2 components, implement reactive data binding, handle component communication, or work with Vue 2 ecosystem tools.
8cypress
Provides comprehensive guidance for Cypress end-to-end testing including commands, assertions, component testing, CI/CD integration, and best practices. Use when the user asks about Cypress, needs to write E2E tests, component tests, or configure Cypress for testing.
8cocos2d-x
Provides comprehensive guidance for Cocos2d-x v4 game engine including scene graph, nodes, sprites, actions, animations, physics, rendering, shaders, and platform deployment. Use when the user asks about Cocos2d-x, needs to create games, implement game features, set up development environments, or deploy games to multiple platforms.
7dalle
Provides comprehensive guidance for DALL-E AI image generation including prompt creation, image generation, variations, and editing. Use when the user asks about DALL-E, needs to generate AI images, create image variations, or work with DALL-E API.
6canvas-design
Creates museum-quality visual art as .png or .pdf by first generating a design philosophy manifesto, then expressing it on canvas with precise composition, color palettes, and typography. Use when the user asks to create a poster, art piece, visual design, or static creative piece. Outputs original designs using design-forward principles.
6