mcpField
C
code-generation-template

code-generation-template

github.com/aj-geddesDevelopment373534 installsUpdated 34w ago
Repository

About code-generation-template

A code generation skill for developers automating scaffolding and repetitive code. It covers templates, AST techniques, schema-based generation, and CLI generators, with guidance on validation and maintainability.

Key features

  1. 01Template-based code generation
  2. 02AST-based generation techniques
  3. 03Project and component scaffolding
  4. 04API client and model generation
  5. 05Custom CLI generator guidance
  6. 06Validation and maintenance practices

Use cases

  1. 01Scaffolding a new project or component
  2. 02Generating CRUD code from patterns
  3. 03Creating API clients from OpenAPI specs
  4. 04Building types from JSON Schema

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill code-generation-template

After installing, type/code-generation-templatein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
ast-based-code-generation.md
database-model-generation.md
graphql-code-generation.md
openapi-client-generation.md
plopjs-generator.md
project-scaffolding.md
template-engines.md
scripts/
validate-api.sh
templates/
api-scaffold.yaml

Details

From the project README

Code Generation & Templates

Table of Contents

Overview

Comprehensive guide to code generation techniques including template engines, AST manipulation, code scaffolding, and automated boilerplate generation for increased productivity and consistency.

When to Use

  • Scaffolding new projects or components
  • Generating repetitive boilerplate code
  • Creating CRUD operations automatically
  • Generating API clients from OpenAPI specs
  • Building code from templates
  • Creating database models from schemas
  • Generating TypeScript types from JSON Schema
  • Building custom CLI generators

Quick Start

Minimal working example:

// templates/component.hbs
import React from 'react';

export interface {{pascalCase name}}Props {
  {{#each props}}
  {{this.name}}{{#if this.optional}}?{{/if}}: {{this.type}};
  {{/each}}
}

export const {{pascalCase name}}: React.FC<{{pascalCase name}}Props> = ({
  {{#each props}}{{this.name}},{{/each}}
}) => {
  return (
    <div className="{{kebabCase name}}">
      {/* Component implementation */}
    </div>
  );
};

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Template EnginesTemplate Engines
AST-Based Code GenerationAST-Based Code Generation
Project ScaffoldingProject Scaffolding
OpenAPI Client GenerationOpenAPI Client Generation
Database Model GenerationDatabase Model Generation
GraphQL Code GenerationGraphQL Code Generation
Plop.js GeneratorPlop.js Generator

Best Practices

✅ DO
  • Use templates for repetitive code patterns
  • Generate TypeScript types from schemas
  • Include tests in generated code
  • Follow project conventions in templates
  • Add comments to explain generated code
  • Version control your templates
  • Make templates configurable
  • Generate documentation alongside code
  • Validate inputs before generating
  • Use consistent naming conventions
  • Keep templates simple and maintainable
  • Provide CLI for easy generation
❌ DON'T
  • Over-generate (avoid unnecessary complexity)
  • Generate code that's hard to maintain
  • Forget to validate generated code
  • Hardcode values in templates
  • Generate code without documentation
  • Create generators for one-off use cases
  • Mix business logic in templates
  • Generate code without formatting
  • Skip error handling in generators
  • Create overly complex templates

Comments

Markdown supported