macOS x64 binary distribution package for the moon repository management tool
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Commands for generating code from templates and managing template libraries to accelerate development and maintain consistency across projects.
Generate and scaffold files from a pre-defined template into the workspace.
moon generate <name> [dest] [--defaults] [--dry-run] [--force] [--template]Alias: moon g
Arguments:
name (required) - Name of the template to generate fromdest (optional) - Destination path relative to workspace root or working directoryOptions:
--defaults - Use default values for all template variables instead of prompting--dry-run - Run the entire generation process without writing any files--force - Force overwrite any existing files at the destination--template - Create a new template instead of generating from an existing oneUsage Examples:
# Generate using interactive prompts
moon generate react-component
# Generate to specific destination
moon generate react-component ./src/components/NewComponent
# Use short alias
moon g nodejs-app ./apps/my-new-app
# Use defaults without prompting
moon generate typescript-library --defaults
# Preview generation without creating files
moon generate react-component --dry-run
# Force overwrite existing files
moon generate api-endpoint ./src/api/users --force
# Create a new template
moon generate my-template --templateDisplay all templates available for code generation in the workspace.
moon templates [--filter <PATTERN>] [--json]Options:
--filter <PATTERN> - Filter templates based on name or description pattern--json - Output template information in JSON formatUsage Examples:
# List all available templates
moon templates
# Filter templates by pattern
moon templates --filter react
# Get template info as JSON
moon templates --json
# Filter with wildcard pattern
moon templates --filter "*-component"Sample Output:
Templates:
react-component Generate a React functional component with TypeScript
nodejs-api Generate a Node.js API server with Express
typescript-library Generate a TypeScript library package
nextjs-app Generate a Next.js application
documentation Generate documentation files and structureMoon templates are organized in the .moon/templates/ directory:
.moon/templates/
├── react-component/
│ ├── template.yml # Template configuration
│ ├── {{name}}.tsx # Component file template
│ ├── {{name}}.test.tsx # Test file template
│ └── index.ts # Export file template
├── nodejs-api/
│ ├── template.yml
│ ├── src/
│ │ ├── app.ts
│ │ └── routes/
│ ├── package.json
│ └── README.md
└── shared/ # Shared template partials
├── license.txt
└── gitignore.txtTemplates are configured using template.yml:
# Example template.yml
name: "React Component"
description: "Generate a React functional component with TypeScript"
destination: "src/components"
variables:
- name: "name"
description: "Component name"
type: "string"
required: true
- name: "withTests"
description: "Include test files"
type: "boolean"
default: true
- name: "styling"
description: "Styling approach"
type: "enum"
options: ["css-modules", "styled-components", "tailwind"]
default: "css-modules"
files:
- source: "{{name}}.tsx"
destination: "{{name}}/{{name}}.tsx"
- source: "{{name}}.test.tsx"
destination: "{{name}}/{{name}}.test.tsx"
condition: "{{withTests}}"
- source: "index.ts"
destination: "{{name}}/index.ts"Templates support various variable types:
Variables can be used in:
{{name}}.tsx)export const {{name}} = () => {}){{name}}/)Moon uses Handlebars-style templating:
// In template file: {{name}}.tsx
import React from 'react';
{{#if withTests}}
import { render } from '@testing-library/react';
{{/if}}
interface {{name}}Props {
{{#each props}}
{{name}}: {{type}};
{{/each}}
}
export const {{name}}: React.FC<{{name}}Props> = ({
{{#each props}}{{name}},{{/each}}
}) => {
return (
<div className="{{kebabCase name}}">
{/* {{description}} */}
</div>
);
};
{{#if withTests}}
// Test file content
describe('{{name}}', () => {
it('renders correctly', () => {
render(<{{name}} />);
});
});
{{/if}}Templates include built-in helper functions:
{{camelCase text}} - Convert to camelCase{{pascalCase text}} - Convert to PascalCase{{kebabCase text}} - Convert to kebab-case{{snakeCase text}} - Convert to snake_case{{upperCase text}} - Convert to UPPER_CASE{{lowerCase text}} - Convert to lower case# Create a new template interactively
moon generate my-template --template
# Manual template creation
mkdir .moon/templates/my-template
touch .moon/templates/my-template/template.yml
# Edit template.yml with configuration
# Add template files with variable placeholdersTemplates can be shared across projects:
# Export template
moon templates export react-component > react-component.tar.gz
# Import template
moon templates import react-component.tar.gz
# Sync templates from remote repository
moon templates sync --from https://github.com/company/moon-templates