codemap_macro_delete
Delete a shell macro.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | ✅ Required | Macro name to delete |
Usage Examples
MCP Usage (for AI Agents like Claude)
json
{
"name": "codemap_macro_delete",
"arguments": {
"name": "build"
}
}Example Output
JSON Response
json
{
"success": true,
"message": "Deleted macro \"build\"."
}When to Use This Tool
-
Use
- Clean up obsolete macros - Remove macros for deprecated commands or workflows
- Fix mistakes - Delete incorrectly configured macros before recreating them
- Replace macros - Delete old version before creating updated macro with same name
- Reduce clutter - Remove temporary or experimental macros
- Workflow updates - Clean up when switching to new build systems or tools
- Team alignment - Remove personal macros when standardizing team workflows
codemap_macro_delete to remove macros that are no longer needed:
Common Patterns
Replace Macro Pattern
Bulk Cleanup Pattern
Conditional Deletion Pattern
Pattern-Based Cleanup
// Delete old, create new with same name
await codemap.macros.delete('build');
await codemap.macros.create({
name: 'build',
description: 'Updated build command',
cmd: 'npm run build:new'
});Bulk Cleanup Pattern
// Remove multiple obsolete macros
const toDelete = ['old-test', 'temp-build', 'deprecated'];
for (const name of toDelete) {
await codemap.macros.delete(name);
}Conditional Deletion Pattern
// Only delete if exists
const macros = await codemap.macros.list();
if (macros.some(m => m.name === 'old-macro')) {
await codemap.macros.delete('old-macro');
}Pattern-Based Cleanup
// Delete macros matching pattern
const macros = await codemap.macros.list();
const tempMacros = macros.filter(m => m.name.startsWith('temp-'));
for (const macro of tempMacros) {
await codemap.macros.delete(macro.name);
}Pro Tips
List before deleting - Use
Delete before recreating - If updating a macro, delete the old version first since macro names must be unique.
No undo - Macro deletion is permanent. Consider documenting macro definitions before deleting.
Use try-catch - Wrap deletions in error handling to gracefully handle non-existent macros.
Clean up regularly - Periodically review and delete unused macros to keep the macro list manageable.
Document removals - If removing team-shared macros, communicate with team first.
codemap_macro_list to see what macros exist before attempting deletion.Delete before recreating - If updating a macro, delete the old version first since macro names must be unique.
No undo - Macro deletion is permanent. Consider documenting macro definitions before deleting.
Use try-catch - Wrap deletions in error handling to gracefully handle non-existent macros.
Clean up regularly - Periodically review and delete unused macros to keep the macro list manageable.
Document removals - If removing team-shared macros, communicate with team first.
Best Practices
Verify before deleting - List macros and confirm the one you want to delete exists.
Use descriptive error messages - When deleting in scripts, provide clear feedback on success/failure.
Batch deletions carefully - When deleting multiple macros, handle each deletion independently with error catching.
Consider team impact - Before deleting, check if other team members use the macro.
Keep audit trail - Log which macros are deleted and why, especially in automated cleanup scripts.
Don't delete without replacement - If a macro is widely used, create the replacement before deleting the old one.
Use descriptive error messages - When deleting in scripts, provide clear feedback on success/failure.
Batch deletions carefully - When deleting multiple macros, handle each deletion independently with error catching.
Consider team impact - Before deleting, check if other team members use the macro.
Keep audit trail - Log which macros are deleted and why, especially in automated cleanup scripts.
Don't delete without replacement - If a macro is widely used, create the replacement before deleting the old one.
Common Mistakes
❌ Mistake: Deleting without checking if it exists
✅ Instead: Check first or use try-catch
---
❌ Mistake: Deleting then trying to run the macro
✅ Instead: Create replacement first
---
❌ Mistake: Bulk deletion without error handling
✅ Instead: Handle errors per deletion
---
❌ Mistake: Not communicating macro removal to team
✅ Instead: Communicate changes
---
❌ Mistake: Deleting by wrong name
✅ Instead: List macros first to get exact name
// Throws error if macro doesn't exist
await codemap.macros.delete('maybe-exists');✅ Instead: Check first or use try-catch
try {
await codemap.macros.delete('maybe-exists');
} catch (error) {
console.log('Macro did not exist');
}---
❌ Mistake: Deleting then trying to run the macro
await codemap.macros.delete('build');
await codemap.macros.run('build'); // Error!✅ Instead: Create replacement first
await codemap.macros.delete('build');
await codemap.macros.create({
name: 'build',
cmd: 'npm run build:new'
});
await codemap.macros.run('build');---
❌ Mistake: Bulk deletion without error handling
// One error stops the entire loop
const names = ['macro1', 'macro2', 'nonexistent', 'macro3'];
for (const name of names) {
await codemap.macros.delete(name); // Fails at 'nonexistent'
}✅ Instead: Handle errors per deletion
for (const name of names) {
try {
await codemap.macros.delete(name);
console.log(✓ Deleted ${name});
} catch (error) {
console.log(✗ ${name}: ${error.message});
}
}---
❌ Mistake: Not communicating macro removal to team
// Silently deletes team-shared macro
await codemap.macros.delete('deploy-prod');
// Team members get errors when trying to use it✅ Instead: Communicate changes
// Document the change
console.log('Removing old deploy-prod macro');
console.log('Please use new deploy-production macro instead');
await codemap.macros.delete('deploy-prod');---
❌ Mistake: Deleting by wrong name
await codemap.macros.delete('biuld'); // Typo!
// Error: Macro "biuld" not found✅ Instead: List macros first to get exact name
const macros = await codemap.macros.list();
console.log('Available macros:', macros.map(m => m.name));
await codemap.macros.delete('build'); // Correct name