Agent skill

code-generator

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.

Stars 254
Forks 41

Install this agent skill to your Project

npx add-skill https://github.com/partme-ai/full-stack-skills/tree/main/skills/dev-utils-skills/code-generator

SKILL.md

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, 项目脚手架

Expand your agent's capabilities with these related and highly-rated skills.

partme-ai/full-stack-skills

ocrmypdf-batch

OCRmyPDF batch processing skill — process multiple PDFs, Docker automation, shell scripting, and CI/CD integration. Use when the user needs to OCR many PDFs, set up automated OCR pipelines, or integrate OCR into workflows.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-optimize

OCRmyPDF optimization skill — compress PDFs, configure PDF/A output, JBIG2 encoding, and lossless optimization. Use when the user needs to reduce PDF file size, create archival PDF/A files, or optimize OCR output.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-image

OCRmyPDF image processing skill — deskew, rotate, clean, despeckle, remove border from scanned documents. Use when the user needs to improve scanned PDF quality, fix skewed pages, remove noise, or clean up scanned documents before OCR.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-api

OCRmyPDF Python API and plugin skill — use OCRmyPDF programmatically from Python, integrate with applications, and extend with plugins (EasyOCR, PaddleOCR, AppleOCR). Use when the user needs to call OCRmyPDF from Python code, build OCR pipelines, or use alternative OCR engines.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf

OCRmyPDF core skill — add searchable OCR text layer to scanned PDFs, convert images to searchable PDFs, support 100+ languages via Tesseract. Use when the user needs to OCR a PDF, make a scanned PDF searchable, or extract text from scanned documents.

254 41
Explore
partme-ai/full-stack-skills

svelte

Guides Svelte and SvelteKit development including reactive components, stores, transitions, lifecycle hooks, SSR, file-based routing, and deployment. Use when the user needs to build Svelte components, create SvelteKit applications, implement reactivity patterns, or configure Svelte with Vite.

254 41
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results