Files
Claude-Code-Workflow/.claude/workflows/tool-strategy.md
catlog22 0a96ee16a8 Add tool strategy documentation with triggering mechanisms and text processing references
- Introduced auto and manual triggering mechanisms for Exa.
- Added quick reference guides for sed and awk text processing.
- Established a fallback strategy for handling edit failures.
2025-12-07 17:09:07 +08:00

72 lines
1.6 KiB
Markdown

# Tool Strategy
## ⚡ Exa Triggering Mechanisms
**Auto-Trigger**:
- User mentions "exa-code" or code-related queries → `mcp__exa__get_code_context_exa`
- Need current web information → `mcp__exa__web_search_exa`
**Manual Trigger**:
- Complex API research → Exa Code Context
- Real-time information needs → Exa Web Search
## ⚡ Bash Text Processing (sed/awk)
**When to Use**: Edit tool fails 2+ times on same file
### sed Quick Reference
```bash
# Replace first occurrence per line
sed 's/old/new/' file.txt
# Replace all occurrences (global)
sed 's/old/new/g' file.txt
# In-place edit (modify file directly)
sed -i 's/old/new/g' file.txt
# Delete lines matching pattern
sed '/pattern/d' file.txt
# Insert line before match
sed '/pattern/i\new line' file.txt
# Insert line after match
sed '/pattern/a\new line' file.txt
# Replace on specific line number
sed '5s/old/new/' file.txt
# Multi-line replacement (escape newlines)
sed ':a;N;$!ba;s/old\npattern/new\ntext/g' file.txt
```
### awk Quick Reference
```bash
# Print specific column
awk '{print $1}' file.txt
# Print lines matching pattern
awk '/pattern/' file.txt
# Replace field value
awk '{$2="new"; print}' file.txt
# Conditional replacement
awk '/pattern/{gsub(/old/,"new")}1' file.txt
# Insert line after match
awk '/pattern/{print; print "new line"; next}1' file.txt
# Multi-field operations
awk -F',' '{print $1, $3}' file.csv
```
### Fallback Strategy
1. **Edit fails 2+ times** → Try sed for simple replacements
2. **sed fails** → Try awk for complex patterns
3. **awk fails** → Use Write to recreate file