Overview
This skill helps you generate high-quality code, supports multiple programming languages, and follows best practices and design patterns.
Keywords: code generation, programming, functions, classes, modules, project development, code examples
Core Features
1. Function and Class Generation
- Generate functions and classes that conform to standards
- Add complete documentation comments
- Implement error handling and boundary checks
- Follow language-specific best practices
2. Module and Package Development
- Create structured modules and packages
- Design clear API interfaces
- Implement dependency management between modules
- Create configuration files and initialization code
3. Project Scaffolding
- Generate a complete project structure
- Create configuration files (package.json, requirements.txt, etc.)
- Set up the build and test environment
- Add README and documentation
4. Code Optimization and Refactoring
- Optimize code performance and readability
- Apply design patterns and best practices
- Refactor code structure
- Add unit tests
Usage Guide
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
- Other common programming languages
Code Structure Requirements
- Import Section: Clear import statements
- Docstrings: Documentation for functions and classes
- Implementation Code: Core logic implementation
- Test Code: Unit tests (if needed)
- Example Code: Usage examples (if needed)
Output Format
The generated code should include:
- Code Files: Complete source code files
- Documentation Comments: Documentation for functions, classes, and modules
- Usage Examples: Code usage examples
- Dependency Description: Required dependencies and versions
- Test Code: Related test cases
Best Practices
- Follow the language's coding standards and style guides
- Use meaningful variable and function names
- Add type hints (if applicable)
- Implement appropriate error handling
- Write clear documentation comments
- Consider performance and scalability
- Follow SOLID principles and design patterns
Common Gotchas
- Version Compatibility: Pay attention to compatibility between framework versions and dependency libraries; APIs may differ across versions
- Configuration File Format: Configuration file format errors are the most common issue; it is recommended to use the editor's syntax checking
- Environment variables: Ensure all necessary environment variables are set correctly, and do not hardcode sensitive information
- Dependency conflicts: When multiple versions coexist, watch out for dependency conflicts, and use a lock file to pin versions
- Performance pitfalls: In large data volume scenarios, pay attention to performance optimization and avoid common problems such as N+1 queries
Usage workflow
Step 1: Environment preparation
Ensure that the necessary dependencies and tools are installed in the development environment.
Step 2: Configuration initialization
Perform basic configuration according to project requirements.
Step 3: Use of core functionality
Implement the core functionality according to the example code.
Step 4: Test verification
Run tests to ensure the functionality works properly.
Step 5: Deployment and release
After development is complete, perform deployment and monitoring.