code-generation-template — Claude Code skill: generate code
A skill for generating code from templates: project scaffolding, boilerplate, AST-based generation and template engines. Useful when you need to produce repetitive code fast.
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a claude-codeWhat code-generation-template does
The skill covers code generation techniques: template engines, AST manipulation, scaffolding and automated boilerplate. Inside you get a short guide plus reference files in the references/ directory — template engines, AST-based generation, project scaffolding, OpenAPI client generation, database model generation, GraphQL code generation and the Plop.js generator.
The quick start shows a Handlebars component template: a props interface, the component itself, and the pascalCase and kebabCase helpers. From there the skill advises keeping templates configurable, versioning them, including tests and docs in generated code, and validating inputs before generation. A separate list covers what to avoid: hardcoded values in templates, mixing business logic into templates, building generators for one-off cases.
The skill installs through npx skills add and runs in Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. It is a set of instructions, not a ready-made generator — you still build the working CLI yourself from the references. If your project already has a code generator, this skill will overlap with it, so it is worth checking whether extending the existing one is simpler.
What it helps with
- scaffold a new project or component
- generate repetitive boilerplate code
- create CRUD operations automatically
- build an API client from an OpenAPI spec
- generate TypeScript types from JSON Schema
Example prompts for the agent
- generate a React component from
templates/component.hbswith name and type props - scaffold a new TypeScript project
- generate an API client from an OpenAPI spec
How to install code-generation-template
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a claude-code2Manually: put the files in place
~/.claude/skills/code-generation-template/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/code-generation-template/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a codex2Manually: put the files in place
.agents/skills/code-generation-template/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a cursor2Manually: put the files in place
.cursor/skills/code-generation-template/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts code-generation-template2Manually: put the files in place
.github/skills/code-generation-template/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/code-generation-templateManually: put the files in place
.devin/skills/code-generation-template/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about code-generation-template
How do I install code-generation-template in Claude?
Run npx skills add aj-geddes/useful-ai-prompts --skill code-generation-template -a claude-code. The skill lands in ~/.claude/skills/code-generation-template/SKILL.md.
What does code-generation-template do?
It covers code generation techniques: template engines, AST work, project scaffolding and boilerplate creation. It ships reference guides for each area plus a Handlebars template example.
Which platforms does the skill support?
Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each platform has its own install command.
Source text
SKILL.md · MIT
---
name: code-generation-template
description: >
Generate code from templates and patterns including scaffolding, boilerplate
generation, AST-based code generation, and template engines. Use when
generating code, scaffolding projects, creating boilerplate, or using
templates.
---
# Code Generation & Templates
## Table of Contents
- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)
## 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:
```typescript
// 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:
| Guide | Contents |
|---|---|
| [Template Engines](references/template-engines.md) | Template Engines |
| [AST-Based Code Generation](references/ast-based-code-generation.md) | AST-Based Code Generation |
| [Project Scaffolding](references/project-scaffolding.md) | Project Scaffolding |
| [OpenAPI Client Generation](references/openapi-client-generation.md) | OpenAPI Client Generation |
| [Database Model Generation](references/database-model-generation.md) | Database Model Generation |
| [GraphQL Code Generation](references/graphql-code-generation.md) | GraphQL Code Generation |
| [Plop.js Generator](references/plopjs-generator.md) | Plop.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
© aj-geddes · MIT · aj-geddes/useful-ai-prompts