codemap_routine_add_macro
Add a macro to a routine.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
routineName | string | ✅ Required | Routine name |
macroName | string | ✅ Required | Macro name to add |
Usage Examples
MCP Usage (for AI Agents like Claude)
json
{
"name": "codemap_routine_add_macro",
"arguments": {
"routineName": "build",
"macroName": "compile-typescript"
}
}Example Output
JSON Response
json
{
"success": true,
"data": {
"macroName": "build-prod",
"message": "Added macro \"build-prod\" to routine \"release-workflow\"."
}
}When to Use This Tool
-
Use
- Add shell command macros to routine workflows
- Automate command execution as part of larger workflows
- Chain multiple shell commands in a routine
- Include build, test, or deployment commands in routines
- Create repeatable workflows that execute macros
codemap_routine_add_macro when you need to:
Common Patterns
Build Workflow Integration
Multi-Step Automation
Deployment Routine
Add build macro to release routine:
1. Create macro: codemap_macro_create({ name: "build-prod", cmd: "npm run build:prod" })
2. Add to routine: codemap_routine_add_macro({
routineName: "release-workflow",
macroName: "build-prod"
})
3. Run routine executes the build command automaticallyMulti-Step Automation
Chain multiple macros in routine:
1. Add linting: codemap_routine_add_macro({ routineName: "pre-commit", macroName: "lint" })
2. Add tests: codemap_routine_add_macro({ routineName: "pre-commit", macroName: "test-unit" })
3. Add build: codemap_routine_add_macro({ routineName: "pre-commit", macroName: "build" })Deployment Routine
Build deployment workflow:
codemap_routine_add_macro({ routineName: "deploy-staging", macroName: "docker-build" })
codemap_routine_add_macro({ routineName: "deploy-staging", macroName: "docker-push" })
codemap_routine_add_macro({ routineName: "deploy-staging", macroName: "k8s-apply" })Pro Tips
- Macro must exist first: Create the macro with
codemap_macro_createbefore adding it to a routine - Macros execute in order added: When routine runs, macros execute in the sequence they were added
- Reuse macros across routines: Same macro can be added to multiple routines
- Check macro availability: Use
codemap_macro_listto see available macros before adding - Routine must exist: Create routine with
codemap_routine_createbefore adding macros
Best Practices
- Create descriptive macro names that indicate what command runs (e.g., "build-prod" not "build1")
- Add macros in logical execution order (lint → test → build → deploy)
- Document why macros are part of routine using
codemap_routine_set_message - Keep macros focused on single commands - use multiple macros rather than complex chained commands
- Test macros individually before adding to critical routines
- Use routine's checklist items to document manual steps between macros
Common Mistakes
❌ Mistake: Adding macro that doesn't exist
✅ Instead: Create macro first
---
❌ Mistake: Adding macros in wrong execution order
✅ Instead: Add in correct logical order
---
❌ Mistake: Not verifying macro works before adding to routine
✅ Instead: Test macro first
---
❌ Mistake: Adding routine that doesn't exist
✅ Instead: Create routine first
---
❌ Mistake: Forgetting macros execute automatically
✅ Instead: Use checklist items for dangerous operations
codemap_routine_add_macro({
routineName: "deploy",
macroName: "docker-deploy" // Macro not created yet
})
// Error: Macro "docker-deploy" not found✅ Instead: Create macro first
codemap_macro_create({
name: "docker-deploy",
cmd: "docker-compose up -d",
shell: "bash"
})
codemap_routine_add_macro({
routineName: "deploy",
macroName: "docker-deploy"
})---
❌ Mistake: Adding macros in wrong execution order
// Deploy before build
codemap_routine_add_macro({ routineName: "release", macroName: "deploy" })
codemap_routine_add_macro({ routineName: "release", macroName: "build" })
// Deploys before code is built!✅ Instead: Add in correct logical order
codemap_routine_add_macro({ routineName: "release", macroName: "build" })
codemap_routine_add_macro({ routineName: "release", macroName: "test" })
codemap_routine_add_macro({ routineName: "release", macroName: "deploy" })---
❌ Mistake: Not verifying macro works before adding to routine
// Add untested macro to critical routine
codemap_routine_add_macro({
routineName: "production-deploy",
macroName: "new-deploy-script"
})
// Routine fails in production✅ Instead: Test macro first
// Test macro individually
codemap_macro_run({ name: "new-deploy-script" })
// Verify it works, then add to routine
codemap_routine_add_macro({
routineName: "production-deploy",
macroName: "new-deploy-script"
})---
❌ Mistake: Adding routine that doesn't exist
codemap_routine_add_macro({
routineName: "ci-pipeline", // Routine not created
macroName: "build"
})
// Error: Routine "ci-pipeline" not found✅ Instead: Create routine first
codemap_routine_create({
name: "ci-pipeline",
message: "Continuous integration workflow"
})
codemap_routine_add_macro({
routineName: "ci-pipeline",
macroName: "build"
})---
❌ Mistake: Forgetting macros execute automatically
// Add destructive macro to routine
codemap_routine_add_macro({
routineName: "cleanup",
macroName: "delete-all-data"
})
// Running routine now deletes data without confirmation✅ Instead: Use checklist items for dangerous operations
// Add checklist reminder instead
codemap_routine_add_item({
routineName: "cleanup",
text: "⚠️ Manually run: npm run delete-data (requires confirmation)",
priority: "high"
})