Skip to main content
Glama

generate_readme_template

Create standardized README templates for various project types with best practices, including libraries, applications, CLI tools, APIs, and documentation.

Instructions

Generate standardized README templates for different project types with best practices

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNameYesName of the project
descriptionYesBrief description of what the project does
templateTypeYesType of project template to generate
authorNoProject author/organization name
licenseNoProject licenseMIT
includeScreenshotsNoInclude screenshot placeholders for applications
includeBadgesNoInclude status badges
includeContributingNoInclude contributing section
outputPathNoPath to write the generated README.md file

Implementation Reference

  • Main handler function that validates the input schema, instantiates the template generator, generates the README content, handles optional file output, and returns the result with metadata.
    export async function generateReadmeTemplate( input: GenerateReadmeTemplateInput, ): Promise<{ content: string; metadata: { templateType: TemplateType; estimatedLength: number; sectionsIncluded: number; }; }> { const validatedInput = GenerateReadmeTemplateSchema.parse(input); const generator = new ReadmeTemplateGenerator(); const content = generator.generateTemplate(validatedInput); const templateInfo = generator.getTemplateInfo(validatedInput.templateType); if (!templateInfo) { throw new Error(`Template type "${validatedInput.templateType}" not found`); } // Write to file if output path specified if (validatedInput.outputPath) { const fs = await import("fs/promises"); await fs.writeFile(validatedInput.outputPath, content, "utf-8"); } return { content, metadata: { templateType: validatedInput.templateType, estimatedLength: templateInfo.estimatedLength, sectionsIncluded: content.split("##").length - 1, }, }; }
  • Zod input schema defining parameters for the tool including project details, template type, and optional flags.
    export const GenerateReadmeTemplateSchema = z.object({ projectName: z.string().min(1, "Project name is required"), description: z.string().min(1, "Project description is required"), templateType: TemplateType, author: z.string().optional(), license: z.string().default("MIT"), includeScreenshots: z.boolean().default(false), includeBadges: z.boolean().default(true), includeContributing: z.boolean().default(true), outputPath: z.string().optional(), });
  • Zod enum schema for supported README template types used in the main input schema.
    export const TemplateType = z.enum([ "library", "application", "cli-tool", "api", "documentation", ]);
  • Core helper method in ReadmeTemplateGenerator class that processes the template sections, handles conditional inclusion of badges, screenshots, and contributing sections, and assembles the final README string.
    generateTemplate(input: GenerateReadmeTemplateInput): string { const template = this.templates.get(input.templateType); if (!template) { throw new Error(`Template type "${input.templateType}" not supported`); } let readme = ""; const camelCaseName = this.toCamelCase(input.projectName); // Process each section for (const section of template.sections) { if (section.title === "Badges" && input.includeBadges) { readme += this.processBadges(template.badges, input) + "\n\n"; } else if (section.title === "Screenshot" && input.includeScreenshots) { readme += this.processScreenshot(input) + "\n\n"; } else if ( section.title === "Contributing" && !input.includeContributing ) { continue; } else { readme += this.processSection(section.content, input, camelCaseName) + "\n\n"; } } return readme.trim(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tosin2013/documcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server