create_goose_recipe
Create reusable Goose recipes for specialized subagents like code reviewers and security auditors, enabling AI clients to delegate tasks to autonomous developer teams with custom instructions and extensions.
Instructions
Create a reusable Goose recipe for specialized subagents
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recipe_name | Yes | Name of the recipe | |
| role | Yes | Agent role (e.g., code_reviewer, security_auditor) | |
| instructions | Yes | Detailed instructions for the agent | |
| extensions | No | List of Goose extensions to enable | |
| parameters | No | Recipe parameters |
Implementation Reference
- src/index.js:280-328 (handler)The handler function that implements the create_goose_recipe tool. It constructs a recipe object from input args, serializes it to YAML using objectToYaml helper, writes it to a file in goose-recipes directory, and returns a success message.async createGooseRecipe(args) { const { recipe_name, role, instructions, extensions = [], parameters = {} } = args; const recipe = { id: recipe_name, version: '1.0.0', title: `${role.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase())} Recipe`, description: `Specialized subagent for ${role}`, instructions: instructions, activities: [ `Perform ${role} tasks`, 'Analyze and provide feedback', 'Generate deliverables' ], extensions: extensions.map(ext => ({ type: 'builtin', name: ext, display_name: ext.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()), timeout: 300, bundled: true })), parameters: Object.entries(parameters).map(([key, value]) => ({ key, input_type: typeof value, requirement: 'optional', description: `Parameter for ${key}`, default: value })), prompt: instructions }; // Create recipes directory if it doesn't exist const recipesDir = path.join(process.cwd(), 'goose-recipes'); await fs.mkdir(recipesDir, { recursive: true }); // Write recipe file const recipeFile = path.join(recipesDir, `${recipe_name}.yaml`); const yamlContent = this.objectToYaml(recipe); await fs.writeFile(recipeFile, yamlContent); return { content: [ { type: 'text', text: `Successfully created Goose recipe "${recipe_name}" at ${recipeFile}\n\nRecipe details:\n- Role: ${role}\n- Extensions: ${extensions.join(', ') || 'none'}\n- Parameters: ${Object.keys(parameters).join(', ') || 'none'}\n\nTo use this recipe, set GOOSE_RECIPE_PATH environment variable to the recipes directory or place the recipe in your working directory.` } ] }; }
- src/index.js:87-117 (registration)Registration of the create_goose_recipe tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.{ name: 'create_goose_recipe', description: 'Create a reusable Goose recipe for specialized subagents', inputSchema: { type: 'object', properties: { recipe_name: { type: 'string', description: 'Name of the recipe' }, role: { type: 'string', description: 'Agent role (e.g., code_reviewer, security_auditor)' }, instructions: { type: 'string', description: 'Detailed instructions for the agent' }, extensions: { type: 'array', items: { type: 'string' }, description: 'List of Goose extensions to enable' }, parameters: { type: 'object', description: 'Recipe parameters' } }, required: ['recipe_name', 'role', 'instructions'] } },
- src/index.js:90-116 (schema)Input schema definition for the create_goose_recipe tool, specifying properties and required fields.inputSchema: { type: 'object', properties: { recipe_name: { type: 'string', description: 'Name of the recipe' }, role: { type: 'string', description: 'Agent role (e.g., code_reviewer, security_auditor)' }, instructions: { type: 'string', description: 'Detailed instructions for the agent' }, extensions: { type: 'array', items: { type: 'string' }, description: 'List of Goose extensions to enable' }, parameters: { type: 'object', description: 'Recipe parameters' } }, required: ['recipe_name', 'role', 'instructions'] }
- src/index.js:330-356 (helper)Helper function used by the handler to convert the recipe object to YAML format for file writing.objectToYaml(obj, indent = 0) { let yaml = ''; const spaces = ' '.repeat(indent); for (const [key, value] of Object.entries(obj)) { if (value === null || value === undefined) continue; if (Array.isArray(value)) { yaml += `${spaces}${key}:\n`; for (const item of value) { if (typeof item === 'object') { yaml += `${spaces}- \n${this.objectToYaml(item, indent + 1).split('\n').map(line => line ? `${spaces} ${line}` : '').join('\n')}\n`; } else { yaml += `${spaces}- ${item}\n`; } } } else if (typeof value === 'object') { yaml += `${spaces}${key}:\n${this.objectToYaml(value, indent + 1)}`; } else if (typeof value === 'string' && value.includes('\n')) { yaml += `${spaces}${key}: |\n${value.split('\n').map(line => `${spaces} ${line}`).join('\n')}\n`; } else { yaml += `${spaces}${key}: ${value}\n`; } } return yaml; }