code-generator
$
npx mdskill add partme-ai/full-stack-skills/code-generatorGenerates production-ready code scaffolds, functions, classes, and project structures across multiple programming languages.
- Helps automate repetitive code creation tasks like building boilerplate classes or modules.
- Integrates with templates and specifications for Python, TypeScript, Java, and Go.
- Decides based on user requirements for language, framework, and coding conventions.
- Presents results as complete, documented code following validation and project patterns.
SKILL.md
.github/skills/code-generatorView on GitHub ↗
---
name: code-generator
description: "Generates production-ready code scaffolds, functions, classes, and project structures across Python, TypeScript, Java, and Go. Use when the user asks to generate code from templates, scaffold a new project, create boilerplate classes or modules, or automate repetitive code creation tasks."
---
## When to use this skill
Use this skill whenever the user wants to:
- Generate functions, classes, or modules with proper documentation and error handling
- Scaffold a new project with configuration files and directory structure
- Create boilerplate code (CRUD controllers, service layers, data models)
- Refactor or optimize existing code structure
- Generate code from templates or specifications
## How to use this skill
### Workflow
1. **Clarify requirements** - Identify the target language, framework, and coding conventions
2. **Choose the generation type** - Function/class, module/package, or full project scaffold
3. **Generate code** - Produce complete, documented, tested code following the patterns below
4. **Validate output** - Ensure the code compiles/runs and follows project conventions
### Code Generation Patterns
**Function generation (Python example):**
```python
def calculate_order_total(
items: list[OrderItem],
discount_pct: float = 0.0,
tax_rate: float = 0.08,
) -> Decimal:
"""Calculate the total price for an order including tax and discount.
Args:
items: List of order items with price and quantity.
discount_pct: Discount percentage (0.0 to 1.0).
tax_rate: Tax rate to apply after discount.
Returns:
Final order total as a Decimal rounded to 2 places.
Raises:
ValueError: If discount_pct is not between 0 and 1.
"""
if not 0 <= discount_pct <= 1:
raise ValueError(f"discount_pct must be 0-1, got {discount_pct}")
subtotal = sum(item.price * item.quantity for item in items)
discounted = subtotal * Decimal(1 - discount_pct)
total = discounted * Decimal(1 + tax_rate)
return total.quantize(Decimal("0.01"))
```
**Project scaffold (TypeScript/Node):**
```
my-service/
├── src/
│ ├── controllers/ # Route handlers
│ ├── services/ # Business logic
│ ├── models/ # Data models / DTOs
│ ├── middleware/ # Auth, logging, error handling
│ └── index.ts # Entry point
├── tests/
│ ├── unit/
│ └── integration/
├── package.json
├── tsconfig.json
└── README.md
```
### Supported Languages
- Python (with type hints, docstrings, pytest)
- JavaScript / TypeScript (ESM, JSDoc or TSDoc)
- Java (JavaDoc, Maven/Gradle)
- Go (godoc, modules)
- Rust (rustdoc, Cargo)
## Best Practices
1. **Always include error handling** - Validate inputs, use typed exceptions, return meaningful error messages
2. **Add documentation** - Every public function/class gets a docstring with params, returns, and raises
3. **Follow language conventions** - PEP 8 for Python, gofmt for Go, Prettier for TypeScript
4. **Generate tests alongside code** - At minimum, one happy-path and one error-path test per function
5. **Use type annotations** - Catch bugs early with static typing where the language supports it
## Keywords
代码生成, code generation, scaffold, boilerplate, template, 函数, 类, 模块, project structure, code scaffold, 项目脚手架
More from partme-ai/full-stack-skills
- adobe-xd"Guides creation of UI/UX designs, interactive prototypes, reusable components, and design specs in Adobe XD. Use when the user asks about Adobe XD artboards, prototype links, repeat grids, component states, design tokens export, or developer handoff."
- angular"Provides comprehensive guidance for Angular framework including components, modules, services, dependency injection, routing, forms, and TypeScript integration. Use when the user asks about Angular, needs to create Angular applications, implement Angular components, or work with Angular features."
- ansible"Provides comprehensive guidance for Ansible automation including playbooks, roles, inventory, and module usage. Use when the user asks about Ansible, needs to automate IT tasks, create Ansible playbooks, or manage infrastructure with Ansible."
- ant-design-mini"Builds mini-program UIs with Ant Design Mini components for Alipay and WeChat mini-programs. Covers Button, Form, List, Modal, Tabs, NavBar, and 60+ components with theme customization and CSS variable theming. Use when the user needs to create mini-program interfaces with Ant Design Mini, configure themes, or implement mini-program-specific UI patterns."
- ant-design-mobile"Builds React mobile UIs with Ant Design Mobile (antd-mobile) components including Button, Form, List, Modal, Picker, Tabs, PullToRefresh, InfiniteScroll, and 50+ mobile-optimized components. Use when the user needs to create mobile-first React interfaces, implement mobile navigation, forms, or data display with Ant Design Mobile."
- ant-design-react"Builds enterprise React UIs with Ant Design (antd) including 60+ components (Button, Form, Table, Select, Modal, Message), design tokens, TypeScript support, and ConfigProvider theming. Use when the user needs to create React applications with Ant Design, build forms with validation, display data tables, or customize the Ant Design theme."
- ant-design-vueProvides comprehensive guidance for Ant Design Vue (AntDV) component library for Vue 3. Covers installation, usage, API reference, templates, and all component categories. Use when building enterprise-class UI with Vue 3 and Ant Design.
- api-doc-generator"Generate API documentation by scanning Controller classes, extracting endpoint URLs, HTTP methods, parameters, and response structures, then producing standardized docs from templates. Use when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting REST APIs. Do not trigger for generic documentation requests without explicit API mention."
- appium"Provides comprehensive guidance for Appium mobile testing including mobile app automation, element location, gestures, and cross-platform testing. Use when the user asks about Appium, needs to test mobile applications, automate mobile apps, or write Appium test scripts."
- ascii-ansi-colorizer"Add an ANSI color layer to existing ASCII/plain-text output (gradient/rainbow/highlights) with alignment-safe rules and a required no-color fallback. Use when the user wants to colorize terminal output, add rainbow effects to CLI text, or style ASCII art with ANSI colors."