codemap_label_assign
Assign label(s) to target(s). Supports wildcards and batch operations.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
labelId | string|array | ✅ Required | Label ID(s) to assign |
target | string|array | ✅ Required | Target path(s) or glob patterns |
targetType | stringfile | directory | symbol | auto | ❌ Optional | Target type (auto-detect if not specified) |
recursive | boolean | ❌ Optional | For future: if directory, apply to children |
Usage Examples
MCP Usage (for AI Agents like Claude)
json
{
"name": "codemap_label_assign",
"arguments": {
"labelId": "lbl_work_in_progress_241291",
"target": "src/components/Header.vue"
}
}Example Output
JSON Response
json
{
"ok": true,
"assigned": 3,
"targets": [
"src/components/DocsSidebar.vue",
"src/components/DocsTableOfContents.vue",
"src/components/DocsBreadcrumbs.vue"
]
}When to Use This Tool
- Mark File Status: Label files as "work in progress", "needs review", "complete", etc.
- Organize by Feature: Group related files with feature-specific labels
- Track Architecture: Label files by architectural layer (API, Service, Component, etc.)
- Batch Operations: Assign labels to multiple files at once for efficiency
- Workflow Automation: Integrate with scripts to automatically label files based on criteria
Common Patterns
Labeling New Work
When starting a new feature, label all related files:
Multi-Label Classification
Apply multiple aspects to a single file:
Directory-Wide Labeling
Label all files in a directory structure:
Symbol-Level Precision
Label specific functions or classes that need attention:
When starting a new feature, label all related files:
{
"name": "codemap_label_assign",
"arguments": {
"labelId": "lbl_feature_xyz",
"target": ["src/features/xyz/*.ts", "src/components/xyz/*.vue"]
}
}Multi-Label Classification
Apply multiple aspects to a single file:
{
"name": "codemap_label_assign",
"arguments": {
"labelId": ["lbl_api_312956", "lbl_auth_308477", "lbl_critical"],
"target": "src/api/auth-routes.ts"
}
}Directory-Wide Labeling
Label all files in a directory structure:
{
"name": "codemap_label_assign",
"arguments": {
"labelId": "lbl_marketplace_419198",
"target": "src/marketplace/**/*"
}
}Symbol-Level Precision
Label specific functions or classes that need attention:
codemap_label_assign({
labelId: "lbl_deprecated",
target: "src/utils/api.ts$oldFunction",
targetType: "symbol"
})Pro Tips
-
Use Wildcards Effectively
*.ts- All TypeScript files in current directory**/*.ts- All TypeScript files recursivelysrc/{api,services}/*.ts- Files in multiple directories
Check Label Exists First
Before assigning, verify the label ID exists:
const labels = await codemap.labelStore.list();
const labelExists = labels.labels.some(l => l.id === 'lbl_my_label');
Batch for Performance
Assign to multiple targets in one call rather than looping:
// ✅ Good - single call
codemap_label_assign({ labelId: "lbl_x", target: ["file1.ts", "file2.ts", "file3.ts"] })
// ❌ Avoid - multiple calls
files.forEach(file => codemap_label_assign({ labelId: "lbl_x", target: file }))
Idempotent Operations
Assigning the same label to a target multiple times is safe - CodeMap won't create duplicates.
Target Type Precision
Specify targetType when you want to avoid ambiguity:
file - Only match filesdirectory - Only match directoriessymbol - Only match symbols (functions, classes)auto or omit - Let CodeMap detectCommon Mistakes
❌ Don't assign to non-existent files - CodeMap will skip files that don't exist
❌ Don't forget to check the result - Always verify
❌ Don't use hardcoded label IDs - Use
✅ Do use meaningful label names - Make labels descriptive for your team
✅ Do combine with label search - Assign labels, then use
✅ Do document label conventions - Create a label guide for your project
❌ Don't forget to check the result - Always verify
result.assigned matches expectations❌ Don't use hardcoded label IDs - Use
label_list to get current IDs✅ Do use meaningful label names - Make labels descriptive for your team
✅ Do combine with label search - Assign labels, then use
label_search to verify✅ Do document label conventions - Create a label guide for your project