codemap_macro_delete

Delete a shell macro.

macroshelldelete

Parameters

NameTypeRequiredDescription
namestring✅ RequiredMacro 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 codemap_macro_delete to remove macros that are no longer needed:
  • 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
💡Common Patterns
Replace Macro Pattern
// 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 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.
⚠️Common Mistakes
Mistake: Deleting without checking if it exists
// 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