codemap_template_add
Create or update a code template with reusable scaffolding content
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | ✅ Required | Template name |
content | string | ✅ Required | Template content |
Usage Examples
MCP Usage (for AI Agents like Claude)
json
{
"name": "codemap_template_add",
"arguments": {
"name": "mcp-tool",
"content": "/**\n * Tool: codemap_{{TOOL_NAME}}\n */\n\nimport { z } from 'zod';\nimport type { ToolDefinition, ToolHandler } from '../../registry/types.js';\n\nexport const inputSchema = z.object({\n // Define parameters here\n});\n\nexport const metadata: ToolDefinition = {\n name: 'codemap_{{TOOL_NAME}}',\n description: '{{DESCRIPTION}}',\n category: '{{CATEGORY}}',\n tags: []\n};\n\nexport const handler: ToolHandler<typeof inputSchema> = async (args, ctx) => {\n // Implementation here\n};"
}
}Example Output
JSON Response
json
{
"success": true,
"message": "Template 'mcp-tool' created successfully",
"name": "mcp-tool",
"path": ".codemap/templates/mcp-tool.txt",
"size": 1024
}When to Use This Tool
-
Use
- Create reusable code scaffolding for common patterns in your project
- Standardize how new files are created across the team
- Build a library of boilerplate code for faster development
- Store project-specific code patterns with placeholders
- Update existing templates with improved versions
codemap_template_add when you need to:
Common Patterns
Template with Placeholders Pattern
Use double curly braces
Team Standards Pattern
1. Create template with {{PLACEHOLDER}} syntax
2. Deploy template to target file
3. Use replace_text to customize placeholdersUse double curly braces
{{NAME}} for values that should be replaced after deployment.Team Standards Pattern
1. Define team coding standards
2. Create templates embodying those standards
3. Team members deploy templates for new files
4. Consistency achieved automaticallyPro Tips
- Placeholder convention: Use
{{UPPERCASE_NAME}}for placeholders that should be replaced after deployment - Templates are updatable: Calling
template_addwith existing name updates the template - Storage format: Templates stored as
.txtfiles in.codemap/templates/ - No size limit: Templates can be any size - from snippets to entire file structures
- Version templates: Consider naming templates with versions (component-v2) when making breaking changes
Best Practices
- Use descriptive, kebab-case names for templates (react-component, api-endpoint, test-suite)
- Include comments in templates explaining what should be customized
- Create templates for all common file types in your project
- Document available templates in your project README
- Use consistent placeholder naming across all templates (
{{COMPONENT_NAME}},{{SERVICE_NAME}}) - Test templates by deploying and customizing them before sharing with team
Common Mistakes
❌ Mistake: Creating templates without placeholders, requiring manual edits
✅ Instead: Use
❌ Mistake: Inconsistent placeholder naming (
✅ Instead: Use consistent
❌ Mistake: Not testing templates before sharing with team
✅ Instead: Deploy and customize templates yourself to ensure they work correctly
❌ Mistake: Creating templates that are too specific and rarely reused
✅ Instead: Focus on patterns you use frequently - 3+ times indicates template-worthy
❌ Mistake: Forgetting to update templates when project patterns change
✅ Instead: Review and update templates regularly to match current best practices
✅ Instead: Use
{{PLACEHOLDER}} syntax for values that need customization❌ Mistake: Inconsistent placeholder naming (
{{name}}, {{NAME}}, {{componentName}})✅ Instead: Use consistent
{{UPPERCASE_SNAKE}} format for all placeholders❌ Mistake: Not testing templates before sharing with team
✅ Instead: Deploy and customize templates yourself to ensure they work correctly
❌ Mistake: Creating templates that are too specific and rarely reused
✅ Instead: Focus on patterns you use frequently - 3+ times indicates template-worthy
❌ Mistake: Forgetting to update templates when project patterns change
✅ Instead: Review and update templates regularly to match current best practices